ajaxify 8.2.5 → 8.2.6
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 +111 -119
- package/ajaxify.min.js +1 -1
- package/package.json +1 -1
package/ajaxify.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright Arvind Gupta; MIT Licensed
|
|
7
7
|
*
|
|
8
|
-
* Version 8.2.
|
|
8
|
+
* Version 8.2.6
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/* INTERFACE: See also https://4nf.org/interface/
|
|
@@ -19,12 +19,21 @@ Ajaxifies the whole site, dynamically replacing the elements specified in "eleme
|
|
|
19
19
|
|
|
20
20
|
let Ay; //to become the global handle for the main Ajaxify parent class - if used by you already, please rename and rebuild
|
|
21
21
|
|
|
22
|
+
function _won(a, b, c = false) { if(c === false) c = {once: true}; window.addEventListener(a, b, c); };
|
|
23
|
+
|
|
22
24
|
//Module global helpers
|
|
23
25
|
let rootUrl = location.origin, inlineclass = "ajy-inline",
|
|
24
26
|
bdy,
|
|
25
27
|
qa=(s,o=document)=>o.querySelectorAll(s),
|
|
26
|
-
qs=(s,o=document)=>o.querySelector(s)
|
|
27
|
-
|
|
28
|
+
qs=(s,o=document)=>o.querySelector(s),
|
|
29
|
+
qha=(e)=>qs("head").appendChild(e),
|
|
30
|
+
prC=(e)=>e.parentNode.removeChild(e),
|
|
31
|
+
dcE=(e)=>document.createElement(e),
|
|
32
|
+
|
|
33
|
+
_copyAttributes=(el, S, flush)=>{ //copy all attributes of element generically
|
|
34
|
+
if(flush) [...el.attributes].forEach(e => el.removeAttribute(e.name)); //delete all old attributes
|
|
35
|
+
[...S.attributes].forEach(e => e.nodeValue == "ajy-body" || el.setAttribute(e.nodeName, e.nodeValue)); //low-level insertion
|
|
36
|
+
};
|
|
28
37
|
|
|
29
38
|
// The main plugin - Ajaxify
|
|
30
39
|
// Is passed the global options
|
|
@@ -72,8 +81,8 @@ Ay.s = {
|
|
|
72
81
|
|
|
73
82
|
|
|
74
83
|
Ay.pass = 0; Ay.currentURL = ""; Ay.h = {};
|
|
75
|
-
Ay.parse = (s, pl) => (pl =
|
|
76
|
-
Ay.trigger = (t, e) => { let ev = document.createEvent('HTMLEvents'); ev.initEvent("pronto." + t, true, false); ev.data = e ? e : Ay.Rq("e"); window.dispatchEvent(ev);
|
|
84
|
+
Ay.parse = (s, pl) => (pl = dcE('div'), pl.insertAdjacentHTML('afterbegin', s), pl.firstElementChild); // HTML parser
|
|
85
|
+
Ay.trigger = (t, e) => { let ev = document.createEvent('HTMLEvents'); ev.initEvent("pronto." + t, true, false); ev.data = e ? e : Ay.Rq("e"); window.dispatchEvent(ev); };
|
|
77
86
|
Ay.internal = (url) => { if (!url) return false; if (typeof(url) === "object") url = url.href; if (url==="") return true; return url.substring(0,rootUrl.length) === rootUrl || !url.iO(":"); };
|
|
78
87
|
Ay.intevents = () => {
|
|
79
88
|
let iFn = function (a, b, c = false) { if ((this === document || this === window) && a=="DOMContentLoaded") setTimeout(b); else this.ael(a,b,c);}; // if "DOMContentLoaded" - execute function, else - add event listener
|
|
@@ -81,11 +90,6 @@ Ay.intevents = () => {
|
|
|
81
90
|
EventTarget.prototype.addEventListener = iFn; // start intercepting event listener addition
|
|
82
91
|
};
|
|
83
92
|
|
|
84
|
-
function _copyAttributes(el, $S, flush) { //copy all attributes of element generically
|
|
85
|
-
if (flush) [...el.attributes].forEach(e => el.removeAttribute(e.name)); //delete all old attributes
|
|
86
|
-
[...$S.attributes].forEach(e => e.nodeValue == "ajy-body" || el.setAttribute(e.nodeName, e.nodeValue)); //low-level insertion
|
|
87
|
-
}
|
|
88
|
-
|
|
89
93
|
function _on(eventName, elementSelector, handler, el = document) { //e.currentTarget is document when the handler is called
|
|
90
94
|
el.addEventListener(eventName, function(e) {
|
|
91
95
|
// loop parent nodes from the target to the delegation node
|
|
@@ -154,10 +158,10 @@ divid12 = '<div id="ajy-$1"$2';
|
|
|
154
158
|
|
|
155
159
|
return qs((o === "title") ? o : ".ajy-" + o, Ay.cache.g());
|
|
156
160
|
};
|
|
157
|
-
let _lSel =
|
|
161
|
+
let _lSel = t => (
|
|
158
162
|
Ay.pass++,
|
|
159
|
-
_lEls(
|
|
160
|
-
qa("body > script").forEach(e => (e.classList.contains(inlineclass)) ?
|
|
163
|
+
_lEls(t),
|
|
164
|
+
qa("body > script").forEach(e => (e.classList.contains(inlineclass)) ? prC(e) : false),
|
|
161
165
|
Ay.scripts(true),
|
|
162
166
|
Ay.scripts("s"),
|
|
163
167
|
Ay.scripts("c")
|
|
@@ -169,19 +173,19 @@ let _lSel = $t => (
|
|
|
169
173
|
plus = 0;
|
|
170
174
|
if (cb) return cb();
|
|
171
175
|
},
|
|
172
|
-
_ld = (
|
|
173
|
-
if(
|
|
176
|
+
_ld = (t, h) => {
|
|
177
|
+
if(!h) return; //no input
|
|
174
178
|
|
|
175
|
-
var
|
|
176
|
-
qa("script",
|
|
177
|
-
_copyAttributes(
|
|
178
|
-
|
|
179
|
+
var c = h.cloneNode(true); // clone element node (true = deep clone)
|
|
180
|
+
qa("script", c).forEach(e => prC(e));
|
|
181
|
+
_copyAttributes(t, c, true);
|
|
182
|
+
t.innerHTML = c.innerHTML;
|
|
179
183
|
},
|
|
180
|
-
_lEls =
|
|
181
|
-
Ay.cache.g() && !_isBody(
|
|
182
|
-
_ld(
|
|
184
|
+
_lEls = t =>
|
|
185
|
+
Ay.cache.g() && !_isBody(t) && t.forEach(function(e) {
|
|
186
|
+
_ld(e, qs("#" + e.getAttribute("id"), Ay.cache.g()));
|
|
183
187
|
}),
|
|
184
|
-
_isBody =
|
|
188
|
+
_isBody = t => t[0].tagName.toLowerCase() == "body" && (_ld(bdy, qs("#ajy-body", Ay.cache.g())), 1),
|
|
185
189
|
_lAjax = (hin, pre) => {
|
|
186
190
|
var ispost = Ay.Rq("is");
|
|
187
191
|
if (pre) rt="p"; else rt="c";
|
|
@@ -220,7 +224,7 @@ let _lSel = $t => (
|
|
|
220
224
|
_cl = c => (plus = 0, (!c) ? cb = 0 : 0), // clear plus AND/OR callback
|
|
221
225
|
_cache = (href, h, err) => Ay.cache.s(Ay.parse(_parseHTML(h))) && (Ay.pages.p([href, Ay.cache.g()]), 1) && cb && cb(err),
|
|
222
226
|
_isHtml = x => (ct = x.headers.get("content-type")) && (ct.iO("html") || ct.iO("form-")),
|
|
223
|
-
_parseHTML = h =>
|
|
227
|
+
_parseHTML = h => dcE("html").innerHTML = _replD(h).trim(),
|
|
224
228
|
_replD = h => String(h).replace(docType, "").replace(tagso, div12).replace(tagsod, divid12).replace(tagsc, "</div>")
|
|
225
229
|
}}
|
|
226
230
|
|
|
@@ -231,116 +235,57 @@ let _lSel = $t => (
|
|
|
231
235
|
// <object> - handle one inline script
|
|
232
236
|
// otherwise - delta loading
|
|
233
237
|
class Scripts { constructor() {
|
|
234
|
-
let
|
|
238
|
+
let S = false, txt = 0;
|
|
235
239
|
Ay.h.inlinehints = new Hints(Ay.s.inlinehints);
|
|
236
240
|
Ay.h.inlineskip = new Hints(Ay.s.inlineskip);
|
|
237
241
|
|
|
238
242
|
this.a = function (o) {
|
|
239
243
|
if (o === "i") {
|
|
240
|
-
if(
|
|
244
|
+
if(!S) S = {};
|
|
241
245
|
return true;
|
|
242
246
|
}
|
|
243
247
|
|
|
244
|
-
if (o === "s") return _allstyle(
|
|
248
|
+
if (o === "s") return _allstyle(S.y);
|
|
245
249
|
|
|
246
250
|
if (o === "1") {
|
|
247
|
-
Ay.detScripts.d(
|
|
248
|
-
return _addScripts(
|
|
251
|
+
Ay.detScripts.d(S);
|
|
252
|
+
return _addScripts(S);
|
|
249
253
|
}
|
|
250
254
|
|
|
251
|
-
if (o === "c") return Ay.s.canonical &&
|
|
252
|
-
if (o === "d") return Ay.detScripts.d(
|
|
255
|
+
if (o === "c") return Ay.s.canonical && S.can ? S.can.getAttribute("href") : false;
|
|
256
|
+
if (o === "d") return Ay.detScripts.d(S);
|
|
253
257
|
if (o && typeof o == "object") return _onetxt(o);
|
|
254
258
|
|
|
255
259
|
if (Ay.scripts("d")) return;
|
|
256
|
-
_addScripts(
|
|
260
|
+
_addScripts(S);
|
|
257
261
|
};
|
|
258
|
-
let _allstyle =
|
|
259
|
-
!Ay.s.style ||
|
|
260
|
-
qa("style", qs("head")).forEach(e =>
|
|
261
|
-
|
|
262
|
+
let _allstyle = S =>
|
|
263
|
+
!Ay.s.style || !S || (
|
|
264
|
+
qa("style", qs("head")).forEach(e => prC(e)), //delete old style tags
|
|
265
|
+
S.forEach(el => {
|
|
266
|
+
let st = Ay.parse('<style>' + el.textContent + '</style>');
|
|
267
|
+
_copyAttributes(st, el);
|
|
268
|
+
qha(st); //append to the head
|
|
269
|
+
})
|
|
262
270
|
),
|
|
263
|
-
_onetxt =
|
|
264
|
-
(!(txt =
|
|
265
|
-
((Ay.s.inline && !Ay.h.inlineskip.find(txt)) ||
|
|
271
|
+
_onetxt = S =>
|
|
272
|
+
(!(txt = S.textContent).iO(").ajaxify(") && (!txt.iO("new Ajaxify(")) &&
|
|
273
|
+
((Ay.s.inline && !Ay.h.inlineskip.find(txt)) || S.classList.contains("ajaxy") ||
|
|
266
274
|
Ay.h.inlinehints.find(txt))
|
|
267
|
-
) && _addtxt(
|
|
268
|
-
_addtxt =
|
|
275
|
+
) && _addtxt(S),
|
|
276
|
+
_addtxt = S => {
|
|
269
277
|
if(!txt || !txt.length) return;
|
|
270
|
-
if(Ay.s.inlineappend || (
|
|
278
|
+
if(Ay.s.inlineappend || (S.getAttribute("type") && !S.getAttribute("type").iO("text/javascript"))) try { return _apptxt(S); } catch (e) { }
|
|
271
279
|
|
|
272
280
|
try { eval(txt); } catch (e1) {
|
|
273
281
|
lg("Error in inline script : " + txt + "\nError code : " + e1);
|
|
274
282
|
}
|
|
275
283
|
},
|
|
276
|
-
_apptxt =
|
|
277
|
-
try {sc.appendChild(document.createTextNode(
|
|
284
|
+
_apptxt = S => { let sc = dcE("script"); _copyAttributes(sc, S); sc.classList.add(inlineclass);
|
|
285
|
+
try {sc.appendChild(document.createTextNode(S.textContent))} catch(e) {sc.text = S.textContent};
|
|
278
286
|
return qs("body").appendChild(sc);
|
|
279
287
|
},
|
|
280
|
-
|
|
281
|
-
_addScripts = $s => (Ay.addAll($s.c, "href"), Ay.addAll($s.j, "src"))
|
|
282
|
-
}}
|
|
283
|
-
|
|
284
|
-
// The AddAll plugin
|
|
285
|
-
// Works on a new selection of scripts to apply delta-loading to it
|
|
286
|
-
// pk parameter:
|
|
287
|
-
// href - operate on stylesheets in the new selection
|
|
288
|
-
// src - operate on JS scripts
|
|
289
|
-
class AddAll { constructor() {
|
|
290
|
-
let $scriptsO = [], $sCssO = [], $sO = [], PK = 0, url = 0,
|
|
291
|
-
linki = '<link rel="stylesheet" type="text/css" href="*" />',
|
|
292
|
-
linkr = 'link[href*="!"]',
|
|
293
|
-
scrr = 'script[src*="!"]';
|
|
294
|
-
|
|
295
|
-
Ay.h.alwayshints = new Hints(Ay.s.alwayshints);
|
|
296
|
-
|
|
297
|
-
this.a = function ($this, pk) {
|
|
298
|
-
if(!$this.length) return; //ensure input
|
|
299
|
-
if(Ay.s.deltas === "n") return true; //Delta-loading completely disabled
|
|
300
|
-
|
|
301
|
-
PK = pk; //Copy "primary key" into internal variable
|
|
302
|
-
|
|
303
|
-
if(!Ay.s.deltas) return _allScripts($this); //process all scripts
|
|
304
|
-
//deltas presumed to be "true" -> proceed with normal delta-loading
|
|
305
|
-
|
|
306
|
-
$scriptsO = PK == "href" ? $sCssO : $sO; //Copy old. Stylesheets or JS
|
|
307
|
-
|
|
308
|
-
if(!Ay.pass) _newArray($this); //Fill new array on initial load, nothing more
|
|
309
|
-
else $this.forEach(function(s) { //Iterate through selection
|
|
310
|
-
var $t = s;
|
|
311
|
-
url = $t.getAttribute(PK);
|
|
312
|
-
if(_classAlways($t)) { //Class always handling
|
|
313
|
-
_removeScript(); //remove from DOM
|
|
314
|
-
_iScript($t); //insert back single external script in the head
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
if(url) { //URL?
|
|
318
|
-
if(!$scriptsO.some(e => e == url)) { // Test, whether new
|
|
319
|
-
$scriptsO.push(url); //If yes: Push to old array
|
|
320
|
-
_iScript($t);
|
|
321
|
-
}
|
|
322
|
-
//Otherwise nothing to do
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if(PK != "href" && !$t.classList.contains("no-ajaxy")) Ay.scripts($t); //Inline JS script? -> inject into DOM
|
|
327
|
-
});
|
|
328
|
-
};
|
|
329
|
-
let _allScripts = $t => $t.forEach(e => _iScript(e)),
|
|
330
|
-
_newArray = $t => $t.forEach(e => (url = e.getAttribute(PK)) ? $scriptsO.push(url) : 0),
|
|
331
|
-
_classAlways = $t => $t.getAttribute("data-class") == "always" || Ay.h.alwayshints.find(url),
|
|
332
|
-
_iScript = $S => {
|
|
333
|
-
url = $S.getAttribute(PK);
|
|
334
|
-
|
|
335
|
-
if(PK == "href") return qs("head").appendChild(Ay.parse(linki.replace("*", url)));
|
|
336
|
-
if(!url) return Ay.scripts($S);
|
|
337
|
-
|
|
338
|
-
var sc = document.createElement("script");
|
|
339
|
-
sc.async = Ay.s.asyncdef;
|
|
340
|
-
_copyAttributes(sc, $S);
|
|
341
|
-
qs("head").appendChild(sc);
|
|
342
|
-
},
|
|
343
|
-
_removeScript = () => qa((PK == "href" ? linkr : scrr).replace("!", url)).forEach(e => e.parentNode.removeChild(e))
|
|
288
|
+
_addScripts = S => (Ay.addAll.a(S.c, "href"), Ay.addAll.a(S.j, "src"))
|
|
344
289
|
}}
|
|
345
290
|
|
|
346
291
|
// The Rq plugin - stands for request
|
|
@@ -357,7 +302,7 @@ let _allScripts = $t => $t.forEach(e => _iScript(e)),
|
|
|
357
302
|
// e - set / get internal "e" (event)
|
|
358
303
|
// p - set / get internal "p" (push flag)
|
|
359
304
|
// is - set / get internal "ispost" (flag whether request is a POST)
|
|
360
|
-
// d - set / get internal "d" (data for central
|
|
305
|
+
// d - set / get internal "d" (data for central fetch())
|
|
361
306
|
// C - set / get internal "can" ("href" of canonical URL)
|
|
362
307
|
// c - check whether simple canonical URL is given and return, otherwise return value passed in "p"
|
|
363
308
|
class RQ { constructor() {
|
|
@@ -420,7 +365,7 @@ class RQ { constructor() {
|
|
|
420
365
|
return ispost;
|
|
421
366
|
}
|
|
422
367
|
|
|
423
|
-
if(o === "d") { //set / get internal "d" (data for central
|
|
368
|
+
if(o === "d") { //set / get internal "d" (data for central fetch())
|
|
424
369
|
if(p) data = p;
|
|
425
370
|
return data;
|
|
426
371
|
}
|
|
@@ -503,23 +448,23 @@ let _k = () => {
|
|
|
503
448
|
// <object> - fetch href part and continue with _request()
|
|
504
449
|
// <URL> - set "h" variable of Rq hard and continue with _request()
|
|
505
450
|
class Pronto { constructor() {
|
|
506
|
-
let
|
|
451
|
+
let gsl = 0, requestTimer = 0, pd = 150, ptim = 0;
|
|
507
452
|
Ay.h.prefetchoff = new Hints(Ay.s.prefetchoff);
|
|
508
453
|
|
|
509
|
-
this.a = function (
|
|
454
|
+
this.a = function (sl, h) {
|
|
510
455
|
if(!h) return; //ensure data
|
|
511
456
|
|
|
512
457
|
if(h === "i") { //request to initialise
|
|
513
458
|
bdy = document.body;
|
|
514
|
-
if(
|
|
515
|
-
|
|
459
|
+
if(!sl.length) sl = "body";
|
|
460
|
+
gsl = qa(sl); //copy selection to global selector
|
|
516
461
|
Ay.frms = new Frms().a; //initialise forms sub-plugin
|
|
517
462
|
if(Ay.s.idleTime) Ay.slides = new classSlides(Ay).a; //initialise optional slideshow sub-plugin
|
|
518
463
|
Ay.scrolly = new Scrolly(); //initialise scroll effects sub-plugin
|
|
519
464
|
(Ay.offsets = new Offsets()).f();
|
|
520
465
|
Ay.hApi = new HApi();
|
|
521
466
|
_init_p(); //initialise Pronto sub-plugin
|
|
522
|
-
return
|
|
467
|
+
return sl; //return query selector for chaining
|
|
523
468
|
}
|
|
524
469
|
|
|
525
470
|
if(typeof(h) === "object") { //jump to internal page programmatically -> handler for forms sub-plugin
|
|
@@ -544,7 +489,7 @@ let _init_p = () => {
|
|
|
544
489
|
_on("click", Ay.s.selector, _click, bdy);
|
|
545
490
|
Ay.frms("d", qa("body"));
|
|
546
491
|
Ay.frms("a");
|
|
547
|
-
Ay.frms("d",
|
|
492
|
+
Ay.frms("d", gsl);
|
|
548
493
|
if(Ay.s.idleTime) Ay.slides("i");
|
|
549
494
|
},
|
|
550
495
|
_preftime = (t, e) => (_prefstop(), ptim = setTimeout(()=> _prefetch(t, e), pd)), // call prefetch if timeout expires without being cleared by _prefstop
|
|
@@ -617,7 +562,7 @@ let _init_p = () => {
|
|
|
617
562
|
|
|
618
563
|
if(Ay.Rq("p")) Ay.hApi.p(href); else Ay.hApi.r(href);
|
|
619
564
|
if(title = Ay.fn("title")) qs("title").innerHTML = title.innerHTML;
|
|
620
|
-
Ay.Rq("C", Ay.fn("-",
|
|
565
|
+
Ay.Rq("C", Ay.fn("-", gsl));
|
|
621
566
|
Ay.frms("a");
|
|
622
567
|
|
|
623
568
|
Ay.scrolly.l();
|
|
@@ -678,7 +623,7 @@ let run = () => {
|
|
|
678
623
|
Ay.memory = new Memory(); Ay.h.memoryoff = new Hints(Ay.s.memoryoff);
|
|
679
624
|
Ay.fn = Ay.getPage = new GetPage().a;
|
|
680
625
|
Ay.detScripts = new DetScripts();
|
|
681
|
-
Ay.addAll = new AddAll().
|
|
626
|
+
Ay.addAll = new AddAll(); Ay.h.alwayshints = new Hints(Ay.s.alwayshints);
|
|
682
627
|
Ay.Rq = new RQ().a;
|
|
683
628
|
return true;
|
|
684
629
|
};
|
|
@@ -764,4 +709,51 @@ class HApi {
|
|
|
764
709
|
r(h){ let c = this.u(h); history.replaceState({ url: c }, "state-" + c, c); } //perform replaceState
|
|
765
710
|
p(h){ let c = this.u(h); if (c !== window.location.href) history.pushState({ url: c }, "state-" + c, c); } //perform pushState
|
|
766
711
|
u(h){ if(h) Ay.currentURL = h; return Ay.currentURL; } //update currentURL if given and return always
|
|
767
|
-
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// The AddAll class
|
|
715
|
+
// Works on a new selection of scripts to apply delta-loading to it
|
|
716
|
+
class AddAll { constructor() { this.CSS = []; this.JS = []; }
|
|
717
|
+
a(sl, pk) { //only public function
|
|
718
|
+
if(!sl.length || Ay.s.deltas === "n") return; //ensure input and that delta-loading is enabled
|
|
719
|
+
|
|
720
|
+
this.PK = pk; //Copy "primary key" into internal variable
|
|
721
|
+
|
|
722
|
+
if(!Ay.s.deltas) return sl.forEach(e => this.iScript(e)); //process all scripts and return quickly
|
|
723
|
+
//deltas presumed to be "true" -> proceed with normal delta-loading
|
|
724
|
+
|
|
725
|
+
this.O = pk == "href" ? this.CSS : this.JS; //Load old stylesheets or JS
|
|
726
|
+
|
|
727
|
+
sl.forEach(t => { //Iterate through selection
|
|
728
|
+
let url = this.gA(t); //fetch URL
|
|
729
|
+
if(!Ay.pass) return url && this.O.push(url); //Fill new array on initial load, nothing more
|
|
730
|
+
if(t.getAttribute("data-class") == "always" || Ay.h.alwayshints.find(url)) { //Class always handling
|
|
731
|
+
this.removeScript(); //remove from DOM
|
|
732
|
+
this.iScript(t); //insert back single external script in the head
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
if(url) { //URL?
|
|
736
|
+
if(!this.O.some(e => e == url)) { // Test, whether new
|
|
737
|
+
this.O.push(url); //If yes: Push to old array
|
|
738
|
+
this.iScript(t);
|
|
739
|
+
}
|
|
740
|
+
//Otherwise nothing to do
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if(pk != "href" && !t.classList.contains("no-ajaxy")) Ay.scripts(t); //Inline JS script? -> inject into DOM
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
gA(e){ return this.u = e.getAttribute(this.PK) }
|
|
748
|
+
iScript(S){
|
|
749
|
+
this.gA(S);
|
|
750
|
+
if(this.PK == "href") return qha(Ay.parse('<link rel="stylesheet" type="text/css" href="*" />'.replace("*", this.u)));
|
|
751
|
+
if(!this.u) return Ay.scripts(S);
|
|
752
|
+
|
|
753
|
+
var sc = dcE("script");
|
|
754
|
+
sc.async = Ay.s.asyncdef;
|
|
755
|
+
_copyAttributes(sc, S);
|
|
756
|
+
qha(sc);
|
|
757
|
+
}
|
|
758
|
+
removeScript(){ qa((this.PK == "href" ? 'link[href*="!"]' : 'script[src*="!"]').replace("!", this.u)).forEach(e => prC(e)) }
|
|
759
|
+
}
|
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=>"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}}
|
|
1
|
+
let Ay;function _won(t,e,r=!1){!1===r&&(r={once:!0}),window.addEventListener(t,e,r)}let rootUrl=location.origin,inlineclass="ajy-inline",bdy,qa=(t,e=document)=>e.querySelectorAll(t),qs=(t,e=document)=>e.querySelector(t),qha=t=>qs("head").appendChild(t),prC=t=>t.parentNode.removeChild(t),dcE=t=>document.createElement(t),_copyAttributes=(t,e,r)=>{r&&[...t.attributes].forEach(e=>t.removeAttribute(e.name)),[...e.attributes].forEach(e=>"ajy-body"==e.nodeValue||t.setAttribute(e.nodeName,e.nodeValue))};class Ajaxify{constructor(options){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: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=(t,e)=>((e=dcE("div")).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)},Ay.internal=t=>!!t&&("object"==typeof t&&(t=t.href),""===t||t.substring(0,rootUrl.length)===rootUrl||!t.iO(":")),Ay.intevents=()=>{let t=function(t,e,r=!1){(this===document||this===window)&&"DOMContentLoaded"==t?setTimeout(e):this.ael(t,e,r)};EventTarget.prototype.ael=EventTarget.prototype.addEventListener,EventTarget.prototype.addEventListener=t};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,a=0,y=/<\!DOCTYPE[^>]*>/i,o=/<(html|head|link)([\s\>])/gi,l=/<(body)([\s\>])/gi,c=/<\/(html|head|body|link)\>/gi,A='<div class="ajy-$1"$2',h='<div id="ajy-$1"$2';this.a=function(i,y,o){if(!i)return Ay.cache.g();if(i.iO("/")){if(e=y,r==i)return;return p(i)}if("+"===i)return r=y,e=o,p(y,!0);if("a"===i){n>0&&(m(),a.abort());return}return"s"===i?(n?1:0)+s:"-"===i?f(y):"x"===i?t:Ay.cache.g()?"body"===i?qs("#ajy-"+i,Ay.cache.g()):"script"===i?qa(i,Ay.cache.g()):qs("title"===i?i:".ajy-"+i,Ay.cache.g()):void 0};let f=t=>(Ay.pass++,u(t),qa("body > script").forEach(t=>!!t.classList.contains(inlineclass)&&prC(t)),Ay.scripts(!0),Ay.scripts("s"),Ay.scripts("c")),p=(t,s)=>(t.iO("#")&&(t=t.split("#")[0]),Ay.Rq("is")||!Ay.cache.l(t))?$(t,s):(r=0,e)?e():void 0,d=(t,e)=>{if(e){var r=e.cloneNode(!0);qa("script",r).forEach(t=>prC(t)),_copyAttributes(t,r,!0),t.innerHTML=r.innerHTML}},u=t=>Ay.cache.g()&&!g(t)&&t.forEach(function(t){d(t,qs("#"+t.getAttribute("id"),Ay.cache.g()))}),g=t=>"body"==t[0].tagName.toLowerCase()&&(d(bdy,qs("#ajy-body",Ay.cache.g())),1),$=(e,r)=>{var i=Ay.Rq("is");s=r?"p":"c",a=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:a.signal}).then(s=>{if(!s.ok||!b(s)){r||(location.href=e);return}return t=s,s.text()}).then(r=>{if(m(1),r)return t.responseText=r,q(e,r)}).catch(t=>{if("AbortError"!==t.name)try{return Ay.trigger("error",t),lg("Response text : "+t.message),q(e,t.message,t)}catch(r){}}).finally(()=>n--)},m=t=>(r=0,t?0:e=0),q=(t,r,s)=>Ay.cache.s(Ay.parse(v(r)))&&(Ay.pages.p([t,Ay.cache.g()]),1)&&e&&e(s),b=t=>(i=t.headers.get("content-type"))&&(i.iO("html")||i.iO("form-")),v=t=>dcE("html").innerHTML=R(t).trim(),R=t=>String(t).replace(y,"").replace(o,A).replace(l,h).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=>prC(t)),t.forEach(t=>{let e=Ay.parse("<style>"+t.textContent+"</style>");_copyAttributes(e,t),qha(e)})),_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(e){}try{eval(txt)}catch(e1){lg("Error in inline script : "+txt+"\nError code : "+e1)}}},_apptxt=t=>{let e=dcE("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)},_addScripts=t=>(Ay.addAll.a(t.c,"href"),Ay.addAll.a(t.j,"src"))}}class RQ{constructor(){let t=0,e=0,r=0,s=0,i=0,n=0,a=!1;this.a=function(o,l,c){if("="===o)return l?n===Ay.currentURL||n===a:n===Ay.currentURL;if("!"===o)return a=n;if("?"===o){let A=Ay.fn("s");return A.iO("0")||l||Ay.fn("a"),("1c"!==A||!l)&&("1p"===A&&l&&Ay.s.memoryoff&&Ay.fn("a"),!0)}if("v"===o){if(!l||(y(l,c),!Ay.internal(n)))return!1;o="i"}return"i"===o?(t=!1,e=null,r=!0,s=!1,n):"h"===o?(l&&("string"==typeof l&&(i=0),n=l.href?l.href:l),n):"e"===o?(l&&y(l,c),i||n):"p"===o?(void 0!==l&&(r=l),r):"is"===o?(void 0!==l&&(t=l),t):"d"===o?(l&&(e=l),e):"C"===o?(void 0!==l&&(s=l),s):"c"===o?!s||s===l||l.iO("#")||l.iO("?")?l:s:void 0};let y=(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",a=t.getAttribute("method");a.length>0&&"post"==a.toLowerCase()&&(i="post");var y,o=t.getAttribute("action");return y=o&&o.length>0?o:Ay.currentURL,Ay.Rq("v",e),"get"==i?y=s(y,n):(Ay.Rq("is",!0),Ay.Rq("d",n)),Ay.trigger("submit",y),Ay.pronto(0,{href:y}),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=150,s=0;Ay.h.prefetchoff=new Hints(Ay.s.prefetchoff),this.a=function(e,r){if(r){if("i"===r)return 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,i(),e;if("object"==typeof r){Ay.Rq("h",r),c();return}r.iO("/")&&(Ay.Rq("h",r),c(!0))}};let i=()=>{Ay.hApi.r(window.location.href),window.addEventListener("popstate",h),!0!==Ay.s.prefetchoff&&(_on("mouseenter",Ay.s.selector,n),_on("mouseleave",Ay.s.selector,a),_on("touchstart",Ay.s.selector,y)),_on("click",Ay.s.selector,l,bdy),Ay.frms("d",qa("body")),Ay.frms("a"),Ay.frms("d",t),Ay.s.idleTime&&Ay.slides("i")},n=(t,e)=>(a(),s=setTimeout(()=>y(t,e),r)),a=()=>clearTimeout(s),y=(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)}},o=t=>(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()),l=(t,e,r)=>{if(Ay.Rq("?")){var s=Ay.Rq("v",e,t);if(!(!s||d(t))){if("#"===s.substr(-1))return!0;if(u())return Ay.hApi.r(s),!0;Ay.scrolly.p(),o(e),Ay.Rq("=")&&Ay.hApi.r(),(Ay.s.refresh||!Ay.Rq("="))&&c(r)}}},c=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)),A()})},A=()=>{Ay.trigger("beforeload"),Ay.s.requestDelay?(e&&clearTimeout(e),e=setTimeout(f,Ay.s.requestDelay)):f()},h=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,A))},f=()=>{Ay.trigger("load"),Ay.s.bodyClasses&&_copyAttributes(bdy,Ay.fn("body"),!0);var e,r=Ay.Rq("h");r=Ay.Rq("c",r),Ay.Rq("p")?Ay.hApi.p(r):Ay.hApi.r(r),(e=Ay.fn("title"))&&(qs("title").innerHTML=e.innerHTML),Ay.Rq("C",Ay.fn("-",t)),Ay.frms("a"),Ay.scrolly.l(),p(r),Ay.trigger("render"),Ay.s.passCount&&(qs("#"+Ay.s.passCount).innerHTML="Pass: "+Ay.pass),Ay.s.cb&&Ay.s.cb()},p=t=>{t="/"+t.replace(rootUrl,""),void 0!==window.ga?window.ga("send","pageview",t):void 0!==window._gaq&&window._gaq.push(["_trackPageview",t])},d=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")},u=()=>{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)?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,Ay.h.alwayshints=new Hints(Ay.s.alwayshints),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}}class AddAll{constructor(){this.CSS=[],this.JS=[]}a(t,e){if(t.length&&"n"!==Ay.s.deltas){if(this.PK=e,!Ay.s.deltas)return t.forEach(t=>this.iScript(t));this.O="href"==e?this.CSS:this.JS,t.forEach(t=>{let r=this.gA(t);if(!Ay.pass)return r&&this.O.push(r);if("always"==t.getAttribute("data-class")||Ay.h.alwayshints.find(r)){this.removeScript(),this.iScript(t);return}if(r){this.O.some(t=>t==r)||(this.O.push(r),this.iScript(t));return}"href"==e||t.classList.contains("no-ajaxy")||Ay.scripts(t)})}}gA(t){return this.u=t.getAttribute(this.PK)}iScript(t){if(this.gA(t),"href"==this.PK)return qha(Ay.parse('<link rel="stylesheet" type="text/css" href="*" />'.replace("*",this.u)));if(!this.u)return Ay.scripts(t);var e=dcE("script");e.async=Ay.s.asyncdef,_copyAttributes(e,t),qha(e)}removeScript(){qa(("href"==this.PK?'link[href*="!"]':'script[src*="!"]').replace("!",this.u)).forEach(t=>prC(t))}}
|