12 |
- /* odometer 0.4.8 */
- (function(){var H,J,L,N,P,R,T,V,W,X,Y,Z,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an,I,K,M,O,Q,S,U=[].slice;ae='<span class="odometer-value"></span>',ab='<span class="odometer-ribbon"><span class="odometer-ribbon-inner">'+ae+"</span></span>",N='<span class="odometer-digit"><span class="odometer-digit-spacer">8</span><span class="odometer-digit-inner">'+ab+"</span></span>",T='<span class="odometer-formatting-mark"></span>',L="(,ddd).dd",V=/^\(?([^)]*)\)?(?:(.)(d+))?$/,W=30,R=2000,H=20,X=2,P=0.5,Y=1000/W,J=1000/H,ac="transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",am=document.createElement("div").style,ad=null!=am.transition||null!=am.webkitTransition||null!=am.mozTransition||null!=am.oTransition,ak=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,Z=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,ag=function(c){var d;return d=document.createElement("div"),d.innerHTML=c,d.children[0]},aj=function(c,d){return c.className=c.className.replace(new RegExp("(^| )"+d.split(" ").join("|")+"( |$)","gi")," ")},af=function(c,d){return aj(c,d),c.className+=" "+d},an=function(d,e){var f;return null!=document.createEvent?(f=document.createEvent("HTMLEvents"),f.initEvent(e,!0,!0),d.dispatchEvent(f)):void 0},ai=function(){var c,d;return null!=(c=null!=(d=window.performance)&&"function"==typeof d.now?d.now():void 0)?c:+new Date},al=function(c,d){return null==d&&(d=0),d?(c*=Math.pow(10,d),c+=0.5,c=Math.floor(c),c/=Math.pow(10,d)):Math.round(c)},I=function(b){return 0>b?Math.ceil(b):Math.floor(b)},ah=function(b){return b-al(b)},M=!1,(K=function(){var f,g,h,i,j;if(!M&&null!=window.jQuery){for(M=!0,i=["html","text"],j=[],g=0,h=i.length;h>g;g++){f=i[g],j.push(function(c){var d;return d=window.jQuery.fn[c],window.jQuery.fn[c]=function(b){var e;return null==b||null==(null!=(e=this[0])?e.odometer:void 0)?d.apply(this,arguments):this[0].odometer.update(b)}}(f))}return j}})(),setTimeout(K,0),aa=function(){function b(a){var f,j,k,r,s,t,u,v,w,x,y=this;if(this.options=a,this.el=this.options.el,null!=this.el.odometer){return this.el.odometer}this.el.odometer=this,v=b.options;for(j in v){r=v[j],null==this.options[j]&&(this.options[j]=r)}null==(s=this.options).duration&&(s.duration=R),this.MAX_VALUES=this.options.duration/Y/X|0,this.resetFormat(),this.value=this.cleanValue(null!=(w=this.options.value)?w:""),this.renderInside(),this.render();try{for(x=["innerHTML","innerText","textContent"],t=0,u=x.length;u>t;t++){k=x[t],null!=this.el[k]&&!function(c){return Object.defineProperty(y.el,c,{get:function(){var d;return"innerHTML"===c?y.inside.outerHTML:null!=(d=y.inside.innerText)?d:y.inside.textContent},set:function(d){return y.update(d)}})}(k)}}catch(z){f=z,this.watchForMutations()}}return b.prototype.renderInside=function(){return this.inside=document.createElement("div"),this.inside.className="odometer-inside",this.el.innerHTML="",this.el.appendChild(this.inside)},b.prototype.watchForMutations=function(){var d,e=this;if(null!=Z){try{return null==this.observer&&(this.observer=new Z(function(g){var h;return h=e.el.innerText,e.renderInside(),e.render(e.value),e.update(h)})),this.watchMutations=!0,this.startWatchingMutations()}catch(f){d=f}}},b.prototype.startWatchingMutations=function(){return this.watchMutations?this.observer.observe(this.el,{childList:!0}):void 0},b.prototype.stopWatchingMutations=function(){var c;return null!=(c=this.observer)?c.disconnect():void 0},b.prototype.cleanValue=function(c){var d;return"string"==typeof c&&(c=c.replace(null!=(d=this.format.radix)?d:".","<radix>"),c=c.replace(/[.,]/g,""),c=c.replace("<radix>","."),c=parseFloat(c,10)||0),al(c,this.format.precision)},b.prototype.bindTransitionEnd=function(){var h,i,j,k,l,m,n=this;if(!this.transitionEndBound){for(this.transitionEndBound=!0,i=!1,l=ac.split(" "),m=[],j=0,k=l.length;k>j;j++){h=l[j],m.push(this.el.addEventListener(h,function(){return i?!0:(i=!0,setTimeout(function(){return n.render(),i=!1,an(n.el,"odometerdone")},0),!0)},!1))}return m}},b.prototype.resetFormat=function(){var c,h,k,l,m,n,o,p;if(c=null!=(o=this.options.format)?o:L,c||(c="d"),k=V.exec(c),!k){throw new Error("Odometer: Unparsable digit format")}return p=k.slice(1,4),n=p[0],m=p[1],h=p[2],l=(null!=h?h.length:void 0)||0,this.format={repeating:n,radix:m,precision:l}},b.prototype.render=function(i){var j,k,l,m,n,o,p;for(null==i&&(i=this.value),this.stopWatchingMutations(),this.resetFormat(),this.inside.innerHTML="",n=this.options.theme,j=this.el.className.split(" "),m=[],o=0,p=j.length;p>o;o++){k=j[o],k.length&&((l=/^odometer-theme-(.+)$/.exec(k))?n=l[1]:/^odometer(-|$)/.test(k)||m.push(k))}return m.push("odometer"),ad||m.push("odometer-no-transitions"),n?m.push("odometer-theme-"+n):m.push("odometer-auto-theme"),this.el.className=m.join(" "),this.ribbons={},this.formatDigits(i),this.startWatchingMutations()},b.prototype.formatDigits=function(l){var m,n,o,p,q,r,s,t,u,v;if(this.digits=[],this.options.formatFunction){for(o=this.options.formatFunction(l),u=o.split("").reverse(),q=0,s=u.length;s>q;q++){n=u[q],n.match(/0-9/)?(m=this.renderDigit(),m.querySelector(".odometer-value").innerHTML=n,this.digits.push(m),this.insertDigit(m)):this.addSpacer(n)}}else{for(p=!this.format.precision||!ah(l)||!1,v=l.toString().split("").reverse(),r=0,t=v.length;t>r;r++){m=v[r],"."===m&&(p=!0),this.addDigit(m,p)}}},b.prototype.update=function(d){var e,f=this;return d=this.cleanValue(d),(e=d-this.value)?(aj(this.el,"odometer-animating-up odometer-animating-down odometer-animating"),e>0?af(this.el,"odometer-animating-up"):af(this.el,"odometer-animating-down"),this.stopWatchingMutations(),this.animate(d),this.startWatchingMutations(),setTimeout(function(){return f.el.offsetHeight,af(f.el,"odometer-animating")},0),this.value=d):void 0},b.prototype.renderDigit=function(){return ag(N)},b.prototype.insertDigit=function(c,d){return null!=d?this.inside.insertBefore(c,d):this.inside.children.length?this.inside.insertBefore(c,this.inside.children[0]):this.inside.appendChild(c)},b.prototype.addSpacer=function(e,f,g){var h;return h=ag(T),h.innerHTML=e,g&&af(h,g),this.insertDigit(h,f)},b.prototype.addDigit=function(g,h){var i,j,k,l;if(null==h&&(h=!0),"-"===g){return this.addSpacer(g,null,"odometer-negation-mark")}if("."===g){return this.addSpacer(null!=(l=this.format.radix)?l:".",null,"odometer-radix-mark")}if(h){for(k=!1;;){if(!this.format.repeating.length){if(k){throw new Error("Bad odometer format without digits")}this.resetFormat(),k=!0}if(i=this.format.repeating[this.format.repeating.length-1],this.format.repeating=this.format.repeating.substring(0,this.format.repeating.length-1),"d"===i){break}this.addSpacer(i)}}return j=this.renderDigit(),j.querySelector(".odometer-value").innerHTML=g,this.digits.push(j),this.insertDigit(j)},b.prototype.animate=function(c){return ad&&"count"!==this.options.animation?this.animateSlide(c):this.animateCount(c)},b.prototype.animateCount=function(i){var j,k,l,m,n,o=this;if(k=+i-this.value){return m=l=ai(),j=this.value,(n=function(){var a,c,d;return ai()-m>o.options.duration?(o.value=i,o.render(),void an(o.el,"odometerdone")):(a=ai()-l,a>J&&(l=ai(),d=a/o.options.duration,c=k*d,j+=c,o.render(Math.round(j))),null!=ak?ak(n):setTimeout(n,J))})()}},b.prototype.getDigitCount=function(){var g,h,i,j,k,l;for(j=1<=arguments.length?U.call(arguments,0):[],g=k=0,l=j.length;l>k;g=++k){i=j[g],j[g]=Math.abs(i)}return h=Math.max.apply(Math,j),Math.ceil(Math.log(h+1)/Math.log(10))},b.prototype.getFractionalDigitCount=function(){var h,i,j,k,l,m,n;for(l=1<=arguments.length?U.call(arguments,0):[],i=/^\-?\d*\.(\d*?)0*$/,h=m=0,n=l.length;n>m;h=++m){k=l[h],l[h]=k.toString(),j=i.exec(l[h]),null==j?l[h]=0:l[h]=j[1].length}return Math.max.apply(Math,l)},b.prototype.resetDigits=function(){return this.digits=[],this.ribbons=[],this.inside.innerHTML="",this.resetFormat()},b.prototype.animateSlide=function(e){var r,F,ao,ar,at,au,av,aw,ax,ay,az,aA,aB,aC,aD,aE,aF,aG,aH,aI,aJ,aK,aL,A,G,ap,aq;if(aE=this.value,aw=this.getFractionalDigitCount(aE,e),aw&&(e*=Math.pow(10,aw),aE*=Math.pow(10,aw)),ao=e-aE){for(this.bindTransitionEnd(),ar=this.getDigitCount(aE,e),at=[],r=0,az=aH=0;ar>=0?ar>aH:aH>ar;az=ar>=0?++aH:--aH){if(aF=I(aE/Math.pow(10,ar-az-1)),av=I(e/Math.pow(10,ar-az-1)),au=av-aF,Math.abs(au)>this.MAX_VALUES){for(ay=[],aA=au/(this.MAX_VALUES+this.MAX_VALUES*r*P),F=aF;au>0&&av>F||0>au&&F>av;){ay.push(Math.round(F)),F+=aA}ay[ay.length-1]!==av&&ay.push(av),r++}else{ay=function(){aq=[];for(var c=aF;av>=aF?av>=c:c>=av;av>=aF?c++:c--){aq.push(c)}return aq}.apply(this)}for(az=aI=0,aK=ay.length;aK>aI;az=++aI){ax=ay[az],ay[az]=Math.abs(ax%10)}at.push(ay)}for(this.resetDigits(),ap=at.reverse(),az=aJ=0,aL=ap.length;aL>aJ;az=++aJ){for(ay=ap[az],this.digits[az]||this.addDigit(" ",az>=aw),null==(aG=this.ribbons)[az]&&(aG[az]=this.digits[az].querySelector(".odometer-ribbon-inner")),this.ribbons[az].innerHTML="",0>ao&&(ay=ay.reverse()),aB=G=0,A=ay.length;A>G;aB=++G){ax=ay[aB],aD=document.createElement("div"),aD.className="odometer-value",aD.innerHTML=ax,this.ribbons[az].appendChild(aD),aB===ay.length-1&&af(aD,"odometer-last-value"),0===aB&&af(aD,"odometer-first-value")}}return 0>aF&&this.addDigit("-"),aC=this.inside.querySelector(".odometer-radix-mark"),null!=aC&&aC.parent.removeChild(aC),aw?this.addSpacer(this.format.radix,this.digits[aw-1],"odometer-radix-mark"):void 0}},b}(),aa.options=null!=(Q=window.odometerOptions)?Q:{},setTimeout(function(){var f,g,h,i,j;if(window.odometerOptions){i=window.odometerOptions,j=[];for(f in i){g=i[f],j.push(null!=(h=aa.options)[f]?(h=aa.options)[f]:h[f]=g)}return j}},0),aa.init=function(){var g,h,i,j,k,l;if(null!=document.querySelectorAll){for(h=document.querySelectorAll(aa.options.selector||".odometer"),l=[],i=0,j=h.length;j>i;i++){g=h[i],l.push(g.odometer=new aa({el:g,value:null!=(k=g.innerText)?k:g.textContent}))}return l}},null!=(null!=(S=document.documentElement)?S.doScroll:void 0)&&null!=document.createEventObject?(O=document.onreadystatechange,document.onreadystatechange=function(){return"complete"===document.readyState&&aa.options.auto!==!1&&aa.init(),null!=O?O.apply(this,arguments):void 0}):document.addEventListener("DOMContentLoaded",function(){return aa.options.auto!==!1?aa.init():void 0},!1),"function"==typeof define&&define.amd?define([],function(){return aa}):"undefined"!=typeof exports&&null!==exports?module.exports=aa:window.Odometer=aa}).call(this);
|