Just post the little plugin I made for this (for the fun of it ..).
(function($){
$.fn['progress'] = function(_options){
var options = {
symbol: '.',
delay: 200,
length: 3,
duration: 0
};
if (typeof _options === 'object'){
$.extend(options, _options);
} else if (_options === 'clear'){
return this.each(function(){
clear.apply(this);
});
}
function display(){
var self = $(this),
txt = self.text() + options.symbol;
if (txt.length > options.length){
txt = '';
}
self.text( txt );
}
function clear(){
var self = $(this),
timer = self.data('progressTimer');
clearInterval(timer);
self.text('');
self.removeData('progressTimer');
}
return this.each(function(){
var self = $(this),
that = this,
timer = null;
timer = setInterval(function(){
display.apply(that);
}, options.delay);
self.data('progressTimer', timer);
if (options.duration){
setTimeout(function(){
clear.apply(that);
}, options.duration);
}
});
}
})(jQuery);
You use it with
$('some-selector').progress({});
$('some-selector').progress('clear');
with affordable options
symbolcharacter to add to each iteration (default - .)length maximum number of characters to display before it starts (default is 3)delay time required to add each additional character (in milliseconds) (default 200)duration ( ) ( 0, )
jsfiddle
$('some-selector').progress({
symbol: '*',
length: 10,
delay: 100,
duration: 5000
});
, - .
var progressElements = $('some-selector').progress({});
setTimeout(function(){
progressElements.progress('clear');
}, 1000);
, duration.
, , .
http://jsfiddle.net/gaby/gh5CD/3/ ( 2 )