$.widget("mobile.progressbar",{options:{outerTheme:null,innerTheme:null,mini:false,value:0,max:100,counter:true},min:0,_create:function(){var f=this.element,e=$.mobile.getInheritedTheme(f,"c"),a=this.options.outerTheme||e,c=this.options.innerTheme||e,d=this.options.mini?" ui-tolito-progressbar-mini":"",b=this.options.counter;this.element.addClass(["ui-tolito-progressbar "," ui-tolito-progressbar-outer-",a," ui-tolito-progressbar-corner-all",d].join("")).attr({role:"progressbar","min-value":this.min,"max-value":this.options.max,"content-value":this._value()});if(b){this.labelContent=($("<div></div>").text(this._value()).addClass("ui-tolito-progressbar-label ui-tolito-progressbar-corner-all")).appendTo(this.element)}this.valueContent=($("<div></div>").addClass(["ui-tolito-progressbar-bg "," ui-tolito-progressbar-active-",c," ui-tolito-progressbar-corner-all"].join(""))).appendTo(this.element);this._refreshValue();this.oldValue=this._value()},_destroy:function(){this.element.removeClass().removeAttr("role").removeAttr("min-value").removeAttr("max-value").removeAttr("content-value");if((typeof this.labelContent!=="undefined")){this.labelContent.remove()}this.valueContent.remove()},value:function(a){if(a===undefined){return this._value()}this._setOption("value",a);return this},_setOption:function(a,b){this.options.value=b;if(a==="value"){this._refreshValue()}},_value:function(){var a=this.options.value;if(typeof a!=="number"){a=0}return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var a=this.value();this.oldValue=a;this.valueContent.css("width",[this._percentage(),"%"].join(""));if((typeof this.labelContent!=="undefined")){this.labelContent.text([this._percentage(),"%"].join(""))}this.element.attr("content-value",a)}});TolitoConstructor=function(a){if(a===undefined){throw"[Error]: The tolito progress bar element id is undefined"}this._id=a;this._defaultOuterTheme=null;this._defaultInnerTheme=null;this._defaultMax=100;this._defaultStartFrom=0;this._defaultInterval=100;this._isBuilt=false;this._isRunning=false;return this};TolitoProgressBar=function(a){return new TolitoConstructor(a)};TolitoConstructor.prototype={logOptions:function(){((typeof console==="undefined")?{log:function(){}}:console).log(["id: '",this.getId(),"' outerTheme: '",this.getOuterTheme(),"' innerTheme: '",this.getInnerTheme(),"' max: '",this.getMax(),"' mini: '",this.getMini(),"' startFrom: '",this.getStartFrom(),"' interval: '",this.getInterval(),"' showCounter: '",this.getShowCounter(),"'"].join(""));return this},getId:function(){return this._id},setOuterTheme:function(a){if(this._isBuilt){throw"[Error]: The tolito progress bar is already built and cannot be configured."}else{this._outerTheme=a;return this}},getOuterTheme:function(){return this._outerTheme||this._defaultOuterTheme},setInnerTheme:function(a){if(this._isBuilt){throw"[Error]: The tolito progress bar is already built and cannot be configured."}else{this._innerTheme=a;return this}},getInnerTheme:function(){return this._innerTheme||this._defaultInnerTheme},setStartFrom:function(a){if(this._isBuilt){throw"[Error]: The tolito progress bar is already built and cannot be configured."}else{this._startFrom=a;return this}},getStartFrom:function(){return this._startFrom||this._defaultStartFrom},setMax:function(a){if(this._isBuilt){throw"[Error]: The tolito progress bar is already built and cannot be configured."}else{this._max=a;return this}},getMax:function(){return this._max||this._defaultMax},isMini:function(a){if(this._isBuilt){throw"[Error]: The tolito progress bar is already built and cannot be configured."}else{this._mini=a;return this}},getMini:function(){return this._mini},showCounter:function(a){if(this._isBuilt){throw"[Error]: The tolito progress bar is already built and cannot be configured."}else{this._showCounter=a;return this}},getShowCounter:function(){return this._showCounter},setInterval:function(a){if(this._isBuilt){throw"[Error]: The tolito progress bar is already built and cannot be configured."}else{this._interval=a;return this}},getInterval:function(){return this._interval||this._defaultInterval},build:function(){if(this._isBuilt){throw"[Error]: The tolito progress bar is already built."}else{$(["#",this.getId()].join("")).progressbar({outerTheme:this.getOuterTheme(),innerTheme:this.getInnerTheme(),value:this.getStartFrom(),max:this.getMax(),mini:this.getMini(),counter:this.getShowCounter()});this._isBuilt=true;return this}},init:function(){if(this._isRunning){throw"[Error]: The tolito progress bar is already running."}else{this.fillProgressBar=setInterval((function(a){return function(){var c=$(["#",a.getId()].join("")).progressbar("option","value"),b=!isNaN(c)?(c+1):1;if(b>a.getMax()){clearInterval(this.fillProgressBar)}else{$(["#",a.getId()].join("")).progressbar({value:b})}}})(this),this.getInterval());this._isRunning=true}return this},stop:function(){if(!this._isRunning){throw"[Error]: The tolito progress bar is already stopped."}else{clearInterval(this.fillProgressBar);this._isRunning=false}return this}};