ajaxify 8.2.0 → 8.2.3
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 +41 -46
- package/ajaxify.min.js +1 -1
- package/package.json +1 -1
package/ajaxify.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ajaxify.js
|
|
1
|
+
/*
|
|
2
|
+
* ajaxify.js
|
|
3
3
|
* Ajaxify - The Ajax Plugin
|
|
4
|
-
* https://4nf.org/
|
|
5
|
-
*
|
|
6
|
-
* Copyright Arvind Gupta; MIT Licensed
|
|
7
|
-
|
|
4
|
+
* https://4nf.org/
|
|
5
|
+
*
|
|
6
|
+
* Copyright Arvind Gupta; MIT Licensed
|
|
7
|
+
*
|
|
8
|
+
* Version 8.2.3
|
|
9
|
+
*/
|
|
8
10
|
|
|
9
11
|
/* INTERFACE: See also https://4nf.org/interface/
|
|
10
12
|
|
|
@@ -45,6 +47,7 @@ Ay.s = {
|
|
|
45
47
|
// visual effects settings
|
|
46
48
|
requestDelay : 0, //in msec - Delay of Pronto request
|
|
47
49
|
scrolltop : "s", // Smart scroll, true = always scroll to top of page, false = no scroll
|
|
50
|
+
scrollDelay : 2, // Minimal delay on all scroll effects in milliseconds, useful in case of e.g. smooth scroll
|
|
48
51
|
bodyClasses : false, // Copy body classes from target page, set to "true" to enable
|
|
49
52
|
|
|
50
53
|
// script and style handling settings, prefetch
|
|
@@ -241,12 +244,12 @@ class Scripts { constructor() {
|
|
|
241
244
|
if (o === "s") return _allstyle($s.y);
|
|
242
245
|
|
|
243
246
|
if (o === "1") {
|
|
244
|
-
Ay.detScripts($s);
|
|
247
|
+
Ay.detScripts.d($s);
|
|
245
248
|
return _addScripts($s);
|
|
246
249
|
}
|
|
247
250
|
|
|
248
251
|
if (o === "c") return Ay.s.canonical && $s.can ? $s.can.getAttribute("href") : false;
|
|
249
|
-
if (o === "d") return Ay.detScripts($s);
|
|
252
|
+
if (o === "d") return Ay.detScripts.d($s);
|
|
250
253
|
if (o && typeof o == "object") return _onetxt(o);
|
|
251
254
|
|
|
252
255
|
if (Ay.scripts("d")) return;
|
|
@@ -278,28 +281,6 @@ let _allstyle = $s =>
|
|
|
278
281
|
_addScripts = $s => (Ay.addAll($s.c, "href"), Ay.addAll($s.j, "src"))
|
|
279
282
|
}}
|
|
280
283
|
|
|
281
|
-
// The DetScripts plugin - stands for "detach scripts"
|
|
282
|
-
// Works on "$s" <object> that is passed in and fills it
|
|
283
|
-
// Fetches all stylesheets in the head
|
|
284
|
-
// Fetches the canonical URL
|
|
285
|
-
// Fetches all external scripts on the page
|
|
286
|
-
// Fetches all inline scripts on the page
|
|
287
|
-
class DetScripts { constructor() {
|
|
288
|
-
let head = 0, lk = 0, j = 0;
|
|
289
|
-
|
|
290
|
-
this.a = function ($s) {
|
|
291
|
-
head = Ay.pass ? Ay.fn("head") : qs("head"); //If "pass" is 0 -> fetch head from DOM, otherwise from target page
|
|
292
|
-
if (!head) return true;
|
|
293
|
-
lk = qa(Ay.pass ? ".ajy-link" : "link", head); //If "pass" is 0 -> fetch links from DOM, otherwise from target page
|
|
294
|
-
j = Ay.pass ? Ay.fn("script") : qa("script"); //If "pass" is 0 -> fetch JSs from DOM, otherwise from target page
|
|
295
|
-
$s.c = _rel(lk, "stylesheet"); //Extract stylesheets
|
|
296
|
-
$s.y = qa("style", head); //Extract style tags
|
|
297
|
-
$s.can = _rel(lk, "canonical"); //Extract canonical tag
|
|
298
|
-
$s.j = j; //Assign JSs to internal selection
|
|
299
|
-
};
|
|
300
|
-
let _rel = (lk, v) => Array.prototype.filter.call(lk, e => e.getAttribute("rel").iO(v));
|
|
301
|
-
}}
|
|
302
|
-
|
|
303
284
|
// The AddAll plugin
|
|
304
285
|
// Works on a new selection of scripts to apply delta-loading to it
|
|
305
286
|
// pk parameter:
|
|
@@ -668,7 +649,7 @@ Ay.init = () => {
|
|
|
668
649
|
if (document.readyState === "complete" ||
|
|
669
650
|
(document.readyState !== "loading" && !document.documentElement.doScroll)) run();
|
|
670
651
|
else document.addEventListener('DOMContentLoaded', run);
|
|
671
|
-
return
|
|
652
|
+
return Ay;
|
|
672
653
|
}
|
|
673
654
|
else return Ay.pronto(0, o);
|
|
674
655
|
};
|
|
@@ -696,7 +677,7 @@ let run = () => {
|
|
|
696
677
|
Ay.cache = new Cache();
|
|
697
678
|
Ay.memory = new Memory(); Ay.h.memoryoff = new Hints(Ay.s.memoryoff);
|
|
698
679
|
Ay.fn = Ay.getPage = new GetPage().a;
|
|
699
|
-
Ay.detScripts = new DetScripts()
|
|
680
|
+
Ay.detScripts = new DetScripts();
|
|
700
681
|
Ay.addAll = new AddAll().a;
|
|
701
682
|
Ay.Rq = new RQ().a;
|
|
702
683
|
return true;
|
|
@@ -731,19 +712,33 @@ class Pages {
|
|
|
731
712
|
P(u){ return (this.i = this.d.findIndex(e => e[0] == u)) + 1 } //lookup page index and store in "i"
|
|
732
713
|
}
|
|
733
714
|
|
|
715
|
+
// The DetScripts class - stands for "detach scripts"
|
|
716
|
+
// Works on "s" <object> that is passed in and fills it
|
|
717
|
+
class DetScripts {
|
|
718
|
+
d(s) {
|
|
719
|
+
if(!(this.h = Ay.pass ? Ay.fn("head") : qs("head"))) return true; //If pass is 0 -> fetch head from DOM, otherwise from target page
|
|
720
|
+
this.lk = qa(Ay.pass ? ".ajy-link" : "link", this.h); //If pass is 0 -> fetch links from DOM, otherwise from target page
|
|
721
|
+
s.j = Ay.pass ? Ay.fn("script") : qa("script"); //If pass is 0 -> fetch JSs from DOM, otherwise from target page
|
|
722
|
+
s.c = this.x("stylesheet"); //Extract stylesheets
|
|
723
|
+
s.y = qa("style", this.h); //Extract style tags
|
|
724
|
+
s.can = this.x("canonical"); //Extract canonical tag
|
|
725
|
+
}
|
|
726
|
+
x(v){ return Array.prototype.filter.call(this.lk, e => e.getAttribute("rel").iO(v)) } //Extract link tags with given "rel"
|
|
727
|
+
}
|
|
728
|
+
|
|
734
729
|
// The Offsets class
|
|
735
730
|
// this.d = Array of pages - [0] = URL // [1] = offset
|
|
736
731
|
class Offsets {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
732
|
+
f(){ this.d = [] } //flush internal offsets array - must be performed by parent
|
|
733
|
+
l(h){ if(h.iO("?")) h = h.split("?")[0]; //lookup page offset
|
|
734
|
+
return this.O(h) ? this.d[this.i][1] : 0; //return if found otherwise 0
|
|
735
|
+
}
|
|
736
|
+
p(h){ let us1 = h.iO("?") ? h.split("?")[0] : h, //initialise all helper variables in one go
|
|
737
|
+
us = us1.iO("#") ? us1.split("#")[0] : us1,
|
|
738
|
+
os = [us, (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop];
|
|
739
|
+
if(this.O(us)) this.d[this.i]=os; else this.d.push(os); // update if found, otherwise push
|
|
740
|
+
}
|
|
741
|
+
O(h){ return (this.i = this.d.findIndex(e => e[0] == h)) + 1 } //find URL in internal array - add 1 for convenience
|
|
747
742
|
}
|
|
748
743
|
|
|
749
744
|
// The Scrolly class
|
|
@@ -752,15 +747,15 @@ class Scrolly { constructor() { if ('scrollRestoration' in history) history.scro
|
|
|
752
747
|
p(){ Ay.s.scrolltop == "s" && Ay.offsets.p(Ay.currentURL) }
|
|
753
748
|
l(){ let o = Ay.currentURL;
|
|
754
749
|
if(o.iO("#") && (o.iO("#") < o.length - 1)) { //if hash in URL and not standalone hash
|
|
755
|
-
let
|
|
756
|
-
if
|
|
757
|
-
let box =
|
|
750
|
+
let el = qs("#" + o.split("#")[1]); //fetch the element
|
|
751
|
+
if(!el) return; //nothing found -> return quickly
|
|
752
|
+
let box = el.getBoundingClientRect();
|
|
758
753
|
return this.s(box.top + window.pageYOffset - document.documentElement.clientTop); // ...animate to ID
|
|
759
754
|
}
|
|
760
755
|
if(Ay.s.scrolltop == "s") this.s(Ay.offsets.l(o)); //smart scroll -> lookup and restore offset
|
|
761
756
|
else Ay.s.scrolltop && this.s(0); //scrolltop true -> scroll to top of page
|
|
762
757
|
}
|
|
763
|
-
s(o){ setTimeout(() => window.scrollTo(0, o),
|
|
758
|
+
s(o){ setTimeout(() => window.scrollTo(0, o), Ay.s.scrollDelay) } //scroll to offset
|
|
764
759
|
}
|
|
765
760
|
|
|
766
761
|
// The HAPi class
|
package/ajaxify.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let Ay,rootUrl=location.origin,inlineclass="ajy-inline",bdy,qa=(t,e=document)=>e.querySelectorAll(t),qs=(t,e=document)=>e.querySelector(t);class Ajaxify{constructor(options){function _copyAttributes(t,e,r){r&&[...t.attributes].forEach(e=>t.removeAttribute(e.name)),[...e.attributes].forEach(e=>t.setAttribute(e.nodeName,e.nodeValue))}function _on(t,e,r,s=document){s.addEventListener(t,function(t){for(var s=t.target;s&&s!=this;s=s.parentNode)if(s.matches(e)){r(s,t);break}},!!t.iO("mo"))}String.prototype.iO=function(t){return this.toString().indexOf(t)+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",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=((t,e)=>(e=document.createElement("div"),e.insertAdjacentHTML("afterbegin",t),e.firstElementChild)),Ay.trigger=((t,e)=>{let r=document.createEvent("HTMLEvents");r.initEvent("pronto."+t,!0,!1),r.data=e||Ay.Rq("e"),window.dispatchEvent(r),document.dispatchEvent(r)}),Ay.internal=(t=>!!t&&("object"==typeof t&&(t=t.href),""===t||(t.substring(0,rootUrl.length)===rootUrl||!t.iO(":")))),Ay.intevents=(()=>{EventTarget.prototype.ael=EventTarget.prototype.addEventListener,EventTarget.prototype.addEventListener=function(t,e,r=!1){this!==document&&this!==window||"DOMContentLoaded"!=t?this.ael(t,e,r):setTimeout(e)}});class Hints{constructor(t){let e=this;e.list="string"==typeof t&&t.length>0&&t.split(", "),e.find=(t=>!(!t||!e.list)&&e.list.some(e=>t.iO(e)))}}function lg(t){Ay.s.verbosity&&console&&console.log(t)}class GetPage{constructor(){let t=0,e=0,r=0,s="",i=0,n=0,o=0,a=/<\!DOCTYPE[^>]*>/i,y=/<(html|head|link)([\s\>])/gi,l=/<(body)([\s\>])/gi,c=/<\/(html|head|body|link)\>/gi;this.a=function(i,a,y){if(!i)return Ay.cache.g();if(i.iO("/")){if(e=a,r==i)return;return d(i)}if("+"===i)return r=a,e=y,d(a,!0);if("a"!==i){if("s"===i)return(n?1:0)+s;if("-"===i)return A(a);if("x"===i)return t;if(Ay.cache.g())return"body"===i?qs("#ajy-"+i,Ay.cache.g()):"script"===i?qa(i,Ay.cache.g()):qs("title"===i?i:".ajy-"+i,Ay.cache.g())}else n>0&&(g(),o.abort())};let A=t=>(Ay.pass++,f(t),qa("body > script").forEach(t=>!!t.classList.contains(inlineclass)&&t.parentNode.removeChild(t)),Ay.scripts(!0),Ay.scripts("s"),Ay.scripts("c")),d=(t,s)=>(t.iO("#")&&(t=t.split("#")[0]),Ay.Rq("is")||!Ay.cache.l(t)?u(t,s):(r=0,e?e():void 0)),h=(t,e)=>{if(e){var r=e.cloneNode(!0);qa("script",r).forEach(t=>t.parentNode.removeChild(t)),_copyAttributes(t,r,!0),t.innerHTML=r.innerHTML}},f=t=>Ay.cache.g()&&!p(t)&&t.forEach(function(t){h(t,qs("#"+t.getAttribute("id"),Ay.cache.g()))}),p=t=>"body"==t[0].tagName.toLowerCase()&&(h(bdy,qs("#ajy-body",Ay.cache.g())),1),u=(e,r)=>{var i=Ay.Rq("is");s=r?"p":"c",o=new AbortController,n++,fetch(e,{method:i?"POST":"GET",cache:"default",mode:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest"},body:i?Ay.Rq("d"):null,signal:o.signal}).then(s=>{if(s.ok&&q(s))return t=s,s.text();r||(location.href=e,g(),Ay.pronto(0,Ay.currentURL))}).then(r=>{if(g(1),r)return t.responseText=r,m(e,r)}).catch(t=>{if("AbortError"!==t.name)try{return Ay.trigger("error",t),lg("Response text : "+t.message),m(e,t.message,t)}catch(t){}}).finally(()=>n--)},g=t=>(r=0,t?0:e=0),m=(t,r,s)=>Ay.cache.s(Ay.parse(v(r)))&&(Ay.pages.p([t,Ay.cache.g()]),1)&&e&&e(s),q=t=>(i=t.headers.get("content-type"))&&(i.iO("html")||i.iO("form-")),v=t=>document.createElement("html").innerHTML=w(t).trim(),w=t=>String(t).replace(a,"").replace(y,'<div class="ajy-$1"$2').replace(l,'<div id="ajy-$1"$2').replace(c,"</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(t){return"i"===t?($s||($s={}),!0):"s"===t?_allstyle($s.y):"1"===t?(Ay.detScripts($s),_addScripts($s)):"c"===t?!(!Ay.s.canonical||!$s.can)&&$s.can.getAttribute("href"):"d"===t?Ay.detScripts($s):t&&"object"==typeof t?_onetxt(t):void(Ay.scripts("d")||_addScripts($s))};let _allstyle=t=>!Ay.s.style||!t||(qa("style",qs("head")).forEach(t=>t.parentNode.removeChild(t)),t.forEach(t=>_addstyle(t.textContent))),_onetxt=t=>!(txt=t.textContent).iO(").ajaxify(")&&!txt.iO("new Ajaxify(")&&(Ay.s.inline&&!Ay.h.inlineskip.find(txt)||t.classList.contains("ajaxy")||Ay.h.inlinehints.find(txt))&&_addtxt(t),_addtxt=$s=>{if(txt&&txt.length){if(Ay.s.inlineappend||$s.getAttribute("type")&&!$s.getAttribute("type").iO("text/javascript"))try{return _apptxt($s)}catch(t){}try{eval(txt)}catch(t){lg("Error in inline script : "+txt+"\nError code : "+t)}}},_apptxt=t=>{let e=document.createElement("script");_copyAttributes(e,t),e.classList.add(inlineclass);try{e.appendChild(document.createTextNode(t.textContent))}catch(r){e.text=t.textContent}return qs("body").appendChild(e)},_addstyle=t=>qs("head").appendChild(Ay.parse("<style>"+t+"</style>")),_addScripts=t=>(Ay.addAll(t.c,"href"),Ay.addAll(t.j,"src"))}}class DetScripts{constructor(){let t=0,e=0,r=0;this.a=function(i){if(!(t=Ay.pass?Ay.fn("head"):qs("head")))return!0;e=qa(Ay.pass?".ajy-link":"link",t),r=Ay.pass?Ay.fn("script"):qa("script"),i.c=s(e,"stylesheet"),i.y=qa("style",t),i.can=s(e,"canonical"),i.j=r};let s=(t,e)=>Array.prototype.filter.call(t,t=>t.getAttribute("rel").iO(e))}}class AddAll{constructor(){let t=[],e=[],r=[],s=0,i=0;Ay.h.alwayshints=new Hints(Ay.s.alwayshints),this.a=function(c,A){if(c.length){if("n"===Ay.s.deltas)return!0;if(s=A,!Ay.s.deltas)return n(c);t="href"==s?e:r,Ay.pass?c.forEach(function(e){var r=e;if(i=r.getAttribute(s),a(r))return l(),void y(r);i?t.some(t=>t==i)||(t.push(i),y(r)):"href"==s||r.classList.contains("no-ajaxy")||Ay.scripts(r)}):o(c)}};let n=t=>t.forEach(t=>y(t)),o=e=>e.forEach(e=>(i=e.getAttribute(s))?t.push(i):0),a=t=>"always"==t.getAttribute("data-class")||Ay.h.alwayshints.find(i),y=t=>{if(i=t.getAttribute(s),"href"==s)return qs("head").appendChild(Ay.parse('<link rel="stylesheet" type="text/css" href="*" />'.replace("*",i)));if(!i)return Ay.scripts(t);var e=document.createElement("script");e.async=Ay.s.asyncdef,_copyAttributes(e,t),qs("head").appendChild(e)},l=()=>qa(("href"==s?'link[href*="!"]':'script[src*="!"]').replace("!",i)).forEach(t=>t.parentNode.removeChild(t))}}class RQ{constructor(){let t=0,e=0,r=0,s=0,i=0,n=0,o=!1;this.a=function(y,l,c){if("="===y)return l?n===Ay.currentURL||n===o:n===Ay.currentURL;if("!"===y)return o=n;if("?"===y){let t=Ay.fn("s");return t.iO("0")||l||Ay.fn("a"),"1c"===t&&l?!1:("1p"===t&&l&&(!Ay.s.memoryoff||Ay.fn("a")),!0)}if("v"===y){if(!l)return!1;if(a(l,c),!Ay.internal(n))return!1;y="i"}return"i"===y?(t=!1,e=null,r=!0,s=!1,n):"h"===y?(l&&("string"==typeof l&&(i=0),n=l.href?l.href:l),n):"e"===y?(l&&a(l,c),i||n):"p"===y?(void 0!==l&&(r=l),r):"is"===y?(void 0!==l&&(t=l),t):"d"===y?(l&&(e=l),e):"C"===y?(void 0!==l&&(s=l),s):"c"===y?!s||s===l||l.iO("#")||l.iO("?")?l:s:void 0};let a=(t,e)=>n="string"!=typeof(i=t)?i.currentTarget&&i.currentTarget.href||e&&e.href||i.currentTarget.action||i.originalEvent.state.url:i}}class Frms{constructor(){let t=0,e=0;this.a=function(i,n){Ay.s.forms&&i&&("d"===i&&(e=n),"a"===i&&e.forEach(e=>{Array.prototype.filter.call(qa(Ay.s.forms,e),function(t){let e=t.getAttribute("action");return Ay.internal(e&&e.length>0?e:Ay.currentURL)}).forEach(e=>{e.addEventListener("submit",e=>{t=e.target,n=r();var i="get",o=t.getAttribute("method");o.length>0&&"post"==o.toLowerCase()&&(i="post");var a,y=t.getAttribute("action");return a=y&&y.length>0?y:Ay.currentURL,Ay.Rq("v",e),"get"==i?a=s(a,n):(Ay.Rq("is",!0),Ay.Rq("d",n)),Ay.trigger("submit",a),Ay.pronto(0,{href:a}),e.preventDefault(),!1})})}))};let r=()=>{let e=new FormData(t),r=qs("input[name][type=submit]",t);return r&&e.append(r.getAttribute("name"),r.value),e},s=(t,e)=>{let r="";for(var[s,i]of(t.iO("?")&&(t=t.substring(0,t.iO("?"))),e.entries()))r+=`${s}=${encodeURIComponent(i)}&`;return`${t}?${r.slice(0,-1)}`}}}class Pronto{constructor(){let t=0,e=0,r=0;Ay.h.prefetchoff=new Hints(Ay.s.prefetchoff),this.a=function(e,r){if(r)return"i"===r?(bdy=document.body,e.length||(e="body"),t=qa(e),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,s(),e):"object"==typeof r?(Ay.Rq("h",r),void y()):void(r.iO("/")&&(Ay.Rq("h",r),y(!0)))};let s=()=>{Ay.hApi.r(window.location.href),window.addEventListener("popstate",c),!0!==Ay.s.prefetchoff&&(_on("mouseenter",Ay.s.selector,i),_on("mouseleave",Ay.s.selector,n),_on("touchstart",Ay.s.selector,o)),_on("click",Ay.s.selector,a,bdy),Ay.frms("d",qa("body")),Ay.frms("a"),Ay.frms("d",t),Ay.s.idleTime&&Ay.slides("i")},i=(t,e)=>(n(),r=setTimeout(()=>o(t,e),150)),n=()=>clearTimeout(r),o=(t,e)=>{if(!0!==Ay.s.prefetchoff&&Ay.Rq("?",!0)){var r=Ay.Rq("v",e,t);Ay.Rq("=",!0)||!r||Ay.h.prefetchoff.find(r)||Ay.fn("+",r,()=>!1)}},a=(t,e,r)=>{if(Ay.Rq("?")){var s=Ay.Rq("v",e,t);if(s&&!h(t)){if("#"===s.substr(-1))return!0;if(f())return Ay.hApi.r(s),!0;Ay.scrolly.p(),(t=>(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))(e),Ay.Rq("=")&&Ay.hApi.r(),!Ay.s.refresh&&Ay.Rq("=")||y(r)}}},y=t=>{Ay.Rq("!"),t&&Ay.Rq("p",!1),Ay.trigger("request"),Ay.fn(Ay.Rq("h"),t=>{t&&(lg("Error in _request : "+t),Ay.trigger("error",t)),l()})},l=()=>{Ay.trigger("beforeload"),Ay.s.requestDelay?(e&&clearTimeout(e),e=setTimeout(A,Ay.s.requestDelay)):A()},c=t=>{var e=window.location.href;Ay.Rq("i"),Ay.Rq("h",e),Ay.Rq("p",!1),Ay.scrolly.p(),e&&e!==Ay.currentURL&&(Ay.trigger("request"),Ay.fn(e,l))},A=()=>{if(Ay.trigger("load"),Ay.s.bodyClasses){var e=Ay.fn("body").getAttribute("class");bdy.setAttribute("class",e||"")}var r,s=Ay.Rq("h");s=Ay.Rq("c",s),Ay.Rq("p")?Ay.hApi.p(s):Ay.hApi.r(s),(r=Ay.fn("title"))&&(qs("title").innerHTML=r.innerHTML),Ay.Rq("C",Ay.fn("-",t)),Ay.frms("a"),Ay.scrolly.l(),d(s),Ay.trigger("render"),Ay.s.passCount&&(qs("#"+Ay.s.passCount).innerHTML="Pass: "+Ay.pass),Ay.s.cb&&Ay.s.cb()},d=t=>{t="/"+t.replace(rootUrl,""),void 0!==window.ga?window.ga("send","pageview",t):void 0!==window._gaq&&window._gaq.push(["_trackPageview",t])},h=t=>{var e=Ay.Rq("h"),r=Ay.Rq("e"),s=r.currentTarget.target||t.target;return r.which>1||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||"_blank"===s||e.iO("wp-login")||e.iO("wp-admin")},f=()=>{var t=Ay.Rq("e");return t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")||t.href===window.location.href+"#"}}}Ay.init=(()=>{let t=options;return t&&"string"==typeof t?Ay.pronto(0,t):("complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?run():document.addEventListener("DOMContentLoaded",run),$)});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).a,Ay.addAll=(new AddAll).a,Ay.Rq=(new RQ).a,!0):(lg("Gracefully exiting..."),!1);Ay.init()}}class Cache{g(){return this.d}s(t){return this.d=t}l(t){let e=Ay.memory.l(t);return this.s(!1===e?e:Ay.pages.l(e))}}class Memory{l(t){return!(!t||!0===Ay.s.memoryoff)&&(!1===Ay.s.memoryoff?t:!Ay.h.memoryoff.find(t)&&t)}}class Pages{f(){this.d=[]}l(t){if(this.P(t))return this.d[this.i][1]}p(t){this.P(t[0])?this.d[this.i]=t:this.d.push(t)}P(t){return(this.i=this.d.findIndex(e=>e[0]==t))+1}}class Offsets{f(){this.d=[]}l(t){return t.iO("?")&&(t=t.split("?")[0]),this.O(t)?this.d[this.i][1]:0}p(t){let e=t.iO("?")?t.split("?")[0]:t,r=e.iO("#")?e.split("#")[0]:e,s=[r,document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop];this.O(r)?this.d[this.i]=s:this.d.push(s)}O(t){return(this.i=this.d.findIndex(e=>e[0]==t))+1}}class Scrolly{constructor(){"scrollRestoration"in history&&(history.scrollRestoration="manual")}p(){"s"==Ay.s.scrolltop&&Ay.offsets.p(Ay.currentURL)}l(){let t=Ay.currentURL;if(t.iO("#")&&t.iO("#")<t.length-1){let e=qs("#"+t.split("#")[1]);if(!e)return;let r=e.getBoundingClientRect();return this.s(r.top+window.pageYOffset-document.documentElement.clientTop)}"s"==Ay.s.scrolltop?this.s(Ay.offsets.l(t)):Ay.s.scrolltop&&this.s(0)}s(t){setTimeout(()=>window.scrollTo(0,t),10)}}class HApi{r(t){let e=this.u(t);history.replaceState({url:e},"state-"+e,e)}p(t){let e=this.u(t);e!==window.location.href&&history.pushState({url:e},"state-"+e,e)}u(t){return t&&(Ay.currentURL=t),Ay.currentURL}}
|
|
1
|
+
let Ay,rootUrl=location.origin,inlineclass="ajy-inline",bdy,qa=(t,e=document)=>e.querySelectorAll(t),qs=(t,e=document)=>e.querySelector(t);class Ajaxify{constructor(options){function _copyAttributes(t,e,r){r&&[...t.attributes].forEach(e=>t.removeAttribute(e.name)),[...e.attributes].forEach(e=>t.setAttribute(e.nodeName,e.nodeValue))}function _on(t,e,r,s=document){s.addEventListener(t,function(t){for(var s=t.target;s&&s!=this;s=s.parentNode)if(s.matches(e)){r(s,t);break}},!!t.iO("mo"))}String.prototype.iO=function(t){return this.toString().indexOf(t)+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:2,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=((t,e)=>(e=document.createElement("div"),e.insertAdjacentHTML("afterbegin",t),e.firstElementChild)),Ay.trigger=((t,e)=>{let r=document.createEvent("HTMLEvents");r.initEvent("pronto."+t,!0,!1),r.data=e||Ay.Rq("e"),window.dispatchEvent(r),document.dispatchEvent(r)}),Ay.internal=(t=>!!t&&("object"==typeof t&&(t=t.href),""===t||(t.substring(0,rootUrl.length)===rootUrl||!t.iO(":")))),Ay.intevents=(()=>{EventTarget.prototype.ael=EventTarget.prototype.addEventListener,EventTarget.prototype.addEventListener=function(t,e,r=!1){this!==document&&this!==window||"DOMContentLoaded"!=t?this.ael(t,e,r):setTimeout(e)}});class Hints{constructor(t){let e=this;e.list="string"==typeof t&&t.length>0&&t.split(", "),e.find=(t=>!(!t||!e.list)&&e.list.some(e=>t.iO(e)))}}function lg(t){Ay.s.verbosity&&console&&console.log(t)}class GetPage{constructor(){let t=0,e=0,r=0,s="",i=0,n=0,o=0,a=/<\!DOCTYPE[^>]*>/i,y=/<(html|head|link)([\s\>])/gi,l=/<(body)([\s\>])/gi,c=/<\/(html|head|body|link)\>/gi;this.a=function(i,a,y){if(!i)return Ay.cache.g();if(i.iO("/")){if(e=a,r==i)return;return d(i)}if("+"===i)return r=a,e=y,d(a,!0);if("a"!==i){if("s"===i)return(n?1:0)+s;if("-"===i)return A(a);if("x"===i)return t;if(Ay.cache.g())return"body"===i?qs("#ajy-"+i,Ay.cache.g()):"script"===i?qa(i,Ay.cache.g()):qs("title"===i?i:".ajy-"+i,Ay.cache.g())}else n>0&&(g(),o.abort())};let A=t=>(Ay.pass++,f(t),qa("body > script").forEach(t=>!!t.classList.contains(inlineclass)&&t.parentNode.removeChild(t)),Ay.scripts(!0),Ay.scripts("s"),Ay.scripts("c")),d=(t,s)=>(t.iO("#")&&(t=t.split("#")[0]),Ay.Rq("is")||!Ay.cache.l(t)?u(t,s):(r=0,e?e():void 0)),h=(t,e)=>{if(e){var r=e.cloneNode(!0);qa("script",r).forEach(t=>t.parentNode.removeChild(t)),_copyAttributes(t,r,!0),t.innerHTML=r.innerHTML}},f=t=>Ay.cache.g()&&!p(t)&&t.forEach(function(t){h(t,qs("#"+t.getAttribute("id"),Ay.cache.g()))}),p=t=>"body"==t[0].tagName.toLowerCase()&&(h(bdy,qs("#ajy-body",Ay.cache.g())),1),u=(e,r)=>{var i=Ay.Rq("is");s=r?"p":"c",o=new AbortController,n++,fetch(e,{method:i?"POST":"GET",cache:"default",mode:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest"},body:i?Ay.Rq("d"):null,signal:o.signal}).then(s=>{if(s.ok&&q(s))return t=s,s.text();r||(location.href=e,g(),Ay.pronto(0,Ay.currentURL))}).then(r=>{if(g(1),r)return t.responseText=r,m(e,r)}).catch(t=>{if("AbortError"!==t.name)try{return Ay.trigger("error",t),lg("Response text : "+t.message),m(e,t.message,t)}catch(t){}}).finally(()=>n--)},g=t=>(r=0,t?0:e=0),m=(t,r,s)=>Ay.cache.s(Ay.parse(v(r)))&&(Ay.pages.p([t,Ay.cache.g()]),1)&&e&&e(s),q=t=>(i=t.headers.get("content-type"))&&(i.iO("html")||i.iO("form-")),v=t=>document.createElement("html").innerHTML=w(t).trim(),w=t=>String(t).replace(a,"").replace(y,'<div class="ajy-$1"$2').replace(l,'<div id="ajy-$1"$2').replace(c,"</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(t){return"i"===t?($s||($s={}),!0):"s"===t?_allstyle($s.y):"1"===t?(Ay.detScripts.d($s),_addScripts($s)):"c"===t?!(!Ay.s.canonical||!$s.can)&&$s.can.getAttribute("href"):"d"===t?Ay.detScripts.d($s):t&&"object"==typeof t?_onetxt(t):void(Ay.scripts("d")||_addScripts($s))};let _allstyle=t=>!Ay.s.style||!t||(qa("style",qs("head")).forEach(t=>t.parentNode.removeChild(t)),t.forEach(t=>_addstyle(t.textContent))),_onetxt=t=>!(txt=t.textContent).iO(").ajaxify(")&&!txt.iO("new Ajaxify(")&&(Ay.s.inline&&!Ay.h.inlineskip.find(txt)||t.classList.contains("ajaxy")||Ay.h.inlinehints.find(txt))&&_addtxt(t),_addtxt=$s=>{if(txt&&txt.length){if(Ay.s.inlineappend||$s.getAttribute("type")&&!$s.getAttribute("type").iO("text/javascript"))try{return _apptxt($s)}catch(t){}try{eval(txt)}catch(t){lg("Error in inline script : "+txt+"\nError code : "+t)}}},_apptxt=t=>{let e=document.createElement("script");_copyAttributes(e,t),e.classList.add(inlineclass);try{e.appendChild(document.createTextNode(t.textContent))}catch(r){e.text=t.textContent}return qs("body").appendChild(e)},_addstyle=t=>qs("head").appendChild(Ay.parse("<style>"+t+"</style>")),_addScripts=t=>(Ay.addAll(t.c,"href"),Ay.addAll(t.j,"src"))}}class AddAll{constructor(){let t=[],e=[],r=[],s=0,i=0;Ay.h.alwayshints=new Hints(Ay.s.alwayshints),this.a=function(c,A){if(c.length){if("n"===Ay.s.deltas)return!0;if(s=A,!Ay.s.deltas)return n(c);t="href"==s?e:r,Ay.pass?c.forEach(function(e){var r=e;if(i=r.getAttribute(s),a(r))return l(),void y(r);i?t.some(t=>t==i)||(t.push(i),y(r)):"href"==s||r.classList.contains("no-ajaxy")||Ay.scripts(r)}):o(c)}};let n=t=>t.forEach(t=>y(t)),o=e=>e.forEach(e=>(i=e.getAttribute(s))?t.push(i):0),a=t=>"always"==t.getAttribute("data-class")||Ay.h.alwayshints.find(i),y=t=>{if(i=t.getAttribute(s),"href"==s)return qs("head").appendChild(Ay.parse('<link rel="stylesheet" type="text/css" href="*" />'.replace("*",i)));if(!i)return Ay.scripts(t);var e=document.createElement("script");e.async=Ay.s.asyncdef,_copyAttributes(e,t),qs("head").appendChild(e)},l=()=>qa(("href"==s?'link[href*="!"]':'script[src*="!"]').replace("!",i)).forEach(t=>t.parentNode.removeChild(t))}}class RQ{constructor(){let t=0,e=0,r=0,s=0,i=0,n=0,o=!1;this.a=function(y,l,c){if("="===y)return l?n===Ay.currentURL||n===o:n===Ay.currentURL;if("!"===y)return o=n;if("?"===y){let t=Ay.fn("s");return t.iO("0")||l||Ay.fn("a"),"1c"===t&&l?!1:("1p"===t&&l&&(!Ay.s.memoryoff||Ay.fn("a")),!0)}if("v"===y){if(!l)return!1;if(a(l,c),!Ay.internal(n))return!1;y="i"}return"i"===y?(t=!1,e=null,r=!0,s=!1,n):"h"===y?(l&&("string"==typeof l&&(i=0),n=l.href?l.href:l),n):"e"===y?(l&&a(l,c),i||n):"p"===y?(void 0!==l&&(r=l),r):"is"===y?(void 0!==l&&(t=l),t):"d"===y?(l&&(e=l),e):"C"===y?(void 0!==l&&(s=l),s):"c"===y?!s||s===l||l.iO("#")||l.iO("?")?l:s:void 0};let a=(t,e)=>n="string"!=typeof(i=t)?i.currentTarget&&i.currentTarget.href||e&&e.href||i.currentTarget.action||i.originalEvent.state.url:i}}class Frms{constructor(){let t=0,e=0;this.a=function(i,n){Ay.s.forms&&i&&("d"===i&&(e=n),"a"===i&&e.forEach(e=>{Array.prototype.filter.call(qa(Ay.s.forms,e),function(t){let e=t.getAttribute("action");return Ay.internal(e&&e.length>0?e:Ay.currentURL)}).forEach(e=>{e.addEventListener("submit",e=>{t=e.target,n=r();var i="get",o=t.getAttribute("method");o.length>0&&"post"==o.toLowerCase()&&(i="post");var a,y=t.getAttribute("action");return a=y&&y.length>0?y:Ay.currentURL,Ay.Rq("v",e),"get"==i?a=s(a,n):(Ay.Rq("is",!0),Ay.Rq("d",n)),Ay.trigger("submit",a),Ay.pronto(0,{href:a}),e.preventDefault(),!1})})}))};let r=()=>{let e=new FormData(t),r=qs("input[name][type=submit]",t);return r&&e.append(r.getAttribute("name"),r.value),e},s=(t,e)=>{let r="";for(var[s,i]of(t.iO("?")&&(t=t.substring(0,t.iO("?"))),e.entries()))r+=`${s}=${encodeURIComponent(i)}&`;return`${t}?${r.slice(0,-1)}`}}}class Pronto{constructor(){let t=0,e=0,r=0;Ay.h.prefetchoff=new Hints(Ay.s.prefetchoff),this.a=function(e,r){if(r)return"i"===r?(bdy=document.body,e.length||(e="body"),t=qa(e),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,s(),e):"object"==typeof r?(Ay.Rq("h",r),void y()):void(r.iO("/")&&(Ay.Rq("h",r),y(!0)))};let s=()=>{Ay.hApi.r(window.location.href),window.addEventListener("popstate",c),!0!==Ay.s.prefetchoff&&(_on("mouseenter",Ay.s.selector,i),_on("mouseleave",Ay.s.selector,n),_on("touchstart",Ay.s.selector,o)),_on("click",Ay.s.selector,a,bdy),Ay.frms("d",qa("body")),Ay.frms("a"),Ay.frms("d",t),Ay.s.idleTime&&Ay.slides("i")},i=(t,e)=>(n(),r=setTimeout(()=>o(t,e),150)),n=()=>clearTimeout(r),o=(t,e)=>{if(!0!==Ay.s.prefetchoff&&Ay.Rq("?",!0)){var r=Ay.Rq("v",e,t);Ay.Rq("=",!0)||!r||Ay.h.prefetchoff.find(r)||Ay.fn("+",r,()=>!1)}},a=(t,e,r)=>{if(Ay.Rq("?")){var s=Ay.Rq("v",e,t);if(s&&!h(t)){if("#"===s.substr(-1))return!0;if(f())return Ay.hApi.r(s),!0;Ay.scrolly.p(),(t=>(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))(e),Ay.Rq("=")&&Ay.hApi.r(),!Ay.s.refresh&&Ay.Rq("=")||y(r)}}},y=t=>{Ay.Rq("!"),t&&Ay.Rq("p",!1),Ay.trigger("request"),Ay.fn(Ay.Rq("h"),t=>{t&&(lg("Error in _request : "+t),Ay.trigger("error",t)),l()})},l=()=>{Ay.trigger("beforeload"),Ay.s.requestDelay?(e&&clearTimeout(e),e=setTimeout(A,Ay.s.requestDelay)):A()},c=t=>{var e=window.location.href;Ay.Rq("i"),Ay.Rq("h",e),Ay.Rq("p",!1),Ay.scrolly.p(),e&&e!==Ay.currentURL&&(Ay.trigger("request"),Ay.fn(e,l))},A=()=>{if(Ay.trigger("load"),Ay.s.bodyClasses){var e=Ay.fn("body").getAttribute("class");bdy.setAttribute("class",e||"")}var r,s=Ay.Rq("h");s=Ay.Rq("c",s),Ay.Rq("p")?Ay.hApi.p(s):Ay.hApi.r(s),(r=Ay.fn("title"))&&(qs("title").innerHTML=r.innerHTML),Ay.Rq("C",Ay.fn("-",t)),Ay.frms("a"),Ay.scrolly.l(),d(s),Ay.trigger("render"),Ay.s.passCount&&(qs("#"+Ay.s.passCount).innerHTML="Pass: "+Ay.pass),Ay.s.cb&&Ay.s.cb()},d=t=>{t="/"+t.replace(rootUrl,""),void 0!==window.ga?window.ga("send","pageview",t):void 0!==window._gaq&&window._gaq.push(["_trackPageview",t])},h=t=>{var e=Ay.Rq("h"),r=Ay.Rq("e"),s=r.currentTarget.target||t.target;return r.which>1||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey||"_blank"===s||e.iO("wp-login")||e.iO("wp-admin")},f=()=>{var t=Ay.Rq("e");return t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")||t.href===window.location.href+"#"}}}Ay.init=(()=>{let t=options;return t&&"string"==typeof t?Ay.pronto(0,t):("complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?run():document.addEventListener("DOMContentLoaded",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(t){return this.d=t}l(t){let e=Ay.memory.l(t);return this.s(!1===e?e:Ay.pages.l(e))}}class Memory{l(t){return!(!t||!0===Ay.s.memoryoff)&&(!1===Ay.s.memoryoff?t:!Ay.h.memoryoff.find(t)&&t)}}class Pages{f(){this.d=[]}l(t){if(this.P(t))return this.d[this.i][1]}p(t){this.P(t[0])?this.d[this.i]=t:this.d.push(t)}P(t){return(this.i=this.d.findIndex(e=>e[0]==t))+1}}class DetScripts{d(t){if(!(this.h=Ay.pass?Ay.fn("head"):qs("head")))return!0;this.lk=qa(Ay.pass?".ajy-link":"link",this.h),t.j=Ay.pass?Ay.fn("script"):qa("script"),t.c=this.x("stylesheet"),t.y=qa("style",this.h),t.can=this.x("canonical")}x(t){return Array.prototype.filter.call(this.lk,e=>e.getAttribute("rel").iO(t))}}class Offsets{f(){this.d=[]}l(t){return t.iO("?")&&(t=t.split("?")[0]),this.O(t)?this.d[this.i][1]:0}p(t){let e=t.iO("?")?t.split("?")[0]:t,r=e.iO("#")?e.split("#")[0]:e,s=[r,document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop];this.O(r)?this.d[this.i]=s:this.d.push(s)}O(t){return(this.i=this.d.findIndex(e=>e[0]==t))+1}}class Scrolly{constructor(){"scrollRestoration"in history&&(history.scrollRestoration="manual")}p(){"s"==Ay.s.scrolltop&&Ay.offsets.p(Ay.currentURL)}l(){let t=Ay.currentURL;if(t.iO("#")&&t.iO("#")<t.length-1){let e=qs("#"+t.split("#")[1]);if(!e)return;let r=e.getBoundingClientRect();return this.s(r.top+window.pageYOffset-document.documentElement.clientTop)}"s"==Ay.s.scrolltop?this.s(Ay.offsets.l(t)):Ay.s.scrolltop&&this.s(0)}s(t){setTimeout(()=>window.scrollTo(0,t),Ay.s.scrollDelay)}}class HApi{r(t){let e=this.u(t);history.replaceState({url:e},"state-"+e,e)}p(t){let e=this.u(t);e!==window.location.href&&history.pushState({url:e},"state-"+e,e)}u(t){return t&&(Ay.currentURL=t),Ay.currentURL}}
|