3 lines
12 KiB
JavaScript
3 lines
12 KiB
JavaScript
|
/*! @lgaitan/pace-progress 1.0.5 */
|
||
|
|
||
|
(function(){var t,e,n,r,s,o,i,u,a,c,l,p,h,f,d,g,y,m,v,w,b,L,k,S,q,x,P,T,R,j,E,O,M,A,_,F,C,U,W,X,D,H,I,z,G,N,B,J,K=[].slice,Q={}.hasOwnProperty,V=function(t,e){function n(){this.constructor=t}for(var r in e)Q.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},Y=[].indexOf||function(t){for(var e=0,n=this.length;e<n;e++)if(e in this&&this[e]===t)return e;return-1};for(P={catchupTime:100,initialRate:.03,minTime:250,ghostTime:100,maxProgressPerFrame:20,easeFactor:1.25,startOnPageLoad:!0,restartOnPushState:!0,restartOnRequestAfter:500,target:"body",elements:{checkInterval:100,selectors:["body"]},eventLag:{minSamples:10,sampleCount:3,lagThreshold:3},ajax:{trackMethods:["GET"],trackWebSockets:!0,ignoreURLs:[]}},C=function(){var t;return null!=(t="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance.now():void 0)?t:+new Date},X=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,x=window.cancelAnimationFrame||window.mozCancelAnimationFrame,null==X&&(X=function(t){return setTimeout(t,50)},x=function(t){return clearTimeout(t)}),H=function(t){var e,n;return e=C(),(n=function(){var r;return(r=C()-e)>=33?(e=C(),t(r,function(){return X(n)})):setTimeout(n,33-r)})()},D=function(){var t,e,n;return n=arguments[0],e=arguments[1],t=3<=arguments.length?K.call(arguments,2):[],"function"==typeof n[e]?n[e].apply(n,t):n[e]},T=function(){var t,e,n,r,s,o,i;for(r=arguments[0],t=0,n=(o=2<=arguments.length?K.call(arguments,1):[]).length;t<n;t++)if(s=o[t])for(e in s)Q.call(s,e)&&(i=s[e],null!=r[e]&&"object"==typeof r[e]&&null!=i&&"object"==typeof i?T(r[e],i):r[e]=i);return r},k=function(t){var e,n,r,s,o;for(s=e=0,n=0,r=t.length;n<r;n++)o=t[n],s+=Math.abs(o),e++;return s/e},j=function(t,e){var n,r,s;if(null==t&&(t="options"),null==e&&(e=!0),s=document.querySelector("[data-pace-"+t+"]")){if(n=s.getAttribute("data-pace-"+t),!e)return n;try{return JSON.parse(n)}catch(t){return r=t,"undefined"!=typeof console&&null!==console?console.error("Error parsing inline pace options",r):void 0}}},i=function(){function t(){}return t.prototype.on=function(t,e,n,r){var s;return null==r&&(r=!1),null==this.bindings&&(this.bindings={}),null==(s=this.bindings)[t]&&(s[t]=[]),this.bindings[t].push({handler:e,ctx:n,once:r})},t.prototype.once=function(t,e,n){return this.on(t,e,n,!0)},t.prototype.off=function(t,e){var n,r,s;if(null!=(null!=(r=this.bindings)?r[t]:void 0)){if(null==e)return delete this.bindings[t];for(n=0,s=[];n<this.bindings[t].length;)this.bindings[t][n].handler===e?s.push(this.bindings[t].splice(n,1)):s.push(n++);return s}},t.prototype.trigger=function(){var t,e,n,r,s,o,i,u,a;if(n=arguments[0],t=2<=arguments.length?K.call(arguments,1):[],null!=(i=this.bindings)?i[n]:void 0){for(s=0,a=[];s<this.bindings[n].length;)r=(u=this.bindings[n][s]).handler,e=u.ctx,o=u.once,r.apply(null!=e?e:this,t),o?a.push(this.bindings[n].splice(s,1)):a.push(s++);return a}},t}(),c=window.Pace||{},window.Pace=c,T(c,i.prototype),U=c.options=T({},P,window.paceOptions,j()),_=0,F=(W=["ajax","document","eventLag","elements"]).length;_<F;_++)!0===U[N=W[_]]&&(U[N]=P[N]);a=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return V(e,t),e}(Error),e=function(){function t(){this.progress=0}return t.prototype.getElement=function(){var t;if(null==this.el){if(!(t=document.querySelector(U.target)))throw new a;this.el=document.createElement("div"),this.el.classList.add("pace"),this.el.classList.add("pace-active"),document.body.classList.remove("pace-done"),document.body.classList.add("pace-running"),this.el.innerHTML='<div class="pace-progress">\n <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>',null!=t.firstChild?t.insertBefore(this.el,t.firstChild):t.appendChild(this.el)}return this.el},t.prototype.finish=function(){var t;return(t=this.getElement()).classList.remove("pace-active"),t.classList.add("pace-inactive"),document.body.classList.remove("pace-running"),document
|