ajaxify 8.1.7 → 8.2.2
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 +189 -195
- 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.2
|
|
9
|
+
*/
|
|
8
10
|
|
|
9
11
|
/* INTERFACE: See also https://4nf.org/interface/
|
|
10
12
|
|
|
@@ -15,7 +17,7 @@ Ajaxifies the whole site, dynamically replacing the elements specified in "eleme
|
|
|
15
17
|
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
|
-
let
|
|
20
|
+
let Ay; //to become the global handle for the main Ajaxify parent class - if used by you already, please rename and rebuild
|
|
19
21
|
|
|
20
22
|
//Module global helpers
|
|
21
23
|
let rootUrl = location.origin, inlineclass = "ajy-inline",
|
|
@@ -31,10 +33,10 @@ let rootUrl = location.origin, inlineclass = "ajy-inline",
|
|
|
31
33
|
// Calls Pronto
|
|
32
34
|
class Ajaxify { constructor(options) {
|
|
33
35
|
String.prototype.iO = function(s) { return this.toString().indexOf(s) + 1; }; //Intuitively better understandable shorthand for String.indexOf() - String.iO()
|
|
34
|
-
|
|
36
|
+
Ay = this;
|
|
35
37
|
|
|
36
38
|
//Options default values
|
|
37
|
-
|
|
39
|
+
Ay.s = {
|
|
38
40
|
// basic config parameters
|
|
39
41
|
elements: "body", //selector for element IDs that are going to be swapped (e.g. "#el1, #el2, #el3")
|
|
40
42
|
selector : "a:not(.no-ajaxy)", //selector for links to trigger swapping - not elements to be swapped - i.e. a selection of links
|
|
@@ -68,11 +70,11 @@ $.s = {
|
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
Ay.pass = 0; Ay.currentURL = ""; Ay.h = {};
|
|
74
|
+
Ay.parse = (s, pl) => (pl = document.createElement('div'), pl.insertAdjacentHTML('afterbegin', s), pl.firstElementChild); // HTML parser
|
|
75
|
+
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); document.dispatchEvent(ev); };
|
|
76
|
+
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(":"); };
|
|
77
|
+
Ay.intevents = () => {
|
|
76
78
|
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
|
|
77
79
|
EventTarget.prototype.ael = EventTarget.prototype.addEventListener; // store original method
|
|
78
80
|
EventTarget.prototype.addEventListener = iFn; // start intercepting event listener addition
|
|
@@ -100,7 +102,7 @@ class Hints { constructor(h) { let _ = this;
|
|
|
100
102
|
_.find = (t) => (!t || !_.list) ? false : _.list.some(h => t.iO(h)); //iterate through hints within passed text (t)
|
|
101
103
|
}}
|
|
102
104
|
|
|
103
|
-
function lg(m){
|
|
105
|
+
function lg(m){ Ay.s.verbosity && console && console.log(m); }
|
|
104
106
|
|
|
105
107
|
// The GetPage class
|
|
106
108
|
// First parameter (o) is a switch:
|
|
@@ -126,7 +128,7 @@ div12 = '<div class="ajy-$1"$2',
|
|
|
126
128
|
divid12 = '<div id="ajy-$1"$2';
|
|
127
129
|
|
|
128
130
|
this.a = function (o, p, p2) {
|
|
129
|
-
if (!o) return
|
|
131
|
+
if (!o) return Ay.cache.g();
|
|
130
132
|
|
|
131
133
|
if (o.iO("/")) {
|
|
132
134
|
cb = p;
|
|
@@ -145,23 +147,23 @@ divid12 = '<div id="ajy-$1"$2';
|
|
|
145
147
|
if (o === "-") return _lSel(p);
|
|
146
148
|
if (o === "x") return rsp;
|
|
147
149
|
|
|
148
|
-
if (
|
|
149
|
-
if (o === "body") return qs("#ajy-" + o,
|
|
150
|
-
if (o === "script") return qa(o,
|
|
150
|
+
if (!Ay.cache.g()) return;
|
|
151
|
+
if (o === "body") return qs("#ajy-" + o, Ay.cache.g());
|
|
152
|
+
if (o === "script") return qa(o, Ay.cache.g());
|
|
151
153
|
|
|
152
|
-
return qs((o === "title") ? o : ".ajy-" + o,
|
|
154
|
+
return qs((o === "title") ? o : ".ajy-" + o, Ay.cache.g());
|
|
153
155
|
};
|
|
154
156
|
let _lSel = $t => (
|
|
155
|
-
|
|
157
|
+
Ay.pass++,
|
|
156
158
|
_lEls($t),
|
|
157
159
|
qa("body > script").forEach(e => (e.classList.contains(inlineclass)) ? e.parentNode.removeChild(e) : false),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
Ay.scripts(true),
|
|
161
|
+
Ay.scripts("s"),
|
|
162
|
+
Ay.scripts("c")
|
|
161
163
|
),
|
|
162
164
|
_lPage = (h, pre) => {
|
|
163
165
|
if (h.iO("#")) h = h.split("#")[0];
|
|
164
|
-
if (
|
|
166
|
+
if (Ay.Rq("is") || !Ay.cache.l(h)) return _lAjax(h, pre);
|
|
165
167
|
|
|
166
168
|
plus = 0;
|
|
167
169
|
if (cb) return cb();
|
|
@@ -175,12 +177,12 @@ let _lSel = $t => (
|
|
|
175
177
|
$t.innerHTML = $c.innerHTML;
|
|
176
178
|
},
|
|
177
179
|
_lEls = $t =>
|
|
178
|
-
|
|
179
|
-
_ld($el, qs("#" + $el.getAttribute("id"),
|
|
180
|
+
Ay.cache.g() && !_isBody($t) && $t.forEach(function($el) {
|
|
181
|
+
_ld($el, qs("#" + $el.getAttribute("id"), Ay.cache.g()));
|
|
180
182
|
}),
|
|
181
|
-
_isBody = $t => $t[0].tagName.toLowerCase() == "body" && (_ld(bdy, qs("#ajy-body",
|
|
183
|
+
_isBody = $t => $t[0].tagName.toLowerCase() == "body" && (_ld(bdy, qs("#ajy-body", Ay.cache.g())), 1),
|
|
182
184
|
_lAjax = (hin, pre) => {
|
|
183
|
-
var ispost =
|
|
185
|
+
var ispost = Ay.Rq("is");
|
|
184
186
|
if (pre) rt="p"; else rt="c";
|
|
185
187
|
|
|
186
188
|
ac = new AbortController(); // set abort controller
|
|
@@ -190,11 +192,11 @@ let _lSel = $t => (
|
|
|
190
192
|
cache: "default",
|
|
191
193
|
mode: "same-origin",
|
|
192
194
|
headers: {"X-Requested-With": "XMLHttpRequest"},
|
|
193
|
-
body: (ispost) ?
|
|
195
|
+
body: (ispost) ? Ay.Rq("d") : null,
|
|
194
196
|
signal: ac.signal
|
|
195
197
|
}).then(r => {
|
|
196
198
|
if (!r.ok || !_isHtml(r)) {
|
|
197
|
-
if (!pre) {location.href = hin; _cl();
|
|
199
|
+
if (!pre) {location.href = hin; _cl(); Ay.pronto(0, Ay.currentURL);}
|
|
198
200
|
return;
|
|
199
201
|
}
|
|
200
202
|
rsp = r; // store response
|
|
@@ -208,14 +210,14 @@ let _lSel = $t => (
|
|
|
208
210
|
}).catch(err => {
|
|
209
211
|
if(err.name === "AbortError") return;
|
|
210
212
|
try {
|
|
211
|
-
|
|
213
|
+
Ay.trigger("error", err);
|
|
212
214
|
lg("Response text : " + err.message);
|
|
213
215
|
return _cache(hin, err.message, err);
|
|
214
216
|
} catch (e) {}
|
|
215
217
|
}).finally(() => rc--); // reset active request counter
|
|
216
218
|
},
|
|
217
219
|
_cl = c => (plus = 0, (!c) ? cb = 0 : 0), // clear plus AND/OR callback
|
|
218
|
-
_cache = (href, h, err) =>
|
|
220
|
+
_cache = (href, h, err) => Ay.cache.s(Ay.parse(_parseHTML(h))) && (Ay.pages.p([href, Ay.cache.g()]), 1) && cb && cb(err),
|
|
219
221
|
_isHtml = x => (ct = x.headers.get("content-type")) && (ct.iO("html") || ct.iO("form-")),
|
|
220
222
|
_parseHTML = h => document.createElement("html").innerHTML = _replD(h).trim(),
|
|
221
223
|
_replD = h => String(h).replace(docType, "").replace(tagso, div12).replace(tagsod, divid12).replace(tagsc, "</div>")
|
|
@@ -229,8 +231,8 @@ let _lSel = $t => (
|
|
|
229
231
|
// otherwise - delta loading
|
|
230
232
|
class Scripts { constructor() {
|
|
231
233
|
let $s = false, txt = 0;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
+
Ay.h.inlinehints = new Hints(Ay.s.inlinehints);
|
|
235
|
+
Ay.h.inlineskip = new Hints(Ay.s.inlineskip);
|
|
234
236
|
|
|
235
237
|
this.a = function (o) {
|
|
236
238
|
if (o === "i") {
|
|
@@ -241,30 +243,30 @@ class Scripts { constructor() {
|
|
|
241
243
|
if (o === "s") return _allstyle($s.y);
|
|
242
244
|
|
|
243
245
|
if (o === "1") {
|
|
244
|
-
|
|
246
|
+
Ay.detScripts.d($s);
|
|
245
247
|
return _addScripts($s);
|
|
246
248
|
}
|
|
247
249
|
|
|
248
|
-
if (o === "c") return
|
|
249
|
-
if (o === "d") return
|
|
250
|
+
if (o === "c") return Ay.s.canonical && $s.can ? $s.can.getAttribute("href") : false;
|
|
251
|
+
if (o === "d") return Ay.detScripts.d($s);
|
|
250
252
|
if (o && typeof o == "object") return _onetxt(o);
|
|
251
253
|
|
|
252
|
-
if (
|
|
254
|
+
if (Ay.scripts("d")) return;
|
|
253
255
|
_addScripts($s);
|
|
254
256
|
};
|
|
255
257
|
let _allstyle = $s =>
|
|
256
|
-
|
|
258
|
+
!Ay.s.style || !$s || (
|
|
257
259
|
qa("style", qs("head")).forEach(e => e.parentNode.removeChild(e)),
|
|
258
260
|
$s.forEach(el => _addstyle(el.textContent))
|
|
259
261
|
),
|
|
260
262
|
_onetxt = $s =>
|
|
261
263
|
(!(txt = $s.textContent).iO(").ajaxify(") && (!txt.iO("new Ajaxify(")) &&
|
|
262
|
-
((
|
|
263
|
-
|
|
264
|
+
((Ay.s.inline && !Ay.h.inlineskip.find(txt)) || $s.classList.contains("ajaxy") ||
|
|
265
|
+
Ay.h.inlinehints.find(txt))
|
|
264
266
|
) && _addtxt($s),
|
|
265
267
|
_addtxt = $s => {
|
|
266
268
|
if(!txt || !txt.length) return;
|
|
267
|
-
if(
|
|
269
|
+
if(Ay.s.inlineappend || ($s.getAttribute("type") && !$s.getAttribute("type").iO("text/javascript"))) try { return _apptxt($s); } catch (e) { }
|
|
268
270
|
|
|
269
271
|
try { eval(txt); } catch (e1) {
|
|
270
272
|
lg("Error in inline script : " + txt + "\nError code : " + e1);
|
|
@@ -274,30 +276,8 @@ let _allstyle = $s =>
|
|
|
274
276
|
try {sc.appendChild(document.createTextNode($s.textContent))} catch(e) {sc.text = $s.textContent};
|
|
275
277
|
return qs("body").appendChild(sc);
|
|
276
278
|
},
|
|
277
|
-
_addstyle = t => qs("head").appendChild(
|
|
278
|
-
_addScripts = $s => (
|
|
279
|
-
}}
|
|
280
|
-
|
|
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 = $.pass ? $.fn("head") : qs("head"); //If "pass" is 0 -> fetch head from DOM, otherwise from target page
|
|
292
|
-
if (!head) return true;
|
|
293
|
-
lk = qa($.pass ? ".ajy-link" : "link", head); //If "pass" is 0 -> fetch links from DOM, otherwise from target page
|
|
294
|
-
j = $.pass ? $.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));
|
|
279
|
+
_addstyle = t => qs("head").appendChild(Ay.parse('<style>' + t + '</style>')),
|
|
280
|
+
_addScripts = $s => (Ay.addAll($s.c, "href"), Ay.addAll($s.j, "src"))
|
|
301
281
|
}}
|
|
302
282
|
|
|
303
283
|
// The AddAll plugin
|
|
@@ -311,20 +291,20 @@ linki = '<link rel="stylesheet" type="text/css" href="*" />',
|
|
|
311
291
|
linkr = 'link[href*="!"]',
|
|
312
292
|
scrr = 'script[src*="!"]';
|
|
313
293
|
|
|
314
|
-
|
|
294
|
+
Ay.h.alwayshints = new Hints(Ay.s.alwayshints);
|
|
315
295
|
|
|
316
296
|
this.a = function ($this, pk) {
|
|
317
297
|
if(!$this.length) return; //ensure input
|
|
318
|
-
if(
|
|
298
|
+
if(Ay.s.deltas === "n") return true; //Delta-loading completely disabled
|
|
319
299
|
|
|
320
300
|
PK = pk; //Copy "primary key" into internal variable
|
|
321
301
|
|
|
322
|
-
if(
|
|
302
|
+
if(!Ay.s.deltas) return _allScripts($this); //process all scripts
|
|
323
303
|
//deltas presumed to be "true" -> proceed with normal delta-loading
|
|
324
304
|
|
|
325
305
|
$scriptsO = PK == "href" ? $sCssO : $sO; //Copy old. Stylesheets or JS
|
|
326
306
|
|
|
327
|
-
if(
|
|
307
|
+
if(!Ay.pass) _newArray($this); //Fill new array on initial load, nothing more
|
|
328
308
|
else $this.forEach(function(s) { //Iterate through selection
|
|
329
309
|
var $t = s;
|
|
330
310
|
url = $t.getAttribute(PK);
|
|
@@ -342,20 +322,20 @@ scrr = 'script[src*="!"]';
|
|
|
342
322
|
return;
|
|
343
323
|
}
|
|
344
324
|
|
|
345
|
-
if(PK != "href" && !$t.classList.contains("no-ajaxy"))
|
|
325
|
+
if(PK != "href" && !$t.classList.contains("no-ajaxy")) Ay.scripts($t); //Inline JS script? -> inject into DOM
|
|
346
326
|
});
|
|
347
327
|
};
|
|
348
328
|
let _allScripts = $t => $t.forEach(e => _iScript(e)),
|
|
349
329
|
_newArray = $t => $t.forEach(e => (url = e.getAttribute(PK)) ? $scriptsO.push(url) : 0),
|
|
350
|
-
_classAlways = $t => $t.getAttribute("data-class") == "always" ||
|
|
330
|
+
_classAlways = $t => $t.getAttribute("data-class") == "always" || Ay.h.alwayshints.find(url),
|
|
351
331
|
_iScript = $S => {
|
|
352
332
|
url = $S.getAttribute(PK);
|
|
353
333
|
|
|
354
|
-
if(PK == "href") return qs("head").appendChild(
|
|
355
|
-
if(!url) return
|
|
334
|
+
if(PK == "href") return qs("head").appendChild(Ay.parse(linki.replace("*", url)));
|
|
335
|
+
if(!url) return Ay.scripts($S);
|
|
356
336
|
|
|
357
337
|
var sc = document.createElement("script");
|
|
358
|
-
sc.async =
|
|
338
|
+
sc.async = Ay.s.asyncdef;
|
|
359
339
|
_copyAttributes(sc, $S);
|
|
360
340
|
qs("head").appendChild(sc);
|
|
361
341
|
},
|
|
@@ -384,26 +364,26 @@ class RQ { constructor() {
|
|
|
384
364
|
|
|
385
365
|
this.a = function (o, p, t) {
|
|
386
366
|
if(o === "=") {
|
|
387
|
-
if(p) return h ===
|
|
367
|
+
if(p) return h === Ay.currentURL //check whether internally stored "href" ("h") variable is the same as the global currentURL
|
|
388
368
|
|| h === l; //or href of last request ("l")
|
|
389
|
-
return h ===
|
|
369
|
+
return h === Ay.currentURL; //for click requests
|
|
390
370
|
}
|
|
391
371
|
|
|
392
372
|
if(o === "!") return l = h; //store href in "l" (last request)
|
|
393
373
|
|
|
394
374
|
if(o === "?") { //Edin previously called this "isOK" - powerful intelligent plausibility check
|
|
395
|
-
let xs
|
|
396
|
-
if (!xs.iO("0") && !p)
|
|
375
|
+
let xs=Ay.fn("s");
|
|
376
|
+
if (!xs.iO("0") && !p) Ay.fn("a"); //if fetch is not idle and new request is standard one, do ac.abort() to set it free
|
|
397
377
|
if (xs==="1c" && p) return false; //if fetch is processing standard request and new request is prefetch, cancel prefetch until fetch is finished
|
|
398
|
-
if (xs==="1p" && p)
|
|
399
|
-
//([semaphore options for requests]
|
|
378
|
+
if (xs==="1p" && p) Ay.s.memoryoff ? Ay.fn("a") : 1; //if fetch is processing prefetch request and new request is prefetch do nothing (see [options] comment below)
|
|
379
|
+
//([semaphore options for requests] Ay.fn("a") -> abort previous, proceed with new | return false -> leave previous, stop new | return true -> proceed)
|
|
400
380
|
return true;
|
|
401
381
|
}
|
|
402
382
|
|
|
403
383
|
if(o === "v") { //validate value passed in "p", which is expected to be a click event value - also performs "i" afterwards
|
|
404
384
|
if(!p) return false; //ensure data
|
|
405
385
|
_setE(p, t); //Set event and href in one go
|
|
406
|
-
if(
|
|
386
|
+
if(!Ay.internal(h)) return false; //if not internal -> report failure
|
|
407
387
|
o = "i"; //continue with "i"
|
|
408
388
|
}
|
|
409
389
|
|
|
@@ -463,13 +443,13 @@ class Frms { constructor() {
|
|
|
463
443
|
let fm = 0, divs = 0;
|
|
464
444
|
|
|
465
445
|
this.a = function (o, p) {
|
|
466
|
-
if (
|
|
446
|
+
if (!Ay.s.forms || !o) return; //ensure data
|
|
467
447
|
|
|
468
448
|
if(o === "d") divs = p; //set divs variable
|
|
469
449
|
if(o === "a") divs.forEach(div => { //iterate through divs
|
|
470
|
-
Array.prototype.filter.call(qa(
|
|
450
|
+
Array.prototype.filter.call(qa(Ay.s.forms, div), function(e) { //filter forms
|
|
471
451
|
let c = e.getAttribute("action");
|
|
472
|
-
return(
|
|
452
|
+
return(Ay.internal(c && c.length > 0 ? c : Ay.currentURL)); //ensure "action"
|
|
473
453
|
}).forEach(frm => { //iterate through forms
|
|
474
454
|
frm.addEventListener("submit", q => { //create event listener
|
|
475
455
|
fm = q.target; // fetch target
|
|
@@ -481,18 +461,18 @@ class Frms { constructor() {
|
|
|
481
461
|
|
|
482
462
|
var h, a = fm.getAttribute("action"); //fetch action attribute
|
|
483
463
|
if (a && a.length > 0) h = a; //found -> store
|
|
484
|
-
else h =
|
|
464
|
+
else h = Ay.currentURL; //not found -> select current URL
|
|
485
465
|
|
|
486
|
-
|
|
466
|
+
Ay.Rq("v", q); //validate request
|
|
487
467
|
|
|
488
468
|
if (g == "get") h = _b(h, p); //GET -> copy URL parameters
|
|
489
469
|
else {
|
|
490
|
-
|
|
491
|
-
|
|
470
|
+
Ay.Rq("is", true); //set is POST in request data
|
|
471
|
+
Ay.Rq("d", p); //save data in request data
|
|
492
472
|
}
|
|
493
473
|
|
|
494
|
-
|
|
495
|
-
|
|
474
|
+
Ay.trigger("submit", h); //raise pronto.submit event
|
|
475
|
+
Ay.pronto(0, { href: h }); //programmatically change page
|
|
496
476
|
|
|
497
477
|
q.preventDefault(); //prevent default form action
|
|
498
478
|
return(false); //success -> disable default behaviour
|
|
@@ -523,7 +503,7 @@ let _k = () => {
|
|
|
523
503
|
// <URL> - set "h" variable of Rq hard and continue with _request()
|
|
524
504
|
class Pronto { constructor() {
|
|
525
505
|
let $gthis = 0, requestTimer = 0, pd = 150, ptim = 0;
|
|
526
|
-
|
|
506
|
+
Ay.h.prefetchoff = new Hints(Ay.s.prefetchoff);
|
|
527
507
|
|
|
528
508
|
this.a = function ($this, h) {
|
|
529
509
|
if(!h) return; //ensure data
|
|
@@ -532,48 +512,48 @@ class Pronto { constructor() {
|
|
|
532
512
|
bdy = document.body;
|
|
533
513
|
if(!$this.length) $this = "body";
|
|
534
514
|
$gthis = qa($this); //copy selection to global selector
|
|
535
|
-
|
|
536
|
-
if(
|
|
537
|
-
|
|
538
|
-
(
|
|
539
|
-
|
|
515
|
+
Ay.frms = new Frms().a; //initialise forms sub-plugin
|
|
516
|
+
if(Ay.s.idleTime) Ay.slides = new classSlides(Ay).a; //initialise optional slideshow sub-plugin
|
|
517
|
+
Ay.scrolly = new Scrolly(); //initialise scroll effects sub-plugin
|
|
518
|
+
(Ay.offsets = new Offsets()).f();
|
|
519
|
+
Ay.hApi = new HApi();
|
|
540
520
|
_init_p(); //initialise Pronto sub-plugin
|
|
541
521
|
return $this; //return query selector for chaining
|
|
542
522
|
}
|
|
543
523
|
|
|
544
524
|
if(typeof(h) === "object") { //jump to internal page programmatically -> handler for forms sub-plugin
|
|
545
|
-
|
|
525
|
+
Ay.Rq("h", h);
|
|
546
526
|
_request();
|
|
547
527
|
return;
|
|
548
528
|
}
|
|
549
529
|
|
|
550
530
|
if(h.iO("/")) { //jump to internal page programmatically -> default handler
|
|
551
|
-
|
|
531
|
+
Ay.Rq("h", h);
|
|
552
532
|
_request(true);
|
|
553
533
|
}
|
|
554
534
|
};
|
|
555
535
|
let _init_p = () => {
|
|
556
|
-
|
|
536
|
+
Ay.hApi.r(window.location.href);
|
|
557
537
|
window.addEventListener("popstate", _onPop);
|
|
558
|
-
if (
|
|
559
|
-
_on("mouseenter",
|
|
560
|
-
_on("mouseleave",
|
|
561
|
-
_on("touchstart",
|
|
538
|
+
if (Ay.s.prefetchoff !== true) {
|
|
539
|
+
_on("mouseenter", Ay.s.selector, _preftime); // start prefetch timeout
|
|
540
|
+
_on("mouseleave", Ay.s.selector, _prefstop); // stop prefetch timeout
|
|
541
|
+
_on("touchstart", Ay.s.selector, _prefetch);
|
|
562
542
|
}
|
|
563
|
-
_on("click",
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
if(
|
|
543
|
+
_on("click", Ay.s.selector, _click, bdy);
|
|
544
|
+
Ay.frms("d", qa("body"));
|
|
545
|
+
Ay.frms("a");
|
|
546
|
+
Ay.frms("d", $gthis);
|
|
547
|
+
if(Ay.s.idleTime) Ay.slides("i");
|
|
568
548
|
},
|
|
569
549
|
_preftime = (t, e) => (_prefstop(), ptim = setTimeout(()=> _prefetch(t, e), pd)), // call prefetch if timeout expires without being cleared by _prefstop
|
|
570
550
|
_prefstop = () => clearTimeout(ptim),
|
|
571
551
|
_prefetch = (t, e) => {
|
|
572
|
-
if(
|
|
573
|
-
if (
|
|
574
|
-
var href =
|
|
575
|
-
if (
|
|
576
|
-
|
|
552
|
+
if(Ay.s.prefetchoff === true) return;
|
|
553
|
+
if (!Ay.Rq("?", true)) return;
|
|
554
|
+
var href = Ay.Rq("v", e, t);
|
|
555
|
+
if (Ay.Rq("=", true) || !href || Ay.h.prefetchoff.find(href)) return;
|
|
556
|
+
Ay.fn("+", href, () => false);
|
|
577
557
|
},
|
|
578
558
|
_stopBubbling = e => (
|
|
579
559
|
e.preventDefault(),
|
|
@@ -581,69 +561,69 @@ let _init_p = () => {
|
|
|
581
561
|
e.stopImmediatePropagation()
|
|
582
562
|
),
|
|
583
563
|
_click = (t, e, notPush) => {
|
|
584
|
-
if(
|
|
585
|
-
var href =
|
|
564
|
+
if(!Ay.Rq("?")) return;
|
|
565
|
+
var href = Ay.Rq("v", e, t);
|
|
586
566
|
if(!href || _exoticKey(t)) return;
|
|
587
567
|
if(href.substr(-1) ==="#") return true;
|
|
588
568
|
if(_hashChange()) {
|
|
589
|
-
|
|
569
|
+
Ay.hApi.r(href);
|
|
590
570
|
return true;
|
|
591
571
|
}
|
|
592
572
|
|
|
593
|
-
|
|
573
|
+
Ay.scrolly.p();
|
|
594
574
|
_stopBubbling(e);
|
|
595
|
-
if(
|
|
596
|
-
if(
|
|
575
|
+
if(Ay.Rq("=")) Ay.hApi.r();
|
|
576
|
+
if(Ay.s.refresh || !Ay.Rq("=")) _request(notPush);
|
|
597
577
|
},
|
|
598
578
|
_request = notPush => {
|
|
599
|
-
|
|
600
|
-
if(notPush)
|
|
601
|
-
|
|
602
|
-
|
|
579
|
+
Ay.Rq("!");
|
|
580
|
+
if(notPush) Ay.Rq("p", false);
|
|
581
|
+
Ay.trigger("request");
|
|
582
|
+
Ay.fn(Ay.Rq("h"), err => {
|
|
603
583
|
if (err) {
|
|
604
584
|
lg("Error in _request : " + err);
|
|
605
|
-
|
|
585
|
+
Ay.trigger("error", err);
|
|
606
586
|
}
|
|
607
587
|
|
|
608
588
|
_render();
|
|
609
589
|
});
|
|
610
590
|
},
|
|
611
591
|
_render = () => {
|
|
612
|
-
|
|
613
|
-
if(
|
|
592
|
+
Ay.trigger("beforeload");
|
|
593
|
+
if(Ay.s.requestDelay) {
|
|
614
594
|
if(requestTimer) clearTimeout(requestTimer);
|
|
615
|
-
requestTimer = setTimeout(_doRender,
|
|
595
|
+
requestTimer = setTimeout(_doRender, Ay.s.requestDelay);
|
|
616
596
|
} else _doRender();
|
|
617
597
|
},
|
|
618
598
|
_onPop = e => {
|
|
619
599
|
var url = window.location.href;
|
|
620
600
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
601
|
+
Ay.Rq("i");
|
|
602
|
+
Ay.Rq("h", url);
|
|
603
|
+
Ay.Rq("p", false);
|
|
604
|
+
Ay.scrolly.p();
|
|
625
605
|
|
|
626
|
-
if (!url || url ===
|
|
627
|
-
|
|
628
|
-
|
|
606
|
+
if (!url || url === Ay.currentURL) return;
|
|
607
|
+
Ay.trigger("request");
|
|
608
|
+
Ay.fn(url, _render);
|
|
629
609
|
},
|
|
630
610
|
_doRender = () => {
|
|
631
|
-
|
|
632
|
-
if(
|
|
611
|
+
Ay.trigger("load");
|
|
612
|
+
if(Ay.s.bodyClasses) { var classes = Ay.fn("body").getAttribute("class"); bdy.setAttribute("class", classes ? classes : ""); }
|
|
633
613
|
|
|
634
|
-
var href =
|
|
635
|
-
href =
|
|
614
|
+
var href = Ay.Rq("h"), title;
|
|
615
|
+
href = Ay.Rq("c", href);
|
|
636
616
|
|
|
637
|
-
if(
|
|
638
|
-
if(title =
|
|
639
|
-
|
|
640
|
-
|
|
617
|
+
if(Ay.Rq("p")) Ay.hApi.p(href); else Ay.hApi.r(href);
|
|
618
|
+
if(title = Ay.fn("title")) qs("title").innerHTML = title.innerHTML;
|
|
619
|
+
Ay.Rq("C", Ay.fn("-", $gthis));
|
|
620
|
+
Ay.frms("a");
|
|
641
621
|
|
|
642
|
-
|
|
622
|
+
Ay.scrolly.l();
|
|
643
623
|
_gaCaptureView(href);
|
|
644
|
-
|
|
645
|
-
if(
|
|
646
|
-
if(
|
|
624
|
+
Ay.trigger("render");
|
|
625
|
+
if(Ay.s.passCount) qs("#" + Ay.s.passCount).innerHTML = "Pass: " + Ay.pass;
|
|
626
|
+
if(Ay.s.cb) Ay.s.cb();
|
|
647
627
|
},
|
|
648
628
|
_gaCaptureView = href => {
|
|
649
629
|
href = "/" + href.replace(rootUrl,"");
|
|
@@ -651,57 +631,57 @@ let _init_p = () => {
|
|
|
651
631
|
else if (typeof window._gaq !== "undefined") window._gaq.push(["_trackPageview", href]);
|
|
652
632
|
},
|
|
653
633
|
_exoticKey = (t) => {
|
|
654
|
-
var href =
|
|
634
|
+
var href = Ay.Rq("h"), e = Ay.Rq("e"), tgt = e.currentTarget.target || t.target;
|
|
655
635
|
return (e.which > 1 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || tgt === "_blank"
|
|
656
636
|
|| href.iO("wp-login") || href.iO("wp-admin"));
|
|
657
637
|
},
|
|
658
638
|
_hashChange = () => {
|
|
659
|
-
var e =
|
|
639
|
+
var e = Ay.Rq("e");
|
|
660
640
|
return (e.hash && e.href.replace(e.hash, "") === window.location.href.replace(location.hash, "") || e.href === window.location.href + "#");
|
|
661
641
|
}
|
|
662
642
|
}}
|
|
663
643
|
|
|
664
644
|
|
|
665
|
-
|
|
645
|
+
Ay.init = () => {
|
|
666
646
|
let o = options;
|
|
667
647
|
if (!o || typeof(o) !== "string") {
|
|
668
648
|
if (document.readyState === "complete" ||
|
|
669
649
|
(document.readyState !== "loading" && !document.documentElement.doScroll)) run();
|
|
670
650
|
else document.addEventListener('DOMContentLoaded', run);
|
|
671
|
-
return
|
|
651
|
+
return Ay;
|
|
672
652
|
}
|
|
673
|
-
else return
|
|
653
|
+
else return Ay.pronto(0, o);
|
|
674
654
|
};
|
|
675
655
|
|
|
676
656
|
let run = () => {
|
|
677
|
-
|
|
678
|
-
(
|
|
679
|
-
|
|
657
|
+
Ay.s = Object.assign(Ay.s, options);
|
|
658
|
+
(Ay.pages = new Pages()).f();
|
|
659
|
+
Ay.pronto = new Pronto().a;
|
|
680
660
|
if (load()) {
|
|
681
|
-
|
|
682
|
-
if (
|
|
661
|
+
Ay.pronto(Ay.s.elements, "i");
|
|
662
|
+
if (Ay.s.deltas) Ay.scripts("1");
|
|
683
663
|
}
|
|
684
664
|
},
|
|
685
665
|
load = () => {
|
|
686
|
-
if (!(window.history && window.history.pushState && window.history.replaceState) ||
|
|
666
|
+
if (!(window.history && window.history.pushState && window.history.replaceState) || !Ay.s.pluginon) {
|
|
687
667
|
lg("Gracefully exiting...");
|
|
688
668
|
return false;
|
|
689
669
|
}
|
|
690
670
|
|
|
691
671
|
lg("Ajaxify loaded..."); //verbosity option steers, whether this initialisation message is output
|
|
692
672
|
|
|
693
|
-
if (
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
673
|
+
if (Ay.s.intevents) Ay.intevents(); // intercept events
|
|
674
|
+
Ay.scripts = new Scripts().a;
|
|
675
|
+
Ay.scripts("i");
|
|
676
|
+
Ay.cache = new Cache();
|
|
677
|
+
Ay.memory = new Memory(); Ay.h.memoryoff = new Hints(Ay.s.memoryoff);
|
|
678
|
+
Ay.fn = Ay.getPage = new GetPage().a;
|
|
679
|
+
Ay.detScripts = new DetScripts();
|
|
680
|
+
Ay.addAll = new AddAll().a;
|
|
681
|
+
Ay.Rq = new RQ().a;
|
|
702
682
|
return true;
|
|
703
683
|
};
|
|
704
|
-
|
|
684
|
+
Ay.init(); // initialize Ajaxify on definition
|
|
705
685
|
}}
|
|
706
686
|
|
|
707
687
|
// The stateful Cache class
|
|
@@ -709,16 +689,16 @@ $.init(); // initialize Ajaxify on definition
|
|
|
709
689
|
class Cache {
|
|
710
690
|
g(){ return this.d } //getter
|
|
711
691
|
s(v){ return this.d = v } //setter
|
|
712
|
-
l(u){ let v =
|
|
692
|
+
l(u){ let v = Ay.memory.l(u); return this.s(v === false ? v : Ay.pages.l(v)) } //lookup URL and load
|
|
713
693
|
}
|
|
714
694
|
|
|
715
695
|
// The stateful Memory class
|
|
716
|
-
// Usage:
|
|
696
|
+
// Usage: Ay.memory.l(<URL>) - returns the same URL if not turned off internally
|
|
717
697
|
class Memory {
|
|
718
698
|
l(h){
|
|
719
|
-
if (!h ||
|
|
720
|
-
if (
|
|
721
|
-
return
|
|
699
|
+
if (!h || Ay.s.memoryoff === true) return false;
|
|
700
|
+
if (Ay.s.memoryoff === false) return h;
|
|
701
|
+
return Ay.h.memoryoff.find(h) ? false : h;
|
|
722
702
|
}
|
|
723
703
|
}
|
|
724
704
|
|
|
@@ -731,42 +711,56 @@ class Pages {
|
|
|
731
711
|
P(u){ return (this.i = this.d.findIndex(e => e[0] == u)) + 1 } //lookup page index and store in "i"
|
|
732
712
|
}
|
|
733
713
|
|
|
714
|
+
// The DetScripts class - stands for "detach scripts"
|
|
715
|
+
// Works on "s" <object> that is passed in and fills it
|
|
716
|
+
class DetScripts {
|
|
717
|
+
d(s) {
|
|
718
|
+
if(!(this.h = Ay.pass ? Ay.fn("head") : qs("head"))) return true; //If pass is 0 -> fetch head from DOM, otherwise from target page
|
|
719
|
+
this.lk = qa(Ay.pass ? ".ajy-link" : "link", this.h); //If pass is 0 -> fetch links from DOM, otherwise from target page
|
|
720
|
+
s.j = Ay.pass ? Ay.fn("script") : qa("script"); //If pass is 0 -> fetch JSs from DOM, otherwise from target page
|
|
721
|
+
s.c = this.x("stylesheet"); //Extract stylesheets
|
|
722
|
+
s.y = qa("style", this.h); //Extract style tags
|
|
723
|
+
s.can = this.x("canonical"); //Extract canonical tag
|
|
724
|
+
}
|
|
725
|
+
x(v){ return Array.prototype.filter.call(this.lk, e => e.getAttribute("rel").iO(v)) } //Extract link tags with given "rel"
|
|
726
|
+
}
|
|
727
|
+
|
|
734
728
|
// The Offsets class
|
|
735
729
|
// this.d = Array of pages - [0] = URL // [1] = offset
|
|
736
730
|
class Offsets {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
731
|
+
f(){ this.d = [] } //flush internal offsets array - must be performed by parent
|
|
732
|
+
l(h){ if(h.iO("?")) h = h.split("?")[0]; //lookup page offset
|
|
733
|
+
return this.O(h) ? this.d[this.i][1] : 0; //return if found otherwise 0
|
|
734
|
+
}
|
|
735
|
+
p(h){ let us1 = h.iO("?") ? h.split("?")[0] : h, //initialise all helper variables in one go
|
|
736
|
+
us = us1.iO("#") ? us1.split("#")[0] : us1,
|
|
737
|
+
os = [us, (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop];
|
|
738
|
+
if(this.O(us)) this.d[this.i]=os; else this.d.push(os); // update if found, otherwise push
|
|
739
|
+
}
|
|
740
|
+
O(h){ return (this.i = this.d.findIndex(e => e[0] == h)) + 1 } //find URL in internal array - add 1 for convenience
|
|
747
741
|
}
|
|
748
742
|
|
|
749
743
|
// The Scrolly class
|
|
750
|
-
// operates on
|
|
744
|
+
// operates on Ay.currentURL
|
|
751
745
|
class Scrolly { constructor() { if ('scrollRestoration' in history) history.scrollRestoration = 'manual' }
|
|
752
|
-
p(){
|
|
753
|
-
l(){ let o =
|
|
746
|
+
p(){ Ay.s.scrolltop == "s" && Ay.offsets.p(Ay.currentURL) }
|
|
747
|
+
l(){ let o = Ay.currentURL;
|
|
754
748
|
if(o.iO("#") && (o.iO("#") < o.length - 1)) { //if hash in URL and not standalone hash
|
|
755
|
-
let
|
|
756
|
-
if
|
|
757
|
-
let box =
|
|
749
|
+
let el = qs("#" + o.split("#")[1]); //fetch the element
|
|
750
|
+
if(!el) return; //nothing found -> return quickly
|
|
751
|
+
let box = el.getBoundingClientRect();
|
|
758
752
|
return this.s(box.top + window.pageYOffset - document.documentElement.clientTop); // ...animate to ID
|
|
759
753
|
}
|
|
760
|
-
if(
|
|
761
|
-
else
|
|
754
|
+
if(Ay.s.scrolltop == "s") this.s(Ay.offsets.l(o)); //smart scroll -> lookup and restore offset
|
|
755
|
+
else Ay.s.scrolltop && this.s(0); //scrolltop true -> scroll to top of page
|
|
762
756
|
}
|
|
763
|
-
s(o){
|
|
757
|
+
s(o){ window.scrollTo(0, o) } //scroll to offset
|
|
764
758
|
}
|
|
765
759
|
|
|
766
760
|
// The HAPi class
|
|
767
|
-
// operates on
|
|
761
|
+
// operates on Ay.currentURL - manages operations on the History API centrally(replaceState / pushState)
|
|
768
762
|
class HApi {
|
|
769
763
|
r(h){ let c = this.u(h); history.replaceState({ url: c }, "state-" + c, c); } //perform replaceState
|
|
770
764
|
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)
|
|
765
|
+
u(h){ if(h) Ay.currentURL = h; return Ay.currentURL; } //update currentURL if given and return always
|
|
772
766
|
}
|
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="",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}}
|
|
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.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){window.scrollTo(0,t)}}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}}
|