PageSourceSearch

https://langx1ng.github.io/js/pjax.js

js langx1ng.github.io collected 2026-10-03 09:29:30 UTC 35,966 bytes, 1,236 lines download raw bytes

1(function (f) { if (typeof exports === "object" && typeof module !== "undefined") { module.exports = f() } else if (typeof define === "function" && define.amd) { define([], f) } else { var g; if (typeof window !== "undefined") { g = window } else if (typeof global !== "undefined") { g = global } else if (typeof self !== "undefined") { g = self } else { g = this } g.Pjax = f() } })(function () {
2	return (function () { function r(e, n, t) { function o(i, f) { if (!n[i]) { if (!e[i]) { var c = "function" == typeof require && require; if (!f && c) return c(i, !0); if (u) return u(i, !0); var a = new Error("Cannot find module '" + i + "'"); throw a.code = "MODULE_NOT_FOUND", a } var p = n[i] = { exports: {} }; e[i][0].call(p.exports, function (r) { var n = e[i][1][r]; return o(n || r) }, p, p.exports, r, e, n, t) } return n[i].exports } for (var u = "function" == typeof require && require, i = 0; i < t.length; i++)o(t[i]); return o } return r })()({
3		1: [function (require, module, exports) {
4			// var executeScripts = require("./lib/execute-scripts");  // unused-var
5			var forEachEls = require("./lib/foreach-els");
6			var parseOptions = require("./lib/parse-options");
7			var switches = require("./lib/switches");
8			var newUid = require("./lib/uniqueid");
9
10			var on = require("./lib/events/on");
11			var trigger = require("./lib/events/trigger");
12
13			var clone = require("./lib/util/clone");
14			var contains = require("./lib/util/contains");
15			var extend = require("./lib/util/extend");
16			var noop = require("./lib/util/noop");
17
18			var Pjax = function (options) {
19				this.state = {
20					numPendingSwitches: 0,
21					href: null,
22					options: null
23				};
24
25				this.options = parseOptions(options);
26				this.log("Pjax options", this.options);
27
28				if (this.options.scrollRestoration && "scrollRestoration" in history) {
29					history.scrollRestoration = "manual";
30					on(
31						window,
32						"beforeunload",
33						function () {
34							history.scrollRestoration = "auto";
35						}
36					);
37				}
38
39				this.maxUid = this.lastUid = newUid();
40
41				this.parseDOM(document);
42
43				on(
44					window,
45					"popstate",
46					function (st) {
47						if (st.state) {
48							var opt = clone(this.options);
49							opt.url = st.state.url;
50							opt.title = st.state.title;
51							// Since state already exists, prevent it from being pushed again
52							opt.history = false;
53							opt.scrollPos = st.state.scrollPos;
54							if (st.state.uid < this.lastUid) {
55								opt.backward = true;
56							} else {
57								opt.forward = true;
58							}
59							this.lastUid = st.state.uid;
60
61							// @todo implement history cache here, based on uid
62							this.loadUrl(st.state.url, opt);
63						}
64					}.bind(this)
65				);
66			};
67
68			Pjax.switches = switches;
69
70			Pjax.prototype = {
71				log: require("./lib/proto/log"),
72
73				getElements: function (el) {
74					return el.querySelectorAll(this.options.elements);
75				},
76
77				parseDOM: function (el) {
78					var parseElement = require("./lib/proto/parse-element");
79					forEachEls(this.getElements(el), parseElement, this);
80				},
81
82				refresh: function (el) {
83					this.parseDOM(el || document);
84				},
85
86				reload: function () {
87					window.location.reload();
88				},
89
90				attachLink: require("./lib/proto/attach-link"),
91
92				attachForm: require("./lib/proto/attach-form"),
93
94				forEachSelectors: function (cb, context, DOMcontext) {
95					return require("./lib/foreach-selectors").bind(this)(
96						this.options.selectors,
97						cb,
98						context,
99						DOMcontext
100					);
101				},
102
103				switchSelectors: function (selectors, fromEl, toEl, options) {
104					var state = this.state;
105					if (state.options.history) {
106						if (!window.history.state) {
107							this.lastUid = this.maxUid = newUid();
108							window.history.replaceState(
109								{
110									url: window.location.href,
111									title: document.title,
112									uid: this.maxUid,
113									scrollPos: [0, 0]
114								},
115								document.title
116							);
117						}
118
119						// Update browser history
120						this.lastUid = this.maxUid = newUid();
121
122						window.history.pushState(
123							{
124								url: state.href,
125								title: state.options.title,
126								uid: this.maxUid,
127								scrollPos: [0, 0]
128							},
129							state.options.title,
130							state.href
131						);
132					}
133
134					trigger(document, "pjax:start", options);
135
136					return require("./lib/switches-selectors").bind(this)(
137						this.options.switches,
138						this.options.switchesOptions,
139						selectors,
140						fromEl,
141						toEl,
142						options
143					);
144				},
145
146				latestChance: function (href) {
147					window.location = href;
148				},
149
150				onSwitch: function () {
151					trigger(window, "resize scroll");
152
153					this.state.numPendingSwitches--;
154
155					// debounce calls, so we only run this once after all switches are finished.
156					if (this.state.numPendingSwitches === 0) {
157						this.afterAllSwitches();
158					}
159				},
160
161				loadContent: function (html, options) {
162					if (typeof html !== "string") {
163						trigger(document, "pjax:complete pjax:error", options);
164						this.loadUrl('/404')
165						return;
166					}
167
168					var tmpEl = document.implementation.createHTMLDocument("pjax");
169
170					// parse HTML attributes to copy them
171					// since we are forced to use documentElement.innerHTML (outerHTML can't be used for <html>)
172					var htmlRegex = /<html[^>]+>/gi;
173					var htmlAttribsRegex = /\s?[a-z:]+(?:=['"][^'">]+['"])*/gi;
174					var matches = html.match(htmlRegex);
175					if (matches && matches.length) {
176						matches = matches[0].match(htmlAttribsRegex);
177						if (matches.length) {
178							matches.shift();
vendor: 4,371 bytes, lines 179-324
179							matches.forEach(function (htmlAttrib) {
180								var attr = htmlAttrib.trim().split("=");
181								if (attr.length === 1) {
182									tmpEl.documentElement.setAttribute(attr[0], true);
183								} else {
184									tmpEl.documentElement.setAttribute(attr[0], attr[1].slice(1, -1));
185								}
186							});
187						}
188					}
189
190					tmpEl.documentElement.innerHTML = html;
191					this.log(
192						"load content",
193						tmpEl.documentElement.attributes,
194						tmpEl.documentElement.innerHTML.length
195					);
196
197					// Clear out any focused controls before inserting new page contents.
198					if (
199						document.activeElement &&
200						contains(document, this.options.selectors, document.activeElement)
201					) {
202						try {
203							document.activeElement.blur();
204						} catch (e) {} // eslint-disable-line no-empty
205					}
206
207					this.switchSelectors(this.options.selectors, tmpEl, document, options);
208				},
209
210				abortRequest: require("./lib/abort-request"),
211
212				doRequest: require("./lib/send-request"),
213
214				handleResponse: require("./lib/proto/handle-response"),
215
216				loadUrl: function (href, options) {
217					options =
218						typeof options === "object"
219							? extend({}, this.options, options)
220							: clone(this.options);
221
222					this.log("load href", href, options);
223
224					// Abort any previous request
225					this.abortRequest(this.request);
226
227					if (href !== '/404') {
228						trigger(document, "pjax:send", options);
229					}
230
231					// Do the request
232					this.request = this.doRequest(
233						href,
234						options,
235						this.handleResponse.bind(this)
236					);
237				},
238
239				executeScripts: function (elements) {
240					elements.forEach(function (element) {
241						var code = element.text || element.textContent || element.innerHTML || '';
242						var script = document.createElement('script');
243						if (element.id) {
244							script.id = element.id;
245						}
246						if (element.className) {
247							script.className = element.className;
248						}
249						if (element.type) {
250							script.type = element.type;
251						}
252						if (element.src) {
253							script.src = element.src;
254							// Force synchronous loading of peripheral JS.
255							script.async = false;
256						}
257						if (element.dataset.pjax !== undefined) {
258							script.dataset.pjax = '';
259						}
260						if (code !== '') {
261							script.appendChild(document.createTextNode(code));
262						}
263						element.parentNode.replaceChild(script, element);
264					});
265				},
266
267				afterAllSwitches: function () {
268					// FF bug: Won’t autofocus fields that are inserted via JS.
269					// This behavior is incorrect. So if theres no current focus, autofocus
270					// the last field.
271					//
272					// http://www.w3.org/html/wg/drafts/html/master/forms.html
273					var autofocusEl = Array.prototype.slice
274						.call(document.querySelectorAll("[autofocus]"))
275						.pop();
276					if (autofocusEl && document.activeElement !== autofocusEl) {
277						autofocusEl.focus();
278					}
279
280					// execute scripts when DOM have been completely updated
281					this.options.selectors.forEach(function (selector) {
282						forEachEls(document.querySelectorAll(selector), function (el) {
283							// executeScripts(el);
284							if (el === 0);  // intentially left blank!
285						});
286					});
287
288					this.forEachSelectors(function (el) {
289						this.parseDOM(el);
290					}, this);
291
292					var state = this.state;
293					// Fire Events
294					trigger(document, "pjax:complete pjax:success", state.options);
295
296					if (typeof state.options.analytics === "function") {
297						state.options.analytics();
298					}
299
300					if (state.options.history) {
301						// First parse url and check for hash to override scroll
302						var a = document.createElement("a");
303						a.href = this.state.href;
304						if (a.hash) {
305							var name = a.hash.slice(1);
306							name = decodeURIComponent(name);
307
308							var curtop = 0;
309							var target =
310								document.getElementById(name) || document.getElementsByName(name)[0];
311							if (target) {
312								// http://stackoverflow.com/questions/8111094/cross-browser-javascript-function-to-find-actual-position-of-an-element-in-page
313								if (target.offsetParent) {
314									do {
315										curtop += target.offsetTop;
316
317										target = target.offsetParent;
318									} while (target);
319								}
320							}
321							window.scrollTo(0, curtop);
322						} else if (state.options.scrollTo !== false) {
323							// Scroll page to top on new page load
324							if (state.options.scrollTo.length > 1) {
vendor: 14,638 bytes, lines 325-825
325								window.scrollTo(state.options.scrollTo[0], state.options.scrollTo[1]);
326							} else {
327								window.scrollTo(0, state.options.scrollTo);
328							}
329						}
330					} else if (state.options.scrollRestoration && state.options.scrollPos) {
331						window.scrollTo(state.options.scrollPos[0], state.options.scrollPos[1]);
332					}
333
334					this.state = {
335						numPendingSwitches: 0,
336						href: null,
337						options: null
338					};
339				}
340			};
341
342			Pjax.isSupported = require("./lib/is-supported");
343
344			// arguably could do `if( require("./lib/is-supported")()) {` but that might be a little to simple
345			if (Pjax.isSupported()) {
346				module.exports = Pjax;
347			}
348			// if there isn’t required browser functions, returning stupid api
349			else {
350				var stupidPjax = noop;
351				for (var key in Pjax.prototype) {
352					if (
353						Pjax.prototype.hasOwnProperty(key) &&
354						typeof Pjax.prototype[key] === "function"
355					) {
356						stupidPjax[key] = noop;
357					}
358				}
359
360				module.exports = stupidPjax;
361			}
362
363		}, { "./lib/abort-request": 2, "./lib/events/on": 3, "./lib/events/trigger": 4, "./lib/foreach-els": 5, "./lib/foreach-selectors": 6, "./lib/is-supported": 7, "./lib/parse-options": 8, "./lib/proto/attach-form": 9, "./lib/proto/attach-link": 10, "./lib/proto/handle-response": 11, "./lib/proto/log": 12, "./lib/proto/parse-element": 13, "./lib/send-request": 14, "./lib/switches": 16, "./lib/switches-selectors": 15, "./lib/uniqueid": 17, "./lib/util/clone": 18, "./lib/util/contains": 19, "./lib/util/extend": 20, "./lib/util/noop": 21 }], 2: [function (require, module, exports) {
364			var noop = require("./util/noop");
365
366			module.exports = function (request) {
367				if (request && request.readyState < 4) {
368					request.onreadystatechange = noop;
369					request.abort();
370				}
371			};
372
373		}, { "./util/noop": 21 }], 3: [function (require, module, exports) {
374			var forEachEls = require("../foreach-els");
375
376			module.exports = function (els, events, listener, useCapture) {
377				events = typeof events === "string" ? events.split(" ") : events;
378
379				events.forEach(function (e) {
380					forEachEls(els, function (el) {
381						el.addEventListener(e, listener, useCapture);
382					});
383				});
384			};
385
386		}, { "../foreach-els": 5 }], 4: [function (require, module, exports) {
387			var forEachEls = require("../foreach-els");
388
389			module.exports = function (els, events, opts) {
390				events = typeof events === "string" ? events.split(" ") : events;
391
392				events.forEach(function (e) {
393					var event = new Event(e)
394					event.eventName = e;
395					if (opts) {
396						Object.keys(opts).forEach(function (key) {
397							event[key] = opts[key];
398						});
399					}
400
401					forEachEls(els, function (el) {
402						var domFix = false;
403						if (!el.parentNode && el !== document && el !== window) {
404							// THANK YOU IE (9/10/11)
405							// dispatchEvent doesn't work if the element is not in the DOM
406							domFix = true;
407							document.body.appendChild(el);
408						}
409						el.dispatchEvent(event);
410						if (domFix) {
411							el.parentNode.removeChild(el);
412						}
413					});
414				});
415			};
416
417		}, { "../foreach-els": 5 }], 5: [function (require, module, exports) {
418			/* global HTMLCollection: true */
419
420			module.exports = function (els, fn, context) {
421				if (
422					els instanceof HTMLCollection ||
423					els instanceof NodeList ||
424					els instanceof Array
425				) {
426					return Array.prototype.forEach.call(els, fn, context);
427				}
428				// assume simple DOM element
429				return fn.call(context, els);
430			};
431
432		}, {}], 6: [function (require, module, exports) {
433			var forEachEls = require("./foreach-els");
434
435			module.exports = function (selectors, cb, context, DOMcontext) {
436				DOMcontext = DOMcontext || document;
437				selectors.forEach(function (selector) {
438					forEachEls(DOMcontext.querySelectorAll(selector), cb, context);
439				});
440			};
441
442		}, { "./foreach-els": 5 }], 7: [function (require, module, exports) {
443			module.exports = function () {
444				// Borrowed wholesale from https://github.com/defunkt/jquery-pjax
445				return (
446					window.history &&
447					window.history.pushState &&
448					window.history.replaceState &&
449					// pushState isn’t reliable on iOS until 5.
450					!navigator.userAgent.match(
451						/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/
452					)
453				);
454			};
455
456		}, {}], 8: [function (require, module, exports) {
457			/* global _gaq: true, ga: true */
458
459			var defaultSwitches = require("./switches");
460
461			module.exports = function (options) {
462				options = options || {};
463				options.elements = options.elements || "a[href], form[action]";
464				options.selectors = options.selectors || ["title", ".js-Pjax"];
465				options.switches = options.switches || {};
466				options.switchesOptions = options.switchesOptions || {};
467				options.history =
468					typeof options.history === "undefined" ? true : options.history;
469				options.analytics =
470					typeof options.analytics === "function" || options.analytics === false
471						? options.analytics
472						: defaultAnalytics;
473				options.scrollTo =
474					typeof options.scrollTo === "undefined" ? 0 : options.scrollTo;
475				options.scrollRestoration =
476					typeof options.scrollRestoration !== "undefined"
477						? options.scrollRestoration
478						: true;
479				options.cacheBust =
480					typeof options.cacheBust === "undefined" ? true : options.cacheBust;
481				options.debug = options.debug || false;
482				options.timeout = options.timeout || 0;
483				options.currentUrlFullReload =
484					typeof options.currentUrlFullReload === "undefined"
485						? false
486						: options.currentUrlFullReload;
487
488				// We can’t replace body.outerHTML or head.outerHTML.
489				// It creates a bug where a new body or head are created in the DOM.
490				// If you set head.outerHTML, a new body tag is appended, so the DOM has 2 body nodes, and vice versa
491				if (!options.switches.head) {
492					options.switches.head = defaultSwitches.switchElementsAlt;
493				}
494				if (!options.switches.body) {
495					options.switches.body = defaultSwitches.switchElementsAlt;
496				}
497
498				return options;
499			};
500
501			/* istanbul ignore next */
502			function defaultAnalytics() {
503				if (window._gaq) {
504					_gaq.push(["_trackPageview"]);
505				}
506				if (window.ga) {
507					ga("send", "pageview", { page: location.pathname, title: document.title });
508				}
509			}
510
511		}, { "./switches": 16 }], 9: [function (require, module, exports) {
512			var on = require("../events/on");
513			var clone = require("../util/clone");
514
515			var attrState = "data-pjax-state";
516
517			var formAction = function (el, event) {
518				if (isDefaultPrevented(event)) {
519					return;
520				}
521
522				// Since loadUrl modifies options and we may add our own modifications below,
523				// clone it so the changes don't persist
524				var options = clone(this.options);
525
526				// Initialize requestOptions
527				options.requestOptions = {
528					requestUrl: el.getAttribute("action") || window.location.href,
529					requestMethod: el.getAttribute("method") || "GET"
530				};
531
532				// create a testable virtual link of the form action
533				var virtLinkElement = document.createElement("a");
534				virtLinkElement.setAttribute("href", options.requestOptions.requestUrl);
535
536				var attrValue = checkIfShouldAbort(virtLinkElement, options);
537				if (attrValue) {
538					el.setAttribute(attrState, attrValue);
539					return;
540				}
541
542				event.preventDefault();
543
544				if (el.enctype === "multipart/form-data") {
545					options.requestOptions.formData = new FormData(el);
546				} else {
547					options.requestOptions.requestParams = parseFormElements(el);
548				}
549
550				el.setAttribute(attrState, "submit");
551
552				options.triggerElement = el;
553				this.loadUrl(virtLinkElement.href, options);
554			};
555
556			function parseFormElements(el) {
557				var requestParams = [];
558				var formElements = el.elements;
559
560				for (var i = 0; i < formElements.length; i++) {
561					var element = formElements[i];
562					var tagName = element.tagName.toLowerCase();
563					// jscs:disable disallowImplicitTypeConversion
564					if (
565						!!element.name &&
566						element.attributes !== undefined &&
567						tagName !== "button"
568					) {
569						// jscs:enable disallowImplicitTypeConversion
570						var type = element.attributes.type;
571
572						if (
573							!type ||
574							(type.value !== "checkbox" && type.value !== "radio") ||
575							element.checked
576						) {
577							// Build array of values to submit
578							var values = [];
579
580							if (tagName === "select") {
581								var opt;
582
583								for (var j = 0; j < element.options.length; j++) {
584									opt = element.options[j];
585									if (opt.selected && !opt.disabled) {
586										values.push(opt.hasAttribute("value") ? opt.value : opt.text);
587									}
588								}
589							} else {
590								values.push(element.value);
591							}
592
593							for (var k = 0; k < values.length; k++) {
594								requestParams.push({
595									name: encodeURIComponent(element.name),
596									value: encodeURIComponent(values[k])
597								});
598							}
599						}
600					}
601				}
602
603				return requestParams;
604			}
605
606			function checkIfShouldAbort(virtLinkElement, options) {
607				// Ignore external links.
608				if (
609					virtLinkElement.protocol !== window.location.protocol ||
610					virtLinkElement.host !== window.location.host
611				) {
612					return "external";
613				}
614
615				// Ignore click if we are on an anchor on the same page
616				if (
617					virtLinkElement.hash &&
618					virtLinkElement.href.replace(virtLinkElement.hash, "") ===
619					window.location.href.replace(location.hash, "")
620				) {
621					return "anchor";
622				}
623
624				// Ignore empty anchor "foo.html#"
625				if (virtLinkElement.href === window.location.href.split("#")[0] + "#") {
626					return "anchor-empty";
627				}
628
629				// if declared as a full reload, just normally submit the form
630				if (
631					options.currentUrlFullReload &&
632					virtLinkElement.href === window.location.href.split("#")[0]
633				) {
634					return "reload";
635				}
636			}
637
638			var isDefaultPrevented = function (event) {
639				return event.defaultPrevented || event.returnValue === false;
640			};
641
642			module.exports = function (el) {
643				var that = this;
644
645				el.setAttribute(attrState, "");
646
647				on(el, "submit", function (event) {
648					formAction.call(that, el, event);
649				});
650			};
651
652		}, { "../events/on": 3, "../util/clone": 18 }], 10: [function (require, module, exports) {
653			var on = require("../events/on");
654			var clone = require("../util/clone");
655
656			var attrState = "data-pjax-state";
657
658			var linkAction = function (el, event) {
659				if (isDefaultPrevented(event)) {
660					return;
661				}
662
663				// Since loadUrl modifies options and we may add our own modifications below,
664				// clone it so the changes don't persist
665				var options = clone(this.options);
666
667				var attrValue = checkIfShouldAbort(el, event);
668				if (attrValue) {
669					el.setAttribute(attrState, attrValue);
670					return;
671				}
672
673				event.preventDefault();
674
675				// don’t do "nothing" if user try to reload the page by clicking the same link twice
676				if (
677					this.options.currentUrlFullReload &&
678					el.href === window.location.href.split("#")[0]
679				) {
680					el.setAttribute(attrState, "reload");
681					this.reload();
682					return;
683				}
684
685				el.setAttribute(attrState, "load");
686
687				options.triggerElement = el;
688				this.loadUrl(el.href, options);
689			};
690
691			function checkIfShouldAbort(el, event) {
692				// Don’t break browser special behavior on links (like page in new window)
693				if (
694					event.which > 1 ||
695					event.metaKey ||
696					event.ctrlKey ||
697					event.shiftKey ||
698					event.altKey
699				) {
700					return "modifier";
701				}
702
703				// we do test on href now to prevent unexpected behavior if for some reason
704				// user have href that can be dynamically updated
705
706				// Ignore external links.
707				if (
708					el.protocol !== window.location.protocol ||
709					el.host !== window.location.host
710				) {
711					return "external";
712				}
713
714				// Ignore anchors on the same page (keep native behavior)
715				if (
716					el.hash &&
717					el.href.replace(el.hash, "") ===
718					window.location.href.replace(location.hash, "")
719				) {
720					return "anchor";
721				}
722
723				// Ignore empty anchor "foo.html#"
724				if (el.href === window.location.href.split("#")[0] + "#") {
725					return "anchor-empty";
726				}
727			}
728
729			var isDefaultPrevented = function (event) {
730				return event.defaultPrevented || event.returnValue === false;
731			};
732
733			module.exports = function (el) {
734				var that = this;
735
736				el.setAttribute(attrState, "");
737
738				on(el, "click", function (event) {
739					linkAction.call(that, el, event);
740				});
741
742				on(
743					el,
744					"keyup",
745					function (event) {
746						if (event.keyCode === 13) {
747							linkAction.call(that, el, event);
748						}
749					}.bind(this)
750				);
751			};
752
753		}, { "../events/on": 3, "../util/clone": 18 }], 11: [function (require, module, exports) {
754			var clone = require("../util/clone");
755			var newUid = require("../uniqueid");
756			var trigger = require("../events/trigger");
757
758			module.exports = function (responseText, request, href, options) {
759				options = clone(options || this.options);
760				options.request = request;
761
762				// Fail if unable to load HTML via AJAX
763				if (responseText === false) {
764					trigger(document, "pjax:complete pjax:error", options);
765					return;
766				}
767
768				// push scroll position to history
769				var currentState = window.history.state || {};
770				window.history.replaceState(
771					{
772						url: currentState.url || window.location.href,
773						title: currentState.title || document.title,
774						uid: currentState.uid || newUid(),
775						scrollPos: [
776							document.documentElement.scrollLeft || document.body.scrollLeft,
777							document.documentElement.scrollTop || document.body.scrollTop
778						]
779					},
780					document.title,
781					window.location.href
782				);
783
784				// Check for redirects
785				var oldHref = href;
786				if (request.responseURL) {
787					if (href !== request.responseURL) {
788						href = request.responseURL;
789					}
790				} else if (request.getResponseHeader("X-PJAX-URL")) {
791					href = request.getResponseHeader("X-PJAX-URL");
792				} else if (request.getResponseHeader("X-XHR-Redirected-To")) {
793					href = request.getResponseHeader("X-XHR-Redirected-To");
794				}
795
796				// Add back the hash if it was removed
797				var a = document.createElement("a");
798				a.href = oldHref;
799				var oldHash = a.hash;
800				a.href = href;
801				if (oldHash && !a.hash) {
802					a.hash = oldHash;
803					href = a.href;
804				}
805
806				this.state.href = href;
807				this.state.options = options;
808
809				try {
810					this.loadContent(responseText, options);
811				} catch (e) {
812					trigger(document, "pjax:error", options);
813
814					if (!this.options.debug) {
815						if (console && console.error) {
816							console.error("Pjax switch fail: ", e);
817						}
818						return this.latestChance(href);
819					} else {
820						throw e;
821					}
822				}
823			};
824
825		}, { "../events/trigger": 4, "../uniqueid": 17, "../util/clone": 18 }
825], 12: [function (require, module, exports) {
826			module.exports = function () {
827				if (this.options.debug && console) {
828					if (typeof console.log === "function") {
829						console.log.apply(console, arguments);
830					}
831					// IE is weird
832					else if (console.log) {
833						console.log(arguments);
834					}
835				}
836			};
837
838		}, {}], 13: [function (require, module, exports) {
839			var attrState = "data-pjax-state";
840
841			module.exports = function (el) {
842				switch (el.tagName.toLowerCase()) {
843					case "a":
844						// only attach link if el does not already have link attached
845						if (!el.hasAttribute(attrState)) {
846							this.attachLink(el);
847						}
848						break;
849
850					case "form":
851						// only attach link if el does not already have link attached
852						if (!el.hasAttribute(attrState)) {
853							this.attachForm(el);
854						}
855						break;
856
857					default:
858						throw "Pjax can only be applied on <a> or <form> submit";
859				}
860			};
861
862		}, {}], 14: [function (require, module, exports) {
863			var updateQueryString = require("./util/update-query-string");
864
865			module.exports = function (location, options, callback) {
866				options = options || {};
867				var queryString;
868				var requestOptions = options.requestOptions || {};
869				var requestMethod = (requestOptions.requestMethod || "GET").toUpperCase();
870				var requestParams = requestOptions.requestParams || null;
871				var formData = requestOptions.formData || null;
872				var requestPayload = null;
873				var request = new XMLHttpRequest();
874				var timeout = options.timeout || 0;
875
876				request.onreadystatechange = function () {
877					if (request.readyState === 4) {
878						if (request.status === 200) {
879							callback(request.responseText, request, location, options);
880						} else if (request.status !== 0) {
881							callback(null, request, location, options);
882						}
883					}
884				};
885
886				if (location !== '/404') {
887					request.onerror = function (e) {
888						console.log(e);
889						callback(null, request, location, options);
890					};
891				} else {
892					request.onerror = function (e) {
893						console.log(e);
894					};
895				}
896
897				request.ontimeout = function () {
898					callback(null, request, location, options);
899				};
900
901				// Prepare the request payload for forms, if available
902				if (requestParams && requestParams.length) {
903					// Build query string
904					queryString = requestParams
905						.map(function (param) {
906							return param.name + "=" + param.value;
907						})
908						.join("&");
909
910					switch (requestMethod) {
911						case "GET":
912							// Reset query string to avoid an issue with repeat submissions where checkboxes that were
913							// previously checked are incorrectly preserved
914							location = location.split("?")[0];
915
916							// Append new query string
917							location += "?" + queryString;
918							break;
919
920						case "POST":
921							// Send query string as request payload
922							requestPayload = queryString;
923							break;
924					}
925				} else if (formData) {
926					requestPayload = formData;
927				}
928
929				// Add a timestamp as part of the query string if cache busting is enabled
930				if (options.cacheBust) {
931					location = updateQueryString(location, "t", Date.now());
932				}
933
934				request.open(requestMethod, location, true);
935				request.timeout = timeout;
936				request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
937				request.setRequestHeader("X-PJAX", "true");
938				request.setRequestHeader(
939					"X-PJAX-Selectors",
940					JSON.stringify(options.selectors)
941				);
942
943				// Send the proper header information for POST forms
944				if (requestPayload && requestMethod === "POST" && !formData) {
945					request.setRequestHeader(
946						"Content-Type",
947						"application/x-www-form-urlencoded"
948					);
949				}
950
951				request.send(requestPayload);
952
953				return request;
954			};
955
956		}, { "./util/update-query-string": 22 }], 15: [function (require, module, exports) {
957			var forEachEls = require("./foreach-els");
958
959			var defaultSwitches = require("./switches");
960
961			module.exports = function (
962				switches,
963				switchesOptions,
964				selectors,
965				fromEl,
966				toEl,
967				options
968			) {
969				var switchesQueue = [];
970
971				selectors.forEach(function (selector) {
972					var newEls = fromEl.querySelectorAll(selector);
973					var oldEls = toEl.querySelectorAll(selector);
974					if (this.log) {
975						this.log("Pjax switch", selector, newEls, oldEls);
976					}
977					if (newEls.length !== oldEls.length) {
978						throw "DOM doesn’t look the same on new loaded page: ’" +
979						selector +
980						"’ - new " +
981						newEls.length +
982						", old " +
983						oldEls.length;
984					}
985
vendor: 6,918 bytes, lines 986-1236
986					forEachEls(
987						newEls,
988						function (newEl, i) {
989							var oldEl = oldEls[i];
990							if (this.log) {
991								this.log("newEl", newEl, "oldEl", oldEl);
992							}
993
994							var callback = switches[selector]
995								? switches[selector].bind(
996									this,
997									oldEl,
998									newEl,
999									options,
1000									switchesOptions[selector]
1001								)
1002								: defaultSwitches.outerHTML.bind(this, oldEl, newEl, options);
1003
1004							switchesQueue.push(callback);
1005						},
1006						this
1007					);
1008				}, this);
1009
1010				this.state.numPendingSwitches = switchesQueue.length;
1011
1012				switchesQueue.forEach(function (queuedSwitch) {
1013					queuedSwitch();
1014				});
1015			};
1016
1017		}, { "./foreach-els": 5, "./switches": 16 }], 16: [function (require, module, exports) {
1018			var on = require("./events/on");
1019
1020			module.exports = {
1021				outerHTML: function (oldEl, newEl) {
1022					oldEl.outerHTML = newEl.outerHTML;
1023					this.onSwitch();
1024				},
1025
1026				innerHTML: function (oldEl, newEl) {
1027					oldEl.innerHTML = newEl.innerHTML;
1028
1029					if (newEl.className === "") {
1030						oldEl.removeAttribute("class");
1031					} else {
1032						oldEl.className = newEl.className;
1033					}
1034
1035					this.onSwitch();
1036				},
1037
1038				switchElementsAlt: function (oldEl, newEl) {
1039					oldEl.innerHTML = newEl.innerHTML;
1040
1041					// Copy attributes from the new element to the old one
1042					if (newEl.hasAttributes()) {
1043						var attrs = newEl.attributes;
1044						for (var i = 0; i < attrs.length; i++) {
1045							oldEl.attributes.setNamedItem(attrs[i].cloneNode());
1046						}
1047					}
1048
1049					this.onSwitch();
1050				},
1051
1052				// Equivalent to outerHTML(), but doesn't require switchElementsAlt() for <head> and <body>
1053				replaceNode: function (oldEl, newEl) {
1054					oldEl.parentNode.replaceChild(newEl, oldEl);
1055					this.onSwitch();
1056				},
1057
1058				sideBySide: function (oldEl, newEl, options, switchOptions) {
1059					var elsToRemove = [];
1060					var elsToAdd = [];
1061					var fragToAppend = document.createDocumentFragment();
1062					var animationEventNames =
1063						"animationend webkitAnimationEnd MSAnimationEnd oanimationend";
1064					var animatedElsNumber = 0;
1065					var sexyAnimationEnd = function (e) {
1066						if (e.target !== e.currentTarget) {
1067							// end triggered by an animation on a child
1068							return;
1069						}
1070
1071						animatedElsNumber--;
1072						if (animatedElsNumber <= 0 && elsToRemove) {
1073							elsToRemove.forEach(function (el) {
1074								// browsing quickly can make the el
1075								// already removed by last page update ?
1076								if (el.parentNode) {
1077									el.parentNode.removeChild(el);
1078								}
1079							});
1080
1081							elsToAdd.forEach(function (el) {
1082								el.className = el.className.replace(
1083									el.getAttribute("data-pjax-classes"),
1084									""
1085								);
1086								el.removeAttribute("data-pjax-classes");
1087							});
1088
1089							elsToAdd = null; // free memory
1090							elsToRemove = null; // free memory
1091
1092							// this is to trigger some repaint (example: picturefill)
1093							this.onSwitch();
1094						}
1095					}.bind(this);
1096
1097					switchOptions = switchOptions || {};
1098
1099					oldEl.childNodes.forEach((el) => {
1100						elsToRemove.push(el);
1101						if (el.classList && !el.classList.contains("js-Pjax-remove")) {
1102							// for fast switch, clean element that just have been added, & not cleaned yet.
1103							if (el.hasAttribute("data-pjax-classes")) {
1104								el.className = el.className.replace(
1105									el.getAttribute("data-pjax-classes"),
1106									""
1107								);
1108								el.removeAttribute("data-pjax-classes");
1109							}
1110							el.classList.add("js-Pjax-remove");
1111							if (switchOptions.callbacks && switchOptions.callbacks.removeElement) {
1112								switchOptions.callbacks.removeElement(el);
1113							}
1114							if (switchOptions.classNames) {
1115								el.className +=
1116									" " +
1117									switchOptions.classNames.remove +
1118									" " +
1119									(options.backward
1120										? switchOptions.classNames.backward
1121										: switchOptions.classNames.forward);
1122							}
1123							animatedElsNumber++;
1124							on(el, animationEventNames, sexyAnimationEnd, true);
1125						}
1126					});
1127
1128					Array.from(newEl.childNodes).forEach(function (el) {
1129						if (el.classList) {
1130							var addClasses = "";
1131							if (switchOptions.classNames) {
1132								addClasses =
1133									" js-Pjax-add " +
1134									switchOptions.classNames.add +
1135									" " +
1136									(options.backward
1137										? switchOptions.classNames.forward
1138										: switchOptions.classNames.backward);
1139							}
1140							if (switchOptions.callbacks && switchOptions.callbacks.addElement) {
1141								switchOptions.callbacks.addElement(el);
1142							}
1143							el.className += addClasses;
1144							el.setAttribute("data-pjax-classes", addClasses);
1145							elsToAdd.push(el);
1146							fragToAppend.appendChild(el);
1147							animatedElsNumber++;
1148							on(el, animationEventNames, sexyAnimationEnd, true);
1149						}
1150					});
1151
1152					// pass all className of the parent
1153					oldEl.className = newEl.className;
1154					oldEl.appendChild(fragToAppend);
1155				}
1156			};
1157
1158		}, { "./events/on": 3 }], 17: [function (require, module, exports) {
1159			module.exports = (function () {
1160				var counter = 0;
1161				return function () {
1162					var id = "pjax" + new Date().getTime() + "_" + counter;
1163					counter++;
1164					return id;
1165				};
1166			})();
1167
1168		}, {}], 18: [function (require, module, exports) {
1169			module.exports = function (obj) {
1170				/* istanbul ignore if */
1171				if (null === obj || "object" !== typeof obj) {
1172					return obj;
1173				}
1174				var copy = obj.constructor();
1175				for (var attr in obj) {
1176					if (obj.hasOwnProperty(attr)) {
1177						copy[attr] = obj[attr];
1178					}
1179				}
1180				return copy;
1181			};
1182
1183		}, {}], 19: [function (require, module, exports) {
1184			module.exports = function contains(doc, selectors, el) {
1185				for (var i = 0; i < selectors.length; i++) {
1186					var selectedEls = doc.querySelectorAll(selectors[i]);
1187					for (var j = 0; j < selectedEls.length; j++) {
1188						if (selectedEls[j].contains(el)) {
1189							return true;
1190						}
1191					}
1192				}
1193
1194				return false;
1195			};
1196
1197		}, {}], 20: [function (require, module, exports) {
1198			module.exports = function (target) {
1199				if (target == null) {
1200					return null;
1201				}
1202
1203				var to = Object(target);
1204
1205				for (var i = 1; i < arguments.length; i++) {
1206					var source = arguments[i];
1207
1208					if (source != null) {
1209						for (var key in source) {
1210							// Avoid bugs when hasOwnProperty is shadowed
1211							if (Object.prototype.hasOwnProperty.call(source, key)) {
1212								to[key] = source[key];
1213							}
1214						}
1215					}
1216				}
1217				return to;
1218			};
1219
1220		}, {}], 21: [function (require, module, exports) {
1221			module.exports = function () {};
1222
1223		}, {}], 22: [function (require, module, exports) {
1224			module.exports = function (uri, key, value) {
1225				var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
1226				var separator = uri.indexOf("?") !== -1 ? "&" : "?";
1227				if (uri.match(re)) {
1228					return uri.replace(re, "$1" + key + "=" + value + "$2");
1229				} else {
1230					return uri + separator + key + "=" + value;
1231				}
1232			};
1233
1234		}, {}]
1235	}, {}, [1])(1)
1236});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.