4 lines
1.4 KiB
JavaScript
4 lines
1.4 KiB
JavaScript
Fx.ProgressBar=new Class({Extends:Fx,options:{text:null,html5:!0},initialize:function(a,b){a=document.id(a);this.parent(b);this.useHtml5=this.options.html5&&this.supportsHtml5();var c=a.className,d=a.id;this.useHtml5?(c=a.className,this.element=(new Element("progress")).replaces(a),this.element.max=100,this.element.value=0):(this.element=(new Element("div",{"class":"progress progress-striped"})).replaces(a),this.barElement=(new Element("div",{"class":"bar"})).inject(this.element),this.element.set("role",
|
|
"progressbar"),this.element.set("aria-valuenow","0"),this.element.set("aria-valuemin","0"),this.element.set("aria-valuemax","100"));this.element.id=d;this.element.addClass(c);this.set(0)},supportsHtml5:function(){return"value"in document.createElement("progress")},start:function(a,b){return this.parent(this.now,1==arguments.length?a.limit(0,100):100*(a/b))},setIndeterminate:function(){this.indeterminate=!0;this.useHtml5?this.element.removeProperty("value"):(this.barElement.setStyle("width","100%"),
|
|
this.barElement.addClass("active"),this.element.removeProperty("aria-valuenow").title="")},set:function(a){100<=a&&(a=100);this.now=a;this.useHtml5?this.element.value=a:(this.barElement.setStyle("width",a+"%"),this.element.set("aria-valuenow",a).title=Math.round(a)+"%");var b=document.id(this.options.text);b&&b.set("text",Math.round(a)+"%");100<=a&&self.fireEvent("complete");return this}});
|