diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2016-07-21 15:30:04 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2016-07-21 15:30:04 +0200 |
| commit | 4df99f1df784fb6f6f6b221aaf9abccfad6f2d8a (patch) | |
| tree | d85eadbd34ee7b419c50762a75fa996b97dbab81 /static/js/barba.min.js | |
| parent | cf1656886b2bc0609243d0c28db899e4cd8c37f1 (diff) | |
| download | blog-4df99f1df784fb6f6f6b221aaf9abccfad6f2d8a.tar.gz blog-4df99f1df784fb6f6f6b221aaf9abccfad6f2d8a.zip | |
update barba; optimize
Diffstat (limited to 'static/js/barba.min.js')
| -rw-r--r-- | static/js/barba.min.js | 80 |
1 files changed, 1 insertions, 79 deletions
diff --git a/static/js/barba.min.js b/static/js/barba.min.js index 5123325..9c0c811 100644 --- a/static/js/barba.min.js +++ b/static/js/barba.min.js @@ -1,79 +1 @@ -(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==='object'&&typeof module==='object') -module.exports=factory();else if(typeof define==='function'&&define.amd) -define("Barba",[],factory);else if(typeof exports==='object') -exports["Barba"]=factory();else -root["Barba"]=factory();})(this,function(){return(function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId]) -return installedModules[moduleId].exports;var module=installedModules[moduleId]={exports:{},id:moduleId,loaded:false};modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);module.loaded=true;return module.exports;} -__webpack_require__.m=modules;__webpack_require__.c=installedModules;__webpack_require__.p="http://localhost:8080/dist";return __webpack_require__(0);}) -([function(module,exports,__webpack_require__){if(typeof Promise!=='function'){window.Promise=__webpack_require__(1);} -var Barba={version:'0.0.9',Dispatcher:__webpack_require__(4),HistoryManager:__webpack_require__(5),BaseTransition:__webpack_require__(6),BaseView:__webpack_require__(8),Pjax:__webpack_require__(9),Prefetch:__webpack_require__(13),Utils:__webpack_require__(7)};module.exports=Barba;},function(module,exports,__webpack_require__){(function(setImmediate){(function(root){var setTimeoutFunc=setTimeout;function noop(){} -var asap=(typeof setImmediate==='function'&&setImmediate)||function(fn){setTimeoutFunc(fn,0);};var onUnhandledRejection=function onUnhandledRejection(err){if(typeof console!=='undefined'&&console){console.warn('Possible Unhandled Promise Rejection:',err);}};function bind(fn,thisArg){return function(){fn.apply(thisArg,arguments);};} -function Promise(fn){if(typeof this!=='object')throw new TypeError('Promises must be constructed via new');if(typeof fn!=='function')throw new TypeError('not a function');this._state=0;this._handled=false;this._value=undefined;this._deferreds=[];doResolve(fn,this);} -function handle(self,deferred){while(self._state===3){self=self._value;} -if(self._state===0){self._deferreds.push(deferred);return;} -self._handled=true;asap(function(){var cb=self._state===1?deferred.onFulfilled:deferred.onRejected;if(cb===null){(self._state===1?resolve:reject)(deferred.promise,self._value);return;} -var ret;try{ret=cb(self._value);}catch(e){reject(deferred.promise,e);return;} -resolve(deferred.promise,ret);});} -function resolve(self,newValue){try{if(newValue===self)throw new TypeError('A promise cannot be resolved with itself.');if(newValue&&(typeof newValue==='object'||typeof newValue==='function')){var then=newValue.then;if(newValue instanceof Promise){self._state=3;self._value=newValue;finale(self);return;}else if(typeof then==='function'){doResolve(bind(then,newValue),self);return;}} -self._state=1;self._value=newValue;finale(self);}catch(e){reject(self,e);}} -function reject(self,newValue){self._state=2;self._value=newValue;finale(self);} -function finale(self){if(self._state===2&&self._deferreds.length===0){asap(function(){if(!self._handled){onUnhandledRejection(self._value);}});} -for(var i=0,len=self._deferreds.length;i<len;i++){handle(self,self._deferreds[i]);} -self._deferreds=null;} -function Handler(onFulfilled,onRejected,promise){this.onFulfilled=typeof onFulfilled==='function'?onFulfilled:null;this.onRejected=typeof onRejected==='function'?onRejected:null;this.promise=promise;} -function doResolve(fn,self){var done=false;try{fn(function(value){if(done)return;done=true;resolve(self,value);},function(reason){if(done)return;done=true;reject(self,reason);});}catch(ex){if(done)return;done=true;reject(self,ex);}} -Promise.prototype['catch']=function(onRejected){return this.then(null,onRejected);};Promise.prototype.then=function(onFulfilled,onRejected){var prom=new(this.constructor)(noop);handle(this,new Handler(onFulfilled,onRejected,prom));return prom;};Promise.all=function(arr){var args=Array.prototype.slice.call(arr);return new Promise(function(resolve,reject){if(args.length===0)return resolve([]);var remaining=args.length;function res(i,val){try{if(val&&(typeof val==='object'||typeof val==='function')){var then=val.then;if(typeof then==='function'){then.call(val,function(val){res(i,val);},reject);return;}} -args[i]=val;if(--remaining===0){resolve(args);}}catch(ex){reject(ex);}} -for(var i=0;i<args.length;i++){res(i,args[i]);}});};Promise.resolve=function(value){if(value&&typeof value==='object'&&value.constructor===Promise){return value;} -return new Promise(function(resolve){resolve(value);});};Promise.reject=function(value){return new Promise(function(resolve,reject){reject(value);});};Promise.race=function(values){return new Promise(function(resolve,reject){for(var i=0,len=values.length;i<len;i++){values[i].then(resolve,reject);}});};Promise._setImmediateFn=function _setImmediateFn(fn){asap=fn;};Promise._setUnhandledRejectionFn=function _setUnhandledRejectionFn(fn){onUnhandledRejection=fn;};if(typeof module!=='undefined'&&module.exports){module.exports=Promise;}else if(!root.Promise){root.Promise=Promise;}})(this);}.call(exports,__webpack_require__(2).setImmediate))},function(module,exports,__webpack_require__){(function(setImmediate,clearImmediate){var nextTick=__webpack_require__(3).nextTick;var apply=Function.prototype.apply;var slice=Array.prototype.slice;var immediateIds={};var nextImmediateId=0;exports.setTimeout=function(){return new Timeout(apply.call(setTimeout,window,arguments),clearTimeout);};exports.setInterval=function(){return new Timeout(apply.call(setInterval,window,arguments),clearInterval);};exports.clearTimeout=exports.clearInterval=function(timeout){timeout.close();};function Timeout(id,clearFn){this._id=id;this._clearFn=clearFn;} -Timeout.prototype.unref=Timeout.prototype.ref=function(){};Timeout.prototype.close=function(){this._clearFn.call(window,this._id);};exports.enroll=function(item,msecs){clearTimeout(item._idleTimeoutId);item._idleTimeout=msecs;};exports.unenroll=function(item){clearTimeout(item._idleTimeoutId);item._idleTimeout=-1;};exports._unrefActive=exports.active=function(item){clearTimeout(item._idleTimeoutId);var msecs=item._idleTimeout;if(msecs>=0){item._idleTimeoutId=setTimeout(function onTimeout(){if(item._onTimeout) -item._onTimeout();},msecs);}};exports.setImmediate=typeof setImmediate==="function"?setImmediate:function(fn){var id=nextImmediateId++;var args=arguments.length<2?false:slice.call(arguments,1);immediateIds[id]=true;nextTick(function onNextTick(){if(immediateIds[id]){if(args){fn.apply(null,args);}else{fn.call(null);} -exports.clearImmediate(id);}});return id;};exports.clearImmediate=typeof clearImmediate==="function"?clearImmediate:function(id){delete immediateIds[id];};}.call(exports,__webpack_require__(2).setImmediate,__webpack_require__(2).clearImmediate))},function(module,exports){var process=module.exports={};var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){if(!draining||!currentQueue){return;} -draining=false;if(currentQueue.length){queue=currentQueue.concat(queue);}else{queueIndex=-1;} -if(queue.length){drainQueue();}} -function drainQueue(){if(draining){return;} -var timeout=setTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){if(currentQueue){currentQueue[queueIndex].run();}} -queueIndex=-1;len=queue.length;} -currentQueue=null;draining=false;clearTimeout(timeout);} -process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i];}} -queue.push(new Item(fun,args));if(queue.length===1&&!draining){setTimeout(drainQueue,0);}};function Item(fun,array){this.fun=fun;this.array=array;} -Item.prototype.run=function(){this.fun.apply(null,this.array);};process.title='browser';process.browser=true;process.env={};process.argv=[];process.version='';process.versions={};function noop(){} -process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error('process.binding is not supported');};process.cwd=function(){return'/'};process.chdir=function(dir){throw new Error('process.chdir is not supported');};process.umask=function(){return 0;};},function(module,exports){var Dispatcher={events:{},on:function(e,f){this.events[e]=this.events[e]||[];this.events[e].push(f);},off:function(e,f){if(e in this.events===false) -return;this.events[e].splice(this.events[e].indexOf(f),1);},trigger:function(e){if(e in this.events===false) -return;for(var i=0;i<this.events[e].length;i++){this.events[e][i].apply(this,Array.prototype.slice.call(arguments,1));}}};module.exports=Dispatcher;},function(module,exports){var HistoryManager={history:[],add:function(url,namespace){if(!namespace) -namespace=undefined;this.history.push({url:url,namespace:namespace});},currentStatus:function(){return this.history[this.history.length-1];},prevStatus:function(){var history=this.history;if(history.length<2) -return null;return history[history.length-2];}};module.exports=HistoryManager;},function(module,exports,__webpack_require__){var Utils=__webpack_require__(7);var BaseTransition={oldContainer:undefined,newContainer:undefined,newContainerLoading:undefined,extend:function(obj){return Utils.extend(this,obj);},init:function(oldContainer,newContainer){var _this=this;this.oldContainer=oldContainer;this._newContainerPromise=newContainer;this.deferred=Utils.deferred();this.newContainerReady=Utils.deferred();this.newContainerLoading=this.newContainerReady.promise;this.start();this._newContainerPromise.then(function(newContainer){_this.newContainer=newContainer;_this.newContainerReady.resolve();});return this.deferred.promise;},done:function(){this.oldContainer.parentNode.removeChild(this.oldContainer);this.deferred.resolve();},start:function(){},};module.exports=BaseTransition;},function(module,exports){var Utils={getCurrentUrl:function(){return window.location.protocol+'//'+ -window.location.host+ -window.location.pathname+ -window.location.search;},cleanLink:function(url){return url.replace(/#.*/,'');},xhrTimeout:5000,xhr:function(url){var deferred=this.deferred();var req=new XMLHttpRequest();req.onreadystatechange=function(){if(req.readyState===4){if(req.status===200){return deferred.resolve(req.responseText);}else{return deferred.reject(new Error('xhr: HTTP code is not 200'));}}};req.ontimeout=function(){return deferred.reject(new Error('xhr: Timeout exceeded'));};req.open('GET',url);req.timeout=this.xhrTimeout;req.setRequestHeader('x-barba','yes');req.send();return deferred.promise;},extend:function(obj,props){var newObj=Object.create(obj);for(var prop in props){if(props.hasOwnProperty(prop)){newObj[prop]=props[prop];}} -return newObj;},deferred:function(){return new function(){this.resolve=null;this.reject=null;this.promise=new Promise(function(resolve,reject){this.resolve=resolve;this.reject=reject;}.bind(this));};},getPort:function(p){var port=typeof p!=='undefined'?p:window.location.port;var protocol=window.location.protocol;if(port!='') -return parseInt(port);if(protocol==='http:') -return 80;if(protocol==='https:') -return 443;}};module.exports=Utils;},function(module,exports,__webpack_require__){var Dispatcher=__webpack_require__(4);var Utils=__webpack_require__(7);var BaseView={namespace:null,extend:function(obj){return Utils.extend(this,obj);},init:function(){var _this=this;Dispatcher.on('initStateChange',function(newStatus,oldStatus){if(oldStatus&&oldStatus.namespace===_this.namespace) -_this.onLeave();});Dispatcher.on('newPageReady',function(newStatus,oldStatus,container){_this.container=container;if(newStatus.namespace===_this.namespace) -_this.onEnter();});Dispatcher.on('transitionCompleted',function(newStatus,oldStatus){if(newStatus.namespace===_this.namespace) -_this.onEnterCompleted();if(oldStatus&&oldStatus.namespace===_this.namespace) -_this.onLeaveCompleted();});},onEnter:function(){},onEnterCompleted:function(){},onLeave:function(){},onLeaveCompleted:function(){}} -module.exports=BaseView;},function(module,exports,__webpack_require__){var Utils=__webpack_require__(7);var Dispatcher=__webpack_require__(4);var HideShowTransition=__webpack_require__(10);var BaseCache=__webpack_require__(11);var HistoryManager=__webpack_require__(5);var Dom=__webpack_require__(12);var Pjax={Dom:Dom,History:HistoryManager,Cache:BaseCache,cacheEnabled:true,transitionProgress:false,start:function(){this.init();},init:function(){var container=this.Dom.getContainer();this.History.add(this.getCurrentUrl(),this.Dom.getNamespace(container));Dispatcher.trigger('initStateChange',this.History.currentStatus());Dispatcher.trigger('newPageReady',this.History.currentStatus(),{},container);Dispatcher.trigger('transitionCompleted',this.History.currentStatus());this.bindEvents();},bindEvents:function(){document.addEventListener('click',this.onLinkClick.bind(this));window.addEventListener('popstate',this.onStateChange.bind(this));},getCurrentUrl:function(){return Utils.cleanLink(Utils.getCurrentUrl());},goTo:function(url){window.history.pushState(null,null,url);this.onStateChange();},forceGoTo:function(url){window.location=url;},load:function(url){var deferred=Utils.deferred();var _this=this;var xhr;xhr=this.Cache.get(url);if(!xhr){xhr=Utils.xhr(url);this.Cache.set(url,xhr);} -xhr.then(function(data){var container=_this.Dom.parseResponse(data);_this.Dom.putContainer(container);if(!_this.cacheEnabled) -_this.Cache.reset();deferred.resolve(container);},function(){_this.forceGoTo(url);deferred.reject();});return deferred.promise;},onLinkClick:function(evt){var el=evt.target;while(el&&!el.href){el=el.parentNode;} -if(this.preventCheck(evt,el)){evt.stopPropagation();evt.preventDefault();Dispatcher.trigger('linkClicked',el);this.goTo(el.href);}},preventCheck:function(evt,element){if(!history.pushState) -return false;if(!element||!element.href) -return false;if(evt.which>1||evt.metaKey||evt.ctrlKey||evt.shiftKey||evt.altKey) -return false;if(element.target&&element.target==='_blank') -return false;if(window.location.protocol!==element.protocol||window.location.hostname!==element.hostname) -return false;if(Utils.getPort()!==Utils.getPort(element.port)) -return false;if(element.href.indexOf('#')>-1) -return false;if(Utils.cleanLink(element.href)==Utils.cleanLink(location.href)) -return false;if(element.classList.contains('no-barba')) -return false;return true;},getTransition:function(){return HideShowTransition;},onStateChange:function(){var newUrl=this.getCurrentUrl();if(this.transitionProgress) -this.forceGoTo(newUrl);if(this.History.currentStatus().url===newUrl) -return false;this.History.add(newUrl);var newContainer=this.load(newUrl);var transition=Object.create(this.getTransition());this.transitionProgress=true;Dispatcher.trigger('initStateChange',this.History.currentStatus(),this.History.prevStatus());var transitionInstance=transition.init(this.Dom.getContainer(),newContainer);newContainer.then(this.onNewContainerLoaded.bind(this));transitionInstance.then(this.onTransitionEnd.bind(this));},onNewContainerLoaded:function(container){var currentStatus=this.History.currentStatus();currentStatus.namespace=this.Dom.getNamespace(container);Dispatcher.trigger('newPageReady',this.History.currentStatus(),this.History.prevStatus(),container);},onTransitionEnd:function(){this.transitionProgress=false;Dispatcher.trigger('transitionCompleted',this.History.currentStatus(),this.History.prevStatus());}};module.exports=Pjax;},function(module,exports,__webpack_require__){var BaseTransition=__webpack_require__(6);var HideShowTransition=BaseTransition.extend({start:function(){this.newContainerLoading.then(this.hideShow.bind(this));},hideShow:function(){this.oldContainer.style.visibility='hidden';this.newContainer.style.visibility='visible';document.body.scrollTop=0;this.done();}});module.exports=HideShowTransition;},function(module,exports){var BaseCache={data:{},extend:function(obj){return Utils.extend(this,obj);},set:function(key,val){this.data[key]=val;},get:function(key){return this.data[key];},reset:function(){this.data={};}};module.exports=BaseCache;},function(module,exports){var Dom={parseResponse:function(responseText){var wrapper=document.createElement('div');wrapper.innerHTML=responseText;var titleEl=wrapper.querySelector('title');if(titleEl) -document.title=titleEl.textContent;return this.getContainer(wrapper);},getContainer:function(element){if(!element) -element=document.body;if(!element) -throw new Error('Barba.js: DOM not ready!');var container=this.parseContainer(element);if(container&&container.jquery) -container=container[0];if(!container) -throw new Error('Barba.js: no container found');return container;},dataNamespace:'namespace',wrapperId:'barba-wrapper',containerClass:'barba-container',getNamespace:function(element){if(element&&element.dataset){return element.dataset[this.dataNamespace];}else if(element){return element.getAttribute('data-'+this.dataNamespace);} -return null;},putContainer:function(element){element.style.visibility='hidden';document.getElementById(this.wrapperId).appendChild(element);},parseContainer:function(element){return element.querySelector('.'+this.containerClass);}};module.exports=Dom;},function(module,exports,__webpack_require__){var Utils=__webpack_require__(7);var Pjax=__webpack_require__(9);var Prefetch={init:function(){document.body.addEventListener('mouseover',this.onLinkEnter.bind(this));document.body.addEventListener('touchstart',this.onLinkEnter.bind(this));},onLinkEnter:function(evt){var el=evt.target;while(el&&!el.href){el=el.parentNode;} -if(!el){return;} -var url=el.href;if(Pjax.preventCheck(evt,el)&&!Pjax.Cache.get(url)){var xhr=Utils.xhr(url);Pjax.Cache.set(url,xhr);}}};module.exports=Prefetch;}])});;
\ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Barba",[],e):"object"==typeof exports?exports.Barba=e():t.Barba=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return t[i].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="http://localhost:8080/dist",e(0)}([function(t,e,n){"function"!=typeof Promise&&(window.Promise=n(1));var i={version:"0.0.10",BaseTransition:n(4),BaseView:n(6),BaseCache:n(8),Dispatcher:n(7),HistoryManager:n(9),Pjax:n(10),Prefetch:n(13),Utils:n(5)};t.exports=i},function(t,e,n){(function(e){!function(n){function i(){}function r(t,e){return function(){t.apply(e,arguments)}}function o(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],h(t,this)}function s(t,e){for(;3===t._state;)t=t._value;return 0===t._state?void t._deferreds.push(e):(t._handled=!0,void l(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null===n)return void(1===t._state?a:c)(e.promise,t._value);var i;try{i=n(t._value)}catch(t){return void c(e.promise,t)}a(e.promise,i)}))}function a(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof o)return t._state=3,t._value=e,void u(t);if("function"==typeof n)return void h(r(n,e),t)}t._state=1,t._value=e,u(t)}catch(e){c(t,e)}}function c(t,e){t._state=2,t._value=e,u(t)}function u(t){2===t._state&&0===t._deferreds.length&&l(function(){t._handled||p(t._value)});for(var e=0,n=t._deferreds.length;n>e;e++)s(t,t._deferreds[e]);t._deferreds=null}function f(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function h(t,e){var n=!1;try{t(function(t){n||(n=!0,a(e,t))},function(t){n||(n=!0,c(e,t))})}catch(t){if(n)return;n=!0,c(e,t)}}var d=setTimeout,l="function"==typeof e&&e||function(t){d(t,0)},p=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};o.prototype.catch=function(t){return this.then(null,t)},o.prototype.then=function(t,e){var n=new this.constructor(i);return s(this,new f(t,e,n)),n},o.all=function(t){var e=Array.prototype.slice.call(t);return new o(function(t,n){function i(o,s){try{if(s&&("object"==typeof s||"function"==typeof s)){var a=s.then;if("function"==typeof a)return void a.call(s,function(t){i(o,t)},n)}e[o]=s,0===--r&&t(e)}catch(t){n(t)}}if(0===e.length)return t([]);for(var r=e.length,o=0;o<e.length;o++)i(o,e[o])})},o.resolve=function(t){return t&&"object"==typeof t&&t.constructor===o?t:new o(function(e){e(t)})},o.reject=function(t){return new o(function(e,n){n(t)})},o.race=function(t){return new o(function(e,n){for(var i=0,r=t.length;r>i;i++)t[i].then(e,n)})},o._setImmediateFn=function(t){l=t},o._setUnhandledRejectionFn=function(t){p=t},"undefined"!=typeof t&&t.exports?t.exports=o:n.Promise||(n.Promise=o)}(this)}).call(e,n(2).setImmediate)},function(t,e,n){(function(t,i){function r(t,e){this._id=t,this._clearFn=e}var o=n(3).nextTick,s=Function.prototype.apply,a=Array.prototype.slice,c={},u=0;e.setTimeout=function(){return new r(s.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new r(s.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},e.setImmediate="function"==typeof t?t:function(t){var n=u++,i=arguments.length<2?!1:a.call(arguments,1);return c[n]=!0,o(function(){c[n]&&(i?t.apply(null,i):t.call(null),e.clearImmediate(n))}),n},e.clearImmediate="function"==typeof i?i:function(t){delete c[t]}}).call(e,n(2).setImmediate,n(2).clearImmediate)},function(t,e){function n(){u&&s&&(u=!1,s.length?c=s.concat(c):f=-1,c.length&&i())}function i(){if(!u){var t=setTimeout(n);u=!0;for(var e=c.length;e;){for(s=c,c=[];++f<e;)s&&s[f].run();f=-1,e=c.length}s=null,u=!1,clearTimeout(t)}}function r(t,e){this.fun=t,this.array=e}function o(){}var s,a=t.exports={},c=[],u=!1,f=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];c.push(new r(t,e)),1!==c.length||u||setTimeout(i,0)},r.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=o,a.addListener=o,a.once=o,a.off=o,a.removeListener=o,a.removeAllListeners=o,a.emit=o,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(t,e,n){var i=n(5),r={oldContainer:void 0,newContainer:void 0,newContainerLoading:void 0,extend:function(t){return i.extend(this,t)},init:function(t,e){var n=this;return this.oldContainer=t,this._newContainerPromise=e,this.deferred=i.deferred(),this.newContainerReady=i.deferred(),this.newContainerLoading=this.newContainerReady.promise,this.start(),this._newContainerPromise.then(function(t){n.newContainer=t,n.newContainerReady.resolve()}),this.deferred.promise},done:function(){this.oldContainer.parentNode.removeChild(this.oldContainer),this.newContainer.style.visibility="visible",this.deferred.resolve()},start:function(){}};t.exports=r},function(t,e){var n={getCurrentUrl:function(){return window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search},cleanLink:function(t){return t.replace(/#.*/,"")},xhrTimeout:5e3,xhr:function(t){var e=this.deferred(),n=new XMLHttpRequest;return n.onreadystatechange=function(){return 4===n.readyState?200===n.status?e.resolve(n.responseText):e.reject(new Error("xhr: HTTP code is not 200")):void 0},n.ontimeout=function(){return e.reject(new Error("xhr: Timeout exceeded"))},n.open("GET",t),n.timeout=this.xhrTimeout,n.setRequestHeader("x-barba","yes"),n.send(),e.promise},extend:function(t,e){var n=Object.create(t);for(var i in e)e.hasOwnProperty(i)&&(n[i]=e[i]);return n},deferred:function(){return new function(){this.resolve=null,this.reject=null,this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this))}},getPort:function(t){var e="undefined"!=typeof t?t:window.location.port,n=window.location.protocol;return""!=e?parseInt(e):"http:"===n?80:"https:"===n?443:void 0}};t.exports=n},function(t,e,n){var i=n(7),r=n(5),o={namespace:null,extend:function(t){return r.extend(this,t)},init:function(){var t=this;i.on("initStateChange",function(e,n){n&&n.namespace===t.namespace&&t.onLeave()}),i.on("newPageReady",function(e,n,i){t.container=i,e.namespace===t.namespace&&t.onEnter()}),i.on("transitionCompleted",function(e,n){e.namespace===t.namespace&&t.onEnterCompleted(),n&&n.namespace===t.namespace&&t.onLeaveCompleted()})},onEnter:function(){},onEnterCompleted:function(){},onLeave:function(){},onLeaveCompleted:function(){}};t.exports=o},function(t,e){var n={events:{},on:function(t,e){this.events[t]=this.events[t]||[],this.events[t].push(e)},off:function(t,e){t in this.events!=!1&&this.events[t].splice(this.events[t].indexOf(e),1)},trigger:function(t){if(t in this.events!=!1)for(var e=0;e<this.events[t].length;e++)this.events[t][e].apply(this,Array.prototype.slice.call(arguments,1))}};t.exports=n},function(t,e,n){var i=n(5),r={data:{},extend:function(t){return i.extend(this,t)},set:function(t,e){this.data[t]=e},get:function(t){return this.data[t]},reset:function(){this.data={}}};t.exports=r},function(t,e){var n={history:[],add:function(t,e){e||(e=void 0),this.history.push({url:t,namespace:e})},currentStatus:function(){return this.history[this.history.length-1]},prevStatus:function(){var t=this.history;return t.length<2?null:t[t.length-2]}};t.exports=n},function(t,e,n){var i=n(5),r=n(7),o=n(11),s=n(8),a=n(9),c=n(12),u={Dom:c,History:a,Cache:s,cacheEnabled:!0,transitionProgress:!1,ignoreClassLink:"no-barba",start:function(){this.init()},init:function(){var t=this.Dom.getContainer(),e=this.Dom.getWrapper();e.setAttribute("aria-live","polite"),this.History.add(this.getCurrentUrl(),this.Dom.getNamespace(t)),r.trigger("initStateChange",this.History.currentStatus()),r.trigger("newPageReady",this.History.currentStatus(),{},t),r.trigger("transitionCompleted",this.History.currentStatus()),this.bindEvents()},bindEvents:function(){document.addEventListener("click",this.onLinkClick.bind(this)),window.addEventListener("popstate",this.onStateChange.bind(this))},getCurrentUrl:function(){return i.cleanLink(i.getCurrentUrl())},goTo:function(t){window.history.pushState(null,null,t),this.onStateChange()},forceGoTo:function(t){window.location=t},load:function(t){var e,n=i.deferred(),r=this;return e=this.Cache.get(t),e||(e=i.xhr(t),this.Cache.set(t,e)),e.then(function(t){var e=r.Dom.parseResponse(t);r.Dom.putContainer(e),r.cacheEnabled||r.Cache.reset(),n.resolve(e)},function(){r.forceGoTo(t),n.reject()}),n.promise},onLinkClick:function(t){for(var e=t.target;e&&!e.href;)e=e.parentNode;this.preventCheck(t,e)&&(t.stopPropagation(),t.preventDefault(),r.trigger("linkClicked",e),this.goTo(e.href))},preventCheck:function(t,e){return window.history.pushState&&e&&e.href?t.which>1||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?!1:e.target&&"_blank"===e.target?!1:window.location.protocol!==e.protocol||window.location.hostname!==e.hostname?!1:i.getPort()!==i.getPort(e.port)?!1:e.href.indexOf("#")>-1?!1:i.cleanLink(e.href)==i.cleanLink(location.href)?!1:!e.classList.contains(this.ignoreClassLink):!1},getTransition:function(){return o},onStateChange:function(){var t=this.getCurrentUrl();if(this.transitionProgress&&this.forceGoTo(t),this.History.currentStatus().url===t)return!1;this.History.add(t);var e=this.load(t),n=Object.create(this.getTransition());this.transitionProgress=!0,r.trigger("initStateChange",this.History.currentStatus(),this.History.prevStatus());var i=n.init(this.Dom.getContainer(),e);e.then(this.onNewContainerLoaded.bind(this)),i.then(this.onTransitionEnd.bind(this))},onNewContainerLoaded:function(t){var e=this.History.currentStatus();e.namespace=this.Dom.getNamespace(t),r.trigger("newPageReady",this.History.currentStatus(),this.History.prevStatus(),t)},onTransitionEnd:function(){this.transitionProgress=!1,r.trigger("transitionCompleted",this.History.currentStatus(),this.History.prevStatus())}};t.exports=u},function(t,e,n){var i=n(4),r=i.extend({start:function(){this.newContainerLoading.then(this.finish.bind(this))},finish:function(){document.body.scrollTop=0,this.done()}});t.exports=r},function(t,e){var n={dataNamespace:"namespace",wrapperId:"barba-wrapper",containerClass:"barba-container",parseResponse:function(t){var e=document.createElement("div");e.innerHTML=t;var n=e.querySelector("title");return n&&(document.title=n.textContent),this.getContainer(e)},getWrapper:function(){var t=document.getElementById(this.wrapperId);if(!t)throw new Error("Barba.js: wrapper not found!");return t},getContainer:function(t){if(t||(t=document.body),!t)throw new Error("Barba.js: DOM not ready!");var e=this.parseContainer(t);if(e&&e.jquery&&(e=e[0]),!e)throw new Error("Barba.js: no container found");return e},getNamespace:function(t){return t&&t.dataset?t.dataset[this.dataNamespace]:t?t.getAttribute("data-"+this.dataNamespace):null},putContainer:function(t){t.style.visibility="hidden";var e=this.getWrapper();e.appendChild(t)},parseContainer:function(t){return t.querySelector("."+this.containerClass)}};t.exports=n},function(t,e,n){var i=n(5),r=n(10),o={ignoreClassLink:"no-barba-prefetch",init:function(){return window.history.pushState?(document.body.addEventListener("mouseover",this.onLinkEnter.bind(this)),void document.body.addEventListener("touchstart",this.onLinkEnter.bind(this))):!1},onLinkEnter:function(t){for(var e=t.target;e&&!e.href;)e=e.parentNode;if(e&&!e.classList.contains(this.ignoreClassLink)){var n=e.href;if(r.preventCheck(t,e)&&!r.Cache.get(n)){var o=i.xhr(n);r.Cache.set(n,o)}}}};t.exports=o}])});
\ No newline at end of file |
