sid/js/loader.js

21 lines
759 B
JavaScript

function Loader(element){ this.element = element; };
Loader.prototype = {
instance: null, // instance Singleton
element: this.element, // contiendra l'élément loader
value: 0, // contiendra le pourcentage de chargement
update: function(){ this.value = (this.value>=100)?100:this.value; this.element.style.width = this.value+'%'; },
start: function(){ this.value = 0; this.update(); },
inc: function(v){ this.value += (v)?v:10; this.update(); },
stop: function(){ this.value = 100; this.update(); },
getInstance: function(element){
if( Loader.prototype.instance == null ) Loader.prototype.instance = new Loader(element);
return Loader.prototype.instance;
}
};