Comparing version 2.0.17 to 2.0.18
@@ -107,3 +107,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
}); | ||
exports.Link = exports.markSwupElements = exports.normalizeUrl = exports.getCurrentUrl = exports.transitionProperty = exports.transitionEnd = exports.fetch = exports.getDataFromHtml = exports.createHistoryRecord = exports.classify = undefined; | ||
exports.cleanupAnimationClasses = exports.Link = exports.markSwupElements = exports.normalizeUrl = exports.getCurrentUrl = exports.transitionProperty = exports.transitionEnd = exports.fetch = exports.getDataFromHtml = exports.createHistoryRecord = exports.classify = undefined; | ||
@@ -150,2 +150,6 @@ var _classify = __webpack_require__(7); | ||
var _cleanupAnimationClasses = __webpack_require__(16); | ||
var _cleanupAnimationClasses2 = _interopRequireDefault(_cleanupAnimationClasses); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -163,2 +167,3 @@ | ||
var Link = exports.Link = _Link2.default; | ||
var cleanupAnimationClasses = exports.cleanupAnimationClasses = _cleanupAnimationClasses2.default; | ||
@@ -306,39 +311,39 @@ /***/ }), | ||
var _loadPage = __webpack_require__(16); | ||
var _loadPage = __webpack_require__(17); | ||
var _loadPage2 = _interopRequireDefault(_loadPage); | ||
var _renderPage = __webpack_require__(17); | ||
var _renderPage = __webpack_require__(18); | ||
var _renderPage2 = _interopRequireDefault(_renderPage); | ||
var _triggerEvent = __webpack_require__(18); | ||
var _triggerEvent = __webpack_require__(19); | ||
var _triggerEvent2 = _interopRequireDefault(_triggerEvent); | ||
var _on = __webpack_require__(19); | ||
var _on = __webpack_require__(20); | ||
var _on2 = _interopRequireDefault(_on); | ||
var _off = __webpack_require__(20); | ||
var _off = __webpack_require__(21); | ||
var _off2 = _interopRequireDefault(_off); | ||
var _updateTransition = __webpack_require__(21); | ||
var _updateTransition = __webpack_require__(22); | ||
var _updateTransition2 = _interopRequireDefault(_updateTransition); | ||
var _getAnchorElement = __webpack_require__(22); | ||
var _getAnchorElement = __webpack_require__(23); | ||
var _getAnchorElement2 = _interopRequireDefault(_getAnchorElement); | ||
var _getAnimationPromises = __webpack_require__(23); | ||
var _getAnimationPromises = __webpack_require__(24); | ||
var _getAnimationPromises2 = _interopRequireDefault(_getAnimationPromises); | ||
var _getPageData = __webpack_require__(24); | ||
var _getPageData = __webpack_require__(25); | ||
var _getPageData2 = _interopRequireDefault(_getPageData); | ||
var _plugins = __webpack_require__(25); | ||
var _plugins = __webpack_require__(26); | ||
@@ -432,2 +437,4 @@ var _utils = __webpack_require__(1); | ||
this.findPlugin = _plugins.findPlugin; | ||
this.getCurrentUrl = _helpers.getCurrentUrl; | ||
this.cleanupAnimationClasses = _helpers.cleanupAnimationClasses; | ||
@@ -576,2 +583,8 @@ // enable swup | ||
this.triggerEvent('popState', event); | ||
if (!this.options.animateHistoryBrowsing) { | ||
document.documentElement.classList.remove('is-animating'); | ||
(0, _helpers.cleanupAnimationClasses)(); | ||
} | ||
this.loadPage({ url: link.getAddress() }, event); | ||
@@ -1008,2 +1021,26 @@ } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var cleanupAnimationClasses = function cleanupAnimationClasses() { | ||
document.documentElement.className.split(' ').forEach(function (classItem) { | ||
if ( | ||
// remove "to-{page}" classes | ||
new RegExp('^to-').test(classItem) || | ||
// remove all other classes | ||
classItem === 'is-changing' || classItem === 'is-rendering' || classItem === 'is-popstate') { | ||
document.documentElement.classList.remove(classItem); | ||
} | ||
}); | ||
}; | ||
exports.default = cleanupAnimationClasses; | ||
/***/ }), | ||
/* 17 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
@@ -1126,3 +1163,3 @@ }); | ||
/***/ }), | ||
/* 17 */ | ||
/* 18 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1146,2 +1183,5 @@ | ||
var isCurrentPage = this.getCurrentUrl() === page.url; | ||
if (!isCurrentPage) return; | ||
// replace state in case the url was redirected | ||
@@ -1166,3 +1206,2 @@ var url = new _helpers.Link(page.responseURL).getPath(); | ||
this.triggerEvent('willReplaceContent', popstate); | ||
// replace blocks | ||
@@ -1172,6 +1211,4 @@ for (var i = 0; i < page.blocks.length; i++) { | ||
} | ||
// set title | ||
document.title = page.title; | ||
this.triggerEvent('contentReplaced', popstate); | ||
@@ -1199,8 +1236,3 @@ this.triggerEvent('pageView', popstate); | ||
_this.triggerEvent('transitionEnd', popstate); | ||
// remove "to-{page}" classes | ||
document.documentElement.className.split(' ').forEach(function (classItem) { | ||
if (new RegExp('^to-').test(classItem) || classItem === 'is-changing' || classItem === 'is-rendering' || classItem === 'is-popstate') { | ||
document.documentElement.classList.remove(classItem); | ||
} | ||
}); | ||
_this.cleanupAnimationClasses(); | ||
}); | ||
@@ -1218,3 +1250,3 @@ } else { | ||
/***/ }), | ||
/* 18 */ | ||
/* 19 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1246,3 +1278,3 @@ | ||
/***/ }), | ||
/* 19 */ | ||
/* 20 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1267,3 +1299,3 @@ | ||
/***/ }), | ||
/* 20 */ | ||
/* 21 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1308,3 +1340,3 @@ | ||
/***/ }), | ||
/* 21 */ | ||
/* 22 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1330,3 +1362,3 @@ | ||
/***/ }), | ||
/* 22 */ | ||
/* 23 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1362,3 +1394,3 @@ | ||
/***/ }), | ||
/* 23 */ | ||
/* 24 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1412,3 +1444,3 @@ | ||
/***/ }), | ||
/* 24 */ | ||
/* 25 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1445,3 +1477,3 @@ | ||
/***/ }), | ||
/* 25 */ | ||
/* 26 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1448,0 +1480,0 @@ |
@@ -1,1 +0,1 @@ | ||
(function e(t,n){if(typeof exports==="object"&&typeof module==="object")module.exports=n();else if(typeof define==="function"&&define.amd)define([],n);else if(typeof exports==="object")exports["Swup"]=n();else t["Swup"]=n()})(window,function(){return function(e){var t={};function n(r){if(t[r]){return t[r].exports}var i=t[r]={i:r,l:false,exports:{}};e[r].call(i.exports,i,i.exports,n);i.l=true;return i.exports}n.m=e;n.c=t;n.d=function(e,t,r){if(!n.o(e,t)){Object.defineProperty(e,t,{enumerable:true,get:r})}};n.r=function(e){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})};n.t=function(e,t){if(t&1)e=n(e);if(t&8)return e;if(t&4&&typeof e==="object"&&e&&e.__esModule)return e;var r=Object.create(null);n.r(r);Object.defineProperty(r,"default",{enumerable:true,value:e});if(t&2&&typeof e!="string")for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r};n.n=function(e){var t=e&&e.__esModule?function t(){return e["default"]}:function t(){return e};n.d(t,"a",t);return t};n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};n.p="";return n(n.s=3)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Link=t.markSwupElements=t.normalizeUrl=t.getCurrentUrl=t.transitionProperty=t.transitionEnd=t.fetch=t.getDataFromHtml=t.createHistoryRecord=t.classify=undefined;var r=n(7);var i=_(r);var a=n(8);var o=_(a);var s=n(9);var u=_(s);var l=n(10);var c=_(l);var f=n(11);var d=_(f);var h=n(12);var p=_(h);var v=n(13);var g=_(v);var m=n(14);var y=_(m);var w=n(15);var b=_(w);var E=n(2);var P=_(E);function _(e){return e&&e.__esModule?e:{default:e}}var k=t.classify=i.default;var S=t.createHistoryRecord=o.default;var O=t.getDataFromHtml=u.default;var j=t.fetch=c.default;var M=t.transitionEnd=d.default;var H=t.transitionProperty=p.default;var L=t.getCurrentUrl=g.default;var T=t.normalizeUrl=y.default;var A=t.markSwupElements=b.default;var C=t.Link=P.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=t.query=function e(t){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:document;if(typeof t!=="string"){return t}return n.querySelector(t)};var i=t.queryAll=function e(t){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:document;if(typeof t!=="string"){return t}return Array.prototype.slice.call(n.querySelectorAll(t))};var a=t.escapeCssIdentifier=function e(t){if(window.CSS&&window.CSS.escape){return CSS.escape(t)}else{return t}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}return function(t,n,r){if(n)e(t.prototype,n);if(r)e(t,r);return t}}();function i(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}var a=function(){function e(t){i(this,e);if(t instanceof Element||t instanceof SVGElement){this.link=t}else{this.link=document.createElement("a");this.link.href=t}}r(e,[{key:"getPath",value:function e(){var t=this.link.pathname;if(t[0]!=="/"){t="/"+t}return t}},{key:"getAddress",value:function e(){var t=this.link.pathname+this.link.search;if(this.link.getAttribute("xlink:href")){t=this.link.getAttribute("xlink:href")}if(t[0]!=="/"){t="/"+t}return t}},{key:"getHash",value:function e(){return this.link.hash}}]);return e}();t.default=a},function(e,t,n){"use strict";var r=n(4);var i=a(r);function a(e){return e&&e.__esModule?e:{default:e}}e.exports=i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(Object.prototype.hasOwnProperty.call(n,r)){e[r]=n[r]}}}return e};var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}return function(t,n,r){if(n)e(t.prototype,n);if(r)e(t,r);return t}}();var a=n(5);var o=L(a);var s=n(6);var u=L(s);var l=n(16);var c=L(l);var f=n(17);var d=L(f);var h=n(18);var p=L(h);var v=n(19);var g=L(v);var m=n(20);var y=L(m);var w=n(21);var b=L(w);var E=n(22);var P=L(E);var _=n(23);var k=L(_);var S=n(24);var O=L(S);var j=n(25);var M=n(1);var H=n(0);function L(e){return e&&e.__esModule?e:{default:e}}function T(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}var A=function(){function e(t){T(this,e);var n={animateHistoryBrowsing:false,animationSelector:'[class*="transition-"]',linkSelector:'a[href^="'+window.location.origin+'"]:not([data-no-swup]), a[href^="/"]:not([data-no-swup]), a[href^="#"]:not([data-no-swup])',cache:true,containers:["#swup"],requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},plugins:[],skipPopStateHandling:function e(t){return!(t.state&&t.state.source==="swup")}};var i=r({},n,t);this._handlers={animationInDone:[],animationInStart:[],animationOutDone:[],animationOutStart:[],animationSkipped:[],clickLink:[],contentReplaced:[],disabled:[],enabled:[],openPageInNewTab:[],pageLoaded:[],pageRetrievedFromCache:[],pageView:[],popState:[],samePage:[],samePageWithHash:[],serverError:[],transitionStart:[],transitionEnd:[],willReplaceContent:[]};this.scrollToElement=null;this.preloadPromise=null;this.options=i;this.plugins=[];this.transition={};this.delegatedListeners={};this.boundPopStateHandler=this.popStateHandler.bind(this);this.cache=new u.default;this.cache.swup=this;this.loadPage=c.default;this.renderPage=d.default;this.triggerEvent=p.default;this.on=g.default;this.off=y.default;this.updateTransition=b.default;this.getAnimationPromises=k.default;this.getPageData=O.default;this.getAnchorElement=P.default;this.log=function(){};this.use=j.use;this.unuse=j.unuse;this.findPlugin=j.findPlugin;this.enable()}i(e,[{key:"enable",value:function e(){var t=this;if(typeof Promise==="undefined"){console.warn("Promise is not supported");return}this.delegatedListeners.click=(0,o.default)(document,this.options.linkSelector,"click",this.linkClickHandler.bind(this));window.addEventListener("popstate",this.boundPopStateHandler);if(this.options.cache){var n=(0,H.getDataFromHtml)(document.documentElement.outerHTML,this.options.containers);n.url=n.responseURL=(0,H.getCurrentUrl)();this.cache.cacheUrl(n)}(0,H.markSwupElements)(document.documentElement,this.options.containers);this.options.plugins.forEach(function(e){t.use(e)});window.history.replaceState(Object.assign({},window.history.state,{url:window.location.href,random:Math.random(),source:"swup"}),document.title,window.location.href);this.triggerEvent("enabled");document.documentElement.classList.add("swup-enabled");this.triggerEvent("pageView")}},{key:"destroy",value:function e(){var t=this;this.delegatedListeners.click.destroy();window.removeEventListener("popstate",this.boundPopStateHandler);this.cache.empty();this.options.plugins.forEach(function(e){t.unuse(e)});(0,M.queryAll)("[data-swup]").forEach(function(e){e.removeAttribute("data-swup")});this.off();this.triggerEvent("disabled");document.documentElement.classList.remove("swup-enabled")}},{key:"linkClickHandler",value:function e(t){if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){if(t.button===0){this.triggerEvent("clickLink",t);t.preventDefault();var n=new H.Link(t.delegateTarget);if(n.getAddress()==(0,H.getCurrentUrl)()||n.getAddress()==""){if(n.getHash()!=""){this.triggerEvent("samePageWithHash",t);var r=(0,P.default)(n.getHash());if(r!=null){history.replaceState({url:n.getAddress()+n.getHash(),random:Math.random(),source:"swup"},document.title,n.getAddress()+n.getHash())}else{console.warn("Element for offset not found ("+n.getHash()+")")}}else{this.triggerEvent("samePage",t)}}else{if(n.getHash()!=""){this.scrollToElement=n.getHash()}var i=t.delegateTarget.getAttribute("data-swup-transition");this.loadPage({url:n.getAddress(),customTransition:i},false)}}}else{this.triggerEvent("openPageInNewTab",t)}}},{key:"popStateHandler",value:function e(t){if(this.options.skipPopStateHandling(t))return;var n=new H.Link(t.state?t.state.url:window.location.pathname);if(n.getHash()!==""){this.scrollToElement=n.getHash()}else{t.preventDefault()}this.triggerEvent("popState",t);this.loadPage({url:n.getAddress()},t)}}]);return e}();t.default=A},function(e,t,n){"use strict";n.r(t);const r=new WeakMap;function i(e,t,n,i){var a,o;if(!e&&!r.has(t)){return false}const s=(a=r.get(t))!==null&&a!==void 0?a:new WeakMap;r.set(t,s);if(!e&&!r.has(t)){return false}const u=(o=s.get(n))!==null&&o!==void 0?o:new Set;s.set(n,u);const l=u.has(i);if(e){u.add(i)}else{u.delete(i)}return l&&e}function a(e){return typeof e.addEventListener==="function"}function o(e,t){let n=e.target;if(n instanceof Text){n=n.parentElement}if(n instanceof Element&&e.currentTarget instanceof Element){const r=n.closest(t);if(r&&e.currentTarget.contains(r)){return r}}}function s(e,t,n,r,u){if(typeof e==="string"){e=document.querySelectorAll(e)}if(!a(e)){const i=Array.prototype.map.call(e,e=>s(e,t,n,r,u));return{destroy(){for(const e of i){e.destroy()}}}}const l=e instanceof Document?e.documentElement:e;const c=Boolean(typeof u==="object"?u.capture:u);const f=e=>{const n=o(e,t);if(n){e.delegateTarget=n;r.call(l,e)}};if(typeof u==="object"){delete u.once}const d=JSON.stringify({selector:t,type:n,capture:c});const h=i(true,l,r,d);const p={destroy(){l.removeEventListener(n,f,u);i(false,l,r,d)}};if(!h){l.addEventListener(n,f,u)}return p}t["default"]=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Cache=undefined;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}return function(t,n,r){if(n)e(t.prototype,n);if(r)e(t,r);return t}}();var i=n(0);function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}var o=t.Cache=function(){function e(){a(this,e);this.pages={};this.last=null}r(e,[{key:"cacheUrl",value:function e(t){t.url=(0,i.normalizeUrl)(t.url);if(t.url in this.pages===false){this.pages[t.url]=t}this.last=this.pages[t.url];this.swup.log("Cache ("+Object.keys(this.pages).length+")",this.pages)}},{key:"getPage",value:function e(t){t=(0,i.normalizeUrl)(t);return this.pages[t]}},{key:"getCurrentPage",value:function e(){return this.getPage((0,i.getCurrentUrl)())}},{key:"exists",value:function e(t){t=(0,i.normalizeUrl)(t);return t in this.pages}},{key:"empty",value:function e(){this.pages={};this.last=null;this.swup.log("Cache cleared")}},{key:"remove",value:function e(t){delete this.pages[t]}}]);return e}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t){var n=t.toString().toLowerCase().replace(/\s+/g,"-").replace(/\//g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");if(n[0]==="/")n=n.splice(1);if(n==="")n="homepage";return n};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t){window.history.pushState({url:t||window.location.href.split(window.location.hostname)[1],random:Math.random(),source:"swup"},document.getElementsByTagName("title")[0].innerText,t||window.location.href.split(window.location.hostname)[1])};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(1);var i=function e(t,n){var i=document.createElement("html");i.innerHTML=t;var a=[];n.forEach(function(e){if((0,r.query)(e,i)==null){console.error("Container "+e+" not found on page.");return null}else{if((0,r.queryAll)(e).length!==(0,r.queryAll)(e,i).length){console.warn("Mismatched number of containers found on new page.")}(0,r.queryAll)(e).forEach(function(t,n){(0,r.queryAll)(e,i)[n].setAttribute("data-swup",a.length);a.push((0,r.queryAll)(e,i)[n].outerHTML)})}});var o={title:i.querySelector("title").innerText,pageClass:i.querySelector("body").className,originalContent:t,blocks:a};i.innerHTML="";i=null;return o};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(Object.prototype.hasOwnProperty.call(n,r)){e[r]=n[r]}}}return e};var i=function e(t){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var i={url:window.location.pathname+window.location.search,method:"GET",data:null,headers:{}};var a=r({},i,t);var o=new XMLHttpRequest;o.onreadystatechange=function(){if(o.readyState===4){if(o.status!==500){n(o)}else{n(o)}}};o.open(a.method,a.url,true);Object.keys(a.headers).forEach(function(e){o.setRequestHeader(e,a.headers[e])});o.send(a.data);return o};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(){if(window.ontransitionend===undefined&&window.onwebkittransitionend!==undefined){return"webkitTransitionEnd"}else{return"transitionend"}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(){if(window.ontransitionend===undefined&&window.onwebkittransitionend!==undefined){return"WebkitTransition"}else{return"transition"}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(){return window.location.pathname+window.location.search};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(2);var i=a(r);function a(e){return e&&e.__esModule?e:{default:e}}var o=function e(t){return new i.default(t).getAddress()};t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(1);var i=function e(t,n){var i=0;n.forEach(function(e){if((0,r.query)(e,t)==null){console.error("Container "+e+" not found on page.")}else{(0,r.queryAll)(e).forEach(function(n,a){(0,r.queryAll)(e,t)[a].setAttribute("data-swup",i);i++})}})};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(Object.prototype.hasOwnProperty.call(n,r)){e[r]=n[r]}}}return e};var i=n(0);var a=function e(t,n){var a=this;var o=[],s=void 0;var u=function e(){a.triggerEvent("animationOutStart");document.documentElement.classList.add("is-changing");document.documentElement.classList.add("is-leaving");document.documentElement.classList.add("is-animating");if(n){document.documentElement.classList.add("is-popstate")}document.documentElement.classList.add("to-"+(0,i.classify)(t.url));o=a.getAnimationPromises("out");Promise.all(o).then(function(){a.triggerEvent("animationOutDone")});if(!n){var r=void 0;if(a.scrollToElement!=null){r=t.url+a.scrollToElement}else{r=t.url}(0,i.createHistoryRecord)(r)}};this.triggerEvent("transitionStart",n);if(t.customTransition!=null){this.updateTransition(window.location.pathname,t.url,t.customTransition);document.documentElement.classList.add("to-"+(0,i.classify)(t.customTransition))}else{this.updateTransition(window.location.pathname,t.url)}if(!n||this.options.animateHistoryBrowsing){u()}else{this.triggerEvent("animationSkipped")}if(this.cache.exists(t.url)){s=new Promise(function(e){e()});this.triggerEvent("pageRetrievedFromCache")}else{if(!this.preloadPromise||this.preloadPromise.route!=t.url){s=new Promise(function(e,n){(0,i.fetch)(r({},t,{headers:a.options.requestHeaders}),function(r){if(r.status===500){a.triggerEvent("serverError");n(t.url);return}else{var i=a.getPageData(r);if(i!=null){i.url=t.url}else{n(t.url);return}a.cache.cacheUrl(i);a.triggerEvent("pageLoaded")}e()})})}else{s=this.preloadPromise}}Promise.all(o.concat([s])).then(function(){a.renderPage(a.cache.getPage(t.url),n);a.preloadPromise=null}).catch(function(e){a.options.skipPopStateHandling=function(){window.location=e;return true};window.history.go(-1)})};t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(Object.prototype.hasOwnProperty.call(n,r)){e[r]=n[r]}}}return e};var i=n(0);var a=function e(t,n){var a=this;document.documentElement.classList.remove("is-leaving");var o=new i.Link(t.responseURL).getPath();if(window.location.pathname!==o){window.history.replaceState({url:o,random:Math.random(),source:"swup"},document.title,o);this.cache.cacheUrl(r({},t,{url:o}))}if(!n||this.options.animateHistoryBrowsing){document.documentElement.classList.add("is-rendering")}this.triggerEvent("willReplaceContent",n);for(var s=0;s<t.blocks.length;s++){document.body.querySelector('[data-swup="'+s+'"]').outerHTML=t.blocks[s]}document.title=t.title;this.triggerEvent("contentReplaced",n);this.triggerEvent("pageView",n);if(!this.options.cache){this.cache.empty()}setTimeout(function(){if(!n||a.options.animateHistoryBrowsing){a.triggerEvent("animationInStart");document.documentElement.classList.remove("is-animating")}},10);if(!n||this.options.animateHistoryBrowsing){var u=this.getAnimationPromises("in");Promise.all(u).then(function(){a.triggerEvent("animationInDone");a.triggerEvent("transitionEnd",n);document.documentElement.className.split(" ").forEach(function(e){if(new RegExp("^to-").test(e)||e==="is-changing"||e==="is-rendering"||e==="is-popstate"){document.documentElement.classList.remove(e)}})})}else{this.triggerEvent("transitionEnd",n)}this.scrollToElement=null};t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t,n){this._handlers[t].forEach(function(e){try{e(n)}catch(e){console.error(e)}});var r=new CustomEvent("swup:"+t,{detail:t});document.dispatchEvent(r)};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t,n){if(this._handlers[t]){this._handlers[t].push(n)}else{console.warn("Unsupported event "+t+".")}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t,n){var r=this;if(t!=null){if(n!=null){if(this._handlers[t]&&this._handlers[t].filter(function(e){return e===n}).length){var i=this._handlers[t].filter(function(e){return e===n})[0];var a=this._handlers[t].indexOf(i);if(a>-1){this._handlers[t].splice(a,1)}}else{console.warn("Handler for event '"+t+"' no found.")}}else{this._handlers[t]=[]}}else{Object.keys(this._handlers).forEach(function(e){r._handlers[e]=[]})}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t,n,r){this.transition={from:t,to:n,custom:r}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(1);var i=function e(t){if(!t){return null}if(t.charAt(0)==="#"){t=t.substring(1)}t=decodeURIComponent(t);t=(0,r.escapeCssIdentifier)(t);return(0,r.query)("#"+t)||(0,r.query)("a[name='"+t+"']")};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(1);var i=n(0);var a=function e(){var t=this;var n=[];var a=(0,r.queryAll)(this.options.animationSelector,document.body);if(!a.length){console.error("No animated elements found by selector "+this.options.animationSelector);return[Promise.resolve()]}a.forEach(function(e){var r=window.getComputedStyle(e)[(0,i.transitionProperty)()+"Duration"];if(!r||r=="0s"){console.error("No CSS transition duration defined for element of selector "+t.options.animationSelector);n.push(Promise.resolve());return}var a=new Promise(function(t){e.addEventListener((0,i.transitionEnd)(),function(n){if(e==n.target){t()}})});n.push(a)});return n};t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(0);var i=function e(t){var n=t.responseText;var i=(0,r.getDataFromHtml)(n,this.options.containers);if(i){i.responseURL=t.responseURL?t.responseURL:window.location.href}else{console.warn("Received page is invalid.");return null}return i};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=t.use=function e(t){if(!t.isSwupPlugin){console.warn("Not swup plugin instance "+t+".");return}this.plugins.push(t);t.swup=this;if(typeof t._beforeMount==="function"){t._beforeMount()}t.mount();return this.plugins};var i=t.unuse=function e(t){var n=void 0;if(typeof t==="string"){n=this.plugins.find(function(e){return t===e.name})}else{n=t}if(!n){console.warn("No such plugin.");return}n.unmount();if(typeof n._afterUnmount==="function"){n._afterUnmount()}var r=this.plugins.indexOf(n);this.plugins.splice(r,1);return this.plugins};var a=t.findPlugin=function e(t){return this.plugins.find(function(e){return t===e.name})}}])}); | ||
(function e(t,n){if(typeof exports==="object"&&typeof module==="object")module.exports=n();else if(typeof define==="function"&&define.amd)define([],n);else if(typeof exports==="object")exports["Swup"]=n();else t["Swup"]=n()})(window,function(){return function(e){var t={};function n(r){if(t[r]){return t[r].exports}var i=t[r]={i:r,l:false,exports:{}};e[r].call(i.exports,i,i.exports,n);i.l=true;return i.exports}n.m=e;n.c=t;n.d=function(e,t,r){if(!n.o(e,t)){Object.defineProperty(e,t,{enumerable:true,get:r})}};n.r=function(e){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})};n.t=function(e,t){if(t&1)e=n(e);if(t&8)return e;if(t&4&&typeof e==="object"&&e&&e.__esModule)return e;var r=Object.create(null);n.r(r);Object.defineProperty(r,"default",{enumerable:true,value:e});if(t&2&&typeof e!="string")for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r};n.n=function(e){var t=e&&e.__esModule?function t(){return e["default"]}:function t(){return e};n.d(t,"a",t);return t};n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};n.p="";return n(n.s=3)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.cleanupAnimationClasses=t.Link=t.markSwupElements=t.normalizeUrl=t.getCurrentUrl=t.transitionProperty=t.transitionEnd=t.fetch=t.getDataFromHtml=t.createHistoryRecord=t.classify=undefined;var r=n(7);var i=S(r);var a=n(8);var o=S(a);var s=n(9);var u=S(s);var l=n(10);var c=S(l);var f=n(11);var d=S(f);var h=n(12);var p=S(h);var v=n(13);var g=S(v);var m=n(14);var y=S(m);var w=n(15);var b=S(w);var E=n(2);var P=S(E);var _=n(16);var k=S(_);function S(e){return e&&e.__esModule?e:{default:e}}var O=t.classify=i.default;var j=t.createHistoryRecord=o.default;var M=t.getDataFromHtml=u.default;var H=t.fetch=c.default;var L=t.transitionEnd=d.default;var C=t.transitionProperty=p.default;var A=t.getCurrentUrl=g.default;var T=t.normalizeUrl=y.default;var q=t.markSwupElements=b.default;var U=t.Link=P.default;var x=t.cleanupAnimationClasses=k.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=t.query=function e(t){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:document;if(typeof t!=="string"){return t}return n.querySelector(t)};var i=t.queryAll=function e(t){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:document;if(typeof t!=="string"){return t}return Array.prototype.slice.call(n.querySelectorAll(t))};var a=t.escapeCssIdentifier=function e(t){if(window.CSS&&window.CSS.escape){return CSS.escape(t)}else{return t}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}return function(t,n,r){if(n)e(t.prototype,n);if(r)e(t,r);return t}}();function i(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}var a=function(){function e(t){i(this,e);if(t instanceof Element||t instanceof SVGElement){this.link=t}else{this.link=document.createElement("a");this.link.href=t}}r(e,[{key:"getPath",value:function e(){var t=this.link.pathname;if(t[0]!=="/"){t="/"+t}return t}},{key:"getAddress",value:function e(){var t=this.link.pathname+this.link.search;if(this.link.getAttribute("xlink:href")){t=this.link.getAttribute("xlink:href")}if(t[0]!=="/"){t="/"+t}return t}},{key:"getHash",value:function e(){return this.link.hash}}]);return e}();t.default=a},function(e,t,n){"use strict";var r=n(4);var i=a(r);function a(e){return e&&e.__esModule?e:{default:e}}e.exports=i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(Object.prototype.hasOwnProperty.call(n,r)){e[r]=n[r]}}}return e};var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}return function(t,n,r){if(n)e(t.prototype,n);if(r)e(t,r);return t}}();var a=n(5);var o=L(a);var s=n(6);var u=L(s);var l=n(17);var c=L(l);var f=n(18);var d=L(f);var h=n(19);var p=L(h);var v=n(20);var g=L(v);var m=n(21);var y=L(m);var w=n(22);var b=L(w);var E=n(23);var P=L(E);var _=n(24);var k=L(_);var S=n(25);var O=L(S);var j=n(26);var M=n(1);var H=n(0);function L(e){return e&&e.__esModule?e:{default:e}}function C(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}var A=function(){function e(t){C(this,e);var n={animateHistoryBrowsing:false,animationSelector:'[class*="transition-"]',linkSelector:'a[href^="'+window.location.origin+'"]:not([data-no-swup]), a[href^="/"]:not([data-no-swup]), a[href^="#"]:not([data-no-swup])',cache:true,containers:["#swup"],requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},plugins:[],skipPopStateHandling:function e(t){return!(t.state&&t.state.source==="swup")}};var i=r({},n,t);this._handlers={animationInDone:[],animationInStart:[],animationOutDone:[],animationOutStart:[],animationSkipped:[],clickLink:[],contentReplaced:[],disabled:[],enabled:[],openPageInNewTab:[],pageLoaded:[],pageRetrievedFromCache:[],pageView:[],popState:[],samePage:[],samePageWithHash:[],serverError:[],transitionStart:[],transitionEnd:[],willReplaceContent:[]};this.scrollToElement=null;this.preloadPromise=null;this.options=i;this.plugins=[];this.transition={};this.delegatedListeners={};this.boundPopStateHandler=this.popStateHandler.bind(this);this.cache=new u.default;this.cache.swup=this;this.loadPage=c.default;this.renderPage=d.default;this.triggerEvent=p.default;this.on=g.default;this.off=y.default;this.updateTransition=b.default;this.getAnimationPromises=k.default;this.getPageData=O.default;this.getAnchorElement=P.default;this.log=function(){};this.use=j.use;this.unuse=j.unuse;this.findPlugin=j.findPlugin;this.getCurrentUrl=H.getCurrentUrl;this.cleanupAnimationClasses=H.cleanupAnimationClasses;this.enable()}i(e,[{key:"enable",value:function e(){var t=this;if(typeof Promise==="undefined"){console.warn("Promise is not supported");return}this.delegatedListeners.click=(0,o.default)(document,this.options.linkSelector,"click",this.linkClickHandler.bind(this));window.addEventListener("popstate",this.boundPopStateHandler);if(this.options.cache){var n=(0,H.getDataFromHtml)(document.documentElement.outerHTML,this.options.containers);n.url=n.responseURL=(0,H.getCurrentUrl)();this.cache.cacheUrl(n)}(0,H.markSwupElements)(document.documentElement,this.options.containers);this.options.plugins.forEach(function(e){t.use(e)});window.history.replaceState(Object.assign({},window.history.state,{url:window.location.href,random:Math.random(),source:"swup"}),document.title,window.location.href);this.triggerEvent("enabled");document.documentElement.classList.add("swup-enabled");this.triggerEvent("pageView")}},{key:"destroy",value:function e(){var t=this;this.delegatedListeners.click.destroy();window.removeEventListener("popstate",this.boundPopStateHandler);this.cache.empty();this.options.plugins.forEach(function(e){t.unuse(e)});(0,M.queryAll)("[data-swup]").forEach(function(e){e.removeAttribute("data-swup")});this.off();this.triggerEvent("disabled");document.documentElement.classList.remove("swup-enabled")}},{key:"linkClickHandler",value:function e(t){if(!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey){if(t.button===0){this.triggerEvent("clickLink",t);t.preventDefault();var n=new H.Link(t.delegateTarget);if(n.getAddress()==(0,H.getCurrentUrl)()||n.getAddress()==""){if(n.getHash()!=""){this.triggerEvent("samePageWithHash",t);var r=(0,P.default)(n.getHash());if(r!=null){history.replaceState({url:n.getAddress()+n.getHash(),random:Math.random(),source:"swup"},document.title,n.getAddress()+n.getHash())}else{console.warn("Element for offset not found ("+n.getHash()+")")}}else{this.triggerEvent("samePage",t)}}else{if(n.getHash()!=""){this.scrollToElement=n.getHash()}var i=t.delegateTarget.getAttribute("data-swup-transition");this.loadPage({url:n.getAddress(),customTransition:i},false)}}}else{this.triggerEvent("openPageInNewTab",t)}}},{key:"popStateHandler",value:function e(t){if(this.options.skipPopStateHandling(t))return;var n=new H.Link(t.state?t.state.url:window.location.pathname);if(n.getHash()!==""){this.scrollToElement=n.getHash()}else{t.preventDefault()}this.triggerEvent("popState",t);if(!this.options.animateHistoryBrowsing){document.documentElement.classList.remove("is-animating");(0,H.cleanupAnimationClasses)()}this.loadPage({url:n.getAddress()},t)}}]);return e}();t.default=A},function(e,t,n){"use strict";n.r(t);const r=new WeakMap;function i(e,t,n,i){var a,o;if(!e&&!r.has(t)){return false}const s=(a=r.get(t))!==null&&a!==void 0?a:new WeakMap;r.set(t,s);if(!e&&!r.has(t)){return false}const u=(o=s.get(n))!==null&&o!==void 0?o:new Set;s.set(n,u);const l=u.has(i);if(e){u.add(i)}else{u.delete(i)}return l&&e}function a(e){return typeof e.addEventListener==="function"}function o(e,t){let n=e.target;if(n instanceof Text){n=n.parentElement}if(n instanceof Element&&e.currentTarget instanceof Element){const r=n.closest(t);if(r&&e.currentTarget.contains(r)){return r}}}function s(e,t,n,r,u){if(typeof e==="string"){e=document.querySelectorAll(e)}if(!a(e)){const i=Array.prototype.map.call(e,e=>s(e,t,n,r,u));return{destroy(){for(const e of i){e.destroy()}}}}const l=e instanceof Document?e.documentElement:e;const c=Boolean(typeof u==="object"?u.capture:u);const f=e=>{const n=o(e,t);if(n){e.delegateTarget=n;r.call(l,e)}};if(typeof u==="object"){delete u.once}const d=JSON.stringify({selector:t,type:n,capture:c});const h=i(true,l,r,d);const p={destroy(){l.removeEventListener(n,f,u);i(false,l,r,d)}};if(!h){l.addEventListener(n,f,u)}return p}t["default"]=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.Cache=undefined;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||false;r.configurable=true;if("value"in r)r.writable=true;Object.defineProperty(e,r.key,r)}}return function(t,n,r){if(n)e(t.prototype,n);if(r)e(t,r);return t}}();var i=n(0);function a(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}}var o=t.Cache=function(){function e(){a(this,e);this.pages={};this.last=null}r(e,[{key:"cacheUrl",value:function e(t){t.url=(0,i.normalizeUrl)(t.url);if(t.url in this.pages===false){this.pages[t.url]=t}this.last=this.pages[t.url];this.swup.log("Cache ("+Object.keys(this.pages).length+")",this.pages)}},{key:"getPage",value:function e(t){t=(0,i.normalizeUrl)(t);return this.pages[t]}},{key:"getCurrentPage",value:function e(){return this.getPage((0,i.getCurrentUrl)())}},{key:"exists",value:function e(t){t=(0,i.normalizeUrl)(t);return t in this.pages}},{key:"empty",value:function e(){this.pages={};this.last=null;this.swup.log("Cache cleared")}},{key:"remove",value:function e(t){delete this.pages[t]}}]);return e}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t){var n=t.toString().toLowerCase().replace(/\s+/g,"-").replace(/\//g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");if(n[0]==="/")n=n.splice(1);if(n==="")n="homepage";return n};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t){window.history.pushState({url:t||window.location.href.split(window.location.hostname)[1],random:Math.random(),source:"swup"},document.getElementsByTagName("title")[0].innerText,t||window.location.href.split(window.location.hostname)[1])};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(1);var i=function e(t,n){var i=document.createElement("html");i.innerHTML=t;var a=[];n.forEach(function(e){if((0,r.query)(e,i)==null){console.error("Container "+e+" not found on page.");return null}else{if((0,r.queryAll)(e).length!==(0,r.queryAll)(e,i).length){console.warn("Mismatched number of containers found on new page.")}(0,r.queryAll)(e).forEach(function(t,n){(0,r.queryAll)(e,i)[n].setAttribute("data-swup",a.length);a.push((0,r.queryAll)(e,i)[n].outerHTML)})}});var o={title:i.querySelector("title").innerText,pageClass:i.querySelector("body").className,originalContent:t,blocks:a};i.innerHTML="";i=null;return o};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(Object.prototype.hasOwnProperty.call(n,r)){e[r]=n[r]}}}return e};var i=function e(t){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var i={url:window.location.pathname+window.location.search,method:"GET",data:null,headers:{}};var a=r({},i,t);var o=new XMLHttpRequest;o.onreadystatechange=function(){if(o.readyState===4){if(o.status!==500){n(o)}else{n(o)}}};o.open(a.method,a.url,true);Object.keys(a.headers).forEach(function(e){o.setRequestHeader(e,a.headers[e])});o.send(a.data);return o};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(){if(window.ontransitionend===undefined&&window.onwebkittransitionend!==undefined){return"webkitTransitionEnd"}else{return"transitionend"}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(){if(window.ontransitionend===undefined&&window.onwebkittransitionend!==undefined){return"WebkitTransition"}else{return"transition"}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(){return window.location.pathname+window.location.search};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(2);var i=a(r);function a(e){return e&&e.__esModule?e:{default:e}}var o=function e(t){return new i.default(t).getAddress()};t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(1);var i=function e(t,n){var i=0;n.forEach(function(e){if((0,r.query)(e,t)==null){console.error("Container "+e+" not found on page.")}else{(0,r.queryAll)(e).forEach(function(n,a){(0,r.queryAll)(e,t)[a].setAttribute("data-swup",i);i++})}})};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(){document.documentElement.className.split(" ").forEach(function(e){if(new RegExp("^to-").test(e)||e==="is-changing"||e==="is-rendering"||e==="is-popstate"){document.documentElement.classList.remove(e)}})};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(Object.prototype.hasOwnProperty.call(n,r)){e[r]=n[r]}}}return e};var i=n(0);var a=function e(t,n){var a=this;var o=[],s=void 0;var u=function e(){a.triggerEvent("animationOutStart");document.documentElement.classList.add("is-changing");document.documentElement.classList.add("is-leaving");document.documentElement.classList.add("is-animating");if(n){document.documentElement.classList.add("is-popstate")}document.documentElement.classList.add("to-"+(0,i.classify)(t.url));o=a.getAnimationPromises("out");Promise.all(o).then(function(){a.triggerEvent("animationOutDone")});if(!n){var r=void 0;if(a.scrollToElement!=null){r=t.url+a.scrollToElement}else{r=t.url}(0,i.createHistoryRecord)(r)}};this.triggerEvent("transitionStart",n);if(t.customTransition!=null){this.updateTransition(window.location.pathname,t.url,t.customTransition);document.documentElement.classList.add("to-"+(0,i.classify)(t.customTransition))}else{this.updateTransition(window.location.pathname,t.url)}if(!n||this.options.animateHistoryBrowsing){u()}else{this.triggerEvent("animationSkipped")}if(this.cache.exists(t.url)){s=new Promise(function(e){e()});this.triggerEvent("pageRetrievedFromCache")}else{if(!this.preloadPromise||this.preloadPromise.route!=t.url){s=new Promise(function(e,n){(0,i.fetch)(r({},t,{headers:a.options.requestHeaders}),function(r){if(r.status===500){a.triggerEvent("serverError");n(t.url);return}else{var i=a.getPageData(r);if(i!=null){i.url=t.url}else{n(t.url);return}a.cache.cacheUrl(i);a.triggerEvent("pageLoaded")}e()})})}else{s=this.preloadPromise}}Promise.all(o.concat([s])).then(function(){a.renderPage(a.cache.getPage(t.url),n);a.preloadPromise=null}).catch(function(e){a.options.skipPopStateHandling=function(){window.location=e;return true};window.history.go(-1)})};t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(Object.prototype.hasOwnProperty.call(n,r)){e[r]=n[r]}}}return e};var i=n(0);var a=function e(t,n){var a=this;document.documentElement.classList.remove("is-leaving");var o=this.getCurrentUrl()===t.url;if(!o)return;var s=new i.Link(t.responseURL).getPath();if(window.location.pathname!==s){window.history.replaceState({url:s,random:Math.random(),source:"swup"},document.title,s);this.cache.cacheUrl(r({},t,{url:s}))}if(!n||this.options.animateHistoryBrowsing){document.documentElement.classList.add("is-rendering")}this.triggerEvent("willReplaceContent",n);for(var u=0;u<t.blocks.length;u++){document.body.querySelector('[data-swup="'+u+'"]').outerHTML=t.blocks[u]}document.title=t.title;this.triggerEvent("contentReplaced",n);this.triggerEvent("pageView",n);if(!this.options.cache){this.cache.empty()}setTimeout(function(){if(!n||a.options.animateHistoryBrowsing){a.triggerEvent("animationInStart");document.documentElement.classList.remove("is-animating")}},10);if(!n||this.options.animateHistoryBrowsing){var l=this.getAnimationPromises("in");Promise.all(l).then(function(){a.triggerEvent("animationInDone");a.triggerEvent("transitionEnd",n);a.cleanupAnimationClasses()})}else{this.triggerEvent("transitionEnd",n)}this.scrollToElement=null};t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t,n){this._handlers[t].forEach(function(e){try{e(n)}catch(e){console.error(e)}});var r=new CustomEvent("swup:"+t,{detail:t});document.dispatchEvent(r)};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t,n){if(this._handlers[t]){this._handlers[t].push(n)}else{console.warn("Unsupported event "+t+".")}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t,n){var r=this;if(t!=null){if(n!=null){if(this._handlers[t]&&this._handlers[t].filter(function(e){return e===n}).length){var i=this._handlers[t].filter(function(e){return e===n})[0];var a=this._handlers[t].indexOf(i);if(a>-1){this._handlers[t].splice(a,1)}}else{console.warn("Handler for event '"+t+"' no found.")}}else{this._handlers[t]=[]}}else{Object.keys(this._handlers).forEach(function(e){r._handlers[e]=[]})}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=function e(t,n,r){this.transition={from:t,to:n,custom:r}};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(1);var i=function e(t){if(!t){return null}if(t.charAt(0)==="#"){t=t.substring(1)}t=decodeURIComponent(t);t=(0,r.escapeCssIdentifier)(t);return(0,r.query)("#"+t)||(0,r.query)("a[name='"+t+"']")};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(1);var i=n(0);var a=function e(){var t=this;var n=[];var a=(0,r.queryAll)(this.options.animationSelector,document.body);if(!a.length){console.error("No animated elements found by selector "+this.options.animationSelector);return[Promise.resolve()]}a.forEach(function(e){var r=window.getComputedStyle(e)[(0,i.transitionProperty)()+"Duration"];if(!r||r=="0s"){console.error("No CSS transition duration defined for element of selector "+t.options.animationSelector);n.push(Promise.resolve());return}var a=new Promise(function(t){e.addEventListener((0,i.transitionEnd)(),function(n){if(e==n.target){t()}})});n.push(a)});return n};t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=n(0);var i=function e(t){var n=t.responseText;var i=(0,r.getDataFromHtml)(n,this.options.containers);if(i){i.responseURL=t.responseURL?t.responseURL:window.location.href}else{console.warn("Received page is invalid.");return null}return i};t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=t.use=function e(t){if(!t.isSwupPlugin){console.warn("Not swup plugin instance "+t+".");return}this.plugins.push(t);t.swup=this;if(typeof t._beforeMount==="function"){t._beforeMount()}t.mount();return this.plugins};var i=t.unuse=function e(t){var n=void 0;if(typeof t==="string"){n=this.plugins.find(function(e){return t===e.name})}else{n=t}if(!n){console.warn("No such plugin.");return}n.unmount();if(typeof n._afterUnmount==="function"){n._afterUnmount()}var r=this.plugins.indexOf(n);this.plugins.splice(r,1);return this.plugins};var a=t.findPlugin=function e(t){return this.plugins.find(function(e){return t===e.name})}}])}); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.Link = exports.markSwupElements = exports.normalizeUrl = exports.getCurrentUrl = exports.transitionProperty = exports.transitionEnd = exports.fetch = exports.getDataFromHtml = exports.createHistoryRecord = exports.classify = undefined; | ||
exports.cleanupAnimationClasses = exports.Link = exports.markSwupElements = exports.normalizeUrl = exports.getCurrentUrl = exports.transitionProperty = exports.transitionEnd = exports.fetch = exports.getDataFromHtml = exports.createHistoryRecord = exports.classify = undefined; | ||
@@ -49,2 +49,6 @@ var _classify = require('./classify'); | ||
var _cleanupAnimationClasses = require('./cleanupAnimationClasses'); | ||
var _cleanupAnimationClasses2 = _interopRequireDefault(_cleanupAnimationClasses); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -61,2 +65,3 @@ | ||
var markSwupElements = exports.markSwupElements = _markSwupElements2.default; | ||
var Link = exports.Link = _Link2.default; | ||
var Link = exports.Link = _Link2.default; | ||
var cleanupAnimationClasses = exports.cleanupAnimationClasses = _cleanupAnimationClasses2.default; |
@@ -147,2 +147,4 @@ 'use strict'; | ||
this.findPlugin = _plugins.findPlugin; | ||
this.getCurrentUrl = _helpers.getCurrentUrl; | ||
this.cleanupAnimationClasses = _helpers.cleanupAnimationClasses; | ||
@@ -291,2 +293,8 @@ // enable swup | ||
this.triggerEvent('popState', event); | ||
if (!this.options.animateHistoryBrowsing) { | ||
document.documentElement.classList.remove('is-animating'); | ||
(0, _helpers.cleanupAnimationClasses)(); | ||
} | ||
this.loadPage({ url: link.getAddress() }, event); | ||
@@ -293,0 +301,0 @@ } |
@@ -16,2 +16,5 @@ 'use strict'; | ||
var isCurrentPage = this.getCurrentUrl() === page.url; | ||
if (!isCurrentPage) return; | ||
// replace state in case the url was redirected | ||
@@ -36,3 +39,2 @@ var url = new _helpers.Link(page.responseURL).getPath(); | ||
this.triggerEvent('willReplaceContent', popstate); | ||
// replace blocks | ||
@@ -42,6 +44,4 @@ for (var i = 0; i < page.blocks.length; i++) { | ||
} | ||
// set title | ||
document.title = page.title; | ||
this.triggerEvent('contentReplaced', popstate); | ||
@@ -69,8 +69,3 @@ this.triggerEvent('pageView', popstate); | ||
_this.triggerEvent('transitionEnd', popstate); | ||
// remove "to-{page}" classes | ||
document.documentElement.className.split(' ').forEach(function (classItem) { | ||
if (new RegExp('^to-').test(classItem) || classItem === 'is-changing' || classItem === 'is-rendering' || classItem === 'is-popstate') { | ||
document.documentElement.classList.remove(classItem); | ||
} | ||
}); | ||
_this.cleanupAnimationClasses(); | ||
}); | ||
@@ -77,0 +72,0 @@ } else { |
{ | ||
"name": "swup", | ||
"version": "2.0.17", | ||
"version": "2.0.18", | ||
"description": "Complete, flexible, extensible and easy to use page transition library for your web.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104995
31
2132