From 8bc1574a86a170e6414ceefd274ac9dc8912d77b Mon Sep 17 00:00:00 2001 From: schneefux Date: Sun, 12 Jun 2016 17:34:50 +0200 Subject: use barba.js for a faster UX --- static/js/barba.min.js | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ static/js/min.js | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 static/js/barba.min.js create mode 100644 static/js/min.js (limited to 'static/js') diff --git a/static/js/barba.min.js b/static/js/barba.min.js new file mode 100644 index 0000000..5123325 --- /dev/null +++ b/static/js/barba.min.js @@ -0,0 +1,79 @@ +(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=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(++queueIndex1){for(var i=1;i1||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 diff --git a/static/js/min.js b/static/js/min.js new file mode 100644 index 0000000..5123325 --- /dev/null +++ b/static/js/min.js @@ -0,0 +1,79 @@ +(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=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(++queueIndex1){for(var i=1;i1||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 -- cgit v1.3.1