ajaxify 8.2.4 → 8.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ajaxify.js CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Copyright Arvind Gupta; MIT Licensed
7
7
  *
8
- * Version 8.2.4
8
+ * Version 8.2.5
9
9
  */
10
10
 
11
11
  /* INTERFACE: See also https://4nf.org/interface/
@@ -48,7 +48,7 @@ Ay.s = {
48
48
  requestDelay : 0, //in msec - Delay of Pronto request
49
49
  scrolltop : "s", // Smart scroll, true = always scroll to top of page, false = no scroll
50
50
  scrollDelay : 0, // Minimal delay on all scroll effects in milliseconds, useful in case of e.g. smooth scroll
51
- bodyClasses : false, // Copy body classes from target page, set to "true" to enable
51
+ bodyClasses : true, // Copy body attributes from target page, set to "false" to disable
52
52
 
53
53
  // script and style handling settings, prefetch
54
54
  deltas : true, // true = deltas loaded, false = all scripts loaded
@@ -83,7 +83,7 @@ Ay.intevents = () => {
83
83
 
84
84
  function _copyAttributes(el, $S, flush) { //copy all attributes of element generically
85
85
  if (flush) [...el.attributes].forEach(e => el.removeAttribute(e.name)); //delete all old attributes
86
- [...$S.attributes].forEach(e => el.setAttribute(e.nodeName, e.nodeValue)); //low-level insertion
86
+ [...$S.attributes].forEach(e => e.nodeValue == "ajy-body" || el.setAttribute(e.nodeName, e.nodeValue)); //low-level insertion
87
87
  }
88
88
 
89
89
  function _on(eventName, elementSelector, handler, el = document) { //e.currentTarget is document when the handler is called
@@ -197,7 +197,7 @@ let _lSel = $t => (
197
197
  signal: ac.signal
198
198
  }).then(r => {
199
199
  if (!r.ok || !_isHtml(r)) {
200
- if (!pre) {location.href = hin;/* _cl(); Ay.pronto(0, Ay.currentURL);*/}
200
+ if (!pre) {location.href = hin;}
201
201
  return;
202
202
  }
203
203
  rsp = r; // store response
@@ -610,7 +610,7 @@ let _init_p = () => {
610
610
  },
