(function(factory){"use strict";if(typeof define==='function'&&define.amd){define(['jquery'],factory);}else{factory(jQuery);}}(function($){"use strict";if(!Date.now){Date.now=function(){return new Date().getTime();};} function getTime(){if(typeof window.performance!=='undefined'&&window.performance.now){return window.performance.now();}else{return Date.now();}} var vendors=['webkit','moz'];for(var i=0;i').append(this.svg).appendTo(this.$element);},buildTrack:function(){var width=this.size,height=this.size,cx=width/2,cy=height/2;var barsize=this.options.barsize;var ellipse=new SvgElement("ellipse",{rx:cx-barsize/2,ry:cy-barsize/2,cx:cx,cy:cy,stroke:this.options.trackcolor,fill:this.options.fillcolor,'stroke-width':barsize});this.svg.appendChild(ellipse);},buildBar:function(){if(!svgSupported){return;} var path=new SvgElement("path",{fill:'none','stroke-width':this.options.barsize,stroke:this.options.barcolor});this.bar=path;this.svg.appendChild(path);this._drawBar(this.first);this._updateBar();},_drawBar:function(n){if(!svgSupported){return;} this.bar_goal=n;var width=this.size,height=this.size,cx=width/2,cy=height/2,start_angle=0;var barsize=this.options.barsize;var r=Math.min(cx,cy)-barsize/2;this.r=r;var percentage=this.getPercentage(n);if(percentage===100){percentage-=0.0001;} var end_angle=start_angle+percentage*Math.PI*2/100;var x1=cx+r*Math.sin(start_angle),y1=cy-r*Math.cos(start_angle),x2=cx+r*Math.sin(end_angle),y2=cy-r*Math.cos(end_angle);var big=0;if(end_angle-start_angle>Math.PI)big=1;var d="M"+x1+","+y1+" A"+r+","+r+" 0 "+big+" 1 "+ x2+","+y2;this.bar.setAttribute("d",d);},_updateBar:function(){if(!svgSupported){return;} var percenage=this.getPercentage(this.now);var length=this.bar.getTotalLength();var offset=length*(1-percenage/this.getPercentage(this.bar_goal));this.bar.style.strokeDasharray=length+" "+length;this.bar.style.strokeDashoffset=offset;},_trigger:function(eventType){var method_arguments=Array.prototype.slice.call(arguments,1),data=[this].concat(method_arguments);this.$element.trigger(pluginName+'::'+eventType,data);eventType=eventType.replace(/\b\w+\b/g,function(word){return word.substring(0,1).toUpperCase()+word.substring(1);});var onFunction='on'+eventType;if(typeof this.options[onFunction]==='function'){this.options[onFunction].apply(this,method_arguments);}},getPercentage:function(n){return 100*(n-this.min)/(this.max-this.min);},go:function(goal){var self=this;this._clear();if(isPercentage(goal)){goal=parseInt(goal.replace('%',''),10);goal=Math.round(this.min+(goal/100)*(this.max-this.min));} if(typeof goal==='undefined'){goal=this.goal;} if(goal>this.max){goal=this.max;}else if(goalendTime){next=goal;}else{var distance=(time-startTime)/self.options.speed;next=Math.round(self.easing.fn(distance/100)*(self.max-self.min));if(goal>start){next=start+next;if(next>goal){next=goal;}}else{next=start-next;if(next0&&typeof this.options.numberCallback==='function'){this.$number.html(this.options.numberCallback.call(this,[this.now]));} if(this.$content.length>0&&typeof this.options.contentCallback==='function'){this.$content.html(this.options.contentCallback.call(this,[this.now]));} this._trigger('update',n);},_clear:function(){if(this._frameId){window.cancelAnimationFrame(this._frameId);this._frameId=null;}},get:function(){return this.now;},start:function(){this._clear();this._trigger('start');this.go(this.goal);},reset:function(){this._clear();this._drawBar(this.first);this._update(this.first);this._trigger('reset');},stop:function(){this._clear();this._trigger('stop');},finish:function(){this._clear();this._update(this.goal);this._trigger('finish');},destory:function(){this.$element.data(pluginName,null);this._trigger('destory');}};$.fn[pluginName]=function(options){if(typeof options==='string'){var method=options;var method_arguments=Array.prototype.slice.call(arguments,1);if(/^\_/.test(method)){return false;}else if((/^(get)$/.test(method))){var api=this.first().data(pluginName);if(api&&typeof api[method]==='function'){return api[method].apply(api,method_arguments);}}else{return this.each(function(){var api=$.data(this,pluginName);if(api&&typeof api[method]==='function'){api[method].apply(api,method_arguments);}});}}else{return this.each(function(){if(!$.data(this,pluginName)){$.data(this,pluginName,new Plugin(this,options));}});}};}));