-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathodometer.min.js
More file actions
1 lines (1 loc) · 10.3 KB
/
odometer.min.js
File metadata and controls
1 lines (1 loc) · 10.3 KB
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Odometer",[],e):"object"==typeof exports?exports.Odometer=e():t.Odometer=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=0)}([function(t,e,n){"use strict";var i,r,o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};(function(){var n,s,a,u,l,h,d,p,c,f,m,g,v,M,w,b,y,x,T,E,L,S,D,A,F,O,j,C,H,k,q,W,z=[].slice;T='<span class="odometer-value"></span>',b='<span class="odometer-ribbon"><span class="odometer-ribbon-inner">'+T+"</span></span>",h='<span class="odometer-digit"><span class="odometer-digit-spacer">8</span><span class="odometer-digit-inner">'+b+"</span></span>",c='<span class="odometer-formatting-mark"></span>',l="(,ddd).dd",f=/^\(?([^)]*)\)?(?:(.)(d+))?$/,m=30,p=2e3,a=20,g=2,d=.5,s=12,n=!1,v=1e3/m,u=1e3/a,y="transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",j=document.createElement("div").style,x=null!=j.transition||null!=j.webkitTransition||null!=j.mozTransition||null!=j.oTransition,F=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,M=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,L=function(t){var e;return e=document.createElement("div"),e.innerHTML=t,e.children[0]},A=function(t,e){return t.className=t.className.replace(new RegExp("(^| )"+e.split(" ").join("|")+"( |$)","gi")," ")},E=function(t,e){return A(t,e),t.className+=" "+e},C=function(t,e){var n;if(null!=document.createEvent)return n=document.createEvent("HTMLEvents"),n.initEvent(e,!0,!0),t.dispatchEvent(n)},D=function(){var t,e;return null!=(t=null!=(e=window.performance)&&"function"==typeof e.now?e.now():void 0)?t:+new Date},O=function(t,e){return null==e&&(e=0),e?(t*=Math.pow(10,e),t+=.5,t=Math.floor(t),t/=Math.pow(10,e)):Math.round(t)},H=function(t){return t<0?Math.ceil(t):Math.floor(t)},S=function(t){return t-O(t)},q=!1,(k=function(){var t,e,n,i,r;if(!q&&null!=window.jQuery){for(q=!0,i=["html","text"],r=[],e=0,n=i.length;e<n;e++)t=i[e],r.push(function(t){var e;return e=window.jQuery.fn[t],window.jQuery.fn[t]=function(t){var n;return null==t||null==(null!=(n=this[0])?n.odometer:void 0)?e.apply(this,arguments):this[0].odometer.update(t)}}(t));return r}})(),setTimeout(k,0),w=function(){function t(e){var i,r,o,a,u,l,h,d,c,f=this;if(this.options=e,this.el=this.options.el,null!=this.el.odometer)return this.el.odometer;this.el.odometer=this,h=t.options;for(i in h)o=h[i],null==this.options[i]&&(this.options[i]=o);null==(a=this.options).duration&&(a.duration=p),s=this.options.numberLength||s,n=this.options.zeroFlag||n,this.MAX_VALUES=this.options.duration/v/g|0,this.resetFormat(),this.value=this.cleanValue(null!=(d=this.options.value)?d:""),this.renderInside(),this.render();try{for(c=["innerHTML","innerText","textContent"],u=0,l=c.length;u<l;u++)r=c[u],null!=this.el[r]&&function(t){Object.defineProperty(f.el,t,{get:function(){var e;return"innerHTML"===t?f.inside.outerHTML:null!=(e=f.inside.innerText)?e:f.inside.textContent},set:function(t){return f.update(t)}})}(r)}catch(t){t,this.watchForMutations()}}return t.prototype.renderInside=function(){return this.inside=document.createElement("div"),this.inside.className="odometer-inside",this.el.innerHTML="",this.el.appendChild(this.inside)},t.prototype.watchForMutations=function(){var t=this;if(null!=M)try{return null==this.observer&&(this.observer=new M(function(e){var n;return n=t.el.innerText,t.renderInside(),t.render(t.value),t.update(n)})),this.watchMutations=!0,this.startWatchingMutations()}catch(t){t}},t.prototype.startWatchingMutations=function(){if(this.watchMutations)return this.observer.observe(this.el,{childList:!0})},t.prototype.stopWatchingMutations=function(){var t;return null!=(t=this.observer)?t.disconnect():void 0},t.prototype.cleanValue=function(t){var e;return"string"==typeof t&&(t=t.replace(null!=(e=this.format.radix)?e:".","<radix>"),t=t.replace(/[.,]/g,""),t=t.replace("<radix>","."),t=parseFloat(t,10)||0),O(t,this.format.precision)},t.prototype.bindTransitionEnd=function(){var t,e,n,i,r,o,s=this;if(!this.transitionEndBound){for(this.transitionEndBound=!0,e=!1,r=y.split(" "),o=[],n=0,i=r.length;n<i;n++)t=r[n],o.push(this.el.addEventListener(t,function(){return!!e||(e=!0,setTimeout(function(){return s.render(),e=!1,C(s.el,"odometerdone")},0),!0)},!1));return o}},t.prototype.resetFormat=function(){var t,e,n,i,r,o,s,a;if(t=null!=(s=this.options.format)?s:l,t||(t="d"),!(n=f.exec(t)))throw new Error("Odometer: Unparsable digit format");return a=n.slice(1,4),o=a[0],r=a[1],e=a[2],i=(null!=e?e.length:void 0)||0,this.format={repeating:o,radix:r,precision:i}},t.prototype.render=function(t){var e,i,r,o,a,u,l,h,d,p,c,f;for(null==t&&(t=this.value),this.stopWatchingMutations(),this.resetFormat(),this.inside.innerHTML="",u=this.options.theme,e=this.el.className.split(" "),a=[],h=0,p=e.length;h<p;h++)i=e[h],i.length&&((o=/^odometer-theme-(.+)$/.exec(i))?u=o[1]:/^odometer(-|$)/.test(i)||a.push(i));a.push("odometer"),x||a.push("odometer-no-transitions"),u?a.push("odometer-theme-"+u):a.push("odometer-auto-theme"),this.el.className=a.join(" "),this.ribbons={},this.digits=[],l=!this.format.precision||!S(t)||!1,f=t.toString().split("").reverse();var m=[];if(n)for(var g=0,v=f.length;g<v;g++)m.push({num:f[g],zflag:!0});var M=[],w=[];if(f.length<s)for(var b=0;b<s-f.length;b++)M.push(n?{num:"0",zflag:!1}:"0");for(w=n?m.concat(M):f.concat(M),d=0,c=w.length;d<c;d++)r=w[d],"."===r&&(l=!0),this.addDigit(r,l);return this.startWatchingMutations()},t.prototype.update=function(t){var e,n=this;if(t=this.cleanValue(t),e=t-this.value)return A(this.el,"odometer-animating-up odometer-animating-down odometer-animating"),e>0?E(this.el,"odometer-animating-up"):E(this.el,"odometer-animating-down"),this.stopWatchingMutations(),this.animate(t),this.startWatchingMutations(),setTimeout(function(){return n.el.offsetHeight,E(n.el,"odometer-animating")},0),this.value=t},t.prototype.renderDigit=function(){return L(h)},t.prototype.insertDigit=function(t,e){return null!=e?this.inside.insertBefore(t,e):this.inside.children.length?this.inside.insertBefore(t,this.inside.children[0]):this.inside.appendChild(t)},t.prototype.addSpacer=function(t,e,n){var i;return i=L(c),i.innerHTML=t,n&&E(i,n),this.insertDigit(i,e)},t.prototype.addDigit=function(t,e){var i,r,o,s;if(null==e&&(e=!0),"-"===(n?t.num:t))return this.addSpacer(n?t.num:t,null,"odometer-negation-mark");if("."===(n?t.num:t))return this.addSpacer(null!=(s=this.format.radix)?s:".",null,"odometer-radix-mark");if(e)for(o=!1;;){if(!this.format.repeating.length){if(o)throw new Error("Bad odometer format without digits");this.resetFormat(),o=!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 r=this.renderDigit(),r.querySelector(".odometer-value").innerHTML=t.num,n&&r.setAttribute("name","digit-"+t.zflag),this.digits.push(r),this.insertDigit(r)},t.prototype.animate=function(t){return x&&"count"!==this.options.animation?this.animateSlide(t):this.animateCount(t)},t.prototype.animateCount=function(t){var e,n,i,r,o,s=this;if(n=+t-this.value)return r=i=D(),e=this.value,(o=function(){var a,l,h;return D()-r>s.options.duration?(s.value=t,s.render(),void C(s.el,"odometerdone")):(a=D()-i,a>u&&(i=D(),h=a/s.options.duration,l=n*h,e+=l,s.render(Math.round(e))),null!=F?F(o):setTimeout(o,u))})()},t.prototype.getDigitCount=function(){var t,e,n,i,r,o;for(i=1<=arguments.length?z.call(arguments,0):[],t=r=0,o=i.length;r<o;t=++r)n=i[t],i[t]=Math.abs(n);return e=Math.max.apply(Math,i),Math.ceil(Math.log(e+1)/Math.log(10))},t.prototype.getFractionalDigitCount=function(){var t,e,n,i,r,o,s;for(r=1<=arguments.length?z.call(arguments,0):[],e=/^\-?\d*\.(\d*?)0*$/,t=o=0,s=r.length;o<s;t=++o)i=r[t],r[t]=i.toString(),n=e.exec(r[t]),r[t]=null==n?0:n[1].length;return Math.max.apply(Math,r)},t.prototype.resetDigits=function(){return this.digits=[],this.ribbons=[],this.inside.innerHTML="",this.resetFormat()},t.prototype.animateSlide=function(t){var e,n,i,r,o,a,u,l,h,p,c,f,m,g,v,M,w,b,y,x,T,L,S,D,A,F;if(v=this.value,u=this.getFractionalDigitCount(v,t),u&&(t*=Math.pow(10,u),v*=Math.pow(10,u)),i=t-v){for(this.bindTransitionEnd(),this.getDigitCount(v,t),r=[],e=0,p=b=0;0<=s?b<s:b>s;p=0<=s?++b:--b){if(M=H(v/Math.pow(10,s-p-1)),a=H(t/Math.pow(10,s-p-1)),o=a-M,Math.abs(o)>this.MAX_VALUES){for(h=[],c=o/(this.MAX_VALUES+this.MAX_VALUES*e*d),n=M;o>0&&n<a||o<0&&n>a;)h.push(Math.round(n)),n+=c;h[h.length-1]!==a&&h.push(a),e++}else h=function(){F=[];for(var t=M;M<=a?t<=a:t>=a;M<=a?t++:t--)F.push(t);return F}.apply(this);for(p=y=0,T=h.length;y<T;p=++y)l=h[p],h[p]=Math.abs(l%10);r.push(h)}for(this.resetDigits(),A=r.reverse(),p=x=0,L=A.length;x<L;p=++x)for(h=A[p],this.digits[p]||this.addDigit(" ",p>=u),null==(w=this.ribbons)[p]&&(w[p]=this.digits[p].querySelector(".odometer-ribbon-inner")),this.ribbons[p].innerHTML="",i<0&&(h=h.reverse()),f=D=0,S=h.length;D<S;f=++D)l=h[f],g=document.createElement("div"),g.className="odometer-value",g.innerHTML=l,this.ribbons[p].appendChild(g),f===h.length-1&&E(g,"odometer-last-value"),0===f&&E(g,"odometer-first-value");return M<0&&this.addDigit("-"),m=this.inside.querySelector(".odometer-radix-mark"),null!=m&&m.parent.removeChild(m),u?this.addSpacer(this.format.radix,this.digits[u-1],"odometer-radix-mark"):void 0}},t}(),w.options=null!=(W=window.odometerOptions)?W:{},w.init=function(t){w.options=t;var e,n,i,r,s,a;if(null!=document.querySelectorAll){for(n=document.querySelectorAll(w.options.selector||".odometer"),a=[],i=0,r=n.length;i<r;i++)e=n[i],a.push(e.odometer=new w(o({el:e,value:null!=(s=e.innerText)?s:e.textContent},t)));return a}},i=[],void 0!==(r=function(){return w}.apply(e,i))&&(t.exports=r)}).call(void 0)}])});