611
611
  _doRender = () => {
612
612
  Ay.trigger("load");
613
- if(Ay.s.bodyClasses) { var classes = Ay.fn("body").getAttribute("class"); bdy.setAttribute("class", classes ? classes : ""); }
613
+ if(Ay.s.bodyClasses) _copyAttributes(bdy, Ay.fn("body"), true);
614
614
 
615
615
  var href = Ay.Rq("h"), title;
616
616
  href = Ay.Rq("c", href);
package/ajaxify.min.js CHANGED
@@ -1 +1 @@
1
- let Ay,rootUrl=location.origin,inlineclass="ajy-inline",bdy,qa=(a,b=document)=>b.querySelectorAll(a),qs=(a,b=document)=>b.querySelector(a);class Ajaxify{constructor(options){function _copyAttributes(el,$S,flush){flush&&[...el.attributes].forEach(a=>el.removeAttribute(a.name)),[...$S.attributes].forEach(a=>el.setAttribute(a.nodeName,a.nodeValue))}function _on(eventName,elementSelector,handler,el=document){el.addEventListener(eventName,function(b){for(var a=b.target;a&&a!=this;a=a.parentNode)if(a.matches(elementSelector)){handler(a,b);break}},!!eventName.iO("mo"))}String.prototype.iO=function(a){return this.toString().indexOf(a)+1},Ay=this,Ay.s={elements:"body",selector:"a:not(.no-ajaxy)",forms:"form:not(.no-ajaxy)",canonical:!1,refresh:!1,requestDelay:0,scrolltop:"s",scrollDelay:0,bodyClasses:!1,deltas:!0,asyncdef:!0,alwayshints:!1,inline:!0,inlinehints:!1,inlineskip:"adsbygoogle",inlineappend:!0,intevents:!0,style:!0,prefetchoff:!1,verbosity:0,memoryoff:!1,cb:0,pluginon:!0,passCount:!1},Ay.pass=0,Ay.currentURL="",Ay.h={},Ay.parse=(b,a)=>((a=document.createElement("div")).insertAdjacentHTML("afterbegin",b),a.firstElementChild),Ay.trigger=(b,c)=>{let a=document.createEvent("HTMLEvents");a.initEvent("pronto."+b,!0,!1),a.data=c||Ay.Rq("e"),window.dispatchEvent(a),document.dispatchEvent(a)},Ay.internal=a=>!!a&&("object"==typeof a&&(a=a.href),""===a||a.substring(0,rootUrl.length)===rootUrl||!a.iO(":")),Ay.intevents=()=>{let a=function(a,b,c=!1){(this===document||this===window)&&"DOMContentLoaded"==a?setTimeout(b):this.ael(a,b,c)};EventTarget.prototype.ael=EventTarget.prototype.addEventListener,EventTarget.prototype.addEventListener=a};class Hints{constructor(a){let _=this;_.list="string"==typeof a&&a.length>0&&a.split(", "),_.find=a=>!!a&&!!_.list&&_.list.some(b=>a.iO(b))}}function lg(m){Ay.s.verbosity&&console&&console.log(m)}class GetPage{constructor(){let a=0,b=0,c=0,d="",e=0,f=0,g=0,h=/<\!DOCTYPE[^>]*>/i,i=/<(html|head|link)([\s\>])/gi,j=/<(body)([\s\>])/gi,k=/<\/(html|head|body|link)\>/gi,l='<div class="ajy-$1"$2',m='<div id="ajy-$1"$2';this.a=function(e,h,i){if(!e)return Ay.cache.g();if(e.iO("/")){if(b=h,c==e)return;return o(e)}if("+"===e)return c=h,b=i,o(h,!0);if("a"===e){f>0&&(t(),g.abort());return}return"s"===e?(f?1:0)+d:"-"===e?n(h):"x"===e?a:Ay.cache.g()?"body"===e?qs("#ajy-"+e,Ay.cache.g()):"script"===e?qa(e,Ay.cache.g()):qs("title"===e?e:".ajy-"+e,Ay.cache.g()):void 0};let n=a=>(Ay.pass++,q(a),qa("body > script").forEach(a=>!!a.classList.contains(inlineclass)&&a.parentNode.removeChild(a)),Ay.scripts(!0),Ay.scripts("s"),Ay.scripts("c")),o=(a,d)=>(a.iO("#")&&(a=a.split("#")[0]),Ay.Rq("is")||!Ay.cache.l(a))?s(a,d):(c=0,b)?b():void 0,p=(b,c)=>{if(c){var a=c.cloneNode(!0);qa("script",a).forEach(a=>a.parentNode.removeChild(a)),_copyAttributes(b,a,!0),b.innerHTML=a.innerHTML}},q=a=>Ay.cache.g()&&!r(a)&&a.forEach(function(a){p(a,qs("#"+a.getAttribute("id"),Ay.cache.g()))}),r=a=>"body"==a[0].tagName.toLowerCase()&&(p(bdy,qs("#ajy-body",Ay.cache.g())),1),s=(c,e)=>{var b=Ay.Rq("is");d=e?"p":"c",g=new AbortController,f++,fetch(c,{method:b?"POST":"GET",cache:"default",mode:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest"},body:b?Ay.Rq("d"):null,signal:g.signal}).then(b=>{if(!b.ok||!v(b)){e||(location.href=c);return}return a=b,b.text()}).then(b=>{if(t(1),b)return a.responseText=b,u(c,b)}).catch(a=>{if("AbortError"!==a.name)try{return Ay.trigger("error",a),lg("Response text : "+a.message),u(c,a.message,a)}catch(b){}}).finally(()=>f--)},t=a=>(c=0,a?0:b=0),u=(a,c,d)=>Ay.cache.s(Ay.parse(w(c)))&&(Ay.pages.p([a,Ay.cache.g()]),1)&&b&&b(d),v=a=>(e=a.headers.get("content-type"))&&(e.iO("html")||e.iO("form-")),w=a=>document.createElement("html").innerHTML=x(a).trim(),x=a=>String(a).replace(h,"").replace(i,l).replace(j,m).replace(k,"</div>")}}class Scripts{constructor(){let $s=!1,txt=0;Ay.h.inlinehints=new Hints(Ay.s.inlinehints),Ay.h.inlineskip=new Hints(Ay.s.inlineskip),this.a=function(a){return"i"===a?($s||($s={}),!0):"s"===a?_allstyle($s.y):"1"===a?(Ay.detScripts.d($s),_addScripts($s)):"c"===a?!!Ay.s.canonical&&!!$s.can&&$s.can.getAttribute("href"):"d"===a?Ay.detScripts.d($s):a&&"object"==typeof a?_onetxt(a):void(Ay.scripts("d")||_addScripts($s))};let _allstyle=a=>!Ay.s.style||!a||(qa("style",qs("head")).forEach(a=>a.parentNode.removeChild(a)),a.forEach(a=>_addstyle(a.textContent))),_onetxt=a=>!(txt=a.textContent).iO(").ajaxify(")&&!txt.iO("new Ajaxify(")&&(Ay.s.inline&&!Ay.h.inlineskip.find(txt)||a.classList.contains("ajaxy")||Ay.h.inlinehints.find(txt))&&_addtxt(a),_addtxt=$s=>{if(txt&&txt.length){if(Ay.s.inlineappend||$s.getAttribute("type")&&!$s.getAttribute("type").iO("text/javascript"))try{return _apptxt($s)}catch(e){}try{eval(txt)}catch(e1){lg("Error in inline script : "+txt+"\nError code : "+e1)}}},_apptxt=b=>{let a=document.createElement("script");_copyAttributes(a,b),a.classList.add(inlineclass);try{a.appendChild(document.createTextNode(b.textContent))}catch(c){a.text=b.textContent}return qs("body").appendChild(a)},_addstyle=a=>qs("head").appendChild(Ay.parse("<style>"+a+"</style>")),_addScripts=a=>(Ay.addAll(a.c,"href"),Ay.addAll(a.j,"src"))}}class AddAll{constructor(){let a=[],b=[],c=[],d=0,e=0,f='<link rel="stylesheet" type="text/css" href="*" />',g='link[href*="!"]',h='script[src*="!"]';Ay.h.alwayshints=new Hints(Ay.s.alwayshints),this.a=function(f,g){if(f.length){if("n"===Ay.s.deltas)return!0;if(d=g,!Ay.s.deltas)return i(f);a="href"==d?b:c,Ay.pass?f.forEach(function(c){var b=c;if(e=b.getAttribute(d),k(b)){m(),l(b);return}if(e){a.some(a=>a==e)||(a.push(e),l(b));return}"href"==d||b.classList.contains("no-ajaxy")||Ay.scripts(b)}):j(f)}};let i=a=>a.forEach(a=>l(a)),j=b=>b.forEach(b=>(e=b.getAttribute(d))?a.push(e):0),k=a=>"always"==a.getAttribute("data-class")||Ay.h.alwayshints.find(e),l=a=>{if(e=a.getAttribute(d),"href"==d)return qs("head").appendChild(Ay.parse(f.replace("*",e)));if(!e)return Ay.scripts(a);var b=document.createElement("script");b.async=Ay.s.asyncdef,_copyAttributes(b,a),qs("head").appendChild(b)},m=()=>qa(("href"==d?g:h).replace("!",e)).forEach(a=>a.parentNode.removeChild(a))}}class RQ{constructor(){let a=0,b=0,c=0,d=0,e=0,f=0,g=!1;this.a=function(j,i,l){if("="===j)return i?f===Ay.currentURL||f===g:f===Ay.currentURL;if("!"===j)return g=f;if("?"===j){let k=Ay.fn("s");return k.iO("0")||i||Ay.fn("a"),("1c"!==k||!i)&&("1p"===k&&i&&Ay.s.memoryoff&&Ay.fn("a"),!0)}if("v"===j){if(!i||(h(i,l),!Ay.internal(f)))return!1;j="i"}return"i"===j?(a=!1,b=null,c=!0,d=!1,f):"h"===j?(i&&("string"==typeof i&&(e=0),f=i.href?i.href:i),f):"e"===j?(i&&h(i,l),e||f):"p"===j?(void 0!==i&&(c=i),c):"is"===j?(void 0!==i&&(a=i),a):"d"===j?(i&&(b=i),b):"C"===j?(void 0!==i&&(d=i),d):"c"===j?!d||d===i||i.iO("#")||i.iO("?")?i:d:void 0};let h=(b,a)=>f="string"!=typeof(e=b)?e.currentTarget&&e.currentTarget.href||a&&a.href||e.currentTarget.action||e.originalEvent.state.url:e}}class Frms{constructor(){let a=0,b=0;this.a=function(e,f){Ay.s.forms&&e&&("d"===e&&(b=f),"a"===e&&b.forEach(b=>{Array.prototype.filter.call(qa(Ay.s.forms,b),function(b){let a=b.getAttribute("action");return Ay.internal(a&&a.length>0?a:Ay.currentURL)}).forEach(b=>{b.addEventListener("submit",e=>{a=e.target,f=c();var h="get",i=a.getAttribute("method");i.length>0&&"post"==i.toLowerCase()&&(h="post");var b,g=a.getAttribute("action");return b=g&&g.length>0?g:Ay.currentURL,Ay.Rq("v",e),"get"==h?b=d(b,f):(Ay.Rq("is",!0),Ay.Rq("d",f)),Ay.trigger("submit",b),Ay.pronto(0,{href:b}),e.preventDefault(),!1})})}))};let c=()=>{let c=new FormData(a),b=qs("input[name][type=submit]",a);return b&&c.append(b.getAttribute("name"),b.value),c},d=(a,c)=>{let b="";for(var[d,e]of(a.iO("?")&&(a=a.substring(0,a.iO("?"))),c.entries()))b+=`${d}=${encodeURIComponent(e)}&`;return`${a}?${b.slice(0,-1)}`}}}class Pronto{constructor(){let a=0,b=0,c=150,d=0;Ay.h.prefetchoff=new Hints(Ay.s.prefetchoff),this.a=function(c,b){if(b){if("i"===b)return bdy=document.body,c.length||(c="body"),a=qa(c),Ay.frms=new Frms().a,Ay.s.idleTime&&(Ay.slides=new classSlides(Ay).a),Ay.scrolly=new Scrolly,(Ay.offsets=new Offsets).f(),Ay.hApi=new HApi,e(),c;if("object"==typeof b){Ay.Rq("h",b),k();return}b.iO("/")&&(Ay.Rq("h",b),k(!0))}};let e=()=>{Ay.hApi.r(window.location.href),window.addEventListener("popstate",m),!0!==Ay.s.prefetchoff&&(_on("mouseenter",Ay.s.selector,f),_on("mouseleave",Ay.s.selector,g),_on("touchstart",Ay.s.selector,h)),_on("click",Ay.s.selector,j,bdy),Ay.frms("d",qa("body")),Ay.frms("a"),Ay.frms("d",a),Ay.s.idleTime&&Ay.slides("i")},f=(a,b)=>(g(),d=setTimeout(()=>h(a,b),c)),g=()=>clearTimeout(d),h=(b,c)=>{if(!0!==Ay.s.prefetchoff&&Ay.Rq("?",!0)){var a=Ay.Rq("v",c,b);Ay.Rq("=",!0)||!a||Ay.h.prefetchoff.find(a)||Ay.fn("+",a,()=>!1)}},i=a=>(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation()),j=(b,c,d)=>{if(Ay.Rq("?")){var a=Ay.Rq("v",c,b);if(!(!a||p(b))){if("#"===a.substr(-1))return!0;if(q())return Ay.hApi.r(a),!0;Ay.scrolly.p(),i(c),Ay.Rq("=")&&Ay.hApi.r(),(Ay.s.refresh||!Ay.Rq("="))&&k(d)}}},k=a=>{Ay.Rq("!"),a&&Ay.Rq("p",!1),Ay.trigger("request"),Ay.fn(Ay.Rq("h"),a=>{a&&(lg("Error in _request : "+a),Ay.trigger("error",a)),l()})},l=()=>{Ay.trigger("beforeload"),Ay.s.requestDelay?(b&&clearTimeout(b),b=setTimeout(n,Ay.s.requestDelay)):n()},m=b=>{var a=window.location.href;Ay.Rq("i"),Ay.Rq("h",a),Ay.Rq("p",!1),Ay.scrolly.p(),a&&a!==Ay.currentURL&&(Ay.trigger("request"),Ay.fn(a,l))},n=()=>{if(Ay.trigger("load"),Ay.s.bodyClasses){var d=Ay.fn("body").getAttribute("class");bdy.setAttribute("class",d||"")}var c,b=Ay.Rq("h");b=Ay.Rq("c",b),Ay.Rq("p")?Ay.hApi.p(b):Ay.hApi.r(b),(c=Ay.fn("title"))&&(qs("title").innerHTML=c.innerHTML),Ay.Rq("C",Ay.fn("-",a)),Ay.frms("a"),Ay.scrolly.l(),o(b),Ay.trigger("render"),Ay.s.passCount&&(qs("#"+Ay.s.passCount).innerHTML="Pass: "+Ay.pass),Ay.s.cb&&Ay.s.cb()},o=a=>{a="/"+a.replace(rootUrl,""),void 0!==window.ga?window.ga("send","pageview",a):void 0!==window._gaq&&window._gaq.push(["_trackPageview",a])},p=c=>{var b=Ay.Rq("h"),a=Ay.Rq("e"),d=a.currentTarget.target||c.target;return a.which>1||a.metaKey||a.ctrlKey||a.shiftKey||a.altKey||"_blank"===d||b.iO("wp-login")||b.iO("wp-admin")},q=()=>{var a=Ay.Rq("e");return a.hash&&a.href.replace(a.hash,"")===window.location.href.replace(location.hash,"")||a.href===window.location.href+"#"}}}Ay.init=()=>{let a=options;return a&&"string"==typeof a?Ay.pronto(0,a):("complete"!==document.readyState&&("loading"===document.readyState||document.documentElement.doScroll)?document.addEventListener("DOMContentLoaded",run):run(),Ay)};let run=()=>{Ay.s=Object.assign(Ay.s,options),(Ay.pages=new Pages).f(),Ay.pronto=new Pronto().a,load()&&(Ay.pronto(Ay.s.elements,"i"),Ay.s.deltas&&Ay.scripts("1"))},load=()=>window.history&&window.history.pushState&&window.history.replaceState&&Ay.s.pluginon?(lg("Ajaxify loaded..."),Ay.s.intevents&&Ay.intevents(),Ay.scripts=new Scripts().a,Ay.scripts("i"),Ay.cache=new Cache,Ay.memory=new Memory,Ay.h.memoryoff=new Hints(Ay.s.memoryoff),Ay.fn=Ay.getPage=new GetPage().a,Ay.detScripts=new DetScripts,Ay.addAll=new AddAll().a,Ay.Rq=new RQ().a,!0):(lg("Gracefully exiting..."),!1);Ay.init()}}class Cache{g(){return this.d}s(a){return this.d=a}l(b){let a=Ay.memory.l(b);return this.s(!1===a?a:Ay.pages.l(a))}}class Memory{l(a){return!!a&& !0!==Ay.s.memoryoff&&(!1===Ay.s.memoryoff?a:!Ay.h.memoryoff.find(a)&&a)}}class Pages{f(){this.d=[]}l(a){if(this.P(a))return this.d[this.i][1]}p(a){this.P(a[0])?this.d[this.i]=a:this.d.push(a)}P(a){return(this.i=this.d.findIndex(b=>b[0]==a))+1}}class DetScripts{d(a){if(!(this.h=Ay.pass?Ay.fn("head"):qs("head")))return!0;this.lk=qa(Ay.pass?".ajy-link":"link",this.h),a.j=Ay.pass?Ay.fn("script"):qa("script"),a.c=this.x("stylesheet"),a.y=qa("style",this.h),a.can=this.x("canonical")}x(a){return Array.prototype.filter.call(this.lk,b=>b.getAttribute("rel").iO(a))}}class Offsets{f(){this.d=[]}l(a){return a.iO("?")&&(a=a.split("?")[0]),this.O(a)?this.d[this.i][1]:0}p(a){let b=a.iO("?")?a.split("?")[0]:a,c=b.iO("#")?b.split("#")[0]:b,d=[c,document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop];this.O(c)?this.d[this.i]=d:this.d.push(d)}O(a){return(this.i=this.d.findIndex(b=>b[0]==a))+1}}class Scrolly{constructor(){"scrollRestoration"in history&&(history.scrollRestoration="manual")}p(){"s"==Ay.s.scrolltop&&Ay.offsets.p(Ay.currentURL)}l(){let a=Ay.currentURL;if(a.iO("#")&&a.iO("#")<a.length-1){let b=qs("#"+a.split("#")[1]);if(!b)return;let c=b.getBoundingClientRect();return this.s(c.top+window.pageYOffset-document.documentElement.clientTop)}"s"==Ay.s.scrolltop?this.s(Ay.offsets.l(a)):Ay.s.scrolltop&&this.s(0)}s(a){setTimeout(()=>window.scrollTo(0,a),Ay.s.scrollDelay)}}class HApi{r(b){let a=this.u(b);history.replaceState({url:a},"state-"+a,a)}p(b){let a=this.u(b);a!==window.location.href&&history.pushState({url:a},"state-"+a,a)}u(a){return a&&(Ay.currentURL=a),Ay.currentURL}}
1
+ let Ay,rootUrl=location.origin,inlineclass="ajy-inline",bdy,qa=(a,b=document)=>b.querySelectorAll(a),qs=(a,b=document)=>b.querySelector(a);class Ajaxify{constructor(options){function _copyAttributes(el,$S,flush){flush&&[...el.attributes].forEach(a=>el.removeAttribute(a.name)),[...$S.attributes].forEach(a=>"ajy-body"==a.nodeValue||el.setAttribute(a.nodeName,a.nodeValue))}function _on(eventName,elementSelector,handler,el=document){el.addEventListener(eventName,function(b){for(var a=b.target;a&&a!=this;a=a.parentNode)if(a.matches(elementSelector)){handler(a,b);break}},!!eventName.iO("mo"))}String.prototype.iO=function(a){return this.toString().indexOf(a)+1},Ay=this,Ay.s={elements:"body",selector:"a:not(.no-ajaxy)",forms:"form:not(.no-ajaxy)",canonical:!1,refresh:!1,requestDelay:0,scrolltop:"s",scrollDelay:0,bodyClasses:!0,deltas:!0,asyncdef:!0,alwayshints:!1,inline:!0,inlinehints:!1,inlineskip:"adsbygoogle",inlineappend:!0,intevents:!0,style:!0,prefetchoff:!1,verbosity:0,memoryoff:!1,cb:0,pluginon:!0,passCount:!1},Ay.pass=0,Ay.currentURL="",Ay.h={},Ay.parse=(b,a)=>((a=document.createElement("div")).insertAdjacentHTML("afterbegin",b),a.firstElementChild),Ay.trigger=(b,c)=>{let a=document.createEvent("HTMLEvents");a.initEvent("pronto."+b,!0,!1),a.data=c||Ay.Rq("e"),window.dispatchEvent(a),document.dispatchEvent(a)},Ay.internal=a=>!!a&&("object"==typeof a&&(a=a.href),""===a||a.substring(0,rootUrl.length)===rootUrl||!a.iO(":")),Ay.intevents=()=>{let a=function(a,b,c=!1){(this===document||this===window)&&"DOMContentLoaded"==a?setTimeout(b):this.ael(a,b,c)};EventTarget.prototype.ael=EventTarget.prototype.addEventListener,EventTarget.prototype.addEventListener=a};class Hints{constructor(a){let _=this;_.list="string"==typeof a&&a.length>0&&a.split(", "),_.find=a=>!!a&&!!_.list&&_.list.some(b=>a.iO(b))}}function lg(m){Ay.s.verbosity&&console&&console.log(m)}class GetPage{constructor(){let a=0,b=0,c=0,d="",e=0,f=0,g=0,h=/<\!DOCTYPE[^>]*>/i,i=/<(html|head|link)([\s\>])/gi,j=/<(body)([\s\>])/gi,k=/<\/(html|head|body|link)\>/gi,l='<div class="ajy-$1"$2',m='<div id="ajy-$1"$2';this.a=function(e,h,i){if(!e)return Ay.cache.g();if(e.iO("/")){if(b=h,c==e)return;return o(e)}if("+"===e)return c=h,b=i,o(h,!0);if("a"===e){f>0&&(t(),g.abort());return}return"s"===e?(f?1:0)+d:"-"===e?n(h):"x"===e?a:Ay.cache.g()?"body"===e?qs("#ajy-"+e,Ay.cache.g()):"script"===e?qa(e,Ay.cache.g()):qs("title"===e?e:".ajy-"+e,Ay.cache.g()):void 0};let n=a=>(Ay.pass++,q(a),qa("body > script").forEach(a=>!!a.classList.contains(inlineclass)&&a.parentNode.removeChild(a)),Ay.scripts(!0),Ay.scripts("s"),Ay.scripts("c")),o=(a,d)=>(a.iO("#")&&(a=a.split("#")[0]),Ay.Rq("is")||!Ay.cache.l(a))?s(a,d):(c=0,b)?b():void 0,p=(b,c)=>{if(c){var a=c.cloneNode(!0);qa("script",a).forEach(a=>a.parentNode.removeChild(a)),_copyAttributes(b,a,!0),b.innerHTML=a.innerHTML}},q=a=>Ay.cache.g()&&!r(a)&&a.forEach(function(a){p(a,qs("#"+a.getAttribute("id"),Ay.cache.g()))}),r=a=>"body"==a[0].tagName.toLowerCase()&&(p(bdy,qs("#ajy-body",Ay.cache.g())),1),s=(c,e)=>{var b=Ay.Rq("is");d=e?"p":"c",g=new AbortController,f++,fetch(c,{method:b?"POST":"GET",cache:"default",mode:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest"},body:b?Ay.Rq("d"):null,signal:g.signal}).then(b=>{if(!b.ok||!v(b)){e||(location.href=c);return}return a=b,b.text()}).then(b=>{if(t(1),b)return a.responseText=b,u(c,b)}).catch(a=>{if("AbortError"!==a.name)try{return Ay.trigger("error",a),lg("Response text : "+a.message),u(c,a.message,a)}catch(b){}}).finally(()=>f--)},t=a=>(c=0,a?0:b=0),u=(a,c,d)=>Ay.cache.s(Ay.parse(w(c)))&&(Ay.pages.p([a,Ay.cache.g()]),1)&&b&&b(d),v=a=>(e=a.headers.get("content-type"))&&(e.iO("html")||e.iO("form-")),w=a=>document.createElement("html").innerHTML=x(a).trim(),x=a=>String(a).replace(h,"").replace(i,l).replace(j,m).replace(k,"</div>")}}class Scripts{constructor(){let $s=!1,txt=0;Ay.h.inlinehints=new Hints(Ay.s.inlinehints),Ay.h.inlineskip=new Hints(Ay.s.inlineskip),this.a=function(a){return"i"===a?($s||($s={}),!0):"s"===a?_allstyle($s.y):"1"===a?(Ay.detScripts.d($s),_addScripts($s)):"c"===a?!!Ay.s.canonical&&!!$s.can&&$s.can.getAttribute("href"):"d"===a?Ay.detScripts.d($s):a&&"object"==typeof a?_onetxt(a):void(Ay.scripts("d")||_addScripts($s))};let _allstyle=a=>!Ay.s.style||!a||(qa("style",qs("head")).forEach(a=>a.parentNode.removeChild(a)),a.forEach(a=>_addstyle(a.textContent))),_onetxt=a=>!(txt=a.textContent).iO(").ajaxify(")&&!txt.iO("new Ajaxify(")&&(Ay.s.inline&&!Ay.h.inlineskip.find(txt)||a.classList.contains("ajaxy")||Ay.h.inlinehints.find(txt))&&_addtxt(a),_addtxt=$s=>{if(txt&&txt.length){if(Ay.s.inlineappend||$s.getAttribute("type")&&!$s.getAttribute("type").iO("text/javascript"))try{return _apptxt($s)}catch(e){}try{eval(txt)}catch(e1){lg("Error in inline script : "+txt+"\nError code : "+e1)}}},_apptxt=b=>{let a=document.createElement("script");_copyAttributes(a,b),a.classList.add(inlineclass);try{a.appendChild(document.createTextNode(b.textContent))}catch(c){a.text=b.textContent}return qs("body").appendChild(a)},_addstyle=a=>qs("head").appendChild(Ay.parse("<style>"+a+"</style>")),_addScripts=a=>(Ay.addAll(a.c,"href"),Ay.addAll(a.j,"src"))}}class AddAll{constructor(){let a=[],b=[],c=[],d=0,e=0,f='<link rel="stylesheet" type="text/css" href="*" />',g='link[href*="!"]',h='script[src*="!"]';Ay.h.alwayshints=new Hints(Ay.s.alwayshints),this.a=function(f,g){if(f.length){if("n"===Ay.s.deltas)return!0;if(d=g,!Ay.s.deltas)return i(f);a="href"==d?b:c,Ay.pass?f.forEach(function(c){var b=c;if(e=b.getAttribute(d),k(b)){m(),l(b);return}if(e){a.some(a=>a==e)||(a.push(e),l(b));return}"href"==d||b.classList.contains("no-ajaxy")||Ay.scripts(b)}):j(f)}};let i=a=>a.forEach(a=>l(a)),j=b=>b.forEach(b=>(e=b.getAttribute(d))?a.push(e):0),k=a=>"always"==a.getAttribute("data-class")||Ay.h.alwayshints.find(e),l=a=>{if(e=a.getAttribute(d),"href"==d)return qs("head").appendChild(Ay.parse(f.replace("*",e)));if(!e)return Ay.scripts(a);var b=document.createElement("script");b.async=Ay.s.asyncdef,_copyAttributes(b,a),qs("head").appendChild(b)},m=()=>qa(("href"==d?g:h).replace("!",e)).forEach(a=>a.parentNode.removeChild(a))}}class RQ{constructor(){let a=0,b=0,c=0,d=0,e=0,f=0,g=!1;this.a=function(j,i,l){if("="===j)return i?f===Ay.currentURL||f===g:f===Ay.currentURL;if("!"===j)return g=f;if("?"===j){let k=Ay.fn("s");return k.iO("0")||i||Ay.fn("a"),("1c"!==k||!i)&&("1p"===k&&i&&Ay.s.memoryoff&&Ay.fn("a"),!0)}if("v"===j){if(!i||(h(i,l),!Ay.internal(f)))return!1;j="i"}return"i"===j?(a=!1,b=null,c=!0,d=!1,f):"h"===j?(i&&("string"==typeof i&&(e=0),f=i.href?i.href:i),f):"e"===j?(i&&h(i,l),e||f):"p"===j?(void 0!==i&&(c=i),c):"is"===j?(void 0!==i&&(a=i),a):"d"===j?(i&&(b=i),b):"C"===j?(void 0!==i&&(d=i),d):"c"===j?!d||d===i||i.iO("#")||i.iO("?")?i:d:void 0};let h=(b,a)=>f="string"!=typeof(e=b)?e.currentTarget&&e.currentTarget.href||a&&a.href||e.currentTarget.action||e.originalEvent.state.url:e}}class Frms{constructor(){let a=0,b=0;this.a=function(e,f){Ay.s.forms&&e&&("d"===e&&(b=f),"a"===e&&b.forEach(b=>{Array.prototype.filter.call(qa(Ay.s.forms,b),function(b){let a=b.getAttribute("action");return Ay.internal(a&&a.length>0?a:Ay.currentURL)}).forEach(b=>{b.addEventListener("submit",e=>{a=e.target,f=c();var h="get",i=a.getAttribute("method");i.length>0&&"post"==i.toLowerCase()&&(h="post");var b,g=a.getAttribute("action");return b=g&&g.length>0?g:Ay.currentURL,Ay.Rq("v",e),"get"==h?b=d(b,f):(Ay.Rq("is",!0),Ay.Rq("d",f)),Ay.trigger("submit",b),Ay.pronto(0,{href:b}),e.preventDefault(),!1})})}))};let c=()=>{let c=new FormData(a),b=qs("input[name][type=submit]",a);return b&&c.append(b.getAttribute("name"),b.value),c},d=(a,c)=>{let b="";for(var[d,e]of(a.iO("?")&&(a=a.substring(0,a.iO("?"))),c.entries()))b+=`${d}=${encodeURIComponent(e)}&`;return`${a}?${b.slice(0,-1)}`}}}class Pronto{constructor(){let a=0,b=0,c=150,d=0;Ay.h.prefetchoff=new Hints(Ay.s.prefetchoff),this.a=function(c,b){if(b){if("i"===b)return bdy=document.body,c.length||(c="body"),a=qa(c),Ay.frms=new Frms().a,Ay.s.idleTime&&(Ay.slides=new classSlides(Ay).a),Ay.scrolly=new Scrolly,(Ay.offsets=new Offsets).f(),Ay.hApi=new HApi,e(),c;if("object"==typeof b){Ay.Rq("h",b),k();return}b.iO("/")&&(Ay.Rq("h",b),k(!0))}};let e=()=>{Ay.hApi.r(window.location.href),window.addEventListener("popstate",m),!0!==Ay.s.prefetchoff&&(_on("mouseenter",Ay.s.selector,f),_on("mouseleave",Ay.s.selector,g),_on("touchstart",Ay.s.selector,h)),_on("click",Ay.s.selector,j,bdy),Ay.frms("d",qa("body")),Ay.frms("a"),Ay.frms("d",a),Ay.s.idleTime&&Ay.slides("i")},f=(a,b)=>(g(),d=setTimeout(()=>h(a,b),c)),g=()=>clearTimeout(d),h=(b,c)=>{if(!0!==Ay.s.prefetchoff&&Ay.Rq("?",!0)){var a=Ay.Rq("v",c,b);Ay.Rq("=",!0)||!a||Ay.h.prefetchoff.find(a)||Ay.fn("+",a,()=>!1)}},i=a=>(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation()),j=(b,c,d)=>{if(Ay.Rq("?")){var a=Ay.Rq("v",c,b);if(!(!a||p(b))){if("#"===a.substr(-1))return!0;if(q())return Ay.hApi.r(a),!0;Ay.scrolly.p(),i(c),Ay.Rq("=")&&Ay.hApi.r(),(Ay.s.refresh||!Ay.Rq("="))&&k(d)}}},k=a=>{Ay.Rq("!"),a&&Ay.Rq("p",!1),Ay.trigger("request"),Ay.fn(Ay.Rq("h"),a=>{a&&(lg("Error in _request : "+a),Ay.trigger("error",a)),l()})},l=()=>{Ay.trigger("beforeload"),Ay.s.requestDelay?(b&&clearTimeout(b),b=setTimeout(n,Ay.s.requestDelay)):n()},m=b=>{var a=window.location.href;Ay.Rq("i"),Ay.Rq("h",a),Ay.Rq("p",!1),Ay.scrolly.p(),a&&a!==Ay.currentURL&&(Ay.trigger("request"),Ay.fn(a,l))},n=()=>{Ay.trigger("load"),Ay.s.bodyClasses&&_copyAttributes(bdy,Ay.fn("body"),!0);var c,b=Ay.Rq("h");b=Ay.Rq("c",b),Ay.Rq("p")?Ay.hApi.p(b):Ay.hApi.r(b),(c=Ay.fn("title"))&&(qs("title").innerHTML=c.innerHTML),Ay.Rq("C",Ay.fn("-",a)),Ay.frms("a"),Ay.scrolly.l(),o(b),Ay.trigger("render"),Ay.s.passCount&&(qs("#"+Ay.s.passCount).innerHTML="Pass: "+Ay.pass),Ay.s.cb&&Ay.s.cb()},o=a=>{a="/"+a.replace(rootUrl,""),void 0!==window.ga?window.ga("send","pageview",a):void 0!==window._gaq&&window._gaq.push(["_trackPageview",a])},p=c=>{var b=Ay.Rq("h"),a=Ay.Rq("e"),d=a.currentTarget.target||c.target;return a.which>1||a.metaKey||a.ctrlKey||a.shiftKey||a.altKey||"_blank"===d||b.iO("wp-login")||b.iO("wp-admin")},q=()=>{var a=Ay.Rq("e");return a.hash&&a.href.replace(a.hash,"")===window.location.href.replace(location.hash,"")||a.href===window.location.href+"#"}}}Ay.init=()=>{let a=options;return a&&"string"==typeof a?Ay.pronto(0,a):("complete"!==document.readyState&&("loading"===document.readyState||document.documentElement.doScroll)?document.addEventListener("DOMContentLoaded",run):run(),Ay)};let run=()=>{Ay.s=Object.assign(Ay.s,options),(Ay.pages=new Pages).f(),Ay.pronto=new Pronto().a,load()&&(Ay.pronto(Ay.s.elements,"i"),Ay.s.deltas&&Ay.scripts("1"))},load=()=>window.history&&window.history.pushState&&window.history.replaceState&&Ay.s.pluginon?(lg("Ajaxify loaded..."),Ay.s.intevents&&Ay.intevents(),Ay.scripts=new Scripts().a,Ay.scripts("i"),Ay.cache=new Cache,Ay.memory=new Memory,Ay.h.memoryoff=new Hints(Ay.s.memoryoff),Ay.fn=Ay.getPage=new GetPage().a,Ay.detScripts=new DetScripts,Ay.addAll=new AddAll().a,Ay.Rq=new RQ().a,!0):(lg("Gracefully exiting..."),!1);Ay.init()}}class Cache{g(){return this.d}s(a){return this.d=a}l(b){let a=Ay.memory.l(b);return this.s(!1===a?a:Ay.pages.l(a))}}class Memory{l(a){return!!a&& !0!==Ay.s.memoryoff&&(!1===Ay.s.memoryoff?a:!Ay.h.memoryoff.find(a)&&a)}}class Pages{f(){this.d=[]}l(a){if(this.P(a))return this.d[this.i][1]}p(a){this.P(a[0])?this.d[this.i]=a:this.d.push(a)}P(a){return(this.i=this.d.findIndex(b=>b[0]==a))+1}}class DetScripts{d(a){if(!(this.h=Ay.pass?Ay.fn("head"):qs("head")))return!0;this.lk=qa(Ay.pass?".ajy-link":"link",this.h),a.j=Ay.pass?Ay.fn("script"):qa("script"),a.c=this.x("stylesheet"),a.y=qa("style",this.h),a.can=this.x("canonical")}x(a){return Array.prototype.filter.call(this.lk,b=>b.getAttribute("rel").iO(a))}}class Offsets{f(){this.d=[]}l(a){return a.iO("?")&&(a=a.split("?")[0]),this.O(a)?this.d[this.i][1]:0}p(a){let b=a.iO("?")?a.split("?")[0]:a,c=b.iO("#")?b.split("#")[0]:b,d=[c,document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop];this.O(c)?this.d[this.i]=d:this.d.push(d)}O(a){return(this.i=this.d.findIndex(b=>b[0]==a))+1}}class Scrolly{constructor(){"scrollRestoration"in history&&(history.scrollRestoration="manual")}p(){"s"==Ay.s.scrolltop&&Ay.offsets.p(Ay.currentURL)}l(){let a=Ay.currentURL;if(a.iO("#")&&a.iO("#")<a.length-1){let b=qs("#"+a.split("#")[1]);if(!b)return;let c=b.getBoundingClientRect();return this.s(c.top+window.pageYOffset-document.documentElement.clientTop)}"s"==Ay.s.scrolltop?this.s(Ay.offsets.l(a)):Ay.s.scrolltop&&this.s(0)}s(a){setTimeout(()=>window.scrollTo(0,a),Ay.s.scrollDelay)}}class HApi{r(b){let a=this.u(b);history.replaceState({url:a},"state-"+a,a)}p(b){let a=this.u(b);a!==window.location.href&&history.pushState({url:a},"state-"+a,a)}u(a){return a&&(Ay.currentURL=a),Ay.currentURL}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ajaxify",
3
- "version": "8.2.4",
3
+ "version": "8.2.5",
4
4
  "description": "Ajaxify - The Ajax Plugin",
5
5
  "main": "ajaxify.min.js",
6
6
  "scripts": {