swup 2.0.18 → 3.0.0-rc.1
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/dist/helpers.cjs +2 -0
- package/dist/helpers.cjs.map +1 -0
- package/dist/helpers.modern.js +2 -0
- package/dist/helpers.modern.js.map +1 -0
- package/dist/helpers.module.js +2 -0
- package/dist/helpers.module.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.modern.js +2 -0
- package/dist/index.modern.js.map +1 -0
- package/dist/index.module.js +2 -0
- package/dist/index.module.js.map +1 -0
- package/dist/index.umd.js +3 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/src/config/version.d.ts +5 -0
- package/dist/src/helpers/Location.d.ts +31 -0
- package/dist/src/helpers/classify.d.ts +2 -0
- package/dist/src/helpers/cleanupAnimationClasses.d.ts +2 -0
- package/dist/src/helpers/createHistoryRecord.d.ts +2 -0
- package/dist/src/helpers/delegateEvent.d.ts +8 -0
- package/dist/src/helpers/fetch.d.ts +6 -0
- package/dist/src/helpers/getCurrentUrl.d.ts +4 -0
- package/dist/src/helpers/getDataFromHtml.d.ts +8 -0
- package/dist/src/helpers/index.d.ts +11 -0
- package/dist/src/helpers/markSwupElements.d.ts +2 -0
- package/dist/src/helpers/updateHistoryRecord.d.ts +2 -0
- package/dist/src/helpers/versionSatisfies.d.ts +12 -0
- package/dist/src/helpers.d.ts +1 -0
- package/dist/src/index.d.ts +97 -0
- package/dist/src/modules/Cache.d.ts +20 -0
- package/dist/src/modules/enterPage.d.ts +6 -0
- package/dist/src/modules/getAnchorElement.d.ts +2 -0
- package/dist/src/modules/getAnimationPromises.d.ts +7 -0
- package/dist/src/modules/getPageData.d.ts +7 -0
- package/dist/src/modules/leavePage.d.ts +7 -0
- package/dist/src/modules/loadPage.d.ts +4 -0
- package/dist/src/modules/off.d.ts +4 -0
- package/dist/src/modules/on.d.ts +4 -0
- package/dist/src/modules/plugins.d.ts +13 -0
- package/dist/src/modules/renderPage.d.ts +7 -0
- package/dist/src/modules/replaceContent.d.ts +17 -0
- package/dist/src/modules/triggerEvent.d.ts +4 -0
- package/dist/src/modules/updateTransition.d.ts +3 -0
- package/dist/src/src/config/version.d.ts +5 -0
- package/dist/src/src/helpers/Location.d.ts +31 -0
- package/dist/src/src/helpers/classify.d.ts +2 -0
- package/dist/src/src/helpers/cleanupAnimationClasses.d.ts +2 -0
- package/dist/src/src/helpers/createHistoryRecord.d.ts +2 -0
- package/dist/src/src/helpers/delegateEvent.d.ts +8 -0
- package/dist/src/src/helpers/fetch.d.ts +6 -0
- package/dist/src/src/helpers/getCurrentUrl.d.ts +4 -0
- package/dist/src/src/helpers/getDataFromHtml.d.ts +8 -0
- package/dist/src/src/helpers/index.d.ts +11 -0
- package/dist/src/src/helpers/markSwupElements.d.ts +2 -0
- package/dist/src/src/helpers/updateHistoryRecord.d.ts +2 -0
- package/dist/src/src/helpers/versionSatisfies.d.ts +12 -0
- package/dist/src/src/helpers.d.ts +1 -0
- package/dist/src/src/index.d.ts +103 -0
- package/dist/src/src/modules/Cache.d.ts +20 -0
- package/dist/src/src/modules/enterPage.d.ts +6 -0
- package/dist/src/src/modules/getAnchorElement.d.ts +2 -0
- package/dist/src/src/modules/getAnimationPromises.d.ts +7 -0
- package/dist/src/src/modules/getPageData.d.ts +7 -0
- package/dist/src/src/modules/leavePage.d.ts +7 -0
- package/dist/src/src/modules/loadPage.d.ts +7 -0
- package/dist/src/src/modules/off.d.ts +4 -0
- package/dist/src/src/modules/on.d.ts +6 -0
- package/dist/src/src/modules/plugins.d.ts +14 -0
- package/dist/src/src/modules/renderPage.d.ts +7 -0
- package/dist/src/src/modules/replaceContent.d.ts +17 -0
- package/dist/src/src/modules/triggerEvent.d.ts +4 -0
- package/dist/src/src/modules/updateTransition.d.ts +3 -0
- package/dist/src/src/utils/index.d.ts +5 -0
- package/dist/src/src/utils.d.ts +1 -0
- package/dist/src/types.d.ts +12 -0
- package/dist/src/utils/index.d.ts +5 -0
- package/dist/src/utils.d.ts +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.modern.js +2 -0
- package/dist/types.modern.js.map +1 -0
- package/dist/types.module.js +2 -0
- package/dist/types.module.js.map +1 -0
- package/dist/utils.cjs +2 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.modern.js +2 -0
- package/dist/utils.modern.js.map +1 -0
- package/dist/utils.module.js +2 -0
- package/dist/utils.module.js.map +1 -0
- package/package.json +44 -21
- package/readme.md +52 -36
- package/src/config/version.ts +13 -0
- package/src/helpers/Location.ts +44 -0
- package/src/helpers/classify.ts +13 -0
- package/src/helpers/cleanupAnimationClasses.ts +10 -0
- package/src/helpers/createHistoryRecord.ts +14 -0
- package/src/helpers/delegateEvent.ts +23 -0
- package/src/helpers/fetch.ts +35 -0
- package/src/helpers/getCurrentUrl.ts +5 -0
- package/src/helpers/getDataFromHtml.ts +41 -0
- package/src/helpers/index.ts +11 -0
- package/src/helpers/markSwupElements.ts +18 -0
- package/src/helpers/updateHistoryRecord.ts +18 -0
- package/src/helpers/versionSatisfies.ts +50 -0
- package/src/helpers.ts +4 -0
- package/src/index.ts +369 -0
- package/src/modules/Cache.ts +57 -0
- package/src/modules/enterPage.ts +28 -0
- package/src/modules/fetchPage.ts +35 -0
- package/src/modules/getAnchorElement.ts +19 -0
- package/src/modules/getAnimationPromises.ts +176 -0
- package/src/modules/getPageData.ts +26 -0
- package/src/modules/leavePage.ts +33 -0
- package/src/modules/loadPage.ts +54 -0
- package/src/modules/off.ts +23 -0
- package/src/modules/on.ts +35 -0
- package/src/modules/plugins.ts +58 -0
- package/src/modules/renderPage.ts +52 -0
- package/src/modules/replaceContent.ts +28 -0
- package/src/modules/triggerEvent.ts +23 -0
- package/src/modules/updateTransition.ts +7 -0
- package/src/utils/index.ts +32 -0
- package/src/utils.ts +4 -0
- package/cypress.config.js +0 -13
- package/dist/swup.js +0 -1519
- package/dist/swup.min.js +0 -1
- package/lib/helpers/Link.js +0 -56
- package/lib/helpers/classify.js +0 -18
- package/lib/helpers/cleanupAnimationClasses.js +0 -18
- package/lib/helpers/createHistoryRecord.js +0 -14
- package/lib/helpers/fetch.js +0 -41
- package/lib/helpers/getCurrentUrl.js +0 -10
- package/lib/helpers/getDataFromHtml.js +0 -43
- package/lib/helpers/index.js +0 -64
- package/lib/helpers/markSwupElements.js +0 -24
- package/lib/helpers/normalizeUrl.js +0 -17
- package/lib/helpers/transitionEnd.js +0 -14
- package/lib/helpers/transitionProperty.js +0 -14
- package/lib/index.js +0 -305
- package/lib/modules/Cache.js +0 -66
- package/lib/modules/getAnchorElement.js +0 -25
- package/lib/modules/getAnimationPromises.js +0 -43
- package/lib/modules/getPageData.js +0 -26
- package/lib/modules/loadPage.js +0 -118
- package/lib/modules/off.js +0 -34
- package/lib/modules/on.js +0 -14
- package/lib/modules/plugins.js +0 -54
- package/lib/modules/renderPage.js +0 -76
- package/lib/modules/triggerEvent.js +0 -21
- package/lib/modules/updateTransition.js +0 -15
- package/lib/utils/index.js +0 -32
package/dist/swup.js
DELETED
|
@@ -1,1519 +0,0 @@
|
|
|
1
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory();
|
|
4
|
-
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define([], factory);
|
|
6
|
-
else if(typeof exports === 'object')
|
|
7
|
-
exports["Swup"] = factory();
|
|
8
|
-
else
|
|
9
|
-
root["Swup"] = factory();
|
|
10
|
-
})(window, function() {
|
|
11
|
-
return /******/ (function(modules) { // webpackBootstrap
|
|
12
|
-
/******/ // The module cache
|
|
13
|
-
/******/ var installedModules = {};
|
|
14
|
-
/******/
|
|
15
|
-
/******/ // The require function
|
|
16
|
-
/******/ function __webpack_require__(moduleId) {
|
|
17
|
-
/******/
|
|
18
|
-
/******/ // Check if module is in cache
|
|
19
|
-
/******/ if(installedModules[moduleId]) {
|
|
20
|
-
/******/ return installedModules[moduleId].exports;
|
|
21
|
-
/******/ }
|
|
22
|
-
/******/ // Create a new module (and put it into the cache)
|
|
23
|
-
/******/ var module = installedModules[moduleId] = {
|
|
24
|
-
/******/ i: moduleId,
|
|
25
|
-
/******/ l: false,
|
|
26
|
-
/******/ exports: {}
|
|
27
|
-
/******/ };
|
|
28
|
-
/******/
|
|
29
|
-
/******/ // Execute the module function
|
|
30
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
31
|
-
/******/
|
|
32
|
-
/******/ // Flag the module as loaded
|
|
33
|
-
/******/ module.l = true;
|
|
34
|
-
/******/
|
|
35
|
-
/******/ // Return the exports of the module
|
|
36
|
-
/******/ return module.exports;
|
|
37
|
-
/******/ }
|
|
38
|
-
/******/
|
|
39
|
-
/******/
|
|
40
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
41
|
-
/******/ __webpack_require__.m = modules;
|
|
42
|
-
/******/
|
|
43
|
-
/******/ // expose the module cache
|
|
44
|
-
/******/ __webpack_require__.c = installedModules;
|
|
45
|
-
/******/
|
|
46
|
-
/******/ // define getter function for harmony exports
|
|
47
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
48
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
49
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
50
|
-
/******/ }
|
|
51
|
-
/******/ };
|
|
52
|
-
/******/
|
|
53
|
-
/******/ // define __esModule on exports
|
|
54
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
55
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
56
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
57
|
-
/******/ }
|
|
58
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
59
|
-
/******/ };
|
|
60
|
-
/******/
|
|
61
|
-
/******/ // create a fake namespace object
|
|
62
|
-
/******/ // mode & 1: value is a module id, require it
|
|
63
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
64
|
-
/******/ // mode & 4: return value when already ns object
|
|
65
|
-
/******/ // mode & 8|1: behave like require
|
|
66
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
67
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
68
|
-
/******/ if(mode & 8) return value;
|
|
69
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
70
|
-
/******/ var ns = Object.create(null);
|
|
71
|
-
/******/ __webpack_require__.r(ns);
|
|
72
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
73
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
74
|
-
/******/ return ns;
|
|
75
|
-
/******/ };
|
|
76
|
-
/******/
|
|
77
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
78
|
-
/******/ __webpack_require__.n = function(module) {
|
|
79
|
-
/******/ var getter = module && module.__esModule ?
|
|
80
|
-
/******/ function getDefault() { return module['default']; } :
|
|
81
|
-
/******/ function getModuleExports() { return module; };
|
|
82
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
83
|
-
/******/ return getter;
|
|
84
|
-
/******/ };
|
|
85
|
-
/******/
|
|
86
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
87
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
88
|
-
/******/
|
|
89
|
-
/******/ // __webpack_public_path__
|
|
90
|
-
/******/ __webpack_require__.p = "";
|
|
91
|
-
/******/
|
|
92
|
-
/******/
|
|
93
|
-
/******/ // Load entry module and return exports
|
|
94
|
-
/******/ return __webpack_require__(__webpack_require__.s = 3);
|
|
95
|
-
/******/ })
|
|
96
|
-
/************************************************************************/
|
|
97
|
-
/******/ ([
|
|
98
|
-
/* 0 */
|
|
99
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
100
|
-
|
|
101
|
-
"use strict";
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
Object.defineProperty(exports, "__esModule", {
|
|
105
|
-
value: true
|
|
106
|
-
});
|
|
107
|
-
exports.cleanupAnimationClasses = exports.Link = exports.markSwupElements = exports.normalizeUrl = exports.getCurrentUrl = exports.transitionProperty = exports.transitionEnd = exports.fetch = exports.getDataFromHtml = exports.createHistoryRecord = exports.classify = undefined;
|
|
108
|
-
|
|
109
|
-
var _classify = __webpack_require__(7);
|
|
110
|
-
|
|
111
|
-
var _classify2 = _interopRequireDefault(_classify);
|
|
112
|
-
|
|
113
|
-
var _createHistoryRecord = __webpack_require__(8);
|
|
114
|
-
|
|
115
|
-
var _createHistoryRecord2 = _interopRequireDefault(_createHistoryRecord);
|
|
116
|
-
|
|
117
|
-
var _getDataFromHtml = __webpack_require__(9);
|
|
118
|
-
|
|
119
|
-
var _getDataFromHtml2 = _interopRequireDefault(_getDataFromHtml);
|
|
120
|
-
|
|
121
|
-
var _fetch = __webpack_require__(10);
|
|
122
|
-
|
|
123
|
-
var _fetch2 = _interopRequireDefault(_fetch);
|
|
124
|
-
|
|
125
|
-
var _transitionEnd = __webpack_require__(11);
|
|
126
|
-
|
|
127
|
-
var _transitionEnd2 = _interopRequireDefault(_transitionEnd);
|
|
128
|
-
|
|
129
|
-
var _transitionProperty = __webpack_require__(12);
|
|
130
|
-
|
|
131
|
-
var _transitionProperty2 = _interopRequireDefault(_transitionProperty);
|
|
132
|
-
|
|
133
|
-
var _getCurrentUrl = __webpack_require__(13);
|
|
134
|
-
|
|
135
|
-
var _getCurrentUrl2 = _interopRequireDefault(_getCurrentUrl);
|
|
136
|
-
|
|
137
|
-
var _normalizeUrl = __webpack_require__(14);
|
|
138
|
-
|
|
139
|
-
var _normalizeUrl2 = _interopRequireDefault(_normalizeUrl);
|
|
140
|
-
|
|
141
|
-
var _markSwupElements = __webpack_require__(15);
|
|
142
|
-
|
|
143
|
-
var _markSwupElements2 = _interopRequireDefault(_markSwupElements);
|
|
144
|
-
|
|
145
|
-
var _Link = __webpack_require__(2);
|
|
146
|
-
|
|
147
|
-
var _Link2 = _interopRequireDefault(_Link);
|
|
148
|
-
|
|
149
|
-
var _cleanupAnimationClasses = __webpack_require__(16);
|
|
150
|
-
|
|
151
|
-
var _cleanupAnimationClasses2 = _interopRequireDefault(_cleanupAnimationClasses);
|
|
152
|
-
|
|
153
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
154
|
-
|
|
155
|
-
var classify = exports.classify = _classify2.default;
|
|
156
|
-
var createHistoryRecord = exports.createHistoryRecord = _createHistoryRecord2.default;
|
|
157
|
-
var getDataFromHtml = exports.getDataFromHtml = _getDataFromHtml2.default;
|
|
158
|
-
var fetch = exports.fetch = _fetch2.default;
|
|
159
|
-
var transitionEnd = exports.transitionEnd = _transitionEnd2.default;
|
|
160
|
-
var transitionProperty = exports.transitionProperty = _transitionProperty2.default;
|
|
161
|
-
var getCurrentUrl = exports.getCurrentUrl = _getCurrentUrl2.default;
|
|
162
|
-
var normalizeUrl = exports.normalizeUrl = _normalizeUrl2.default;
|
|
163
|
-
var markSwupElements = exports.markSwupElements = _markSwupElements2.default;
|
|
164
|
-
var Link = exports.Link = _Link2.default;
|
|
165
|
-
var cleanupAnimationClasses = exports.cleanupAnimationClasses = _cleanupAnimationClasses2.default;
|
|
166
|
-
|
|
167
|
-
/***/ }),
|
|
168
|
-
/* 1 */
|
|
169
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
170
|
-
|
|
171
|
-
"use strict";
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
Object.defineProperty(exports, "__esModule", {
|
|
175
|
-
value: true
|
|
176
|
-
});
|
|
177
|
-
var query = exports.query = function query(selector) {
|
|
178
|
-
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
179
|
-
|
|
180
|
-
if (typeof selector !== 'string') {
|
|
181
|
-
return selector;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return context.querySelector(selector);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
var queryAll = exports.queryAll = function queryAll(selector) {
|
|
188
|
-
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
189
|
-
|
|
190
|
-
if (typeof selector !== 'string') {
|
|
191
|
-
return selector;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return Array.prototype.slice.call(context.querySelectorAll(selector));
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
var escapeCssIdentifier = exports.escapeCssIdentifier = function escapeCssIdentifier(ident) {
|
|
198
|
-
if (window.CSS && window.CSS.escape) {
|
|
199
|
-
return CSS.escape(ident);
|
|
200
|
-
} else {
|
|
201
|
-
return ident;
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
/***/ }),
|
|
206
|
-
/* 2 */
|
|
207
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
208
|
-
|
|
209
|
-
"use strict";
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
Object.defineProperty(exports, "__esModule", {
|
|
213
|
-
value: true
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
217
|
-
|
|
218
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
219
|
-
|
|
220
|
-
var Link = function () {
|
|
221
|
-
function Link(elementOrUrl) {
|
|
222
|
-
_classCallCheck(this, Link);
|
|
223
|
-
|
|
224
|
-
if (elementOrUrl instanceof Element || elementOrUrl instanceof SVGElement) {
|
|
225
|
-
this.link = elementOrUrl;
|
|
226
|
-
} else {
|
|
227
|
-
this.link = document.createElement('a');
|
|
228
|
-
this.link.href = elementOrUrl;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
_createClass(Link, [{
|
|
233
|
-
key: 'getPath',
|
|
234
|
-
value: function getPath() {
|
|
235
|
-
var path = this.link.pathname;
|
|
236
|
-
if (path[0] !== '/') {
|
|
237
|
-
path = '/' + path;
|
|
238
|
-
}
|
|
239
|
-
return path;
|
|
240
|
-
}
|
|
241
|
-
}, {
|
|
242
|
-
key: 'getAddress',
|
|
243
|
-
value: function getAddress() {
|
|
244
|
-
var path = this.link.pathname + this.link.search;
|
|
245
|
-
|
|
246
|
-
if (this.link.getAttribute('xlink:href')) {
|
|
247
|
-
path = this.link.getAttribute('xlink:href');
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (path[0] !== '/') {
|
|
251
|
-
path = '/' + path;
|
|
252
|
-
}
|
|
253
|
-
return path;
|
|
254
|
-
}
|
|
255
|
-
}, {
|
|
256
|
-
key: 'getHash',
|
|
257
|
-
value: function getHash() {
|
|
258
|
-
return this.link.hash;
|
|
259
|
-
}
|
|
260
|
-
}]);
|
|
261
|
-
|
|
262
|
-
return Link;
|
|
263
|
-
}();
|
|
264
|
-
|
|
265
|
-
exports.default = Link;
|
|
266
|
-
|
|
267
|
-
/***/ }),
|
|
268
|
-
/* 3 */
|
|
269
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
270
|
-
|
|
271
|
-
"use strict";
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
var _index = __webpack_require__(4);
|
|
275
|
-
|
|
276
|
-
var _index2 = _interopRequireDefault(_index);
|
|
277
|
-
|
|
278
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
279
|
-
|
|
280
|
-
module.exports = _index2.default; // this is here for webpack to expose Swup as window.Swup
|
|
281
|
-
|
|
282
|
-
/***/ }),
|
|
283
|
-
/* 4 */
|
|
284
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
285
|
-
|
|
286
|
-
"use strict";
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
Object.defineProperty(exports, "__esModule", {
|
|
290
|
-
value: true
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
294
|
-
|
|
295
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
296
|
-
|
|
297
|
-
// modules
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
var _delegateIt = __webpack_require__(5);
|
|
301
|
-
|
|
302
|
-
var _delegateIt2 = _interopRequireDefault(_delegateIt);
|
|
303
|
-
|
|
304
|
-
var _Cache = __webpack_require__(6);
|
|
305
|
-
|
|
306
|
-
var _Cache2 = _interopRequireDefault(_Cache);
|
|
307
|
-
|
|
308
|
-
var _loadPage = __webpack_require__(17);
|
|
309
|
-
|
|
310
|
-
var _loadPage2 = _interopRequireDefault(_loadPage);
|
|
311
|
-
|
|
312
|
-
var _renderPage = __webpack_require__(18);
|
|
313
|
-
|
|
314
|
-
var _renderPage2 = _interopRequireDefault(_renderPage);
|
|
315
|
-
|
|
316
|
-
var _triggerEvent = __webpack_require__(19);
|
|
317
|
-
|
|
318
|
-
var _triggerEvent2 = _interopRequireDefault(_triggerEvent);
|
|
319
|
-
|
|
320
|
-
var _on = __webpack_require__(20);
|
|
321
|
-
|
|
322
|
-
var _on2 = _interopRequireDefault(_on);
|
|
323
|
-
|
|
324
|
-
var _off = __webpack_require__(21);
|
|
325
|
-
|
|
326
|
-
var _off2 = _interopRequireDefault(_off);
|
|
327
|
-
|
|
328
|
-
var _updateTransition = __webpack_require__(22);
|
|
329
|
-
|
|
330
|
-
var _updateTransition2 = _interopRequireDefault(_updateTransition);
|
|
331
|
-
|
|
332
|
-
var _getAnchorElement = __webpack_require__(23);
|
|
333
|
-
|
|
334
|
-
var _getAnchorElement2 = _interopRequireDefault(_getAnchorElement);
|
|
335
|
-
|
|
336
|
-
var _getAnimationPromises = __webpack_require__(24);
|
|
337
|
-
|
|
338
|
-
var _getAnimationPromises2 = _interopRequireDefault(_getAnimationPromises);
|
|
339
|
-
|
|
340
|
-
var _getPageData = __webpack_require__(25);
|
|
341
|
-
|
|
342
|
-
var _getPageData2 = _interopRequireDefault(_getPageData);
|
|
343
|
-
|
|
344
|
-
var _plugins = __webpack_require__(26);
|
|
345
|
-
|
|
346
|
-
var _utils = __webpack_require__(1);
|
|
347
|
-
|
|
348
|
-
var _helpers = __webpack_require__(0);
|
|
349
|
-
|
|
350
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
351
|
-
|
|
352
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
353
|
-
|
|
354
|
-
var Swup = function () {
|
|
355
|
-
function Swup(setOptions) {
|
|
356
|
-
_classCallCheck(this, Swup);
|
|
357
|
-
|
|
358
|
-
// default options
|
|
359
|
-
var defaults = {
|
|
360
|
-
animateHistoryBrowsing: false,
|
|
361
|
-
animationSelector: '[class*="transition-"]',
|
|
362
|
-
linkSelector: 'a[href^="' + window.location.origin + '"]:not([data-no-swup]), a[href^="/"]:not([data-no-swup]), a[href^="#"]:not([data-no-swup])',
|
|
363
|
-
cache: true,
|
|
364
|
-
containers: ['#swup'],
|
|
365
|
-
requestHeaders: {
|
|
366
|
-
'X-Requested-With': 'swup',
|
|
367
|
-
Accept: 'text/html, application/xhtml+xml'
|
|
368
|
-
},
|
|
369
|
-
plugins: [],
|
|
370
|
-
skipPopStateHandling: function skipPopStateHandling(event) {
|
|
371
|
-
return !(event.state && event.state.source === 'swup');
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
// merge options
|
|
376
|
-
var options = _extends({}, defaults, setOptions);
|
|
377
|
-
|
|
378
|
-
// handler arrays
|
|
379
|
-
this._handlers = {
|
|
380
|
-
animationInDone: [],
|
|
381
|
-
animationInStart: [],
|
|
382
|
-
animationOutDone: [],
|
|
383
|
-
animationOutStart: [],
|
|
384
|
-
animationSkipped: [],
|
|
385
|
-
clickLink: [],
|
|
386
|
-
contentReplaced: [],
|
|
387
|
-
disabled: [],
|
|
388
|
-
enabled: [],
|
|
389
|
-
openPageInNewTab: [],
|
|
390
|
-
pageLoaded: [],
|
|
391
|
-
pageRetrievedFromCache: [],
|
|
392
|
-
pageView: [],
|
|
393
|
-
popState: [],
|
|
394
|
-
samePage: [],
|
|
395
|
-
samePageWithHash: [],
|
|
396
|
-
serverError: [],
|
|
397
|
-
transitionStart: [],
|
|
398
|
-
transitionEnd: [],
|
|
399
|
-
willReplaceContent: []
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
// variable for anchor to scroll to after render
|
|
403
|
-
this.scrollToElement = null;
|
|
404
|
-
// variable for promise used for preload, so no new loading of the same page starts while page is loading
|
|
405
|
-
this.preloadPromise = null;
|
|
406
|
-
// variable for save options
|
|
407
|
-
this.options = options;
|
|
408
|
-
// variable for plugins array
|
|
409
|
-
this.plugins = [];
|
|
410
|
-
// variable for current transition object
|
|
411
|
-
this.transition = {};
|
|
412
|
-
// variable for keeping event listeners from "delegate"
|
|
413
|
-
this.delegatedListeners = {};
|
|
414
|
-
// so we are able to remove the listener
|
|
415
|
-
this.boundPopStateHandler = this.popStateHandler.bind(this);
|
|
416
|
-
|
|
417
|
-
// make modules accessible in instance
|
|
418
|
-
this.cache = new _Cache2.default();
|
|
419
|
-
this.cache.swup = this;
|
|
420
|
-
this.loadPage = _loadPage2.default;
|
|
421
|
-
this.renderPage = _renderPage2.default;
|
|
422
|
-
this.triggerEvent = _triggerEvent2.default;
|
|
423
|
-
this.on = _on2.default;
|
|
424
|
-
this.off = _off2.default;
|
|
425
|
-
this.updateTransition = _updateTransition2.default;
|
|
426
|
-
this.getAnimationPromises = _getAnimationPromises2.default;
|
|
427
|
-
this.getPageData = _getPageData2.default;
|
|
428
|
-
this.getAnchorElement = _getAnchorElement2.default;
|
|
429
|
-
this.log = function () {}; // here so it can be used by plugins
|
|
430
|
-
this.use = _plugins.use;
|
|
431
|
-
this.unuse = _plugins.unuse;
|
|
432
|
-
this.findPlugin = _plugins.findPlugin;
|
|
433
|
-
this.getCurrentUrl = _helpers.getCurrentUrl;
|
|
434
|
-
this.cleanupAnimationClasses = _helpers.cleanupAnimationClasses;
|
|
435
|
-
|
|
436
|
-
// enable swup
|
|
437
|
-
this.enable();
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
_createClass(Swup, [{
|
|
441
|
-
key: 'enable',
|
|
442
|
-
value: function enable() {
|
|
443
|
-
var _this = this;
|
|
444
|
-
|
|
445
|
-
// check for Promise support
|
|
446
|
-
if (typeof Promise === 'undefined') {
|
|
447
|
-
console.warn('Promise is not supported');
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
// add event listeners
|
|
452
|
-
this.delegatedListeners.click = (0, _delegateIt2.default)(document, this.options.linkSelector, 'click', this.linkClickHandler.bind(this));
|
|
453
|
-
window.addEventListener('popstate', this.boundPopStateHandler);
|
|
454
|
-
|
|
455
|
-
// initial save to cache
|
|
456
|
-
if (this.options.cache) {
|
|
457
|
-
var page = (0, _helpers.getDataFromHtml)(document.documentElement.outerHTML, this.options.containers);
|
|
458
|
-
page.url = page.responseURL = (0, _helpers.getCurrentUrl)();
|
|
459
|
-
this.cache.cacheUrl(page);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// mark swup blocks in html
|
|
463
|
-
(0, _helpers.markSwupElements)(document.documentElement, this.options.containers);
|
|
464
|
-
|
|
465
|
-
// mount plugins
|
|
466
|
-
this.options.plugins.forEach(function (plugin) {
|
|
467
|
-
_this.use(plugin);
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
// modify initial history record
|
|
471
|
-
window.history.replaceState(Object.assign({}, window.history.state, {
|
|
472
|
-
url: window.location.href,
|
|
473
|
-
random: Math.random(),
|
|
474
|
-
source: 'swup'
|
|
475
|
-
}), document.title, window.location.href);
|
|
476
|
-
|
|
477
|
-
// trigger enabled event
|
|
478
|
-
this.triggerEvent('enabled');
|
|
479
|
-
|
|
480
|
-
// add swup-enabled class to html tag
|
|
481
|
-
document.documentElement.classList.add('swup-enabled');
|
|
482
|
-
|
|
483
|
-
// trigger page view event
|
|
484
|
-
this.triggerEvent('pageView');
|
|
485
|
-
}
|
|
486
|
-
}, {
|
|
487
|
-
key: 'destroy',
|
|
488
|
-
value: function destroy() {
|
|
489
|
-
var _this2 = this;
|
|
490
|
-
|
|
491
|
-
// remove delegated listeners
|
|
492
|
-
this.delegatedListeners.click.destroy();
|
|
493
|
-
|
|
494
|
-
// remove popstate listener
|
|
495
|
-
window.removeEventListener('popstate', this.boundPopStateHandler);
|
|
496
|
-
|
|
497
|
-
// empty cache
|
|
498
|
-
this.cache.empty();
|
|
499
|
-
|
|
500
|
-
// unmount plugins
|
|
501
|
-
this.options.plugins.forEach(function (plugin) {
|
|
502
|
-
_this2.unuse(plugin);
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
// remove swup data atributes from blocks
|
|
506
|
-
(0, _utils.queryAll)('[data-swup]').forEach(function (element) {
|
|
507
|
-
element.removeAttribute('data-swup');
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
// remove handlers
|
|
511
|
-
this.off();
|
|
512
|
-
|
|
513
|
-
// trigger disable event
|
|
514
|
-
this.triggerEvent('disabled');
|
|
515
|
-
|
|
516
|
-
// remove swup-enabled class from html tag
|
|
517
|
-
document.documentElement.classList.remove('swup-enabled');
|
|
518
|
-
}
|
|
519
|
-
}, {
|
|
520
|
-
key: 'linkClickHandler',
|
|
521
|
-
value: function linkClickHandler(event) {
|
|
522
|
-
// no control key pressed
|
|
523
|
-
if (!event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey) {
|
|
524
|
-
// index of pressed button needs to be checked because Firefox triggers click on all mouse buttons
|
|
525
|
-
if (event.button === 0) {
|
|
526
|
-
this.triggerEvent('clickLink', event);
|
|
527
|
-
event.preventDefault();
|
|
528
|
-
var link = new _helpers.Link(event.delegateTarget);
|
|
529
|
-
if (link.getAddress() == (0, _helpers.getCurrentUrl)() || link.getAddress() == '') {
|
|
530
|
-
// link to the same URL
|
|
531
|
-
if (link.getHash() != '') {
|
|
532
|
-
// link to the same URL with hash
|
|
533
|
-
this.triggerEvent('samePageWithHash', event);
|
|
534
|
-
var element = (0, _getAnchorElement2.default)(link.getHash());
|
|
535
|
-
if (element != null) {
|
|
536
|
-
history.replaceState({
|
|
537
|
-
url: link.getAddress() + link.getHash(),
|
|
538
|
-
random: Math.random(),
|
|
539
|
-
source: 'swup'
|
|
540
|
-
}, document.title, link.getAddress() + link.getHash());
|
|
541
|
-
} else {
|
|
542
|
-
// referenced element not found
|
|
543
|
-
console.warn('Element for offset not found (' + link.getHash() + ')');
|
|
544
|
-
}
|
|
545
|
-
} else {
|
|
546
|
-
// link to the same URL without hash
|
|
547
|
-
this.triggerEvent('samePage', event);
|
|
548
|
-
}
|
|
549
|
-
} else {
|
|
550
|
-
// link to different url
|
|
551
|
-
if (link.getHash() != '') {
|
|
552
|
-
this.scrollToElement = link.getHash();
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// get custom transition from data
|
|
556
|
-
var customTransition = event.delegateTarget.getAttribute('data-swup-transition');
|
|
557
|
-
|
|
558
|
-
// load page
|
|
559
|
-
this.loadPage({ url: link.getAddress(), customTransition: customTransition }, false);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
} else {
|
|
563
|
-
// open in new tab (do nothing)
|
|
564
|
-
this.triggerEvent('openPageInNewTab', event);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}, {
|
|
568
|
-
key: 'popStateHandler',
|
|
569
|
-
value: function popStateHandler(event) {
|
|
570
|
-
if (this.options.skipPopStateHandling(event)) return;
|
|
571
|
-
var link = new _helpers.Link(event.state ? event.state.url : window.location.pathname);
|
|
572
|
-
if (link.getHash() !== '') {
|
|
573
|
-
this.scrollToElement = link.getHash();
|
|
574
|
-
} else {
|
|
575
|
-
event.preventDefault();
|
|
576
|
-
}
|
|
577
|
-
this.triggerEvent('popState', event);
|
|
578
|
-
|
|
579
|
-
if (!this.options.animateHistoryBrowsing) {
|
|
580
|
-
document.documentElement.classList.remove('is-animating');
|
|
581
|
-
(0, _helpers.cleanupAnimationClasses)();
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
this.loadPage({ url: link.getAddress() }, event);
|
|
585
|
-
}
|
|
586
|
-
}]);
|
|
587
|
-
|
|
588
|
-
return Swup;
|
|
589
|
-
}();
|
|
590
|
-
|
|
591
|
-
exports.default = Swup;
|
|
592
|
-
|
|
593
|
-
/***/ }),
|
|
594
|
-
/* 5 */
|
|
595
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
596
|
-
|
|
597
|
-
"use strict";
|
|
598
|
-
__webpack_require__.r(__webpack_exports__);
|
|
599
|
-
/** Keeps track of raw listeners added to the base elements to avoid duplication */
|
|
600
|
-
const ledger = new WeakMap();
|
|
601
|
-
function editLedger(wanted, baseElement, callback, setup) {
|
|
602
|
-
var _a, _b;
|
|
603
|
-
if (!wanted && !ledger.has(baseElement)) {
|
|
604
|
-
return false;
|
|
605
|
-
}
|
|
606
|
-
const elementMap = (_a = ledger.get(baseElement)) !== null && _a !== void 0 ? _a : new WeakMap();
|
|
607
|
-
ledger.set(baseElement, elementMap);
|
|
608
|
-
if (!wanted && !ledger.has(baseElement)) {
|
|
609
|
-
return false;
|
|
610
|
-
}
|
|
611
|
-
const setups = (_b = elementMap.get(callback)) !== null && _b !== void 0 ? _b : new Set();
|
|
612
|
-
elementMap.set(callback, setups);
|
|
613
|
-
const existed = setups.has(setup);
|
|
614
|
-
if (wanted) {
|
|
615
|
-
setups.add(setup);
|
|
616
|
-
}
|
|
617
|
-
else {
|
|
618
|
-
setups.delete(setup);
|
|
619
|
-
}
|
|
620
|
-
return existed && wanted;
|
|
621
|
-
}
|
|
622
|
-
function isEventTarget(elements) {
|
|
623
|
-
return typeof elements.addEventListener === 'function';
|
|
624
|
-
}
|
|
625
|
-
function safeClosest(event, selector) {
|
|
626
|
-
let target = event.target;
|
|
627
|
-
if (target instanceof Text) {
|
|
628
|
-
target = target.parentElement;
|
|
629
|
-
}
|
|
630
|
-
if (target instanceof Element && event.currentTarget instanceof Element) {
|
|
631
|
-
// `.closest()` may match ancestors of `currentTarget` but we only need its children
|
|
632
|
-
const closest = target.closest(selector);
|
|
633
|
-
if (closest && event.currentTarget.contains(closest)) {
|
|
634
|
-
return closest;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
// This type isn't exported as a declaration, so it needs to be duplicated above
|
|
639
|
-
function delegate(base, selector, type, callback, options) {
|
|
640
|
-
// Handle Selector-based usage
|
|
641
|
-
if (typeof base === 'string') {
|
|
642
|
-
base = document.querySelectorAll(base);
|
|
643
|
-
}
|
|
644
|
-
// Handle Array-like based usage
|
|
645
|
-
if (!isEventTarget(base)) {
|
|
646
|
-
const subscriptions = Array.prototype.map.call(base, (element) => delegate(element, selector, type, callback, options));
|
|
647
|
-
return {
|
|
648
|
-
destroy() {
|
|
649
|
-
for (const subscription of subscriptions) {
|
|
650
|
-
subscription.destroy();
|
|
651
|
-
}
|
|
652
|
-
},
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
// `document` should never be the base, it's just an easy way to define "global event listeners"
|
|
656
|
-
const baseElement = base instanceof Document ? base.documentElement : base;
|
|
657
|
-
// Handle the regular Element usage
|
|
658
|
-
const capture = Boolean(typeof options === 'object' ? options.capture : options);
|
|
659
|
-
const listenerFn = (event) => {
|
|
660
|
-
const delegateTarget = safeClosest(event, selector);
|
|
661
|
-
if (delegateTarget) {
|
|
662
|
-
event.delegateTarget = delegateTarget;
|
|
663
|
-
callback.call(baseElement, event);
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
// Drop unsupported `once` option https://github.com/fregante/delegate-it/pull/28#discussion_r863467939
|
|
667
|
-
if (typeof options === 'object') {
|
|
668
|
-
delete options.once;
|
|
669
|
-
}
|
|
670
|
-
const setup = JSON.stringify({ selector, type, capture });
|
|
671
|
-
const isAlreadyListening = editLedger(true, baseElement, callback, setup);
|
|
672
|
-
const delegateSubscription = {
|
|
673
|
-
destroy() {
|
|
674
|
-
baseElement.removeEventListener(type, listenerFn, options);
|
|
675
|
-
editLedger(false, baseElement, callback, setup);
|
|
676
|
-
},
|
|
677
|
-
};
|
|
678
|
-
if (!isAlreadyListening) {
|
|
679
|
-
baseElement.addEventListener(type, listenerFn, options);
|
|
680
|
-
}
|
|
681
|
-
return delegateSubscription;
|
|
682
|
-
}
|
|
683
|
-
/* harmony default export */ __webpack_exports__["default"] = (delegate);
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
/***/ }),
|
|
687
|
-
/* 6 */
|
|
688
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
689
|
-
|
|
690
|
-
"use strict";
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
Object.defineProperty(exports, "__esModule", {
|
|
694
|
-
value: true
|
|
695
|
-
});
|
|
696
|
-
exports.Cache = undefined;
|
|
697
|
-
|
|
698
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
699
|
-
|
|
700
|
-
var _helpers = __webpack_require__(0);
|
|
701
|
-
|
|
702
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
703
|
-
|
|
704
|
-
var Cache = exports.Cache = function () {
|
|
705
|
-
function Cache() {
|
|
706
|
-
_classCallCheck(this, Cache);
|
|
707
|
-
|
|
708
|
-
this.pages = {};
|
|
709
|
-
this.last = null;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
_createClass(Cache, [{
|
|
713
|
-
key: 'cacheUrl',
|
|
714
|
-
value: function cacheUrl(page) {
|
|
715
|
-
page.url = (0, _helpers.normalizeUrl)(page.url);
|
|
716
|
-
if (page.url in this.pages === false) {
|
|
717
|
-
this.pages[page.url] = page;
|
|
718
|
-
}
|
|
719
|
-
this.last = this.pages[page.url];
|
|
720
|
-
this.swup.log('Cache (' + Object.keys(this.pages).length + ')', this.pages);
|
|
721
|
-
}
|
|
722
|
-
}, {
|
|
723
|
-
key: 'getPage',
|
|
724
|
-
value: function getPage(url) {
|
|
725
|
-
url = (0, _helpers.normalizeUrl)(url);
|
|
726
|
-
return this.pages[url];
|
|
727
|
-
}
|
|
728
|
-
}, {
|
|
729
|
-
key: 'getCurrentPage',
|
|
730
|
-
value: function getCurrentPage() {
|
|
731
|
-
return this.getPage((0, _helpers.getCurrentUrl)());
|
|
732
|
-
}
|
|
733
|
-
}, {
|
|
734
|
-
key: 'exists',
|
|
735
|
-
value: function exists(url) {
|
|
736
|
-
url = (0, _helpers.normalizeUrl)(url);
|
|
737
|
-
return url in this.pages;
|
|
738
|
-
}
|
|
739
|
-
}, {
|
|
740
|
-
key: 'empty',
|
|
741
|
-
value: function empty() {
|
|
742
|
-
this.pages = {};
|
|
743
|
-
this.last = null;
|
|
744
|
-
this.swup.log('Cache cleared');
|
|
745
|
-
}
|
|
746
|
-
}, {
|
|
747
|
-
key: 'remove',
|
|
748
|
-
value: function remove(url) {
|
|
749
|
-
delete this.pages[url];
|
|
750
|
-
}
|
|
751
|
-
}]);
|
|
752
|
-
|
|
753
|
-
return Cache;
|
|
754
|
-
}();
|
|
755
|
-
|
|
756
|
-
exports.default = Cache;
|
|
757
|
-
|
|
758
|
-
/***/ }),
|
|
759
|
-
/* 7 */
|
|
760
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
761
|
-
|
|
762
|
-
"use strict";
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
Object.defineProperty(exports, "__esModule", {
|
|
766
|
-
value: true
|
|
767
|
-
});
|
|
768
|
-
var classify = function classify(text) {
|
|
769
|
-
var output = text.toString().toLowerCase().replace(/\s+/g, '-') // Replace spaces with -
|
|
770
|
-
.replace(/\//g, '-') // Replace / with -
|
|
771
|
-
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
|
772
|
-
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
|
773
|
-
.replace(/^-+/, '') // Trim - from start of text
|
|
774
|
-
.replace(/-+$/, ''); // Trim - from end of text
|
|
775
|
-
if (output[0] === '/') output = output.splice(1);
|
|
776
|
-
if (output === '') output = 'homepage';
|
|
777
|
-
return output;
|
|
778
|
-
};
|
|
779
|
-
|
|
780
|
-
exports.default = classify;
|
|
781
|
-
|
|
782
|
-
/***/ }),
|
|
783
|
-
/* 8 */
|
|
784
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
785
|
-
|
|
786
|
-
"use strict";
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
Object.defineProperty(exports, "__esModule", {
|
|
790
|
-
value: true
|
|
791
|
-
});
|
|
792
|
-
var createHistoryRecord = function createHistoryRecord(url) {
|
|
793
|
-
window.history.pushState({
|
|
794
|
-
url: url || window.location.href.split(window.location.hostname)[1],
|
|
795
|
-
random: Math.random(),
|
|
796
|
-
source: 'swup'
|
|
797
|
-
}, document.getElementsByTagName('title')[0].innerText, url || window.location.href.split(window.location.hostname)[1]);
|
|
798
|
-
};
|
|
799
|
-
|
|
800
|
-
exports.default = createHistoryRecord;
|
|
801
|
-
|
|
802
|
-
/***/ }),
|
|
803
|
-
/* 9 */
|
|
804
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
805
|
-
|
|
806
|
-
"use strict";
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
Object.defineProperty(exports, "__esModule", {
|
|
810
|
-
value: true
|
|
811
|
-
});
|
|
812
|
-
|
|
813
|
-
var _utils = __webpack_require__(1);
|
|
814
|
-
|
|
815
|
-
var getDataFromHtml = function getDataFromHtml(html, containers) {
|
|
816
|
-
var fakeDom = document.createElement('html');
|
|
817
|
-
fakeDom.innerHTML = html;
|
|
818
|
-
var blocks = [];
|
|
819
|
-
|
|
820
|
-
containers.forEach(function (selector) {
|
|
821
|
-
if ((0, _utils.query)(selector, fakeDom) == null) {
|
|
822
|
-
console.error('Container ' + selector + ' not found on page.');
|
|
823
|
-
return null;
|
|
824
|
-
} else {
|
|
825
|
-
if ((0, _utils.queryAll)(selector).length !== (0, _utils.queryAll)(selector, fakeDom).length) {
|
|
826
|
-
console.warn('Mismatched number of containers found on new page.');
|
|
827
|
-
}
|
|
828
|
-
(0, _utils.queryAll)(selector).forEach(function (item, index) {
|
|
829
|
-
(0, _utils.queryAll)(selector, fakeDom)[index].setAttribute('data-swup', blocks.length);
|
|
830
|
-
blocks.push((0, _utils.queryAll)(selector, fakeDom)[index].outerHTML);
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
|
|
835
|
-
var json = {
|
|
836
|
-
title: fakeDom.querySelector('title').innerText,
|
|
837
|
-
pageClass: fakeDom.querySelector('body').className,
|
|
838
|
-
originalContent: html,
|
|
839
|
-
blocks: blocks
|
|
840
|
-
};
|
|
841
|
-
|
|
842
|
-
// to prevent memory leaks
|
|
843
|
-
fakeDom.innerHTML = '';
|
|
844
|
-
fakeDom = null;
|
|
845
|
-
|
|
846
|
-
return json;
|
|
847
|
-
};
|
|
848
|
-
|
|
849
|
-
exports.default = getDataFromHtml;
|
|
850
|
-
|
|
851
|
-
/***/ }),
|
|
852
|
-
/* 10 */
|
|
853
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
854
|
-
|
|
855
|
-
"use strict";
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
Object.defineProperty(exports, "__esModule", {
|
|
859
|
-
value: true
|
|
860
|
-
});
|
|
861
|
-
|
|
862
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
863
|
-
|
|
864
|
-
var fetch = function fetch(setOptions) {
|
|
865
|
-
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
866
|
-
|
|
867
|
-
var defaults = {
|
|
868
|
-
url: window.location.pathname + window.location.search,
|
|
869
|
-
method: 'GET',
|
|
870
|
-
data: null,
|
|
871
|
-
headers: {}
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
var options = _extends({}, defaults, setOptions);
|
|
875
|
-
|
|
876
|
-
var request = new XMLHttpRequest();
|
|
877
|
-
|
|
878
|
-
request.onreadystatechange = function () {
|
|
879
|
-
if (request.readyState === 4) {
|
|
880
|
-
if (request.status !== 500) {
|
|
881
|
-
callback(request);
|
|
882
|
-
} else {
|
|
883
|
-
callback(request);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
|
|
888
|
-
request.open(options.method, options.url, true);
|
|
889
|
-
Object.keys(options.headers).forEach(function (key) {
|
|
890
|
-
request.setRequestHeader(key, options.headers[key]);
|
|
891
|
-
});
|
|
892
|
-
request.send(options.data);
|
|
893
|
-
return request;
|
|
894
|
-
};
|
|
895
|
-
|
|
896
|
-
exports.default = fetch;
|
|
897
|
-
|
|
898
|
-
/***/ }),
|
|
899
|
-
/* 11 */
|
|
900
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
901
|
-
|
|
902
|
-
"use strict";
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
Object.defineProperty(exports, "__esModule", {
|
|
906
|
-
value: true
|
|
907
|
-
});
|
|
908
|
-
var transitionEnd = function transitionEnd() {
|
|
909
|
-
if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
|
|
910
|
-
return 'webkitTransitionEnd';
|
|
911
|
-
} else {
|
|
912
|
-
return 'transitionend';
|
|
913
|
-
}
|
|
914
|
-
};
|
|
915
|
-
|
|
916
|
-
exports.default = transitionEnd;
|
|
917
|
-
|
|
918
|
-
/***/ }),
|
|
919
|
-
/* 12 */
|
|
920
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
921
|
-
|
|
922
|
-
"use strict";
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
Object.defineProperty(exports, "__esModule", {
|
|
926
|
-
value: true
|
|
927
|
-
});
|
|
928
|
-
var transitionProperty = function transitionProperty() {
|
|
929
|
-
if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
|
|
930
|
-
return 'WebkitTransition';
|
|
931
|
-
} else {
|
|
932
|
-
return 'transition';
|
|
933
|
-
}
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
exports.default = transitionProperty;
|
|
937
|
-
|
|
938
|
-
/***/ }),
|
|
939
|
-
/* 13 */
|
|
940
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
941
|
-
|
|
942
|
-
"use strict";
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
Object.defineProperty(exports, "__esModule", {
|
|
946
|
-
value: true
|
|
947
|
-
});
|
|
948
|
-
var getCurrentUrl = function getCurrentUrl() {
|
|
949
|
-
return window.location.pathname + window.location.search;
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
exports.default = getCurrentUrl;
|
|
953
|
-
|
|
954
|
-
/***/ }),
|
|
955
|
-
/* 14 */
|
|
956
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
957
|
-
|
|
958
|
-
"use strict";
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
Object.defineProperty(exports, "__esModule", {
|
|
962
|
-
value: true
|
|
963
|
-
});
|
|
964
|
-
|
|
965
|
-
var _Link = __webpack_require__(2);
|
|
966
|
-
|
|
967
|
-
var _Link2 = _interopRequireDefault(_Link);
|
|
968
|
-
|
|
969
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
970
|
-
|
|
971
|
-
var normalizeUrl = function normalizeUrl(url) {
|
|
972
|
-
return new _Link2.default(url).getAddress();
|
|
973
|
-
};
|
|
974
|
-
|
|
975
|
-
exports.default = normalizeUrl;
|
|
976
|
-
|
|
977
|
-
/***/ }),
|
|
978
|
-
/* 15 */
|
|
979
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
980
|
-
|
|
981
|
-
"use strict";
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
Object.defineProperty(exports, "__esModule", {
|
|
985
|
-
value: true
|
|
986
|
-
});
|
|
987
|
-
|
|
988
|
-
var _utils = __webpack_require__(1);
|
|
989
|
-
|
|
990
|
-
var markSwupElements = function markSwupElements(element, containers) {
|
|
991
|
-
var blocks = 0;
|
|
992
|
-
|
|
993
|
-
containers.forEach(function (selector) {
|
|
994
|
-
if ((0, _utils.query)(selector, element) == null) {
|
|
995
|
-
console.error('Container ' + selector + ' not found on page.');
|
|
996
|
-
} else {
|
|
997
|
-
(0, _utils.queryAll)(selector).forEach(function (item, index) {
|
|
998
|
-
(0, _utils.queryAll)(selector, element)[index].setAttribute('data-swup', blocks);
|
|
999
|
-
blocks++;
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
};
|
|
1004
|
-
|
|
1005
|
-
exports.default = markSwupElements;
|
|
1006
|
-
|
|
1007
|
-
/***/ }),
|
|
1008
|
-
/* 16 */
|
|
1009
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1010
|
-
|
|
1011
|
-
"use strict";
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1015
|
-
value: true
|
|
1016
|
-
});
|
|
1017
|
-
var cleanupAnimationClasses = function cleanupAnimationClasses() {
|
|
1018
|
-
document.documentElement.className.split(' ').forEach(function (classItem) {
|
|
1019
|
-
if (
|
|
1020
|
-
// remove "to-{page}" classes
|
|
1021
|
-
new RegExp('^to-').test(classItem) ||
|
|
1022
|
-
// remove all other classes
|
|
1023
|
-
classItem === 'is-changing' || classItem === 'is-rendering' || classItem === 'is-popstate') {
|
|
1024
|
-
document.documentElement.classList.remove(classItem);
|
|
1025
|
-
}
|
|
1026
|
-
});
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
exports.default = cleanupAnimationClasses;
|
|
1030
|
-
|
|
1031
|
-
/***/ }),
|
|
1032
|
-
/* 17 */
|
|
1033
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1034
|
-
|
|
1035
|
-
"use strict";
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1039
|
-
value: true
|
|
1040
|
-
});
|
|
1041
|
-
|
|
1042
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
1043
|
-
|
|
1044
|
-
var _helpers = __webpack_require__(0);
|
|
1045
|
-
|
|
1046
|
-
var loadPage = function loadPage(data, popstate) {
|
|
1047
|
-
var _this = this;
|
|
1048
|
-
|
|
1049
|
-
// create array for storing animation promises
|
|
1050
|
-
var animationPromises = [],
|
|
1051
|
-
xhrPromise = void 0;
|
|
1052
|
-
var animateOut = function animateOut() {
|
|
1053
|
-
_this.triggerEvent('animationOutStart');
|
|
1054
|
-
|
|
1055
|
-
// handle classes
|
|
1056
|
-
document.documentElement.classList.add('is-changing');
|
|
1057
|
-
document.documentElement.classList.add('is-leaving');
|
|
1058
|
-
document.documentElement.classList.add('is-animating');
|
|
1059
|
-
if (popstate) {
|
|
1060
|
-
document.documentElement.classList.add('is-popstate');
|
|
1061
|
-
}
|
|
1062
|
-
document.documentElement.classList.add('to-' + (0, _helpers.classify)(data.url));
|
|
1063
|
-
|
|
1064
|
-
// animation promise stuff
|
|
1065
|
-
animationPromises = _this.getAnimationPromises('out');
|
|
1066
|
-
Promise.all(animationPromises).then(function () {
|
|
1067
|
-
_this.triggerEvent('animationOutDone');
|
|
1068
|
-
});
|
|
1069
|
-
|
|
1070
|
-
// create history record if this is not a popstate call
|
|
1071
|
-
if (!popstate) {
|
|
1072
|
-
// create pop element with or without anchor
|
|
1073
|
-
var state = void 0;
|
|
1074
|
-
if (_this.scrollToElement != null) {
|
|
1075
|
-
state = data.url + _this.scrollToElement;
|
|
1076
|
-
} else {
|
|
1077
|
-
state = data.url;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
(0, _helpers.createHistoryRecord)(state);
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
|
|
1084
|
-
this.triggerEvent('transitionStart', popstate);
|
|
1085
|
-
|
|
1086
|
-
// set transition object
|
|
1087
|
-
if (data.customTransition != null) {
|
|
1088
|
-
this.updateTransition(window.location.pathname, data.url, data.customTransition);
|
|
1089
|
-
document.documentElement.classList.add('to-' + (0, _helpers.classify)(data.customTransition));
|
|
1090
|
-
} else {
|
|
1091
|
-
this.updateTransition(window.location.pathname, data.url);
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
// start/skip animation
|
|
1095
|
-
if (!popstate || this.options.animateHistoryBrowsing) {
|
|
1096
|
-
animateOut();
|
|
1097
|
-
} else {
|
|
1098
|
-
this.triggerEvent('animationSkipped');
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
// start/skip loading of page
|
|
1102
|
-
if (this.cache.exists(data.url)) {
|
|
1103
|
-
xhrPromise = new Promise(function (resolve) {
|
|
1104
|
-
resolve();
|
|
1105
|
-
});
|
|
1106
|
-
this.triggerEvent('pageRetrievedFromCache');
|
|
1107
|
-
} else {
|
|
1108
|
-
if (!this.preloadPromise || this.preloadPromise.route != data.url) {
|
|
1109
|
-
xhrPromise = new Promise(function (resolve, reject) {
|
|
1110
|
-
(0, _helpers.fetch)(_extends({}, data, { headers: _this.options.requestHeaders }), function (response) {
|
|
1111
|
-
if (response.status === 500) {
|
|
1112
|
-
_this.triggerEvent('serverError');
|
|
1113
|
-
reject(data.url);
|
|
1114
|
-
return;
|
|
1115
|
-
} else {
|
|
1116
|
-
// get json data
|
|
1117
|
-
var page = _this.getPageData(response);
|
|
1118
|
-
if (page != null) {
|
|
1119
|
-
page.url = data.url;
|
|
1120
|
-
} else {
|
|
1121
|
-
reject(data.url);
|
|
1122
|
-
return;
|
|
1123
|
-
}
|
|
1124
|
-
// render page
|
|
1125
|
-
_this.cache.cacheUrl(page);
|
|
1126
|
-
_this.triggerEvent('pageLoaded');
|
|
1127
|
-
}
|
|
1128
|
-
resolve();
|
|
1129
|
-
});
|
|
1130
|
-
});
|
|
1131
|
-
} else {
|
|
1132
|
-
xhrPromise = this.preloadPromise;
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
// when everything is ready, handle the outcome
|
|
1137
|
-
Promise.all(animationPromises.concat([xhrPromise])).then(function () {
|
|
1138
|
-
// render page
|
|
1139
|
-
_this.renderPage(_this.cache.getPage(data.url), popstate);
|
|
1140
|
-
_this.preloadPromise = null;
|
|
1141
|
-
}).catch(function (errorUrl) {
|
|
1142
|
-
// rewrite the skipPopStateHandling function to redirect manually when the history.go is processed
|
|
1143
|
-
_this.options.skipPopStateHandling = function () {
|
|
1144
|
-
window.location = errorUrl;
|
|
1145
|
-
return true;
|
|
1146
|
-
};
|
|
1147
|
-
|
|
1148
|
-
// go back to the actual page were still at
|
|
1149
|
-
window.history.go(-1);
|
|
1150
|
-
});
|
|
1151
|
-
};
|
|
1152
|
-
|
|
1153
|
-
exports.default = loadPage;
|
|
1154
|
-
|
|
1155
|
-
/***/ }),
|
|
1156
|
-
/* 18 */
|
|
1157
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1158
|
-
|
|
1159
|
-
"use strict";
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1163
|
-
value: true
|
|
1164
|
-
});
|
|
1165
|
-
|
|
1166
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
1167
|
-
|
|
1168
|
-
var _helpers = __webpack_require__(0);
|
|
1169
|
-
|
|
1170
|
-
var renderPage = function renderPage(page, popstate) {
|
|
1171
|
-
var _this = this;
|
|
1172
|
-
|
|
1173
|
-
document.documentElement.classList.remove('is-leaving');
|
|
1174
|
-
|
|
1175
|
-
var isCurrentPage = this.getCurrentUrl() === page.url;
|
|
1176
|
-
if (!isCurrentPage) return;
|
|
1177
|
-
|
|
1178
|
-
// replace state in case the url was redirected
|
|
1179
|
-
var url = new _helpers.Link(page.responseURL).getPath();
|
|
1180
|
-
if (window.location.pathname !== url) {
|
|
1181
|
-
window.history.replaceState({
|
|
1182
|
-
url: url,
|
|
1183
|
-
random: Math.random(),
|
|
1184
|
-
source: 'swup'
|
|
1185
|
-
}, document.title, url);
|
|
1186
|
-
|
|
1187
|
-
// save new record for redirected url
|
|
1188
|
-
this.cache.cacheUrl(_extends({}, page, { url: url }));
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
// only add for non-popstate transitions
|
|
1192
|
-
if (!popstate || this.options.animateHistoryBrowsing) {
|
|
1193
|
-
document.documentElement.classList.add('is-rendering');
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
this.triggerEvent('willReplaceContent', popstate);
|
|
1197
|
-
// replace blocks
|
|
1198
|
-
for (var i = 0; i < page.blocks.length; i++) {
|
|
1199
|
-
document.body.querySelector('[data-swup="' + i + '"]').outerHTML = page.blocks[i];
|
|
1200
|
-
}
|
|
1201
|
-
// set title
|
|
1202
|
-
document.title = page.title;
|
|
1203
|
-
this.triggerEvent('contentReplaced', popstate);
|
|
1204
|
-
this.triggerEvent('pageView', popstate);
|
|
1205
|
-
|
|
1206
|
-
// empty cache if it's disabled (because pages could be preloaded and stuff)
|
|
1207
|
-
if (!this.options.cache) {
|
|
1208
|
-
this.cache.empty();
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
// start animation IN
|
|
1212
|
-
setTimeout(function () {
|
|
1213
|
-
if (!popstate || _this.options.animateHistoryBrowsing) {
|
|
1214
|
-
_this.triggerEvent('animationInStart');
|
|
1215
|
-
document.documentElement.classList.remove('is-animating');
|
|
1216
|
-
}
|
|
1217
|
-
}, 10);
|
|
1218
|
-
|
|
1219
|
-
// handle end of animation
|
|
1220
|
-
if (!popstate || this.options.animateHistoryBrowsing) {
|
|
1221
|
-
var animationPromises = this.getAnimationPromises('in');
|
|
1222
|
-
Promise.all(animationPromises).then(function () {
|
|
1223
|
-
_this.triggerEvent('animationInDone');
|
|
1224
|
-
_this.triggerEvent('transitionEnd', popstate);
|
|
1225
|
-
_this.cleanupAnimationClasses();
|
|
1226
|
-
});
|
|
1227
|
-
} else {
|
|
1228
|
-
this.triggerEvent('transitionEnd', popstate);
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
// reset scroll-to element
|
|
1232
|
-
this.scrollToElement = null;
|
|
1233
|
-
};
|
|
1234
|
-
|
|
1235
|
-
exports.default = renderPage;
|
|
1236
|
-
|
|
1237
|
-
/***/ }),
|
|
1238
|
-
/* 19 */
|
|
1239
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1240
|
-
|
|
1241
|
-
"use strict";
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1245
|
-
value: true
|
|
1246
|
-
});
|
|
1247
|
-
var triggerEvent = function triggerEvent(eventName, originalEvent) {
|
|
1248
|
-
// call saved handlers with "on" method and pass originalEvent object if available
|
|
1249
|
-
this._handlers[eventName].forEach(function (handler) {
|
|
1250
|
-
try {
|
|
1251
|
-
handler(originalEvent);
|
|
1252
|
-
} catch (error) {
|
|
1253
|
-
console.error(error);
|
|
1254
|
-
}
|
|
1255
|
-
});
|
|
1256
|
-
|
|
1257
|
-
// trigger event on document with prefix "swup:"
|
|
1258
|
-
var event = new CustomEvent('swup:' + eventName, { detail: eventName });
|
|
1259
|
-
document.dispatchEvent(event);
|
|
1260
|
-
};
|
|
1261
|
-
|
|
1262
|
-
exports.default = triggerEvent;
|
|
1263
|
-
|
|
1264
|
-
/***/ }),
|
|
1265
|
-
/* 20 */
|
|
1266
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1267
|
-
|
|
1268
|
-
"use strict";
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1272
|
-
value: true
|
|
1273
|
-
});
|
|
1274
|
-
var on = function on(event, handler) {
|
|
1275
|
-
if (this._handlers[event]) {
|
|
1276
|
-
this._handlers[event].push(handler);
|
|
1277
|
-
} else {
|
|
1278
|
-
console.warn("Unsupported event " + event + ".");
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
|
|
1282
|
-
exports.default = on;
|
|
1283
|
-
|
|
1284
|
-
/***/ }),
|
|
1285
|
-
/* 21 */
|
|
1286
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1287
|
-
|
|
1288
|
-
"use strict";
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1292
|
-
value: true
|
|
1293
|
-
});
|
|
1294
|
-
var off = function off(event, handler) {
|
|
1295
|
-
var _this = this;
|
|
1296
|
-
|
|
1297
|
-
if (event != null) {
|
|
1298
|
-
if (handler != null) {
|
|
1299
|
-
if (this._handlers[event] && this._handlers[event].filter(function (savedHandler) {
|
|
1300
|
-
return savedHandler === handler;
|
|
1301
|
-
}).length) {
|
|
1302
|
-
var toRemove = this._handlers[event].filter(function (savedHandler) {
|
|
1303
|
-
return savedHandler === handler;
|
|
1304
|
-
})[0];
|
|
1305
|
-
var index = this._handlers[event].indexOf(toRemove);
|
|
1306
|
-
if (index > -1) {
|
|
1307
|
-
this._handlers[event].splice(index, 1);
|
|
1308
|
-
}
|
|
1309
|
-
} else {
|
|
1310
|
-
console.warn("Handler for event '" + event + "' no found.");
|
|
1311
|
-
}
|
|
1312
|
-
} else {
|
|
1313
|
-
this._handlers[event] = [];
|
|
1314
|
-
}
|
|
1315
|
-
} else {
|
|
1316
|
-
Object.keys(this._handlers).forEach(function (keys) {
|
|
1317
|
-
_this._handlers[keys] = [];
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
|
-
exports.default = off;
|
|
1323
|
-
|
|
1324
|
-
/***/ }),
|
|
1325
|
-
/* 22 */
|
|
1326
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1327
|
-
|
|
1328
|
-
"use strict";
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1332
|
-
value: true
|
|
1333
|
-
});
|
|
1334
|
-
var updateTransition = function updateTransition(from, to, custom) {
|
|
1335
|
-
// transition routes
|
|
1336
|
-
this.transition = {
|
|
1337
|
-
from: from,
|
|
1338
|
-
to: to,
|
|
1339
|
-
custom: custom
|
|
1340
|
-
};
|
|
1341
|
-
};
|
|
1342
|
-
|
|
1343
|
-
exports.default = updateTransition;
|
|
1344
|
-
|
|
1345
|
-
/***/ }),
|
|
1346
|
-
/* 23 */
|
|
1347
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1348
|
-
|
|
1349
|
-
"use strict";
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1353
|
-
value: true
|
|
1354
|
-
});
|
|
1355
|
-
|
|
1356
|
-
var _utils = __webpack_require__(1);
|
|
1357
|
-
|
|
1358
|
-
var getAnchorElement = function getAnchorElement(hash) {
|
|
1359
|
-
if (!hash) {
|
|
1360
|
-
return null;
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
if (hash.charAt(0) === '#') {
|
|
1364
|
-
hash = hash.substring(1);
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
hash = decodeURIComponent(hash);
|
|
1368
|
-
hash = (0, _utils.escapeCssIdentifier)(hash);
|
|
1369
|
-
|
|
1370
|
-
// https://html.spec.whatwg.org/#find-a-potential-indicated-element
|
|
1371
|
-
return (0, _utils.query)('#' + hash) || (0, _utils.query)('a[name=\'' + hash + '\']');
|
|
1372
|
-
};
|
|
1373
|
-
|
|
1374
|
-
exports.default = getAnchorElement;
|
|
1375
|
-
|
|
1376
|
-
/***/ }),
|
|
1377
|
-
/* 24 */
|
|
1378
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1379
|
-
|
|
1380
|
-
"use strict";
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1384
|
-
value: true
|
|
1385
|
-
});
|
|
1386
|
-
|
|
1387
|
-
var _utils = __webpack_require__(1);
|
|
1388
|
-
|
|
1389
|
-
var _helpers = __webpack_require__(0);
|
|
1390
|
-
|
|
1391
|
-
var getAnimationPromises = function getAnimationPromises() {
|
|
1392
|
-
var _this = this;
|
|
1393
|
-
|
|
1394
|
-
var promises = [];
|
|
1395
|
-
var animatedElements = (0, _utils.queryAll)(this.options.animationSelector, document.body);
|
|
1396
|
-
|
|
1397
|
-
if (!animatedElements.length) {
|
|
1398
|
-
console.error('No animated elements found by selector ' + this.options.animationSelector);
|
|
1399
|
-
return [Promise.resolve()];
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
animatedElements.forEach(function (element) {
|
|
1403
|
-
var transitionDuration = window.getComputedStyle(element)[(0, _helpers.transitionProperty)() + 'Duration'];
|
|
1404
|
-
// Resolve immediately if no transition defined
|
|
1405
|
-
if (!transitionDuration || transitionDuration == '0s') {
|
|
1406
|
-
console.error('No CSS transition duration defined for element of selector ' + _this.options.animationSelector);
|
|
1407
|
-
promises.push(Promise.resolve());
|
|
1408
|
-
return;
|
|
1409
|
-
}
|
|
1410
|
-
var promise = new Promise(function (resolve) {
|
|
1411
|
-
element.addEventListener((0, _helpers.transitionEnd)(), function (event) {
|
|
1412
|
-
if (element == event.target) {
|
|
1413
|
-
resolve();
|
|
1414
|
-
}
|
|
1415
|
-
});
|
|
1416
|
-
});
|
|
1417
|
-
promises.push(promise);
|
|
1418
|
-
});
|
|
1419
|
-
|
|
1420
|
-
return promises;
|
|
1421
|
-
};
|
|
1422
|
-
|
|
1423
|
-
exports.default = getAnimationPromises;
|
|
1424
|
-
|
|
1425
|
-
/***/ }),
|
|
1426
|
-
/* 25 */
|
|
1427
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1428
|
-
|
|
1429
|
-
"use strict";
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1433
|
-
value: true
|
|
1434
|
-
});
|
|
1435
|
-
|
|
1436
|
-
var _helpers = __webpack_require__(0);
|
|
1437
|
-
|
|
1438
|
-
var getPageData = function getPageData(request) {
|
|
1439
|
-
// this method can be replaced in case other content than html is expected to be received from server
|
|
1440
|
-
// this function should always return {title, pageClass, originalContent, blocks, responseURL}
|
|
1441
|
-
// in case page has invalid structure - return null
|
|
1442
|
-
var html = request.responseText;
|
|
1443
|
-
var pageObject = (0, _helpers.getDataFromHtml)(html, this.options.containers);
|
|
1444
|
-
|
|
1445
|
-
if (pageObject) {
|
|
1446
|
-
pageObject.responseURL = request.responseURL ? request.responseURL : window.location.href;
|
|
1447
|
-
} else {
|
|
1448
|
-
console.warn('Received page is invalid.');
|
|
1449
|
-
return null;
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
return pageObject;
|
|
1453
|
-
};
|
|
1454
|
-
|
|
1455
|
-
exports.default = getPageData;
|
|
1456
|
-
|
|
1457
|
-
/***/ }),
|
|
1458
|
-
/* 26 */
|
|
1459
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
1460
|
-
|
|
1461
|
-
"use strict";
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1465
|
-
value: true
|
|
1466
|
-
});
|
|
1467
|
-
var use = exports.use = function use(plugin) {
|
|
1468
|
-
if (!plugin.isSwupPlugin) {
|
|
1469
|
-
console.warn('Not swup plugin instance ' + plugin + '.');
|
|
1470
|
-
return;
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
this.plugins.push(plugin);
|
|
1474
|
-
plugin.swup = this;
|
|
1475
|
-
if (typeof plugin._beforeMount === 'function') {
|
|
1476
|
-
plugin._beforeMount();
|
|
1477
|
-
}
|
|
1478
|
-
plugin.mount();
|
|
1479
|
-
|
|
1480
|
-
return this.plugins;
|
|
1481
|
-
};
|
|
1482
|
-
|
|
1483
|
-
var unuse = exports.unuse = function unuse(plugin) {
|
|
1484
|
-
var pluginReference = void 0;
|
|
1485
|
-
|
|
1486
|
-
if (typeof plugin === 'string') {
|
|
1487
|
-
pluginReference = this.plugins.find(function (p) {
|
|
1488
|
-
return plugin === p.name;
|
|
1489
|
-
});
|
|
1490
|
-
} else {
|
|
1491
|
-
pluginReference = plugin;
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
if (!pluginReference) {
|
|
1495
|
-
console.warn('No such plugin.');
|
|
1496
|
-
return;
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
pluginReference.unmount();
|
|
1500
|
-
|
|
1501
|
-
if (typeof pluginReference._afterUnmount === 'function') {
|
|
1502
|
-
pluginReference._afterUnmount();
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
var index = this.plugins.indexOf(pluginReference);
|
|
1506
|
-
this.plugins.splice(index, 1);
|
|
1507
|
-
|
|
1508
|
-
return this.plugins;
|
|
1509
|
-
};
|
|
1510
|
-
|
|
1511
|
-
var findPlugin = exports.findPlugin = function findPlugin(pluginName) {
|
|
1512
|
-
return this.plugins.find(function (p) {
|
|
1513
|
-
return pluginName === p.name;
|
|
1514
|
-
});
|
|
1515
|
-
};
|
|
1516
|
-
|
|
1517
|
-
/***/ })
|
|
1518
|
-
/******/ ]);
|
|
1519
|
-
});
|