ajaxify 8.1.6 → 8.1.7
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 -71
- package/ajaxify.min.js +1 -1
- package/package.json +1 -1
package/ajaxify.js
CHANGED
|
@@ -515,68 +515,6 @@ let _k = () => {
|
|
|
515
515
|
}
|
|
516
516
|
}}
|
|
517
517
|
|
|
518
|
-
// The stateful Offsets plugin
|
|
519
|
-
// Usage:
|
|
520
|
-
// 1) $.offsets(<URL>) - returns offset of specified URL from internal array
|
|
521
|
-
// 2) $.offsets() - saves the current URL + offset in internal array
|
|
522
|
-
class Offsets { constructor() {
|
|
523
|
-
let d = [], i = -1;
|
|
524
|
-
|
|
525
|
-
this.a = function (h) {
|
|
526
|
-
if (typeof h === "string") { //Lookup page offset
|
|
527
|
-
h = h.iO("?") ? h.split("?")[0] : h; //Handle root URL only from dynamic pages
|
|
528
|
-
i = _iOffset(h); //Fetch offset
|
|
529
|
-
if(i === -1) return 0; // scrollTop if not found
|
|
530
|
-
return d[i][1]; //Return offset that was found
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
//Add page offset
|
|
534
|
-
var u = $.currentURL, us1 = u.iO("?") ? u.split("?")[0] : u, us = us1.iO("#") ? us1.split("#")[0] : us1, os = [us, (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop];
|
|
535
|
-
i = _iOffset(us); //get page index
|
|
536
|
-
if(i === -1) d.push(os); //doesn't exist -> push to array
|
|
537
|
-
else d[i] = os; //exists -> overwrite
|
|
538
|
-
};
|
|
539
|
-
let _iOffset = h => d.findIndex(e => e[0] == h)
|
|
540
|
-
}}
|
|
541
|
-
|
|
542
|
-
// The Scrolly plugin - manages scroll effects centrally
|
|
543
|
-
// scrolltop values: "s" - "smart" (default), true - always scroll to top, false - no scroll
|
|
544
|
-
// Switch (o) values:
|
|
545
|
-
// + - add current page to offsets
|
|
546
|
-
// ! - scroll to current page offset
|
|
547
|
-
class Scrolly { constructor() {
|
|
548
|
-
|
|
549
|
-
if ('scrollRestoration' in history) history.scrollRestoration = 'manual';
|
|
550
|
-
|
|
551
|
-
this.a = function (o) {
|
|
552
|
-
if(!o) return; //ensure operator
|
|
553
|
-
|
|
554
|
-
var op = o; //cache operator
|
|
555
|
-
|
|
556
|
-
if(o === "+" || o === "!") o = $.currentURL; //fetch currentURL for "+" and "-" operators
|
|
557
|
-
|
|
558
|
-
if(op !== "+" && o.iO("#") && (o.iO("#") < o.length - 1)) { //if hash in URL and not standalone hash
|
|
559
|
-
let $el = qs("#" + o.split("#")[1]); //fetch the element
|
|
560
|
-
if (!$el) return; //nothing found -> return quickly
|
|
561
|
-
let box = $el.getBoundingClientRect();
|
|
562
|
-
_scrll(box.top + window.pageYOffset - document.documentElement.clientTop); // ...animate to ID
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
if($.s.scrolltop === "s") { //smart scroll enabled
|
|
567
|
-
if(op === "+") $.offsets(); //add page offset
|
|
568
|
-
if(op === "!") _scrll($.offsets(o)); //scroll to stored position of page
|
|
569
|
-
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
if(op !== "+" && $.s.scrolltop) _scrll(0); //otherwise scroll to top of page
|
|
574
|
-
|
|
575
|
-
//default -> do nothing
|
|
576
|
-
};
|
|
577
|
-
let _scrll = o => setTimeout(() => window.scrollTo(0, o), 10) //delay of 10 milliseconds on all scroll effects
|
|
578
|
-
}}
|
|
579
|
-
|
|
580
518
|
// The Pronto plugin - Pronto variant of Ben Plum's Pronto plugin - low level event handling in general
|
|
581
519
|
// Works on a selection, passed to Pronto by the selection, which specifies, which elements to Ajaxify
|
|
582
520
|
// Switch (h) values:
|
|
@@ -596,8 +534,8 @@ class Pronto { constructor() {
|
|
|
596
534
|
$gthis = qa($this); //copy selection to global selector
|
|
597
535
|
$.frms = new Frms().a; //initialise forms sub-plugin
|
|
598
536
|
if($.s.idleTime) $.slides = new classSlides($).a; //initialise optional slideshow sub-plugin
|
|
599
|
-
$.scrolly = new Scrolly()
|
|
600
|
-
$.offsets = new Offsets().
|
|
537
|
+
$.scrolly = new Scrolly(); //initialise scroll effects sub-plugin
|
|
538
|
+
($.offsets = new Offsets()).f();
|
|
601
539
|
$.hApi = new HApi();
|
|
602
540
|
_init_p(); //initialise Pronto sub-plugin
|
|
603
541
|
return $this; //return query selector for chaining
|
|
@@ -652,7 +590,7 @@ let _init_p = () => {
|
|
|
652
590
|
return true;
|
|
653
591
|
}
|
|
654
592
|
|
|
655
|
-
$.scrolly(
|
|
593
|
+
$.scrolly.p();
|
|
656
594
|
_stopBubbling(e);
|
|
657
595
|
if($.Rq("=")) $.hApi.r();
|
|
658
596
|
if($.s.refresh || !$.Rq("=")) _request(notPush);
|
|
@@ -683,7 +621,7 @@ let _init_p = () => {
|
|
|
683
621
|
$.Rq("i");
|
|
684
622
|
$.Rq("h", url);
|
|
685
623
|
$.Rq("p", false);
|
|
686
|
-
$.scrolly(
|
|
624
|
+
$.scrolly.p();
|
|
687
625
|
|
|
688
626
|
if (!url || url === $.currentURL) return;
|
|
689
627
|
$.trigger("request");
|
|
@@ -701,7 +639,7 @@ let _init_p = () => {
|
|
|
701
639
|
$.Rq("C", $.fn("-", $gthis));
|
|
702
640
|
$.frms("a");
|
|
703
641
|
|
|
704
|
-
$.scrolly(
|
|
642
|
+
$.scrolly.l();
|
|
705
643
|
_gaCaptureView(href);
|
|
706
644
|
$.trigger("render");
|
|
707
645
|
if($.s.passCount) qs("#" + $.s.passCount).innerHTML = "Pass: " + $.pass;
|
|
@@ -777,7 +715,7 @@ class Cache {
|
|
|
777
715
|
// The stateful Memory class
|
|
778
716
|
// Usage: $.memory.l(<URL>) - returns the same URL if not turned off internally
|
|
779
717
|
class Memory {
|
|
780
|
-
l(h)
|
|
718
|
+
l(h){
|
|
781
719
|
if (!h || $.s.memoryoff === true) return false;
|
|
782
720
|
if ($.s.memoryoff === false) return h;
|
|
783
721
|
return $.h.memoryoff.find(h) ? false : h;
|
|
@@ -793,10 +731,42 @@ class Pages {
|
|
|
793
731
|
P(u){ return (this.i = this.d.findIndex(e => e[0] == u)) + 1 } //lookup page index and store in "i"
|
|
794
732
|
}
|
|
795
733
|
|
|
734
|
+
// The Offsets class
|
|
735
|
+
// this.d = Array of pages - [0] = URL // [1] = offset
|
|
736
|
+
class Offsets {
|
|
737
|
+
f(){ this.d = [] } //flush internal offsets array - must be performed by parent
|
|
738
|
+
l(h){ if(h.iO("?")) h = h.split("?")[0]; //lookup page offset
|
|
739
|
+
return this.O(h) ? this.d[this.i][1] : 0; //return if found otherwise 0
|
|
740
|
+
}
|
|
741
|
+
p(h){ let us1 = h.iO("?") ? h.split("?")[0] : h, //initialise all helper variables in one go
|
|
742
|
+
us = us1.iO("#") ? us1.split("#")[0] : us1,
|
|
743
|
+
os = [us, (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop];
|
|
744
|
+
if(this.O(us)) this.d[this.i]=os; else this.d.push(os); // update if found, otherwise push
|
|
745
|
+
}
|
|
746
|
+
O(h){ return (this.i = this.d.findIndex(e => e[0] == h)) + 1 } //find URL in internal array - add 1 for convenience
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// The Scrolly class
|
|
750
|
+
// operates on $.currentURL
|
|
751
|
+
class Scrolly { constructor() { if ('scrollRestoration' in history) history.scrollRestoration = 'manual' }
|
|
752
|
+
p(){ $.s.scrolltop == "s" && $.offsets.p($.currentURL) }
|
|
753
|
+
l(){ let o = $.currentURL;
|
|
754
|
+
if(o.iO("#") && (o.iO("#") < o.length - 1)) { //if hash in URL and not standalone hash
|
|
755
|
+
let $el = qs("#" + o.split("#")[1]); //fetch the element
|
|
756
|
+
if (!$el) return; //nothing found -> return quickly
|
|
757
|
+
let box = $el.getBoundingClientRect();
|
|
758
|
+
return this.s(box.top + window.pageYOffset - document.documentElement.clientTop); // ...animate to ID
|
|
759
|
+
}
|
|
760
|
+
if($.s.scrolltop == "s") this.s($.offsets.l(o)); //smart scroll -> lookup and restore offset
|
|
761
|
+
else $.s.scrolltop && this.s(0); //scrolltop true -> scroll to top of page
|
|
762
|
+
}
|
|
763
|
+
s(o){ setTimeout(() => window.scrollTo(0, o), 10) } //scroll to offset with small timeout
|
|
764
|
+
}
|
|
765
|
+
|
|
796
766
|
// The HAPi class
|
|
797
767
|
// operates on $.currentURL - manages operations on the History API centrally(replaceState / pushState)
|
|
798
768
|
class HApi {
|
|
799
|
-
r(h)
|
|
800
|
-
p(h)
|
|
801
|
-
u(h)
|
|
769
|
+
r(h){ let c = this.u(h); history.replaceState({ url: c }, "state-" + c, c); } //perform replaceState
|
|
770
|
+
p(h){ let c = this.u(h); if (c !== window.location.href) history.pushState({ url: c }, "state-" + c, c); } //perform pushState
|
|
771
|
+
u(h){ if(h) $.currentURL = h; return $.currentURL; } //update currentURL if given and return always
|
|
802
772
|
}
|
package/ajaxify.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let $,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},$=this,$.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},$.pass=0,$.currentURL="",$.h={},$.parse=((t,e)=>(e=document.createElement("div"),e.insertAdjacentHTML("afterbegin",t),e.firstElementChild)),$.trigger=((t,e)=>{let r=document.createEvent("HTMLEvents");r.initEvent("pronto."+t,!0,!1),r.data=e||$.Rq("e"),window.dispatchEvent(r),document.dispatchEvent(r)}),$.internal=(t=>!!t&&("object"==typeof t&&(t=t.href),""===t||(t.substring(0,rootUrl.length)===rootUrl||!t.iO(":")))),$.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){$.s.verbosity&&console&&console.log(t)}class GetPage{constructor(){let t=0,e=0,r=0,s="",n=0,i=0,o=0,a=/<\!DOCTYPE[^>]*>/i,l=/<(html|head|link)([\s\>])/gi,c=/<(body)([\s\>])/gi,d=/<\/(html|head|body|link)\>/gi;this.a=function(n,a,l){if(!n)return $.cache.g();if(n.iO("/")){if(e=a,r==n)return;return u(n)}if("+"===n)return r=a,e=l,u(a,!0);if("a"!==n){if("s"===n)return(i?1:0)+s;if("-"===n)return f(a);if("x"===n)return t;if($.cache.g())return"body"===n?qs("#ajy-"+n,$.cache.g()):"script"===n?qa(n,$.cache.g()):qs("title"===n?n:".ajy-"+n,$.cache.g())}else i>0&&(m(),o.abort())};let f=t=>($.pass++,p(t),qa("body > script").forEach(t=>!!t.classList.contains(inlineclass)&&t.parentNode.removeChild(t)),$.scripts(!0),$.scripts("s"),$.scripts("c")),u=(t,s)=>(t.iO("#")&&(t=t.split("#")[0]),$.Rq("is")||!$.cache.l(t)?g(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}},p=t=>$.cache.g()&&!y(t)&&t.forEach(function(t){h(t,qs("#"+t.getAttribute("id"),$.cache.g()))}),y=t=>"body"==t[0].tagName.toLowerCase()&&(h(bdy,qs("#ajy-body",$.cache.g())),1),g=(e,r)=>{var n=$.Rq("is");s=r?"p":"c",o=new AbortController,i++,fetch(e,{method:n?"POST":"GET",cache:"default",mode:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest"},body:n?$.Rq("d"):null,signal:o.signal}).then(s=>{if(s.ok&&q(s))return t=s,s.text();r||(location.href=e,m(),$.pronto(0,$.currentURL))}).then(r=>{if(m(1),r)return t.responseText=r,v(e,r)}).catch(t=>{if("AbortError"!==t.name)try{return $.trigger("error",t),lg("Response text : "+t.message),v(e,t.message,t)}catch(t){}}).finally(()=>i--)},m=t=>(r=0,t?0:e=0),v=(t,r,s)=>$.cache.s($.parse(w(r)))&&($.pages.p([t,$.cache.g()]),1)&&e&&e(s),q=t=>(n=t.headers.get("content-type"))&&(n.iO("html")||n.iO("form-")),w=t=>document.createElement("html").innerHTML=b(t).trim(),b=t=>String(t).replace(a,"").replace(l,'<div class="ajy-$1"$2').replace(c,'<div id="ajy-$1"$2').replace(d,"</div>")}}class Scripts{constructor(){let $s=!1,txt=0;$.h.inlinehints=new Hints($.s.inlinehints),$.h.inlineskip=new Hints($.s.inlineskip),this.a=function(t){return"i"===t?($s||($s={}),!0):"s"===t?_allstyle($s.y):"1"===t?($.detScripts($s),_addScripts($s)):"c"===t?!(!$.s.canonical||!$s.can)&&$s.can.getAttribute("href"):"d"===t?$.detScripts($s):t&&"object"==typeof t?_onetxt(t):void($.scripts("d")||_addScripts($s))};let _allstyle=t=>!$.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(")&&($.s.inline&&!$.h.inlineskip.find(txt)||t.classList.contains("ajaxy")||$.h.inlinehints.find(txt))&&_addtxt(t),_addtxt=$s=>{if(txt&&txt.length){if($.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($.parse("<style>"+t+"</style>")),_addScripts=t=>($.addAll(t.c,"href"),$.addAll(t.j,"src"))}}class DetScripts{constructor(){let t=0,e=0,r=0;this.a=function(n){if(!(t=$.pass?$.fn("head"):qs("head")))return!0;e=qa($.pass?".ajy-link":"link",t),r=$.pass?$.fn("script"):qa("script"),n.c=s(e,"stylesheet"),n.y=qa("style",t),n.can=s(e,"canonical"),n.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,n=0;$.h.alwayshints=new Hints($.s.alwayshints),this.a=function(d,f){if(d.length){if("n"===$.s.deltas)return!0;if(s=f,!$.s.deltas)return i(d);t="href"==s?e:r,$.pass?d.forEach(function(e){var r=e;if(n=r.getAttribute(s),a(r))return c(),void l(r);n?t.some(t=>t==n)||(t.push(n),l(r)):"href"==s||r.classList.contains("no-ajaxy")||$.scripts(r)}):o(d)}};let i=t=>t.forEach(t=>l(t)),o=e=>e.forEach(e=>(n=e.getAttribute(s))?t.push(n):0),a=t=>"always"==t.getAttribute("data-class")||$.h.alwayshints.find(n),l=t=>{if(n=t.getAttribute(s),"href"==s)return qs("head").appendChild($.parse('<link rel="stylesheet" type="text/css" href="*" />'.replace("*",n)));if(!n)return $.scripts(t);var e=document.createElement("script");e.async=$.s.asyncdef,_copyAttributes(e,t),qs("head").appendChild(e)},c=()=>qa(("href"==s?'link[href*="!"]':'script[src*="!"]').replace("!",n)).forEach(t=>t.parentNode.removeChild(t))}}class RQ{constructor(){let t=0,e=0,r=0,s=0,n=0,i=0,o=!1;this.a=function(l,c,d){if("="===l)return c?i===$.currentURL||i===o:i===$.currentURL;if("!"===l)return o=i;if("?"===l){let t=$.fn("s");return t.iO("0")||c||$.fn("a"),"1c"===t&&c?!1:("1p"===t&&c&&(!$.s.memoryoff||$.fn("a")),!0)}if("v"===l){if(!c)return!1;if(a(c,d),!$.internal(i))return!1;l="i"}return"i"===l?(t=!1,e=null,r=!0,s=!1,i):"h"===l?(c&&("string"==typeof c&&(n=0),i=c.href?c.href:c),i):"e"===l?(c&&a(c,d),n||i):"p"===l?(void 0!==c&&(r=c),r):"is"===l?(void 0!==c&&(t=c),t):"d"===l?(c&&(e=c),e):"C"===l?(void 0!==c&&(s=c),s):"c"===l?!s||s===c||c.iO("#")||c.iO("?")?c:s:void 0};let a=(t,e)=>i="string"!=typeof(n=t)?n.currentTarget&&n.currentTarget.href||e&&e.href||n.currentTarget.action||n.originalEvent.state.url:n}}class Frms{constructor(){let t=0,e=0;this.a=function(n,i){$.s.forms&&n&&("d"===n&&(e=i),"a"===n&&e.forEach(e=>{Array.prototype.filter.call(qa($.s.forms,e),function(t){let e=t.getAttribute("action");return $.internal(e&&e.length>0?e:$.currentURL)}).forEach(e=>{e.addEventListener("submit",e=>{t=e.target,i=r();var n="get",o=t.getAttribute("method");o.length>0&&"post"==o.toLowerCase()&&(n="post");var a,l=t.getAttribute("action");return a=l&&l.length>0?l:$.currentURL,$.Rq("v",e),"get"==n?a=s(a,i):($.Rq("is",!0),$.Rq("d",i)),$.trigger("submit",a),$.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,n]of(t.iO("?")&&(t=t.substring(0,t.iO("?"))),e.entries()))r+=`${s}=${encodeURIComponent(n)}&`;return`${t}?${r.slice(0,-1)}`}}}class Offsets{constructor(){let t=[],e=-1;this.a=function(s){if("string"==typeof s)return s=s.iO("?")?s.split("?")[0]:s,-1===(e=r(s))?0:t[e][1];var n=$.currentURL,i=n.iO("?")?n.split("?")[0]:n,o=i.iO("#")?i.split("#")[0]:i,a=[o,document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop];-1===(e=r(o))?t.push(a):t[e]=a};let r=e=>t.findIndex(t=>t[0]==e)}}class Scrolly{constructor(){"scrollRestoration"in history&&(history.scrollRestoration="manual"),this.a=function(e){if(e){var r=e;if("+"!==e&&"!"!==e||(e=$.currentURL),"+"!==r&&e.iO("#")&&e.iO("#")<e.length-1){let r=qs("#"+e.split("#")[1]);if(!r)return;let s=r.getBoundingClientRect();t(s.top+window.pageYOffset-document.documentElement.clientTop)}else{if("s"===$.s.scrolltop)return"+"===r&&$.offsets(),void("!"===r&&t($.offsets(e)));"+"!==r&&$.s.scrolltop&&t(0)}}};let t=t=>setTimeout(()=>window.scrollTo(0,t),10)}}class Pronto{constructor(){let t=0,e=0,r=0;$.h.prefetchoff=new Hints($.s.prefetchoff),this.a=function(e,r){if(r)return"i"===r?(bdy=document.body,e.length||(e="body"),t=qa(e),$.frms=(new Frms).a,$.s.idleTime&&($.slides=new classSlides($).a),$.scrolly=(new Scrolly).a,$.offsets=(new Offsets).a,$.hApi=new HApi,s(),e):"object"==typeof r?($.Rq("h",r),void l()):void(r.iO("/")&&($.Rq("h",r),l(!0)))};let s=()=>{$.hApi.r(window.location.href),window.addEventListener("popstate",d),!0!==$.s.prefetchoff&&(_on("mouseenter",$.s.selector,n),_on("mouseleave",$.s.selector,i),_on("touchstart",$.s.selector,o)),_on("click",$.s.selector,a,bdy),$.frms("d",qa("body")),$.frms("a"),$.frms("d",t),$.s.idleTime&&$.slides("i")},n=(t,e)=>(i(),r=setTimeout(()=>o(t,e),150)),i=()=>clearTimeout(r),o=(t,e)=>{if(!0!==$.s.prefetchoff&&$.Rq("?",!0)){var r=$.Rq("v",e,t);$.Rq("=",!0)||!r||$.h.prefetchoff.find(r)||$.fn("+",r,()=>!1)}},a=(t,e,r)=>{if($.Rq("?")){var s=$.Rq("v",e,t);if(s&&!h(t)){if("#"===s.substr(-1))return!0;if(p())return $.hApi.r(s),!0;$.scrolly("+"),(t=>(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))(e),$.Rq("=")&&$.hApi.r(),!$.s.refresh&&$.Rq("=")||l(r)}}},l=t=>{$.Rq("!"),t&&$.Rq("p",!1),$.trigger("request"),$.fn($.Rq("h"),t=>{t&&(lg("Error in _request : "+t),$.trigger("error",t)),c()})},c=()=>{$.trigger("beforeload"),$.s.requestDelay?(e&&clearTimeout(e),e=setTimeout(f,$.s.requestDelay)):f()},d=t=>{var e=window.location.href;$.Rq("i"),$.Rq("h",e),$.Rq("p",!1),$.scrolly("+"),e&&e!==$.currentURL&&($.trigger("request"),$.fn(e,c))},f=()=>{if($.trigger("load"),$.s.bodyClasses){var e=$.fn("body").getAttribute("class");bdy.setAttribute("class",e||"")}var r,s=$.Rq("h");s=$.Rq("c",s),$.Rq("p")?$.hApi.p(s):$.hApi.r(s),(r=$.fn("title"))&&(qs("title").innerHTML=r.innerHTML),$.Rq("C",$.fn("-",t)),$.frms("a"),$.scrolly("!"),u(s),$.trigger("render"),$.s.passCount&&(qs("#"+$.s.passCount).innerHTML="Pass: "+$.pass),$.s.cb&&$.s.cb()},u=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=$.Rq("h"),r=$.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")},p=()=>{var t=$.Rq("e");return t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")||t.href===window.location.href+"#"}}}$.init=(()=>{let t=options;return t&&"string"==typeof t?$.pronto(0,t):("complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?run():document.addEventListener("DOMContentLoaded",run),$)});let run=()=>{$.s=Object.assign($.s,options),($.pages=new Pages).f(),$.pronto=(new Pronto).a,load()&&($.pronto($.s.elements,"i"),$.s.deltas&&$.scripts("1"))},load=()=>window.history&&window.history.pushState&&window.history.replaceState&&$.s.pluginon?(lg("Ajaxify loaded..."),$.s.intevents&&$.intevents(),$.scripts=(new Scripts).a,$.scripts("i"),$.cache=new Cache,$.memory=new Memory,$.h.memoryoff=new Hints($.s.memoryoff),$.fn=$.getPage=(new GetPage).a,$.detScripts=(new DetScripts).a,$.addAll=(new AddAll).a,$.Rq=(new RQ).a,!0):(lg("Gracefully exiting..."),!1);$.init()}}class Cache{g(){return this.d}s(t){return this.d=t}l(t){let e=$.memory.l(t);return this.s(!1===e?e:$.pages.l(e))}}class Memory{l(t){return!(!t||!0===$.s.memoryoff)&&(!1===$.s.memoryoff?t:!$.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 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&&($.currentURL=t),$.currentURL}}
|
|
1
|
+
let $,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},$=this,$.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},$.pass=0,$.currentURL="",$.h={},$.parse=((t,e)=>(e=document.createElement("div"),e.insertAdjacentHTML("afterbegin",t),e.firstElementChild)),$.trigger=((t,e)=>{let r=document.createEvent("HTMLEvents");r.initEvent("pronto."+t,!0,!1),r.data=e||$.Rq("e"),window.dispatchEvent(r),document.dispatchEvent(r)}),$.internal=(t=>!!t&&("object"==typeof t&&(t=t.href),""===t||(t.substring(0,rootUrl.length)===rootUrl||!t.iO(":")))),$.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){$.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,l=/<(html|head|link)([\s\>])/gi,c=/<(body)([\s\>])/gi,d=/<\/(html|head|body|link)\>/gi;this.a=function(i,a,l){if(!i)return $.cache.g();if(i.iO("/")){if(e=a,r==i)return;return f(i)}if("+"===i)return r=a,e=l,f(a,!0);if("a"!==i){if("s"===i)return(n?1:0)+s;if("-"===i)return h(a);if("x"===i)return t;if($.cache.g())return"body"===i?qs("#ajy-"+i,$.cache.g()):"script"===i?qa(i,$.cache.g()):qs("title"===i?i:".ajy-"+i,$.cache.g())}else n>0&&(m(),o.abort())};let h=t=>($.pass++,u(t),qa("body > script").forEach(t=>!!t.classList.contains(inlineclass)&&t.parentNode.removeChild(t)),$.scripts(!0),$.scripts("s"),$.scripts("c")),f=(t,s)=>(t.iO("#")&&(t=t.split("#")[0]),$.Rq("is")||!$.cache.l(t)?g(t,s):(r=0,e?e():void 0)),p=(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}},u=t=>$.cache.g()&&!y(t)&&t.forEach(function(t){p(t,qs("#"+t.getAttribute("id"),$.cache.g()))}),y=t=>"body"==t[0].tagName.toLowerCase()&&(p(bdy,qs("#ajy-body",$.cache.g())),1),g=(e,r)=>{var i=$.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?$.Rq("d"):null,signal:o.signal}).then(s=>{if(s.ok&&v(s))return t=s,s.text();r||(location.href=e,m(),$.pronto(0,$.currentURL))}).then(r=>{if(m(1),r)return t.responseText=r,q(e,r)}).catch(t=>{if("AbortError"!==t.name)try{return $.trigger("error",t),lg("Response text : "+t.message),q(e,t.message,t)}catch(t){}}).finally(()=>n--)},m=t=>(r=0,t?0:e=0),q=(t,r,s)=>$.cache.s($.parse(w(r)))&&($.pages.p([t,$.cache.g()]),1)&&e&&e(s),v=t=>(i=t.headers.get("content-type"))&&(i.iO("html")||i.iO("form-")),w=t=>document.createElement("html").innerHTML=b(t).trim(),b=t=>String(t).replace(a,"").replace(l,'<div class="ajy-$1"$2').replace(c,'<div id="ajy-$1"$2').replace(d,"</div>")}}class Scripts{constructor(){let $s=!1,txt=0;$.h.inlinehints=new Hints($.s.inlinehints),$.h.inlineskip=new Hints($.s.inlineskip),this.a=function(t){return"i"===t?($s||($s={}),!0):"s"===t?_allstyle($s.y):"1"===t?($.detScripts($s),_addScripts($s)):"c"===t?!(!$.s.canonical||!$s.can)&&$s.can.getAttribute("href"):"d"===t?$.detScripts($s):t&&"object"==typeof t?_onetxt(t):void($.scripts("d")||_addScripts($s))};let _allstyle=t=>!$.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(")&&($.s.inline&&!$.h.inlineskip.find(txt)||t.classList.contains("ajaxy")||$.h.inlinehints.find(txt))&&_addtxt(t),_addtxt=$s=>{if(txt&&txt.length){if($.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($.parse("<style>"+t+"</style>")),_addScripts=t=>($.addAll(t.c,"href"),$.addAll(t.j,"src"))}}class DetScripts{constructor(){let t=0,e=0,r=0;this.a=function(i){if(!(t=$.pass?$.fn("head"):qs("head")))return!0;e=qa($.pass?".ajy-link":"link",t),r=$.pass?$.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;$.h.alwayshints=new Hints($.s.alwayshints),this.a=function(d,h){if(d.length){if("n"===$.s.deltas)return!0;if(s=h,!$.s.deltas)return n(d);t="href"==s?e:r,$.pass?d.forEach(function(e){var r=e;if(i=r.getAttribute(s),a(r))return c(),void l(r);i?t.some(t=>t==i)||(t.push(i),l(r)):"href"==s||r.classList.contains("no-ajaxy")||$.scripts(r)}):o(d)}};let n=t=>t.forEach(t=>l(t)),o=e=>e.forEach(e=>(i=e.getAttribute(s))?t.push(i):0),a=t=>"always"==t.getAttribute("data-class")||$.h.alwayshints.find(i),l=t=>{if(i=t.getAttribute(s),"href"==s)return qs("head").appendChild($.parse('<link rel="stylesheet" type="text/css" href="*" />'.replace("*",i)));if(!i)return $.scripts(t);var e=document.createElement("script");e.async=$.s.asyncdef,_copyAttributes(e,t),qs("head").appendChild(e)},c=()=>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(l,c,d){if("="===l)return c?n===$.currentURL||n===o:n===$.currentURL;if("!"===l)return o=n;if("?"===l){let t=$.fn("s");return t.iO("0")||c||$.fn("a"),"1c"===t&&c?!1:("1p"===t&&c&&(!$.s.memoryoff||$.fn("a")),!0)}if("v"===l){if(!c)return!1;if(a(c,d),!$.internal(n))return!1;l="i"}return"i"===l?(t=!1,e=null,r=!0,s=!1,n):"h"===l?(c&&("string"==typeof c&&(i=0),n=c.href?c.href:c),n):"e"===l?(c&&a(c,d),i||n):"p"===l?(void 0!==c&&(r=c),r):"is"===l?(void 0!==c&&(t=c),t):"d"===l?(c&&(e=c),e):"C"===l?(void 0!==c&&(s=c),s):"c"===l?!s||s===c||c.iO("#")||c.iO("?")?c: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){$.s.forms&&i&&("d"===i&&(e=n),"a"===i&&e.forEach(e=>{Array.prototype.filter.call(qa($.s.forms,e),function(t){let e=t.getAttribute("action");return $.internal(e&&e.length>0?e:$.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,l=t.getAttribute("action");return a=l&&l.length>0?l:$.currentURL,$.Rq("v",e),"get"==i?a=s(a,n):($.Rq("is",!0),$.Rq("d",n)),$.trigger("submit",a),$.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;$.h.prefetchoff=new Hints($.s.prefetchoff),this.a=function(e,r){if(r)return"i"===r?(bdy=document.body,e.length||(e="body"),t=qa(e),$.frms=(new Frms).a,$.s.idleTime&&($.slides=new classSlides($).a),$.scrolly=new Scrolly,($.offsets=new Offsets).f(),$.hApi=new HApi,s(),e):"object"==typeof r?($.Rq("h",r),void l()):void(r.iO("/")&&($.Rq("h",r),l(!0)))};let s=()=>{$.hApi.r(window.location.href),window.addEventListener("popstate",d),!0!==$.s.prefetchoff&&(_on("mouseenter",$.s.selector,i),_on("mouseleave",$.s.selector,n),_on("touchstart",$.s.selector,o)),_on("click",$.s.selector,a,bdy),$.frms("d",qa("body")),$.frms("a"),$.frms("d",t),$.s.idleTime&&$.slides("i")},i=(t,e)=>(n(),r=setTimeout(()=>o(t,e),150)),n=()=>clearTimeout(r),o=(t,e)=>{if(!0!==$.s.prefetchoff&&$.Rq("?",!0)){var r=$.Rq("v",e,t);$.Rq("=",!0)||!r||$.h.prefetchoff.find(r)||$.fn("+",r,()=>!1)}},a=(t,e,r)=>{if($.Rq("?")){var s=$.Rq("v",e,t);if(s&&!p(t)){if("#"===s.substr(-1))return!0;if(u())return $.hApi.r(s),!0;$.scrolly.p(),(t=>(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()))(e),$.Rq("=")&&$.hApi.r(),!$.s.refresh&&$.Rq("=")||l(r)}}},l=t=>{$.Rq("!"),t&&$.Rq("p",!1),$.trigger("request"),$.fn($.Rq("h"),t=>{t&&(lg("Error in _request : "+t),$.trigger("error",t)),c()})},c=()=>{$.trigger("beforeload"),$.s.requestDelay?(e&&clearTimeout(e),e=setTimeout(h,$.s.requestDelay)):h()},d=t=>{var e=window.location.href;$.Rq("i"),$.Rq("h",e),$.Rq("p",!1),$.scrolly.p(),e&&e!==$.currentURL&&($.trigger("request"),$.fn(e,c))},h=()=>{if($.trigger("load"),$.s.bodyClasses){var e=$.fn("body").getAttribute("class");bdy.setAttribute("class",e||"")}var r,s=$.Rq("h");s=$.Rq("c",s),$.Rq("p")?$.hApi.p(s):$.hApi.r(s),(r=$.fn("title"))&&(qs("title").innerHTML=r.innerHTML),$.Rq("C",$.fn("-",t)),$.frms("a"),$.scrolly.l(),f(s),$.trigger("render"),$.s.passCount&&(qs("#"+$.s.passCount).innerHTML="Pass: "+$.pass),$.s.cb&&$.s.cb()},f=t=>{t="/"+t.replace(rootUrl,""),void 0!==window.ga?window.ga("send","pageview",t):void 0!==window._gaq&&window._gaq.push(["_trackPageview",t])},p=t=>{var e=$.Rq("h"),r=$.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")},u=()=>{var t=$.Rq("e");return t.hash&&t.href.replace(t.hash,"")===window.location.href.replace(location.hash,"")||t.href===window.location.href+"#"}}}$.init=(()=>{let t=options;return t&&"string"==typeof t?$.pronto(0,t):("complete"===document.readyState||"loading"!==document.readyState&&!document.documentElement.doScroll?run():document.addEventListener("DOMContentLoaded",run),$)});let run=()=>{$.s=Object.assign($.s,options),($.pages=new Pages).f(),$.pronto=(new Pronto).a,load()&&($.pronto($.s.elements,"i"),$.s.deltas&&$.scripts("1"))},load=()=>window.history&&window.history.pushState&&window.history.replaceState&&$.s.pluginon?(lg("Ajaxify loaded..."),$.s.intevents&&$.intevents(),$.scripts=(new Scripts).a,$.scripts("i"),$.cache=new Cache,$.memory=new Memory,$.h.memoryoff=new Hints($.s.memoryoff),$.fn=$.getPage=(new GetPage).a,$.detScripts=(new DetScripts).a,$.addAll=(new AddAll).a,$.Rq=(new RQ).a,!0):(lg("Gracefully exiting..."),!1);$.init()}}class Cache{g(){return this.d}s(t){return this.d=t}l(t){let e=$.memory.l(t);return this.s(!1===e?e:$.pages.l(e))}}class Memory{l(t){return!(!t||!0===$.s.memoryoff)&&(!1===$.s.memoryoff?t:!$.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"==$.s.scrolltop&&$.offsets.p($.currentURL)}l(){let t=$.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"==$.s.scrolltop?this.s($.offsets.l(t)):$.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&&($.currentURL=t),$.currentURL}}
|