!function(a){var b=function(b,c){var d=a.extend({duration:1e4,style:"basic",min:0,max:100,current:0,reverse:!1,shownQuery:".number-pb-shown",numQuery:".number-pb-num"},c||{});switch(this.duration=d.duration,d.style){case"percentage":this.style="percentage",this.min=0,this.max=100;break;case"step":this.style="step",this.min=0,this.max=d.max>this.min?d.max:100;break;default:this.style="basic",this.reverse=d.reverse,d.min<d.max?(this.min=d.min,this.max=d.max):(this.min=0,this.max=100)}this.current=d.current>=this.min&&d.current<=this.max?d.current:this.reverse?this.max:this.min,this.interval=this.max-this.min,this.last=this.reverse?this.max:this.min,this.$element=a(b),this.$shownBar=this.$element.find(d.shownQuery),this.$num=this.$element.find(d.numQuery),this.reach(this.current)};b.prototype.calDestination=function(a){return a<this.min?this.min:a>this.max?this.max:a},b.prototype.calDuration=function(){return this.duration*Math.abs(this.current-this.last)/this.interval},b.prototype.shuffle=function(a){var b=Math.round(Math.random()*this.interval)+this.min;this.reach(b,null,a)},b.prototype.calPercentage=function(){return this.reverse?Math.abs(this.current-this.max)/this.interval*100:(this.current-this.min)/this.interval*100},b.prototype.numStyle=function(a){var b=Math.ceil(a),c="";switch(this.style){case"percentage":c=b+"%";break;case"step":c=b+"/"+this.max;break;default:c=b}return c},b.prototype.reach=function(a,b,c){this.current=this.calDestination(a),this.moveShown(b),this.moveNum(b,c),this.last=this.current},b.prototype.moveShown=function(a){this.$shownBar.velocity({width:this.calPercentage()+"%"},{duration:a||this.calDuration()})},b.prototype.moveNum=function(b,c){var d=this,b=b||this.calDuration();this.$num.velocity({left:this.calPercentage()+"%"},{duration:b,complete:c}),a({num:this.last}).animate({num:this.current},{queue:!0,duration:b,step:function(){d.$num.text(d.numStyle(this.num))},complete:function(){d.$num.text(d.numStyle(d.current))}})},a.fn.NumberProgressBar=function(c){return this.each(function(){var d=a(this);d.data("number-pb")||d.data("number-pb",new b(this,c))})},a.fn.reach=function(b,c){var d=a.extend({duration:null,complete:null},c||{});return this.each(function(){var c=a(this),e=c.data("number-pb");e&&("undefined"==typeof b?e.shuffle(d.complete):e.reach(b,d.duration,d.complete))})}}(jQuery);