UNPKG

475 kBJavaScriptView Raw
1/**
2 * Framework7 6.1.0-beta.6
3 * Full featured mobile HTML framework for building iOS & Android apps
4 * https://framework7.io/
5 *
6 * Copyright 2014-2021 Vladimir Kharlampidi
7 *
8 * Released under the MIT License
9 *
10 * Released on: July 19, 2021
11 */
12
13(function (global, factory) {
14 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
15 typeof define === 'function' && define.amd ? define(factory) :
16 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Framework7 = factory());
17}(this, (function () { 'use strict';
18
19 /**
20 * SSR Window 3.0.0
21 * Better handling for window object in SSR environment
22 * https://github.com/nolimits4web/ssr-window
23 *
24 * Copyright 2020, Vladimir Kharlampidi
25 *
26 * Licensed under MIT
27 *
28 * Released on: November 9, 2020
29 */
30
31 /* eslint-disable no-param-reassign */
32 function isObject$1(obj) {
33 return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object;
34 }
35
36 function extend$1(target, src) {
37 if (target === void 0) {
38 target = {};
39 }
40
41 if (src === void 0) {
42 src = {};
43 }
44
45 Object.keys(src).forEach(function (key) {
46 if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject$1(src[key]) && isObject$1(target[key]) && Object.keys(src[key]).length > 0) {
47 extend$1(target[key], src[key]);
48 }
49 });
50 }
51
52 var ssrDocument = {
53 body: {},
54 addEventListener: function addEventListener() {},
55 removeEventListener: function removeEventListener() {},
56 activeElement: {
57 blur: function blur() {},
58 nodeName: ''
59 },
60 querySelector: function querySelector() {
61 return null;
62 },
63 querySelectorAll: function querySelectorAll() {
64 return [];
65 },
66 getElementById: function getElementById() {
67 return null;
68 },
69 createEvent: function createEvent() {
70 return {
71 initEvent: function initEvent() {}
72 };
73 },
74 createElement: function createElement() {
75 return {
76 children: [],
77 childNodes: [],
78 style: {},
79 setAttribute: function setAttribute() {},
80 getElementsByTagName: function getElementsByTagName() {
81 return [];
82 }
83 };
84 },
85 createElementNS: function createElementNS() {
86 return {};
87 },
88 importNode: function importNode() {
89 return null;
90 },
91 location: {
92 hash: '',
93 host: '',
94 hostname: '',
95 href: '',
96 origin: '',
97 pathname: '',
98 protocol: '',
99 search: ''
100 }
101 };
102
103 function getDocument() {
104 var doc = typeof document !== 'undefined' ? document : {};
105 extend$1(doc, ssrDocument);
106 return doc;
107 }
108
109 var ssrWindow = {
110 document: ssrDocument,
111 navigator: {
112 userAgent: ''
113 },
114 location: {
115 hash: '',
116 host: '',
117 hostname: '',
118 href: '',
119 origin: '',
120 pathname: '',
121 protocol: '',
122 search: ''
123 },
124 history: {
125 replaceState: function replaceState() {},
126 pushState: function pushState() {},
127 go: function go() {},
128 back: function back() {}
129 },
130 CustomEvent: function CustomEvent() {
131 return this;
132 },
133 addEventListener: function addEventListener() {},
134 removeEventListener: function removeEventListener() {},
135 getComputedStyle: function getComputedStyle() {
136 return {
137 getPropertyValue: function getPropertyValue() {
138 return '';
139 }
140 };
141 },
142 Image: function Image() {},
143 Date: function Date() {},
144 screen: {},
145 setTimeout: function setTimeout() {},
146 clearTimeout: function clearTimeout() {},
147 matchMedia: function matchMedia() {
148 return {};
149 },
150 requestAnimationFrame: function requestAnimationFrame(callback) {
151 if (typeof setTimeout === 'undefined') {
152 callback();
153 return null;
154 }
155
156 return setTimeout(callback, 0);
157 },
158 cancelAnimationFrame: function cancelAnimationFrame(id) {
159 if (typeof setTimeout === 'undefined') {
160 return;
161 }
162
163 clearTimeout(id);
164 }
165 };
166
167 function getWindow() {
168 var win = typeof window !== 'undefined' ? window : {};
169 extend$1(win, ssrWindow);
170 return win;
171 }
172
173 /**
174 * Dom7 3.0.0
175 * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
176 * https://framework7.io/docs/dom7.html
177 *
178 * Copyright 2020, Vladimir Kharlampidi
179 *
180 * Licensed under MIT
181 *
182 * Released on: November 9, 2020
183 */
184
185 function _inheritsLoose$1(subClass, superClass) {
186 subClass.prototype = Object.create(superClass.prototype);
187 subClass.prototype.constructor = subClass;
188 subClass.__proto__ = superClass;
189 }
190
191 function _getPrototypeOf$1(o) {
192 _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
193 return o.__proto__ || Object.getPrototypeOf(o);
194 };
195 return _getPrototypeOf$1(o);
196 }
197
198 function _setPrototypeOf$1(o, p) {
199 _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
200 o.__proto__ = p;
201 return o;
202 };
203
204 return _setPrototypeOf$1(o, p);
205 }
206
207 function _isNativeReflectConstruct$1() {
208 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
209 if (Reflect.construct.sham) return false;
210 if (typeof Proxy === "function") return true;
211
212 try {
213 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
214 return true;
215 } catch (e) {
216 return false;
217 }
218 }
219
220 function _construct$1(Parent, args, Class) {
221 if (_isNativeReflectConstruct$1()) {
222 _construct$1 = Reflect.construct;
223 } else {
224 _construct$1 = function _construct(Parent, args, Class) {
225 var a = [null];
226 a.push.apply(a, args);
227 var Constructor = Function.bind.apply(Parent, a);
228 var instance = new Constructor();
229 if (Class) _setPrototypeOf$1(instance, Class.prototype);
230 return instance;
231 };
232 }
233
234 return _construct$1.apply(null, arguments);
235 }
236
237 function _isNativeFunction$1(fn) {
238 return Function.toString.call(fn).indexOf("[native code]") !== -1;
239 }
240
241 function _wrapNativeSuper$1(Class) {
242 var _cache = typeof Map === "function" ? new Map() : undefined;
243
244 _wrapNativeSuper$1 = function _wrapNativeSuper(Class) {
245 if (Class === null || !_isNativeFunction$1(Class)) return Class;
246
247 if (typeof Class !== "function") {
248 throw new TypeError("Super expression must either be null or a function");
249 }
250
251 if (typeof _cache !== "undefined") {
252 if (_cache.has(Class)) return _cache.get(Class);
253
254 _cache.set(Class, Wrapper);
255 }
256
257 function Wrapper() {
258 return _construct$1(Class, arguments, _getPrototypeOf$1(this).constructor);
259 }
260
261 Wrapper.prototype = Object.create(Class.prototype, {
262 constructor: {
263 value: Wrapper,
264 enumerable: false,
265 writable: true,
266 configurable: true
267 }
268 });
269 return _setPrototypeOf$1(Wrapper, Class);
270 };
271
272 return _wrapNativeSuper$1(Class);
273 }
274
275 function _assertThisInitialized$1(self) {
276 if (self === void 0) {
277 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
278 }
279
280 return self;
281 }
282 /* eslint-disable no-proto */
283
284
285 function makeReactive(obj) {
286 var proto = obj.__proto__;
287 Object.defineProperty(obj, '__proto__', {
288 get: function get() {
289 return proto;
290 },
291 set: function set(value) {
292 proto.__proto__ = value;
293 }
294 });
295 }
296
297 var Dom7 = /*#__PURE__*/function (_Array) {
298 _inheritsLoose$1(Dom7, _Array);
299
300 function Dom7(items) {
301 var _this;
302
303 _this = _Array.call.apply(_Array, [this].concat(items)) || this;
304 makeReactive(_assertThisInitialized$1(_this));
305 return _this;
306 }
307
308 return Dom7;
309 }( /*#__PURE__*/_wrapNativeSuper$1(Array));
310
311 function arrayFlat(arr) {
312 if (arr === void 0) {
313 arr = [];
314 }
315
316 var res = [];
317 arr.forEach(function (el) {
318 if (Array.isArray(el)) {
319 res.push.apply(res, arrayFlat(el));
320 } else {
321 res.push(el);
322 }
323 });
324 return res;
325 }
326
327 function arrayFilter(arr, callback) {
328 return Array.prototype.filter.call(arr, callback);
329 }
330
331 function arrayUnique(arr) {
332 var uniqueArray = [];
333
334 for (var i = 0; i < arr.length; i += 1) {
335 if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);
336 }
337
338 return uniqueArray;
339 }
340
341 function toCamelCase$1(string) {
342 return string.toLowerCase().replace(/-(.)/g, function (match, group) {
343 return group.toUpperCase();
344 });
345 }
346
347 function qsa(selector, context) {
348 if (typeof selector !== 'string') {
349 return [selector];
350 }
351
352 var a = [];
353 var res = context.querySelectorAll(selector);
354
355 for (var i = 0; i < res.length; i += 1) {
356 a.push(res[i]);
357 }
358
359 return a;
360 }
361
362 function $$1(selector, context) {
363 var window = getWindow();
364 var document = getDocument();
365 var arr = [];
366
367 if (!context && selector instanceof Dom7) {
368 return selector;
369 }
370
371 if (!selector) {
372 return new Dom7(arr);
373 }
374
375 if (typeof selector === 'string') {
376 var html = selector.trim();
377
378 if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
379 var toCreate = 'div';
380 if (html.indexOf('<li') === 0) toCreate = 'ul';
381 if (html.indexOf('<tr') === 0) toCreate = 'tbody';
382 if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
383 if (html.indexOf('<tbody') === 0) toCreate = 'table';
384 if (html.indexOf('<option') === 0) toCreate = 'select';
385 var tempParent = document.createElement(toCreate);
386 tempParent.innerHTML = html;
387
388 for (var i = 0; i < tempParent.childNodes.length; i += 1) {
389 arr.push(tempParent.childNodes[i]);
390 }
391 } else {
392 arr = qsa(selector.trim(), context || document);
393 } // arr = qsa(selector, document);
394
395 } else if (selector.nodeType || selector === window || selector === document) {
396 arr.push(selector);
397 } else if (Array.isArray(selector)) {
398 if (selector instanceof Dom7) return selector;
399 arr = selector;
400 }
401
402 return new Dom7(arrayUnique(arr));
403 }
404
405 $$1.fn = Dom7.prototype;
406
407 function addClass() {
408 for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) {
409 classes[_key] = arguments[_key];
410 }
411
412 var classNames = arrayFlat(classes.map(function (c) {
413 return c.split(' ');
414 }));
415 this.forEach(function (el) {
416 var _el$classList;
417
418 (_el$classList = el.classList).add.apply(_el$classList, classNames);
419 });
420 return this;
421 }
422
423 function removeClass() {
424 for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
425 classes[_key2] = arguments[_key2];
426 }
427
428 var classNames = arrayFlat(classes.map(function (c) {
429 return c.split(' ');
430 }));
431 this.forEach(function (el) {
432 var _el$classList2;
433
434 (_el$classList2 = el.classList).remove.apply(_el$classList2, classNames);
435 });
436 return this;
437 }
438
439 function toggleClass() {
440 for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
441 classes[_key3] = arguments[_key3];
442 }
443
444 var classNames = arrayFlat(classes.map(function (c) {
445 return c.split(' ');
446 }));
447 this.forEach(function (el) {
448 classNames.forEach(function (className) {
449 el.classList.toggle(className);
450 });
451 });
452 }
453
454 function hasClass() {
455 for (var _len4 = arguments.length, classes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
456 classes[_key4] = arguments[_key4];
457 }
458
459 var classNames = arrayFlat(classes.map(function (c) {
460 return c.split(' ');
461 }));
462 return arrayFilter(this, function (el) {
463 return classNames.filter(function (className) {
464 return el.classList.contains(className);
465 }).length > 0;
466 }).length > 0;
467 }
468
469 function attr(attrs, value) {
470 if (arguments.length === 1 && typeof attrs === 'string') {
471 // Get attr
472 if (this[0]) return this[0].getAttribute(attrs);
473 return undefined;
474 } // Set attrs
475
476
477 for (var i = 0; i < this.length; i += 1) {
478 if (arguments.length === 2) {
479 // String
480 this[i].setAttribute(attrs, value);
481 } else {
482 // Object
483 for (var attrName in attrs) {
484 this[i][attrName] = attrs[attrName];
485 this[i].setAttribute(attrName, attrs[attrName]);
486 }
487 }
488 }
489
490 return this;
491 }
492
493 function removeAttr(attr) {
494 for (var i = 0; i < this.length; i += 1) {
495 this[i].removeAttribute(attr);
496 }
497
498 return this;
499 }
500
501 function prop(props, value) {
502 if (arguments.length === 1 && typeof props === 'string') {
503 // Get prop
504 if (this[0]) return this[0][props];
505 } else {
506 // Set props
507 for (var i = 0; i < this.length; i += 1) {
508 if (arguments.length === 2) {
509 // String
510 this[i][props] = value;
511 } else {
512 // Object
513 for (var propName in props) {
514 this[i][propName] = props[propName];
515 }
516 }
517 }
518
519 return this;
520 }
521
522 return this;
523 }
524
525 function data(key, value) {
526 var el;
527
528 if (typeof value === 'undefined') {
529 el = this[0];
530 if (!el) return undefined; // Get value
531
532 if (el.dom7ElementDataStorage && key in el.dom7ElementDataStorage) {
533 return el.dom7ElementDataStorage[key];
534 }
535
536 var dataKey = el.getAttribute("data-" + key);
537
538 if (dataKey) {
539 return dataKey;
540 }
541
542 return undefined;
543 } // Set value
544
545
546 for (var i = 0; i < this.length; i += 1) {
547 el = this[i];
548 if (!el.dom7ElementDataStorage) el.dom7ElementDataStorage = {};
549 el.dom7ElementDataStorage[key] = value;
550 }
551
552 return this;
553 }
554
555 function removeData(key) {
556 for (var i = 0; i < this.length; i += 1) {
557 var el = this[i];
558
559 if (el.dom7ElementDataStorage && el.dom7ElementDataStorage[key]) {
560 el.dom7ElementDataStorage[key] = null;
561 delete el.dom7ElementDataStorage[key];
562 }
563 }
564 }
565
566 function dataset() {
567 var el = this[0];
568 if (!el) return undefined;
569 var dataset = {}; // eslint-disable-line
570
571 if (el.dataset) {
572 for (var dataKey in el.dataset) {
573 dataset[dataKey] = el.dataset[dataKey];
574 }
575 } else {
576 for (var i = 0; i < el.attributes.length; i += 1) {
577 var _attr = el.attributes[i];
578
579 if (_attr.name.indexOf('data-') >= 0) {
580 dataset[toCamelCase$1(_attr.name.split('data-')[1])] = _attr.value;
581 }
582 }
583 }
584
585 for (var key in dataset) {
586 if (dataset[key] === 'false') dataset[key] = false;else if (dataset[key] === 'true') dataset[key] = true;else if (parseFloat(dataset[key]) === dataset[key] * 1) dataset[key] *= 1;
587 }
588
589 return dataset;
590 }
591
592 function val(value) {
593 if (typeof value === 'undefined') {
594 // get value
595 var el = this[0];
596 if (!el) return undefined;
597
598 if (el.multiple && el.nodeName.toLowerCase() === 'select') {
599 var values = [];
600
601 for (var i = 0; i < el.selectedOptions.length; i += 1) {
602 values.push(el.selectedOptions[i].value);
603 }
604
605 return values;
606 }
607
608 return el.value;
609 } // set value
610
611
612 for (var _i = 0; _i < this.length; _i += 1) {
613 var _el = this[_i];
614
615 if (Array.isArray(value) && _el.multiple && _el.nodeName.toLowerCase() === 'select') {
616 for (var j = 0; j < _el.options.length; j += 1) {
617 _el.options[j].selected = value.indexOf(_el.options[j].value) >= 0;
618 }
619 } else {
620 _el.value = value;
621 }
622 }
623
624 return this;
625 }
626
627 function value(value) {
628 return this.val(value);
629 }
630
631 function transform(transform) {
632 for (var i = 0; i < this.length; i += 1) {
633 this[i].style.transform = transform;
634 }
635
636 return this;
637 }
638
639 function transition(duration) {
640 for (var i = 0; i < this.length; i += 1) {
641 this[i].style.transitionDuration = typeof duration !== 'string' ? duration + "ms" : duration;
642 }
643
644 return this;
645 }
646
647 function on() {
648 for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
649 args[_key5] = arguments[_key5];
650 }
651
652 var eventType = args[0],
653 targetSelector = args[1],
654 listener = args[2],
655 capture = args[3];
656
657 if (typeof args[1] === 'function') {
658 eventType = args[0];
659 listener = args[1];
660 capture = args[2];
661 targetSelector = undefined;
662 }
663
664 if (!capture) capture = false;
665
666 function handleLiveEvent(e) {
667 var target = e.target;
668 if (!target) return;
669 var eventData = e.target.dom7EventData || [];
670
671 if (eventData.indexOf(e) < 0) {
672 eventData.unshift(e);
673 }
674
675 if ($$1(target).is(targetSelector)) listener.apply(target, eventData);else {
676 var _parents = $$1(target).parents(); // eslint-disable-line
677
678
679 for (var k = 0; k < _parents.length; k += 1) {
680 if ($$1(_parents[k]).is(targetSelector)) listener.apply(_parents[k], eventData);
681 }
682 }
683 }
684
685 function handleEvent(e) {
686 var eventData = e && e.target ? e.target.dom7EventData || [] : [];
687
688 if (eventData.indexOf(e) < 0) {
689 eventData.unshift(e);
690 }
691
692 listener.apply(this, eventData);
693 }
694
695 var events = eventType.split(' ');
696 var j;
697
698 for (var i = 0; i < this.length; i += 1) {
699 var el = this[i];
700
701 if (!targetSelector) {
702 for (j = 0; j < events.length; j += 1) {
703 var event = events[j];
704 if (!el.dom7Listeners) el.dom7Listeners = {};
705 if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];
706 el.dom7Listeners[event].push({
707 listener: listener,
708 proxyListener: handleEvent
709 });
710 el.addEventListener(event, handleEvent, capture);
711 }
712 } else {
713 // Live events
714 for (j = 0; j < events.length; j += 1) {
715 var _event = events[j];
716 if (!el.dom7LiveListeners) el.dom7LiveListeners = {};
717 if (!el.dom7LiveListeners[_event]) el.dom7LiveListeners[_event] = [];
718
719 el.dom7LiveListeners[_event].push({
720 listener: listener,
721 proxyListener: handleLiveEvent
722 });
723
724 el.addEventListener(_event, handleLiveEvent, capture);
725 }
726 }
727 }
728
729 return this;
730 }
731
732 function off() {
733 for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
734 args[_key6] = arguments[_key6];
735 }
736
737 var eventType = args[0],
738 targetSelector = args[1],
739 listener = args[2],
740 capture = args[3];
741
742 if (typeof args[1] === 'function') {
743 eventType = args[0];
744 listener = args[1];
745 capture = args[2];
746 targetSelector = undefined;
747 }
748
749 if (!capture) capture = false;
750 var events = eventType.split(' ');
751
752 for (var i = 0; i < events.length; i += 1) {
753 var event = events[i];
754
755 for (var j = 0; j < this.length; j += 1) {
756 var el = this[j];
757 var handlers = void 0;
758
759 if (!targetSelector && el.dom7Listeners) {
760 handlers = el.dom7Listeners[event];
761 } else if (targetSelector && el.dom7LiveListeners) {
762 handlers = el.dom7LiveListeners[event];
763 }
764
765 if (handlers && handlers.length) {
766 for (var k = handlers.length - 1; k >= 0; k -= 1) {
767 var handler = handlers[k];
768
769 if (listener && handler.listener === listener) {
770 el.removeEventListener(event, handler.proxyListener, capture);
771 handlers.splice(k, 1);
772 } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {
773 el.removeEventListener(event, handler.proxyListener, capture);
774 handlers.splice(k, 1);
775 } else if (!listener) {
776 el.removeEventListener(event, handler.proxyListener, capture);
777 handlers.splice(k, 1);
778 }
779 }
780 }
781 }
782 }
783
784 return this;
785 }
786
787 function once() {
788 var dom = this;
789
790 for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
791 args[_key7] = arguments[_key7];
792 }
793
794 var eventName = args[0],
795 targetSelector = args[1],
796 listener = args[2],
797 capture = args[3];
798
799 if (typeof args[1] === 'function') {
800 eventName = args[0];
801 listener = args[1];
802 capture = args[2];
803 targetSelector = undefined;
804 }
805
806 function onceHandler() {
807 for (var _len8 = arguments.length, eventArgs = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
808 eventArgs[_key8] = arguments[_key8];
809 }
810
811 listener.apply(this, eventArgs);
812 dom.off(eventName, targetSelector, onceHandler, capture);
813
814 if (onceHandler.dom7proxy) {
815 delete onceHandler.dom7proxy;
816 }
817 }
818
819 onceHandler.dom7proxy = listener;
820 return dom.on(eventName, targetSelector, onceHandler, capture);
821 }
822
823 function trigger() {
824 var window = getWindow();
825
826 for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
827 args[_key9] = arguments[_key9];
828 }
829
830 var events = args[0].split(' ');
831 var eventData = args[1];
832
833 for (var i = 0; i < events.length; i += 1) {
834 var event = events[i];
835
836 for (var j = 0; j < this.length; j += 1) {
837 var el = this[j];
838
839 if (window.CustomEvent) {
840 var evt = new window.CustomEvent(event, {
841 detail: eventData,
842 bubbles: true,
843 cancelable: true
844 });
845 el.dom7EventData = args.filter(function (data, dataIndex) {
846 return dataIndex > 0;
847 });
848 el.dispatchEvent(evt);
849 el.dom7EventData = [];
850 delete el.dom7EventData;
851 }
852 }
853 }
854
855 return this;
856 }
857
858 function transitionEnd(callback) {
859 var dom = this;
860
861 function fireCallBack(e) {
862 if (e.target !== this) return;
863 callback.call(this, e);
864 dom.off('transitionend', fireCallBack);
865 }
866
867 if (callback) {
868 dom.on('transitionend', fireCallBack);
869 }
870
871 return this;
872 }
873
874 function animationEnd(callback) {
875 var dom = this;
876
877 function fireCallBack(e) {
878 if (e.target !== this) return;
879 callback.call(this, e);
880 dom.off('animationend', fireCallBack);
881 }
882
883 if (callback) {
884 dom.on('animationend', fireCallBack);
885 }
886
887 return this;
888 }
889
890 function width() {
891 var window = getWindow();
892
893 if (this[0] === window) {
894 return window.innerWidth;
895 }
896
897 if (this.length > 0) {
898 return parseFloat(this.css('width'));
899 }
900
901 return null;
902 }
903
904 function outerWidth(includeMargins) {
905 if (this.length > 0) {
906 if (includeMargins) {
907 var _styles = this.styles();
908
909 return this[0].offsetWidth + parseFloat(_styles.getPropertyValue('margin-right')) + parseFloat(_styles.getPropertyValue('margin-left'));
910 }
911
912 return this[0].offsetWidth;
913 }
914
915 return null;
916 }
917
918 function height() {
919 var window = getWindow();
920
921 if (this[0] === window) {
922 return window.innerHeight;
923 }
924
925 if (this.length > 0) {
926 return parseFloat(this.css('height'));
927 }
928
929 return null;
930 }
931
932 function outerHeight(includeMargins) {
933 if (this.length > 0) {
934 if (includeMargins) {
935 var _styles2 = this.styles();
936
937 return this[0].offsetHeight + parseFloat(_styles2.getPropertyValue('margin-top')) + parseFloat(_styles2.getPropertyValue('margin-bottom'));
938 }
939
940 return this[0].offsetHeight;
941 }
942
943 return null;
944 }
945
946 function offset() {
947 if (this.length > 0) {
948 var window = getWindow();
949 var document = getDocument();
950 var el = this[0];
951 var box = el.getBoundingClientRect();
952 var body = document.body;
953 var clientTop = el.clientTop || body.clientTop || 0;
954 var clientLeft = el.clientLeft || body.clientLeft || 0;
955 var scrollTop = el === window ? window.scrollY : el.scrollTop;
956 var scrollLeft = el === window ? window.scrollX : el.scrollLeft;
957 return {
958 top: box.top + scrollTop - clientTop,
959 left: box.left + scrollLeft - clientLeft
960 };
961 }
962
963 return null;
964 }
965
966 function hide() {
967 for (var i = 0; i < this.length; i += 1) {
968 this[i].style.display = 'none';
969 }
970
971 return this;
972 }
973
974 function show() {
975 var window = getWindow();
976
977 for (var i = 0; i < this.length; i += 1) {
978 var el = this[i];
979
980 if (el.style.display === 'none') {
981 el.style.display = '';
982 }
983
984 if (window.getComputedStyle(el, null).getPropertyValue('display') === 'none') {
985 // Still not visible
986 el.style.display = 'block';
987 }
988 }
989
990 return this;
991 }
992
993 function styles() {
994 var window = getWindow();
995 if (this[0]) return window.getComputedStyle(this[0], null);
996 return {};
997 }
998
999 function css(props, value) {
1000 var window = getWindow();
1001 var i;
1002
1003 if (arguments.length === 1) {
1004 if (typeof props === 'string') {
1005 // .css('width')
1006 if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);
1007 } else {
1008 // .css({ width: '100px' })
1009 for (i = 0; i < this.length; i += 1) {
1010 for (var _prop in props) {
1011 this[i].style[_prop] = props[_prop];
1012 }
1013 }
1014
1015 return this;
1016 }
1017 }
1018
1019 if (arguments.length === 2 && typeof props === 'string') {
1020 // .css('width', '100px')
1021 for (i = 0; i < this.length; i += 1) {
1022 this[i].style[props] = value;
1023 }
1024
1025 return this;
1026 }
1027
1028 return this;
1029 }
1030
1031 function each(callback) {
1032 if (!callback) return this;
1033 this.forEach(function (el, index) {
1034 callback.apply(el, [el, index]);
1035 });
1036 return this;
1037 }
1038
1039 function filter(callback) {
1040 var result = arrayFilter(this, callback);
1041 return $$1(result);
1042 }
1043
1044 function html(html) {
1045 if (typeof html === 'undefined') {
1046 return this[0] ? this[0].innerHTML : null;
1047 }
1048
1049 for (var i = 0; i < this.length; i += 1) {
1050 this[i].innerHTML = html;
1051 }
1052
1053 return this;
1054 }
1055
1056 function text(text) {
1057 if (typeof text === 'undefined') {
1058 return this[0] ? this[0].textContent.trim() : null;
1059 }
1060
1061 for (var i = 0; i < this.length; i += 1) {
1062 this[i].textContent = text;
1063 }
1064
1065 return this;
1066 }
1067
1068 function is(selector) {
1069 var window = getWindow();
1070 var document = getDocument();
1071 var el = this[0];
1072 var compareWith;
1073 var i;
1074 if (!el || typeof selector === 'undefined') return false;
1075
1076 if (typeof selector === 'string') {
1077 if (el.matches) return el.matches(selector);
1078 if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
1079 if (el.msMatchesSelector) return el.msMatchesSelector(selector);
1080 compareWith = $$1(selector);
1081
1082 for (i = 0; i < compareWith.length; i += 1) {
1083 if (compareWith[i] === el) return true;
1084 }
1085
1086 return false;
1087 }
1088
1089 if (selector === document) {
1090 return el === document;
1091 }
1092
1093 if (selector === window) {
1094 return el === window;
1095 }
1096
1097 if (selector.nodeType || selector instanceof Dom7) {
1098 compareWith = selector.nodeType ? [selector] : selector;
1099
1100 for (i = 0; i < compareWith.length; i += 1) {
1101 if (compareWith[i] === el) return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 return false;
1108 }
1109
1110 function index() {
1111 var child = this[0];
1112 var i;
1113
1114 if (child) {
1115 i = 0; // eslint-disable-next-line
1116
1117 while ((child = child.previousSibling) !== null) {
1118 if (child.nodeType === 1) i += 1;
1119 }
1120
1121 return i;
1122 }
1123
1124 return undefined;
1125 }
1126
1127 function eq(index) {
1128 if (typeof index === 'undefined') return this;
1129 var length = this.length;
1130
1131 if (index > length - 1) {
1132 return $$1([]);
1133 }
1134
1135 if (index < 0) {
1136 var returnIndex = length + index;
1137 if (returnIndex < 0) return $$1([]);
1138 return $$1([this[returnIndex]]);
1139 }
1140
1141 return $$1([this[index]]);
1142 }
1143
1144 function append() {
1145 var newChild;
1146 var document = getDocument();
1147
1148 for (var k = 0; k < arguments.length; k += 1) {
1149 newChild = k < 0 || arguments.length <= k ? undefined : arguments[k];
1150
1151 for (var i = 0; i < this.length; i += 1) {
1152 if (typeof newChild === 'string') {
1153 var tempDiv = document.createElement('div');
1154 tempDiv.innerHTML = newChild;
1155
1156 while (tempDiv.firstChild) {
1157 this[i].appendChild(tempDiv.firstChild);
1158 }
1159 } else if (newChild instanceof Dom7) {
1160 for (var j = 0; j < newChild.length; j += 1) {
1161 this[i].appendChild(newChild[j]);
1162 }
1163 } else {
1164 this[i].appendChild(newChild);
1165 }
1166 }
1167 }
1168
1169 return this;
1170 }
1171
1172 function appendTo(parent) {
1173 $$1(parent).append(this);
1174 return this;
1175 }
1176
1177 function prepend(newChild) {
1178 var document = getDocument();
1179 var i;
1180 var j;
1181
1182 for (i = 0; i < this.length; i += 1) {
1183 if (typeof newChild === 'string') {
1184 var tempDiv = document.createElement('div');
1185 tempDiv.innerHTML = newChild;
1186
1187 for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {
1188 this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);
1189 }
1190 } else if (newChild instanceof Dom7) {
1191 for (j = 0; j < newChild.length; j += 1) {
1192 this[i].insertBefore(newChild[j], this[i].childNodes[0]);
1193 }
1194 } else {
1195 this[i].insertBefore(newChild, this[i].childNodes[0]);
1196 }
1197 }
1198
1199 return this;
1200 }
1201
1202 function prependTo(parent) {
1203 $$1(parent).prepend(this);
1204 return this;
1205 }
1206
1207 function insertBefore$1(selector) {
1208 var before = $$1(selector);
1209
1210 for (var i = 0; i < this.length; i += 1) {
1211 if (before.length === 1) {
1212 before[0].parentNode.insertBefore(this[i], before[0]);
1213 } else if (before.length > 1) {
1214 for (var j = 0; j < before.length; j += 1) {
1215 before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]);
1216 }
1217 }
1218 }
1219 }
1220
1221 function insertAfter(selector) {
1222 var after = $$1(selector);
1223
1224 for (var i = 0; i < this.length; i += 1) {
1225 if (after.length === 1) {
1226 after[0].parentNode.insertBefore(this[i], after[0].nextSibling);
1227 } else if (after.length > 1) {
1228 for (var j = 0; j < after.length; j += 1) {
1229 after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling);
1230 }
1231 }
1232 }
1233 }
1234
1235 function next(selector) {
1236 if (this.length > 0) {
1237 if (selector) {
1238 if (this[0].nextElementSibling && $$1(this[0].nextElementSibling).is(selector)) {
1239 return $$1([this[0].nextElementSibling]);
1240 }
1241
1242 return $$1([]);
1243 }
1244
1245 if (this[0].nextElementSibling) return $$1([this[0].nextElementSibling]);
1246 return $$1([]);
1247 }
1248
1249 return $$1([]);
1250 }
1251
1252 function nextAll(selector) {
1253 var nextEls = [];
1254 var el = this[0];
1255 if (!el) return $$1([]);
1256
1257 while (el.nextElementSibling) {
1258 var _next = el.nextElementSibling; // eslint-disable-line
1259
1260 if (selector) {
1261 if ($$1(_next).is(selector)) nextEls.push(_next);
1262 } else nextEls.push(_next);
1263
1264 el = _next;
1265 }
1266
1267 return $$1(nextEls);
1268 }
1269
1270 function prev(selector) {
1271 if (this.length > 0) {
1272 var el = this[0];
1273
1274 if (selector) {
1275 if (el.previousElementSibling && $$1(el.previousElementSibling).is(selector)) {
1276 return $$1([el.previousElementSibling]);
1277 }
1278
1279 return $$1([]);
1280 }
1281
1282 if (el.previousElementSibling) return $$1([el.previousElementSibling]);
1283 return $$1([]);
1284 }
1285
1286 return $$1([]);
1287 }
1288
1289 function prevAll(selector) {
1290 var prevEls = [];
1291 var el = this[0];
1292 if (!el) return $$1([]);
1293
1294 while (el.previousElementSibling) {
1295 var _prev = el.previousElementSibling; // eslint-disable-line
1296
1297 if (selector) {
1298 if ($$1(_prev).is(selector)) prevEls.push(_prev);
1299 } else prevEls.push(_prev);
1300
1301 el = _prev;
1302 }
1303
1304 return $$1(prevEls);
1305 }
1306
1307 function siblings(selector) {
1308 return this.nextAll(selector).add(this.prevAll(selector));
1309 }
1310
1311 function parent(selector) {
1312 var parents = []; // eslint-disable-line
1313
1314 for (var i = 0; i < this.length; i += 1) {
1315 if (this[i].parentNode !== null) {
1316 if (selector) {
1317 if ($$1(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);
1318 } else {
1319 parents.push(this[i].parentNode);
1320 }
1321 }
1322 }
1323
1324 return $$1(parents);
1325 }
1326
1327 function parents(selector) {
1328 var parents = []; // eslint-disable-line
1329
1330 for (var i = 0; i < this.length; i += 1) {
1331 var _parent = this[i].parentNode; // eslint-disable-line
1332
1333 while (_parent) {
1334 if (selector) {
1335 if ($$1(_parent).is(selector)) parents.push(_parent);
1336 } else {
1337 parents.push(_parent);
1338 }
1339
1340 _parent = _parent.parentNode;
1341 }
1342 }
1343
1344 return $$1(parents);
1345 }
1346
1347 function closest(selector) {
1348 var closest = this; // eslint-disable-line
1349
1350 if (typeof selector === 'undefined') {
1351 return $$1([]);
1352 }
1353
1354 if (!closest.is(selector)) {
1355 closest = closest.parents(selector).eq(0);
1356 }
1357
1358 return closest;
1359 }
1360
1361 function find(selector) {
1362 var foundElements = [];
1363
1364 for (var i = 0; i < this.length; i += 1) {
1365 var found = this[i].querySelectorAll(selector);
1366
1367 for (var j = 0; j < found.length; j += 1) {
1368 foundElements.push(found[j]);
1369 }
1370 }
1371
1372 return $$1(foundElements);
1373 }
1374
1375 function children(selector) {
1376 var children = []; // eslint-disable-line
1377
1378 for (var i = 0; i < this.length; i += 1) {
1379 var childNodes = this[i].children;
1380
1381 for (var j = 0; j < childNodes.length; j += 1) {
1382 if (!selector || $$1(childNodes[j]).is(selector)) {
1383 children.push(childNodes[j]);
1384 }
1385 }
1386 }
1387
1388 return $$1(children);
1389 }
1390
1391 function remove() {
1392 for (var i = 0; i < this.length; i += 1) {
1393 if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);
1394 }
1395
1396 return this;
1397 }
1398
1399 function detach() {
1400 return this.remove();
1401 }
1402
1403 function add() {
1404 var dom = this;
1405 var i;
1406 var j;
1407
1408 for (var _len10 = arguments.length, els = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
1409 els[_key10] = arguments[_key10];
1410 }
1411
1412 for (i = 0; i < els.length; i += 1) {
1413 var toAdd = $$1(els[i]);
1414
1415 for (j = 0; j < toAdd.length; j += 1) {
1416 dom.push(toAdd[j]);
1417 }
1418 }
1419
1420 return dom;
1421 }
1422
1423 function empty() {
1424 for (var i = 0; i < this.length; i += 1) {
1425 var el = this[i];
1426
1427 if (el.nodeType === 1) {
1428 for (var j = 0; j < el.childNodes.length; j += 1) {
1429 if (el.childNodes[j].parentNode) {
1430 el.childNodes[j].parentNode.removeChild(el.childNodes[j]);
1431 }
1432 }
1433
1434 el.textContent = '';
1435 }
1436 }
1437
1438 return this;
1439 }
1440
1441 function scrollTo() {
1442 var window = getWindow();
1443
1444 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1445 args[_key] = arguments[_key];
1446 }
1447
1448 var left = args[0],
1449 top = args[1],
1450 duration = args[2],
1451 easing = args[3],
1452 callback = args[4];
1453
1454 if (args.length === 4 && typeof easing === 'function') {
1455 callback = easing;
1456 left = args[0];
1457 top = args[1];
1458 duration = args[2];
1459 callback = args[3];
1460 easing = args[4];
1461 }
1462
1463 if (typeof easing === 'undefined') easing = 'swing';
1464 return this.each(function animate() {
1465 var el = this;
1466 var currentTop;
1467 var currentLeft;
1468 var maxTop;
1469 var maxLeft;
1470 var newTop;
1471 var newLeft;
1472 var scrollTop; // eslint-disable-line
1473
1474 var scrollLeft; // eslint-disable-line
1475
1476 var animateTop = top > 0 || top === 0;
1477 var animateLeft = left > 0 || left === 0;
1478
1479 if (typeof easing === 'undefined') {
1480 easing = 'swing';
1481 }
1482
1483 if (animateTop) {
1484 currentTop = el.scrollTop;
1485
1486 if (!duration) {
1487 el.scrollTop = top;
1488 }
1489 }
1490
1491 if (animateLeft) {
1492 currentLeft = el.scrollLeft;
1493
1494 if (!duration) {
1495 el.scrollLeft = left;
1496 }
1497 }
1498
1499 if (!duration) return;
1500
1501 if (animateTop) {
1502 maxTop = el.scrollHeight - el.offsetHeight;
1503 newTop = Math.max(Math.min(top, maxTop), 0);
1504 }
1505
1506 if (animateLeft) {
1507 maxLeft = el.scrollWidth - el.offsetWidth;
1508 newLeft = Math.max(Math.min(left, maxLeft), 0);
1509 }
1510
1511 var startTime = null;
1512 if (animateTop && newTop === currentTop) animateTop = false;
1513 if (animateLeft && newLeft === currentLeft) animateLeft = false;
1514
1515 function render(time) {
1516 if (time === void 0) {
1517 time = new Date().getTime();
1518 }
1519
1520 if (startTime === null) {
1521 startTime = time;
1522 }
1523
1524 var progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
1525 var easeProgress = easing === 'linear' ? progress : 0.5 - Math.cos(progress * Math.PI) / 2;
1526 var done;
1527 if (animateTop) scrollTop = currentTop + easeProgress * (newTop - currentTop);
1528 if (animateLeft) scrollLeft = currentLeft + easeProgress * (newLeft - currentLeft);
1529
1530 if (animateTop && newTop > currentTop && scrollTop >= newTop) {
1531 el.scrollTop = newTop;
1532 done = true;
1533 }
1534
1535 if (animateTop && newTop < currentTop && scrollTop <= newTop) {
1536 el.scrollTop = newTop;
1537 done = true;
1538 }
1539
1540 if (animateLeft && newLeft > currentLeft && scrollLeft >= newLeft) {
1541 el.scrollLeft = newLeft;
1542 done = true;
1543 }
1544
1545 if (animateLeft && newLeft < currentLeft && scrollLeft <= newLeft) {
1546 el.scrollLeft = newLeft;
1547 done = true;
1548 }
1549
1550 if (done) {
1551 if (callback) callback();
1552 return;
1553 }
1554
1555 if (animateTop) el.scrollTop = scrollTop;
1556 if (animateLeft) el.scrollLeft = scrollLeft;
1557 window.requestAnimationFrame(render);
1558 }
1559
1560 window.requestAnimationFrame(render);
1561 });
1562 } // scrollTop(top, duration, easing, callback) {
1563
1564
1565 function scrollTop() {
1566 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1567 args[_key2] = arguments[_key2];
1568 }
1569
1570 var top = args[0],
1571 duration = args[1],
1572 easing = args[2],
1573 callback = args[3];
1574
1575 if (args.length === 3 && typeof easing === 'function') {
1576 top = args[0];
1577 duration = args[1];
1578 callback = args[2];
1579 easing = args[3];
1580 }
1581
1582 var dom = this;
1583
1584 if (typeof top === 'undefined') {
1585 if (dom.length > 0) return dom[0].scrollTop;
1586 return null;
1587 }
1588
1589 return dom.scrollTo(undefined, top, duration, easing, callback);
1590 }
1591
1592 function scrollLeft() {
1593 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1594 args[_key3] = arguments[_key3];
1595 }
1596
1597 var left = args[0],
1598 duration = args[1],
1599 easing = args[2],
1600 callback = args[3];
1601
1602 if (args.length === 3 && typeof easing === 'function') {
1603 left = args[0];
1604 duration = args[1];
1605 callback = args[2];
1606 easing = args[3];
1607 }
1608
1609 var dom = this;
1610
1611 if (typeof left === 'undefined') {
1612 if (dom.length > 0) return dom[0].scrollLeft;
1613 return null;
1614 }
1615
1616 return dom.scrollTo(left, undefined, duration, easing, callback);
1617 }
1618
1619 function animate(initialProps, initialParams) {
1620 var window = getWindow();
1621 var els = this;
1622 var a = {
1623 props: Object.assign({}, initialProps),
1624 params: Object.assign({
1625 duration: 300,
1626 easing: 'swing' // or 'linear'
1627
1628 /* Callbacks
1629 begin(elements)
1630 complete(elements)
1631 progress(elements, complete, remaining, start, tweenValue)
1632 */
1633
1634 }, initialParams),
1635 elements: els,
1636 animating: false,
1637 que: [],
1638 easingProgress: function easingProgress(easing, progress) {
1639 if (easing === 'swing') {
1640 return 0.5 - Math.cos(progress * Math.PI) / 2;
1641 }
1642
1643 if (typeof easing === 'function') {
1644 return easing(progress);
1645 }
1646
1647 return progress;
1648 },
1649 stop: function stop() {
1650 if (a.frameId) {
1651 window.cancelAnimationFrame(a.frameId);
1652 }
1653
1654 a.animating = false;
1655 a.elements.each(function (el) {
1656 var element = el;
1657 delete element.dom7AnimateInstance;
1658 });
1659 a.que = [];
1660 },
1661 done: function done(complete) {
1662 a.animating = false;
1663 a.elements.each(function (el) {
1664 var element = el;
1665 delete element.dom7AnimateInstance;
1666 });
1667 if (complete) complete(els);
1668
1669 if (a.que.length > 0) {
1670 var que = a.que.shift();
1671 a.animate(que[0], que[1]);
1672 }
1673 },
1674 animate: function animate(props, params) {
1675 if (a.animating) {
1676 a.que.push([props, params]);
1677 return a;
1678 }
1679
1680 var elements = []; // Define & Cache Initials & Units
1681
1682 a.elements.each(function (el, index) {
1683 var initialFullValue;
1684 var initialValue;
1685 var unit;
1686 var finalValue;
1687 var finalFullValue;
1688 if (!el.dom7AnimateInstance) a.elements[index].dom7AnimateInstance = a;
1689 elements[index] = {
1690 container: el
1691 };
1692 Object.keys(props).forEach(function (prop) {
1693 initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.');
1694 initialValue = parseFloat(initialFullValue);
1695 unit = initialFullValue.replace(initialValue, '');
1696 finalValue = parseFloat(props[prop]);
1697 finalFullValue = props[prop] + unit;
1698 elements[index][prop] = {
1699 initialFullValue: initialFullValue,
1700 initialValue: initialValue,
1701 unit: unit,
1702 finalValue: finalValue,
1703 finalFullValue: finalFullValue,
1704 currentValue: initialValue
1705 };
1706 });
1707 });
1708 var startTime = null;
1709 var time;
1710 var elementsDone = 0;
1711 var propsDone = 0;
1712 var done;
1713 var began = false;
1714 a.animating = true;
1715
1716 function render() {
1717 time = new Date().getTime();
1718 var progress;
1719 var easeProgress; // let el;
1720
1721 if (!began) {
1722 began = true;
1723 if (params.begin) params.begin(els);
1724 }
1725
1726 if (startTime === null) {
1727 startTime = time;
1728 }
1729
1730 if (params.progress) {
1731 // eslint-disable-next-line
1732 params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), startTime + params.duration - time < 0 ? 0 : startTime + params.duration - time, startTime);
1733 }
1734
1735 elements.forEach(function (element) {
1736 var el = element;
1737 if (done || el.done) return;
1738 Object.keys(props).forEach(function (prop) {
1739 if (done || el.done) return;
1740 progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0);
1741 easeProgress = a.easingProgress(params.easing, progress);
1742 var _el$prop = el[prop],
1743 initialValue = _el$prop.initialValue,
1744 finalValue = _el$prop.finalValue,
1745 unit = _el$prop.unit;
1746 el[prop].currentValue = initialValue + easeProgress * (finalValue - initialValue);
1747 var currentValue = el[prop].currentValue;
1748
1749 if (finalValue > initialValue && currentValue >= finalValue || finalValue < initialValue && currentValue <= finalValue) {
1750 el.container.style[prop] = finalValue + unit;
1751 propsDone += 1;
1752
1753 if (propsDone === Object.keys(props).length) {
1754 el.done = true;
1755 elementsDone += 1;
1756 }
1757
1758 if (elementsDone === elements.length) {
1759 done = true;
1760 }
1761 }
1762
1763 if (done) {
1764 a.done(params.complete);
1765 return;
1766 }
1767
1768 el.container.style[prop] = currentValue + unit;
1769 });
1770 });
1771 if (done) return; // Then call
1772
1773 a.frameId = window.requestAnimationFrame(render);
1774 }
1775
1776 a.frameId = window.requestAnimationFrame(render);
1777 return a;
1778 }
1779 };
1780
1781 if (a.elements.length === 0) {
1782 return els;
1783 }
1784
1785 var animateInstance;
1786
1787 for (var i = 0; i < a.elements.length; i += 1) {
1788 if (a.elements[i].dom7AnimateInstance) {
1789 animateInstance = a.elements[i].dom7AnimateInstance;
1790 } else a.elements[i].dom7AnimateInstance = a;
1791 }
1792
1793 if (!animateInstance) {
1794 animateInstance = a;
1795 }
1796
1797 if (initialProps === 'stop') {
1798 animateInstance.stop();
1799 } else {
1800 animateInstance.animate(a.props, a.params);
1801 }
1802
1803 return els;
1804 }
1805
1806 function stop() {
1807 var els = this;
1808
1809 for (var i = 0; i < els.length; i += 1) {
1810 if (els[i].dom7AnimateInstance) {
1811 els[i].dom7AnimateInstance.stop();
1812 }
1813 }
1814 }
1815
1816 var noTrigger = 'resize scroll'.split(' ');
1817
1818 function shortcut(name) {
1819 function eventHandler() {
1820 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1821 args[_key] = arguments[_key];
1822 }
1823
1824 if (typeof args[0] === 'undefined') {
1825 for (var i = 0; i < this.length; i += 1) {
1826 if (noTrigger.indexOf(name) < 0) {
1827 if (name in this[i]) this[i][name]();else {
1828 $$1(this[i]).trigger(name);
1829 }
1830 }
1831 }
1832
1833 return this;
1834 }
1835
1836 return this.on.apply(this, [name].concat(args));
1837 }
1838
1839 return eventHandler;
1840 }
1841
1842 var click = shortcut('click');
1843 var blur = shortcut('blur');
1844 var focus = shortcut('focus');
1845 var focusin = shortcut('focusin');
1846 var focusout = shortcut('focusout');
1847 var keyup = shortcut('keyup');
1848 var keydown = shortcut('keydown');
1849 var keypress = shortcut('keypress');
1850 var submit = shortcut('submit');
1851 var change = shortcut('change');
1852 var mousedown = shortcut('mousedown');
1853 var mousemove = shortcut('mousemove');
1854 var mouseup = shortcut('mouseup');
1855 var mouseenter = shortcut('mouseenter');
1856 var mouseleave = shortcut('mouseleave');
1857 var mouseout = shortcut('mouseout');
1858 var mouseover = shortcut('mouseover');
1859 var touchstart = shortcut('touchstart');
1860 var touchend = shortcut('touchend');
1861 var touchmove = shortcut('touchmove');
1862 var resize = shortcut('resize');
1863 var scroll = shortcut('scroll');
1864
1865 var methods = /*#__PURE__*/Object.freeze({
1866 __proto__: null,
1867 'default': $$1,
1868 $: $$1,
1869 add: add,
1870 addClass: addClass,
1871 animate: animate,
1872 animationEnd: animationEnd,
1873 append: append,
1874 appendTo: appendTo,
1875 attr: attr,
1876 blur: blur,
1877 change: change,
1878 children: children,
1879 click: click,
1880 closest: closest,
1881 css: css,
1882 data: data,
1883 dataset: dataset,
1884 detach: detach,
1885 each: each,
1886 empty: empty,
1887 eq: eq,
1888 filter: filter,
1889 find: find,
1890 focus: focus,
1891 focusin: focusin,
1892 focusout: focusout,
1893 hasClass: hasClass,
1894 height: height,
1895 hide: hide,
1896 html: html,
1897 index: index,
1898 insertAfter: insertAfter,
1899 insertBefore: insertBefore$1,
1900 is: is,
1901 keydown: keydown,
1902 keypress: keypress,
1903 keyup: keyup,
1904 mousedown: mousedown,
1905 mouseenter: mouseenter,
1906 mouseleave: mouseleave,
1907 mousemove: mousemove,
1908 mouseout: mouseout,
1909 mouseover: mouseover,
1910 mouseup: mouseup,
1911 next: next,
1912 nextAll: nextAll,
1913 off: off,
1914 offset: offset,
1915 on: on,
1916 once: once,
1917 outerHeight: outerHeight,
1918 outerWidth: outerWidth,
1919 parent: parent,
1920 parents: parents,
1921 prepend: prepend,
1922 prependTo: prependTo,
1923 prev: prev,
1924 prevAll: prevAll,
1925 prop: prop,
1926 remove: remove,
1927 removeAttr: removeAttr,
1928 removeClass: removeClass,
1929 removeData: removeData,
1930 resize: resize,
1931 scroll: scroll,
1932 scrollLeft: scrollLeft,
1933 scrollTo: scrollTo,
1934 scrollTop: scrollTop,
1935 show: show,
1936 siblings: siblings,
1937 stop: stop,
1938 styles: styles,
1939 submit: submit,
1940 text: text,
1941 toggleClass: toggleClass,
1942 touchend: touchend,
1943 touchmove: touchmove,
1944 touchstart: touchstart,
1945 transform: transform,
1946 transition: transition,
1947 transitionEnd: transitionEnd,
1948 trigger: trigger,
1949 val: val,
1950 value: value,
1951 width: width
1952 });
1953
1954 Object.keys(methods).forEach(function (methodName) {
1955 if (methodName === '$') return;
1956 $$1.fn[methodName] = methods[methodName];
1957 });
1958 var $ = $$1;
1959
1960 function _defineProperties(target, props) {
1961 for (var i = 0; i < props.length; i++) {
1962 var descriptor = props[i];
1963 descriptor.enumerable = descriptor.enumerable || false;
1964 descriptor.configurable = true;
1965 if ("value" in descriptor) descriptor.writable = true;
1966 Object.defineProperty(target, descriptor.key, descriptor);
1967 }
1968 }
1969
1970 function _createClass(Constructor, protoProps, staticProps) {
1971 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1972 if (staticProps) _defineProperties(Constructor, staticProps);
1973 return Constructor;
1974 }
1975
1976 function _extends() {
1977 _extends = Object.assign || function (target) {
1978 for (var i = 1; i < arguments.length; i++) {
1979 var source = arguments[i];
1980
1981 for (var key in source) {
1982 if (Object.prototype.hasOwnProperty.call(source, key)) {
1983 target[key] = source[key];
1984 }
1985 }
1986 }
1987
1988 return target;
1989 };
1990
1991 return _extends.apply(this, arguments);
1992 }
1993
1994 function _inheritsLoose(subClass, superClass) {
1995 subClass.prototype = Object.create(superClass.prototype);
1996 subClass.prototype.constructor = subClass;
1997
1998 _setPrototypeOf(subClass, superClass);
1999 }
2000
2001 function _getPrototypeOf(o) {
2002 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
2003 return o.__proto__ || Object.getPrototypeOf(o);
2004 };
2005 return _getPrototypeOf(o);
2006 }
2007
2008 function _setPrototypeOf(o, p) {
2009 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
2010 o.__proto__ = p;
2011 return o;
2012 };
2013
2014 return _setPrototypeOf(o, p);
2015 }
2016
2017 function _isNativeReflectConstruct() {
2018 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
2019 if (Reflect.construct.sham) return false;
2020 if (typeof Proxy === "function") return true;
2021
2022 try {
2023 Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
2024 return true;
2025 } catch (e) {
2026 return false;
2027 }
2028 }
2029
2030 function _construct(Parent, args, Class) {
2031 if (_isNativeReflectConstruct()) {
2032 _construct = Reflect.construct;
2033 } else {
2034 _construct = function _construct(Parent, args, Class) {
2035 var a = [null];
2036 a.push.apply(a, args);
2037 var Constructor = Function.bind.apply(Parent, a);
2038 var instance = new Constructor();
2039 if (Class) _setPrototypeOf(instance, Class.prototype);
2040 return instance;
2041 };
2042 }
2043
2044 return _construct.apply(null, arguments);
2045 }
2046
2047 function _isNativeFunction(fn) {
2048 return Function.toString.call(fn).indexOf("[native code]") !== -1;
2049 }
2050
2051 function _wrapNativeSuper(Class) {
2052 var _cache = typeof Map === "function" ? new Map() : undefined;
2053
2054 _wrapNativeSuper = function _wrapNativeSuper(Class) {
2055 if (Class === null || !_isNativeFunction(Class)) return Class;
2056
2057 if (typeof Class !== "function") {
2058 throw new TypeError("Super expression must either be null or a function");
2059 }
2060
2061 if (typeof _cache !== "undefined") {
2062 if (_cache.has(Class)) return _cache.get(Class);
2063
2064 _cache.set(Class, Wrapper);
2065 }
2066
2067 function Wrapper() {
2068 return _construct(Class, arguments, _getPrototypeOf(this).constructor);
2069 }
2070
2071 Wrapper.prototype = Object.create(Class.prototype, {
2072 constructor: {
2073 value: Wrapper,
2074 enumerable: false,
2075 writable: true,
2076 configurable: true
2077 }
2078 });
2079 return _setPrototypeOf(Wrapper, Class);
2080 };
2081
2082 return _wrapNativeSuper(Class);
2083 }
2084
2085 function _assertThisInitialized(self) {
2086 if (self === void 0) {
2087 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2088 }
2089
2090 return self;
2091 }
2092
2093 function _readOnlyError(name) {
2094 throw new TypeError("\"" + name + "\" is read-only");
2095 }
2096
2097 var uniqueNum = 0;
2098 function uniqueNumber() {
2099 uniqueNum += 1;
2100 return uniqueNum;
2101 }
2102 function id(mask, map) {
2103 if (mask === void 0) {
2104 mask = 'xxxxxxxxxx';
2105 }
2106
2107 if (map === void 0) {
2108 map = '0123456789abcdef';
2109 }
2110
2111 var length = map.length;
2112 return mask.replace(/x/g, function () {
2113 return map[Math.floor(Math.random() * length)];
2114 });
2115 }
2116 var mdPreloaderContent = "\n <span class=\"preloader-inner\">\n <svg viewBox=\"0 0 36 36\">\n <circle cx=\"18\" cy=\"18\" r=\"16\"></circle>\n </svg>\n </span>\n".trim();
2117 var iosPreloaderContent = ("\n <span class=\"preloader-inner\">\n " + [0, 1, 2, 3, 4, 5, 6, 7].map(function () {
2118 return '<span class="preloader-inner-line"></span>';
2119 }).join('') + "\n </span>\n").trim();
2120 var auroraPreloaderContent = "\n <span class=\"preloader-inner\">\n <span class=\"preloader-inner-circle\"></span>\n </span>\n";
2121 function eventNameToColonCase(eventName) {
2122 var hasColon;
2123 return eventName.split('').map(function (char, index) {
2124 if (char.match(/[A-Z]/) && index !== 0 && !hasColon) {
2125 hasColon = true;
2126 return ":" + char.toLowerCase();
2127 }
2128
2129 return char.toLowerCase();
2130 }).join('');
2131 }
2132 function deleteProps(obj) {
2133 var object = obj;
2134 Object.keys(object).forEach(function (key) {
2135 try {
2136 object[key] = null;
2137 } catch (e) {// no setter for object
2138 }
2139
2140 try {
2141 delete object[key];
2142 } catch (e) {// something got wrong
2143 }
2144 });
2145 }
2146 function requestAnimationFrame(callback) {
2147 var window = getWindow();
2148 return window.requestAnimationFrame(callback);
2149 }
2150 function cancelAnimationFrame(frameId) {
2151 var window = getWindow();
2152 return window.cancelAnimationFrame(frameId);
2153 }
2154 function nextTick(callback, delay) {
2155 if (delay === void 0) {
2156 delay = 0;
2157 }
2158
2159 return setTimeout(callback, delay);
2160 }
2161 function nextFrame$1(callback) {
2162 return requestAnimationFrame(function () {
2163 requestAnimationFrame(callback);
2164 });
2165 }
2166 function now() {
2167 return Date.now();
2168 }
2169 function parseUrlQuery(url) {
2170 var window = getWindow();
2171 var query = {};
2172 var urlToParse = url || window.location.href;
2173 var i;
2174 var params;
2175 var param;
2176 var length;
2177
2178 if (typeof urlToParse === 'string' && urlToParse.length) {
2179 urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : '';
2180 params = urlToParse.split('&').filter(function (paramsPart) {
2181 return paramsPart !== '';
2182 });
2183 length = params.length;
2184
2185 for (i = 0; i < length; i += 1) {
2186 param = params[i].replace(/#\S+/g, '').split('=');
2187 query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param.slice(1).join('=')) || '';
2188 }
2189 }
2190
2191 return query;
2192 }
2193 function getTranslate(el, axis) {
2194 if (axis === void 0) {
2195 axis = 'x';
2196 }
2197
2198 var window = getWindow();
2199 var matrix;
2200 var curTransform;
2201 var transformMatrix;
2202 var curStyle = window.getComputedStyle(el, null);
2203
2204 if (window.WebKitCSSMatrix) {
2205 curTransform = curStyle.transform || curStyle.webkitTransform;
2206
2207 if (curTransform.split(',').length > 6) {
2208 curTransform = curTransform.split(', ').map(function (a) {
2209 return a.replace(',', '.');
2210 }).join(', ');
2211 } // Some old versions of Webkit choke when 'none' is passed; pass
2212 // empty string instead in this case
2213
2214
2215 transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
2216 } else {
2217 transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
2218 matrix = transformMatrix.toString().split(',');
2219 }
2220
2221 if (axis === 'x') {
2222 // Latest Chrome and webkits Fix
2223 if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix
2224 else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers
2225 else curTransform = parseFloat(matrix[4]);
2226 }
2227
2228 if (axis === 'y') {
2229 // Latest Chrome and webkits Fix
2230 if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix
2231 else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers
2232 else curTransform = parseFloat(matrix[5]);
2233 }
2234
2235 return curTransform || 0;
2236 }
2237 function serializeObject(obj, parents) {
2238 if (parents === void 0) {
2239 parents = [];
2240 }
2241
2242 if (typeof obj === 'string') return obj;
2243 var resultArray = [];
2244 var separator = '&';
2245 var newParents;
2246
2247 function varName(name) {
2248 if (parents.length > 0) {
2249 var parentParts = '';
2250
2251 for (var j = 0; j < parents.length; j += 1) {
2252 if (j === 0) parentParts += parents[j];else parentParts += "[" + encodeURIComponent(parents[j]) + "]";
2253 }
2254
2255 return parentParts + "[" + encodeURIComponent(name) + "]";
2256 }
2257
2258 return encodeURIComponent(name);
2259 }
2260
2261 function varValue(value) {
2262 return encodeURIComponent(value);
2263 }
2264
2265 Object.keys(obj).forEach(function (prop) {
2266 var toPush;
2267
2268 if (Array.isArray(obj[prop])) {
2269 toPush = [];
2270
2271 for (var i = 0; i < obj[prop].length; i += 1) {
2272 if (!Array.isArray(obj[prop][i]) && typeof obj[prop][i] === 'object') {
2273 newParents = parents.slice();
2274 newParents.push(prop);
2275 newParents.push(String(i));
2276 toPush.push(serializeObject(obj[prop][i], newParents));
2277 } else {
2278 toPush.push(varName(prop) + "[]=" + varValue(obj[prop][i]));
2279 }
2280 }
2281
2282 if (toPush.length > 0) resultArray.push(toPush.join(separator));
2283 } else if (obj[prop] === null || obj[prop] === '') {
2284 resultArray.push(varName(prop) + "=");
2285 } else if (typeof obj[prop] === 'object') {
2286 // Object, convert to named array
2287 newParents = parents.slice();
2288 newParents.push(prop);
2289 toPush = serializeObject(obj[prop], newParents);
2290 if (toPush !== '') resultArray.push(toPush);
2291 } else if (typeof obj[prop] !== 'undefined' && obj[prop] !== '') {
2292 // Should be string or plain value
2293 resultArray.push(varName(prop) + "=" + varValue(obj[prop]));
2294 } else if (obj[prop] === '') resultArray.push(varName(prop));
2295 });
2296 return resultArray.join(separator);
2297 }
2298 function isObject(o) {
2299 return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object;
2300 }
2301 function merge() {
2302 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2303 args[_key] = arguments[_key];
2304 }
2305
2306 var to = args[0];
2307 args.splice(0, 1);
2308 var from = args;
2309
2310 for (var i = 0; i < from.length; i += 1) {
2311 var nextSource = args[i];
2312
2313 if (nextSource !== undefined && nextSource !== null) {
2314 var keysArray = Object.keys(Object(nextSource));
2315
2316 for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
2317 var nextKey = keysArray[nextIndex];
2318 var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
2319
2320 if (desc !== undefined && desc.enumerable) {
2321 to[nextKey] = nextSource[nextKey];
2322 }
2323 }
2324 }
2325 }
2326
2327 return to;
2328 }
2329 function extend() {
2330 var deep = true;
2331 var to;
2332 var from;
2333
2334 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2335 args[_key2] = arguments[_key2];
2336 }
2337
2338 if (typeof args[0] === 'boolean') {
2339 deep = args[0];
2340 to = args[1];
2341 args.splice(0, 2);
2342 from = args;
2343 } else {
2344 to = args[0];
2345 args.splice(0, 1);
2346 from = args;
2347 }
2348
2349 for (var i = 0; i < from.length; i += 1) {
2350 var nextSource = args[i];
2351
2352 if (nextSource !== undefined && nextSource !== null) {
2353 var keysArray = Object.keys(Object(nextSource));
2354
2355 for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
2356 var nextKey = keysArray[nextIndex];
2357 var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
2358
2359 if (desc !== undefined && desc.enumerable) {
2360 if (!deep) {
2361 to[nextKey] = nextSource[nextKey];
2362 } else if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
2363 extend(to[nextKey], nextSource[nextKey]);
2364 } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
2365 to[nextKey] = {};
2366 extend(to[nextKey], nextSource[nextKey]);
2367 } else {
2368 to[nextKey] = nextSource[nextKey];
2369 }
2370 }
2371 }
2372 }
2373 }
2374
2375 return to;
2376 }
2377 function colorHexToRgb(hex) {
2378 var h = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
2379 return r + r + g + g + b + b;
2380 });
2381 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(h);
2382 return result ? result.slice(1).map(function (n) {
2383 return parseInt(n, 16);
2384 }) : null;
2385 }
2386 function colorRgbToHex(r, g, b) {
2387 var result = [r, g, b].map(function (n) {
2388 var hex = n.toString(16);
2389 return hex.length === 1 ? "0" + hex : hex;
2390 }).join('');
2391 return "#" + result;
2392 }
2393 function colorRgbToHsl(r, g, b) {
2394 r /= 255; // eslint-disable-line
2395
2396 g /= 255; // eslint-disable-line
2397
2398 b /= 255; // eslint-disable-line
2399
2400 var max = Math.max(r, g, b);
2401 var min = Math.min(r, g, b);
2402 var d = max - min;
2403 var h;
2404 if (d === 0) h = 0;else if (max === r) h = (g - b) / d % 6;else if (max === g) h = (b - r) / d + 2;else if (max === b) h = (r - g) / d + 4;
2405 var l = (min + max) / 2;
2406 var s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
2407 if (h < 0) h = 360 / 60 + h;
2408 return [h * 60, s, l];
2409 }
2410 function colorHslToRgb(h, s, l) {
2411 var c = (1 - Math.abs(2 * l - 1)) * s;
2412 var hp = h / 60;
2413 var x = c * (1 - Math.abs(hp % 2 - 1));
2414 var rgb1;
2415
2416 if (Number.isNaN(h) || typeof h === 'undefined') {
2417 rgb1 = [0, 0, 0];
2418 } else if (hp <= 1) rgb1 = [c, x, 0];else if (hp <= 2) rgb1 = [x, c, 0];else if (hp <= 3) rgb1 = [0, c, x];else if (hp <= 4) rgb1 = [0, x, c];else if (hp <= 5) rgb1 = [x, 0, c];else if (hp <= 6) rgb1 = [c, 0, x];
2419
2420 var m = l - c / 2;
2421 return rgb1.map(function (n) {
2422 return Math.max(0, Math.min(255, Math.round(255 * (n + m))));
2423 });
2424 }
2425 function colorHsbToHsl(h, s, b) {
2426 var HSL = {
2427 h: h,
2428 s: 0,
2429 l: 0
2430 };
2431 var HSB = {
2432 h: h,
2433 s: s,
2434 b: b
2435 };
2436 HSL.l = (2 - HSB.s) * HSB.b / 2;
2437 HSL.s = HSL.l && HSL.l < 1 ? HSB.s * HSB.b / (HSL.l < 0.5 ? HSL.l * 2 : 2 - HSL.l * 2) : HSL.s;
2438 return [HSL.h, HSL.s, HSL.l];
2439 }
2440 function colorHslToHsb(h, s, l) {
2441 var HSB = {
2442 h: h,
2443 s: 0,
2444 b: 0
2445 };
2446 var HSL = {
2447 h: h,
2448 s: s,
2449 l: l
2450 };
2451 var t = HSL.s * (HSL.l < 0.5 ? HSL.l : 1 - HSL.l);
2452 HSB.b = HSL.l + t;
2453 HSB.s = HSL.l > 0 ? 2 * t / HSB.b : HSB.s;
2454 return [HSB.h, HSB.s, HSB.b];
2455 }
2456 function colorThemeCSSProperties() {
2457 var hex;
2458 var rgb;
2459
2460 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
2461 args[_key3] = arguments[_key3];
2462 }
2463
2464 if (args.length === 1) {
2465 hex = args[0];
2466 rgb = colorHexToRgb(hex);
2467 } else if (args.length === 3) {
2468 rgb = args;
2469 hex = colorRgbToHex.apply(void 0, rgb);
2470 }
2471
2472 if (!rgb) return {};
2473 var hsl = colorRgbToHsl.apply(void 0, rgb);
2474 var hslShade = [hsl[0], hsl[1], Math.max(0, hsl[2] - 0.08)];
2475 var hslTint = [hsl[0], hsl[1], Math.max(0, hsl[2] + 0.08)];
2476 var shade = colorRgbToHex.apply(void 0, colorHslToRgb.apply(void 0, hslShade));
2477 var tint = colorRgbToHex.apply(void 0, colorHslToRgb.apply(void 0, hslTint));
2478 return {
2479 '--f7-theme-color': hex,
2480 '--f7-theme-color-rgb': rgb.join(', '),
2481 '--f7-theme-color-shade': shade,
2482 '--f7-theme-color-tint': tint
2483 };
2484 }
2485 function bindMethods(instance, obj) {
2486 Object.keys(obj).forEach(function (key) {
2487 if (isObject(obj[key])) {
2488 Object.keys(obj[key]).forEach(function (subKey) {
2489 if (typeof obj[key][subKey] === 'function') {
2490 obj[key][subKey] = obj[key][subKey].bind(instance);
2491 }
2492 });
2493 }
2494
2495 instance[key] = obj[key];
2496 });
2497 }
2498 function flattenArray() {
2499 var arr = [];
2500
2501 for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2502 args[_key4] = arguments[_key4];
2503 }
2504
2505 args.forEach(function (arg) {
2506 if (Array.isArray(arg)) arr.push.apply(arr, flattenArray.apply(void 0, arg));else arr.push(arg);
2507 });
2508 return arr;
2509 }
2510
2511 var utils = /*#__PURE__*/Object.freeze({
2512 __proto__: null,
2513 uniqueNumber: uniqueNumber,
2514 id: id,
2515 mdPreloaderContent: mdPreloaderContent,
2516 iosPreloaderContent: iosPreloaderContent,
2517 auroraPreloaderContent: auroraPreloaderContent,
2518 eventNameToColonCase: eventNameToColonCase,
2519 deleteProps: deleteProps,
2520 requestAnimationFrame: requestAnimationFrame,
2521 cancelAnimationFrame: cancelAnimationFrame,
2522 nextTick: nextTick,
2523 nextFrame: nextFrame$1,
2524 now: now,
2525 parseUrlQuery: parseUrlQuery,
2526 getTranslate: getTranslate,
2527 serializeObject: serializeObject,
2528 isObject: isObject,
2529 merge: merge,
2530 extend: extend,
2531 colorHexToRgb: colorHexToRgb,
2532 colorRgbToHex: colorRgbToHex,
2533 colorRgbToHsl: colorRgbToHsl,
2534 colorHslToRgb: colorHslToRgb,
2535 colorHsbToHsl: colorHsbToHsl,
2536 colorHslToHsb: colorHslToHsb,
2537 colorThemeCSSProperties: colorThemeCSSProperties,
2538 bindMethods: bindMethods,
2539 flattenArray: flattenArray
2540 });
2541
2542 var support;
2543
2544 function calcSupport() {
2545 var window = getWindow();
2546 var document = getDocument();
2547 return {
2548 touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
2549 pointerEvents: !!window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints >= 0,
2550 passiveListener: function checkPassiveListener() {
2551 var supportsPassive = false;
2552
2553 try {
2554 var opts = Object.defineProperty({}, 'passive', {
2555 // eslint-disable-next-line
2556 get: function get() {
2557 supportsPassive = true;
2558 }
2559 });
2560 window.addEventListener('testPassiveListener', null, opts);
2561 } catch (e) {// No support
2562 }
2563
2564 return supportsPassive;
2565 }(),
2566 intersectionObserver: function checkObserver() {
2567 return 'IntersectionObserver' in window;
2568 }()
2569 };
2570 }
2571
2572 function getSupport() {
2573 if (!support) {
2574 support = calcSupport();
2575 }
2576
2577 return support;
2578 }
2579
2580 var deviceCalculated;
2581
2582 function calcDevice(_temp) {
2583 var _ref = _temp === void 0 ? {} : _temp,
2584 userAgent = _ref.userAgent;
2585
2586 var support = getSupport();
2587 var window = getWindow();
2588 var platform = window.navigator.platform;
2589 var ua = userAgent || window.navigator.userAgent;
2590 var device = {
2591 ios: false,
2592 android: false,
2593 androidChrome: false,
2594 desktop: false,
2595 iphone: false,
2596 ipod: false,
2597 ipad: false,
2598 edge: false,
2599 ie: false,
2600 firefox: false,
2601 macos: false,
2602 windows: false,
2603 cordova: !!(window.cordova || window.phonegap),
2604 phonegap: !!(window.cordova || window.phonegap),
2605 electron: false,
2606 capacitor: !!window.Capacitor,
2607 nwjs: false
2608 };
2609 var screenWidth = window.screen.width;
2610 var screenHeight = window.screen.height;
2611 var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
2612
2613 var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
2614 var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
2615 var iphone = !ipad && ua.match(/(iPhone\sOS|iOS|iPhone;\sCPU\sOS)\s([\d_]+)/);
2616 var ie = ua.indexOf('MSIE ') >= 0 || ua.indexOf('Trident/') >= 0;
2617 var edge = ua.indexOf('Edge/') >= 0;
2618 var firefox = ua.indexOf('Gecko/') >= 0 && ua.indexOf('Firefox/') >= 0;
2619 var windows = platform === 'Win32';
2620 var electron = ua.toLowerCase().indexOf('electron') >= 0;
2621 var nwjs = typeof nw !== 'undefined' && typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.nw !== 'undefined';
2622 var macos = platform === 'MacIntel'; // iPadOs 13 fix
2623
2624 var iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
2625
2626 if (!ipad && macos && support.touch && iPadScreens.indexOf(screenWidth + "x" + screenHeight) >= 0) {
2627 ipad = ua.match(/(Version)\/([\d.]+)/);
2628 if (!ipad) ipad = [0, 1, '13_0_0'];
2629 macos = false;
2630 }
2631
2632 device.ie = ie;
2633 device.edge = edge;
2634 device.firefox = firefox; // Android
2635
2636 if (android) {
2637 device.os = 'android';
2638 device.osVersion = android[2];
2639 device.android = true;
2640 device.androidChrome = ua.toLowerCase().indexOf('chrome') >= 0;
2641 }
2642
2643 if (ipad || iphone || ipod) {
2644 device.os = 'ios';
2645 device.ios = true;
2646 } // iOS
2647
2648
2649 if (iphone && !ipod) {
2650 device.osVersion = iphone[2].replace(/_/g, '.');
2651 device.iphone = true;
2652 }
2653
2654 if (ipad) {
2655 device.osVersion = ipad[2].replace(/_/g, '.');
2656 device.ipad = true;
2657 }
2658
2659 if (ipod) {
2660 device.osVersion = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
2661 device.ipod = true;
2662 } // iOS 8+ changed UA
2663
2664
2665 if (device.ios && device.osVersion && ua.indexOf('Version/') >= 0) {
2666 if (device.osVersion.split('.')[0] === '10') {
2667 device.osVersion = ua.toLowerCase().split('version/')[1].split(' ')[0];
2668 }
2669 } // Webview
2670
2671
2672 device.webView = !!((iphone || ipad || ipod) && (ua.match(/.*AppleWebKit(?!.*Safari)/i) || window.navigator.standalone)) || window.matchMedia && window.matchMedia('(display-mode: standalone)').matches;
2673 device.webview = device.webView;
2674 device.standalone = device.webView; // Desktop
2675
2676 device.desktop = !(device.ios || device.android) || electron || nwjs;
2677
2678 if (device.desktop) {
2679 device.electron = electron;
2680 device.nwjs = nwjs;
2681 device.macos = macos;
2682 device.windows = windows;
2683
2684 if (device.macos) {
2685 device.os = 'macos';
2686 }
2687
2688 if (device.windows) {
2689 device.os = 'windows';
2690 }
2691 } // Pixel Ratio
2692
2693
2694 device.pixelRatio = window.devicePixelRatio || 1; // Color Scheme
2695
2696 var DARK = '(prefers-color-scheme: dark)';
2697 var LIGHT = '(prefers-color-scheme: light)';
2698
2699 device.prefersColorScheme = function prefersColorTheme() {
2700 var theme;
2701
2702 if (window.matchMedia && window.matchMedia(LIGHT).matches) {
2703 theme = 'light';
2704 }
2705
2706 if (window.matchMedia && window.matchMedia(DARK).matches) {
2707 theme = 'dark';
2708 }
2709
2710 return theme;
2711 }; // Export object
2712
2713
2714 return device;
2715 }
2716
2717 function getDevice(overrides, reset) {
2718 if (overrides === void 0) {
2719 overrides = {};
2720 }
2721
2722 if (!deviceCalculated || reset) {
2723 deviceCalculated = calcDevice(overrides);
2724 }
2725
2726 return deviceCalculated;
2727 }
2728
2729 var EventsClass = /*#__PURE__*/function () {
2730 function EventsClass(parents) {
2731 if (parents === void 0) {
2732 parents = [];
2733 }
2734
2735 var self = this;
2736 self.eventsParents = parents;
2737 self.eventsListeners = {};
2738 }
2739
2740 var _proto = EventsClass.prototype;
2741
2742 _proto.on = function on(events, handler, priority) {
2743 var self = this;
2744 if (typeof handler !== 'function') return self;
2745 var method = priority ? 'unshift' : 'push';
2746 events.split(' ').forEach(function (event) {
2747 if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
2748 self.eventsListeners[event][method](handler);
2749 });
2750 return self;
2751 };
2752
2753 _proto.once = function once(events, handler, priority) {
2754 var self = this;
2755 if (typeof handler !== 'function') return self;
2756
2757 function onceHandler() {
2758 self.off(events, onceHandler);
2759
2760 if (onceHandler.f7proxy) {
2761 delete onceHandler.f7proxy;
2762 }
2763
2764 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2765 args[_key] = arguments[_key];
2766 }
2767
2768 handler.apply(self, args);
2769 }
2770
2771 onceHandler.f7proxy = handler;
2772 return self.on(events, onceHandler, priority);
2773 };
2774
2775 _proto.off = function off(events, handler) {
2776 var self = this;
2777 if (!self.eventsListeners) return self;
2778 events.split(' ').forEach(function (event) {
2779 if (typeof handler === 'undefined') {
2780 self.eventsListeners[event] = [];
2781 } else if (self.eventsListeners[event]) {
2782 self.eventsListeners[event].forEach(function (eventHandler, index) {
2783 if (eventHandler === handler || eventHandler.f7proxy && eventHandler.f7proxy === handler) {
2784 self.eventsListeners[event].splice(index, 1);
2785 }
2786 });
2787 }
2788 });
2789 return self;
2790 };
2791
2792 _proto.emit = function emit() {
2793 var self = this;
2794 if (!self.eventsListeners) return self;
2795 var events;
2796 var data;
2797 var context;
2798 var eventsParents;
2799
2800 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2801 args[_key2] = arguments[_key2];
2802 }
2803
2804 if (typeof args[0] === 'string' || Array.isArray(args[0])) {
2805 events = args[0];
2806 data = args.slice(1, args.length);
2807 context = self;
2808 eventsParents = self.eventsParents;
2809 } else {
2810 events = args[0].events;
2811 data = args[0].data;
2812 context = args[0].context || self;
2813 eventsParents = args[0].local ? [] : args[0].parents || self.eventsParents;
2814 }
2815
2816 var eventsArray = Array.isArray(events) ? events : events.split(' ');
2817 var localEvents = eventsArray.map(function (eventName) {
2818 return eventName.replace('local::', '');
2819 });
2820 var parentEvents = eventsArray.filter(function (eventName) {
2821 return eventName.indexOf('local::') < 0;
2822 });
2823 localEvents.forEach(function (event) {
2824 if (self.eventsListeners && self.eventsListeners[event]) {
2825 var handlers = [];
2826 self.eventsListeners[event].forEach(function (eventHandler) {
2827 handlers.push(eventHandler);
2828 });
2829 handlers.forEach(function (eventHandler) {
2830 eventHandler.apply(context, data);
2831 });
2832 }
2833 });
2834
2835 if (eventsParents && eventsParents.length > 0) {
2836 eventsParents.forEach(function (eventsParent) {
2837 eventsParent.emit.apply(eventsParent, [parentEvents].concat(data));
2838 });
2839 }
2840
2841 return self;
2842 };
2843
2844 return EventsClass;
2845 }();
2846
2847 var Framework7Class = /*#__PURE__*/function (_EventsClass) {
2848 _inheritsLoose(Framework7Class, _EventsClass);
2849
2850 function Framework7Class(params, parents) {
2851 var _this;
2852
2853 if (params === void 0) {
2854 params = {};
2855 }
2856
2857 if (parents === void 0) {
2858 parents = [];
2859 }
2860
2861 _this = _EventsClass.call(this, parents) || this;
2862
2863 var self = _assertThisInitialized(_this);
2864
2865 self.params = params;
2866
2867 if (self.params && self.params.on) {
2868 Object.keys(self.params.on).forEach(function (eventName) {
2869 self.on(eventName, self.params.on[eventName]);
2870 });
2871 }
2872
2873 return _this;
2874 } // eslint-disable-next-line
2875
2876
2877 var _proto = Framework7Class.prototype;
2878
2879 _proto.useModuleParams = function useModuleParams(module, instanceParams) {
2880 if (module.params) {
2881 var originalParams = {};
2882 Object.keys(module.params).forEach(function (paramKey) {
2883 if (typeof instanceParams[paramKey] === 'undefined') return;
2884 originalParams[paramKey] = extend({}, instanceParams[paramKey]);
2885 });
2886 extend(instanceParams, module.params);
2887 Object.keys(originalParams).forEach(function (paramKey) {
2888 extend(instanceParams[paramKey], originalParams[paramKey]);
2889 });
2890 }
2891 };
2892
2893 _proto.useModulesParams = function useModulesParams(instanceParams) {
2894 var instance = this;
2895 if (!instance.modules) return;
2896 Object.keys(instance.modules).forEach(function (moduleName) {
2897 var module = instance.modules[moduleName]; // Extend params
2898
2899 if (module.params) {
2900 extend(instanceParams, module.params);
2901 }
2902 });
2903 };
2904
2905 _proto.useModule = function useModule(moduleName, moduleParams) {
2906 if (moduleName === void 0) {
2907 moduleName = '';
2908 }
2909
2910 if (moduleParams === void 0) {
2911 moduleParams = {};
2912 }
2913
2914 var instance = this;
2915 if (!instance.modules) return;
2916 var module = typeof moduleName === 'string' ? instance.modules[moduleName] : moduleName;
2917 if (!module) return; // Extend instance methods and props
2918
2919 if (module.instance) {
2920 Object.keys(module.instance).forEach(function (modulePropName) {
2921 var moduleProp = module.instance[modulePropName];
2922
2923 if (typeof moduleProp === 'function') {
2924 instance[modulePropName] = moduleProp.bind(instance);
2925 } else {
2926 instance[modulePropName] = moduleProp;
2927 }
2928 });
2929 } // Add event listeners
2930
2931
2932 if (module.on && instance.on) {
2933 Object.keys(module.on).forEach(function (moduleEventName) {
2934 instance.on(moduleEventName, module.on[moduleEventName]);
2935 });
2936 } // Add vnode hooks
2937
2938
2939 if (module.vnode) {
2940 if (!instance.vnodeHooks) instance.vnodeHooks = {};
2941 Object.keys(module.vnode).forEach(function (vnodeId) {
2942 Object.keys(module.vnode[vnodeId]).forEach(function (hookName) {
2943 var handler = module.vnode[vnodeId][hookName];
2944 if (!instance.vnodeHooks[hookName]) instance.vnodeHooks[hookName] = {};
2945 if (!instance.vnodeHooks[hookName][vnodeId]) instance.vnodeHooks[hookName][vnodeId] = [];
2946 instance.vnodeHooks[hookName][vnodeId].push(handler.bind(instance));
2947 });
2948 });
2949 } // Module create callback
2950
2951
2952 if (module.create) {
2953 module.create.bind(instance)(moduleParams);
2954 }
2955 };
2956
2957 _proto.useModules = function useModules(modulesParams) {
2958 if (modulesParams === void 0) {
2959 modulesParams = {};
2960 }
2961
2962 var instance = this;
2963 if (!instance.modules) return;
2964 Object.keys(instance.modules).forEach(function (moduleName) {
2965 var moduleParams = modulesParams[moduleName] || {};
2966 instance.useModule(moduleName, moduleParams);
2967 });
2968 };
2969
2970 Framework7Class.installModule = function installModule(module) {
2971 var Class = this;
2972 if (!Class.prototype.modules) Class.prototype.modules = {};
2973 var name = module.name || Object.keys(Class.prototype.modules).length + "_" + now();
2974 Class.prototype.modules[name] = module; // Prototype
2975
2976 if (module.proto) {
2977 Object.keys(module.proto).forEach(function (key) {
2978 Class.prototype[key] = module.proto[key];
2979 });
2980 } // Class
2981
2982
2983 if (module.static) {
2984 Object.keys(module.static).forEach(function (key) {
2985 Class[key] = module.static[key];
2986 });
2987 } // Callback
2988
2989
2990 if (module.install) {
2991 for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2992 params[_key - 1] = arguments[_key];
2993 }
2994
2995 module.install.apply(Class, params);
2996 }
2997
2998 return Class;
2999 };
3000
3001 Framework7Class.use = function use(module) {
3002 var Class = this;
3003
3004 if (Array.isArray(module)) {
3005 module.forEach(function (m) {
3006 return Class.installModule(m);
3007 });
3008 return Class;
3009 }
3010
3011 for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
3012 params[_key2 - 1] = arguments[_key2];
3013 }
3014
3015 return Class.installModule.apply(Class, [module].concat(params));
3016 };
3017
3018 _createClass(Framework7Class, null, [{
3019 key: "components",
3020 set: function set(components) {
3021 var Class = this;
3022 if (!Class.use) return;
3023 Class.use(components);
3024 }
3025 }]);
3026
3027 return Framework7Class;
3028 }(EventsClass);
3029
3030 function ConstructorMethods(parameters) {
3031 if (parameters === void 0) {
3032 parameters = {};
3033 }
3034
3035 var _parameters = parameters,
3036 defaultSelector = _parameters.defaultSelector,
3037 Constructor = _parameters.constructor,
3038 domProp = _parameters.domProp,
3039 app = _parameters.app,
3040 addMethods = _parameters.addMethods;
3041 var methods = {
3042 create: function create() {
3043 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3044 args[_key] = arguments[_key];
3045 }
3046
3047 if (app) return _construct(Constructor, [app].concat(args));
3048 return _construct(Constructor, args);
3049 },
3050 get: function get(el) {
3051 if (el === void 0) {
3052 el = defaultSelector;
3053 }
3054
3055 if (el instanceof Constructor) return el;
3056 var $el = $(el);
3057 if ($el.length === 0) return undefined;
3058 return $el[0][domProp];
3059 },
3060 destroy: function destroy(el) {
3061 var instance = methods.get(el);
3062 if (instance && instance.destroy) return instance.destroy();
3063 return undefined;
3064 }
3065 };
3066
3067 if (addMethods && Array.isArray(addMethods)) {
3068 addMethods.forEach(function (methodName) {
3069 methods[methodName] = function (el) {
3070 if (el === void 0) {
3071 el = defaultSelector;
3072 }
3073
3074 var instance = methods.get(el);
3075
3076 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
3077 args[_key2 - 1] = arguments[_key2];
3078 }
3079
3080 if (instance && instance[methodName]) return instance[methodName].apply(instance, args);
3081 return undefined;
3082 };
3083 });
3084 }
3085
3086 return methods;
3087 }
3088
3089 function ModalMethods(parameters) {
3090 if (parameters === void 0) {
3091 parameters = {};
3092 }
3093
3094 var _parameters = parameters,
3095 defaultSelector = _parameters.defaultSelector,
3096 Constructor = _parameters.constructor,
3097 app = _parameters.app;
3098 var methods = extend(ConstructorMethods({
3099 defaultSelector: defaultSelector,
3100 constructor: Constructor,
3101 app: app,
3102 domProp: 'f7Modal'
3103 }), {
3104 open: function open(el, animate, targetEl) {
3105 var $el = $(el);
3106
3107 if ($el.length > 1 && targetEl) {
3108 // check if same modal in other page
3109 var $targetPage = $(targetEl).parents('.page');
3110
3111 if ($targetPage.length) {
3112 $el.each(function (modalEl) {
3113 var $modalEl = $(modalEl);
3114
3115 if ($modalEl.parents($targetPage)[0] === $targetPage[0]) {
3116 $el = $modalEl;
3117 }
3118 });
3119 }
3120 }
3121
3122 if ($el.length > 1) {
3123 $el = $el.eq($el.length - 1);
3124 }
3125
3126 if (!$el.length) return undefined;
3127 var instance = $el[0].f7Modal;
3128
3129 if (!instance) {
3130 var params = $el.dataset();
3131 instance = new Constructor(app, _extends({
3132 el: $el
3133 }, params));
3134 }
3135
3136 return instance.open(animate);
3137 },
3138 close: function close(el, animate, targetEl) {
3139 if (el === void 0) {
3140 el = defaultSelector;
3141 }
3142
3143 var $el = $(el);
3144 if (!$el.length) return undefined;
3145
3146 if ($el.length > 1) {
3147 // check if close link (targetEl) in this modal
3148 var $parentEl;
3149
3150 if (targetEl) {
3151 var $targetEl = $(targetEl);
3152
3153 if ($targetEl.length) {
3154 $parentEl = $targetEl.parents($el);
3155 }
3156 }
3157
3158 if ($parentEl && $parentEl.length > 0) {
3159 $el = $parentEl;
3160 } else {
3161 $el = $el.eq($el.length - 1);
3162 }
3163 }
3164
3165 var instance = $el[0].f7Modal;
3166
3167 if (!instance) {
3168 var params = $el.dataset();
3169 instance = new Constructor(app, _extends({
3170 el: $el
3171 }, params));
3172 }
3173
3174 return instance.close(animate);
3175 }
3176 });
3177 return methods;
3178 }
3179
3180 var fetchedModules = [];
3181
3182 function loadModule(moduleToLoad) {
3183 var Framework7 = this;
3184 var window = getWindow();
3185 var document = getDocument();
3186 return new Promise(function (resolve, reject) {
3187 var app = Framework7.instance;
3188 var modulePath;
3189 var moduleObj;
3190 var moduleFunc;
3191
3192 if (!moduleToLoad) {
3193 reject(new Error('Framework7: Lazy module must be specified'));
3194 return;
3195 }
3196
3197 function install(module) {
3198 Framework7.use(module);
3199
3200 if (app) {
3201 app.useModuleParams(module, app.params);
3202 app.useModule(module);
3203 }
3204 }
3205
3206 if (typeof moduleToLoad === 'string') {
3207 var matchNamePattern = moduleToLoad.match(/([a-z0-9-]*)/i);
3208
3209 if (moduleToLoad.indexOf('.') < 0 && matchNamePattern && matchNamePattern[0].length === moduleToLoad.length) {
3210 if (!app || app && !app.params.lazyModulesPath) {
3211 reject(new Error('Framework7: "lazyModulesPath" app parameter must be specified to fetch module by name'));
3212 return;
3213 }
3214
3215 modulePath = app.params.lazyModulesPath + "/" + moduleToLoad + "/" + moduleToLoad + ".js";
3216 } else {
3217 modulePath = moduleToLoad;
3218 }
3219 } else if (typeof moduleToLoad === 'function') {
3220 moduleFunc = moduleToLoad;
3221 } else {
3222 // considering F7-Plugin object
3223 moduleObj = moduleToLoad;
3224 }
3225
3226 if (moduleFunc) {
3227 var module = moduleFunc(Framework7, false);
3228
3229 if (!module) {
3230 reject(new Error("Framework7: Can't find Framework7 component in specified component function"));
3231 return;
3232 } // Check if it was added
3233
3234
3235 if (Framework7.prototype.modules && Framework7.prototype.modules[module.name]) {
3236 resolve();
3237 return;
3238 } // Install It
3239
3240
3241 install(module);
3242 resolve();
3243 }
3244
3245 if (moduleObj) {
3246 var _module = moduleObj;
3247
3248 if (!_module) {
3249 reject(new Error("Framework7: Can't find Framework7 component in specified component"));
3250 return;
3251 } // Check if it was added
3252
3253
3254 if (Framework7.prototype.modules && Framework7.prototype.modules[_module.name]) {
3255 resolve();
3256 return;
3257 } // Install It
3258
3259
3260 install(_module);
3261 resolve();
3262 }
3263
3264 if (modulePath) {
3265 if (fetchedModules.indexOf(modulePath) >= 0) {
3266 resolve();
3267 return;
3268 }
3269
3270 fetchedModules.push(modulePath);
3271 var scriptLoad = new Promise(function (resolveScript, rejectScript) {
3272 Framework7.request.get(modulePath, function (scriptContent) {
3273 var callbackId = id();
3274 var callbackLoadName = "f7_component_loader_callback_" + callbackId;
3275 var scriptEl = document.createElement('script');
3276 scriptEl.innerHTML = "window." + callbackLoadName + " = function (Framework7, Framework7AutoInstallComponent) {return " + scriptContent.trim() + "}";
3277 $('head').append(scriptEl);
3278 var componentLoader = window[callbackLoadName];
3279 delete window[callbackLoadName];
3280 $(scriptEl).remove();
3281 var module = componentLoader(Framework7, false);
3282
3283 if (!module) {
3284 rejectScript(new Error("Framework7: Can't find Framework7 component in " + modulePath + " file"));
3285 return;
3286 } // Check if it was added
3287
3288
3289 if (Framework7.prototype.modules && Framework7.prototype.modules[module.name]) {
3290 resolveScript();
3291 return;
3292 } // Install It
3293
3294
3295 install(module);
3296 resolveScript();
3297 }, function (xhr, status) {
3298 rejectScript(xhr, status);
3299 });
3300 });
3301 var styleLoad = new Promise(function (resolveStyle) {
3302 Framework7.request.get(modulePath.replace('.js', app.rtl ? '.rtl.css' : '.css'), function (styleContent) {
3303 var styleEl = document.createElement('style');
3304 styleEl.innerHTML = styleContent;
3305 $('head').append(styleEl);
3306 resolveStyle();
3307 }, function () {
3308 resolveStyle();
3309 });
3310 });
3311 Promise.all([scriptLoad, styleLoad]).then(function () {
3312 resolve();
3313 }).catch(function (err) {
3314 reject(err);
3315 });
3316 }
3317 });
3318 }
3319
3320 var Framework7 = /*#__PURE__*/function (_Framework7Class) {
3321 _inheritsLoose(Framework7, _Framework7Class);
3322
3323 function Framework7(params) {
3324 var _this;
3325
3326 if (params === void 0) {
3327 params = {};
3328 }
3329
3330 _this = _Framework7Class.call(this, params) || this; // eslint-disable-next-line
3331
3332 if (Framework7.instance && typeof window !== 'undefined') {
3333 throw new Error("Framework7 is already initialized and can't be initialized more than once");
3334 }
3335
3336 var device = getDevice({
3337 userAgent: params.userAgent || undefined
3338 });
3339 var support = getSupport();
3340 var passedParams = extend({}, params); // App Instance
3341
3342 var app = _assertThisInitialized(_this);
3343
3344 app.device = device;
3345 app.support = support;
3346 var w = getWindow();
3347 var d = getDocument();
3348 Framework7.instance = app; // Default
3349
3350 var defaults = {
3351 version: '1.0.0',
3352 id: 'io.framework7.myapp',
3353 el: 'body',
3354 theme: 'auto',
3355 language: w.navigator.language,
3356 routes: [],
3357 name: 'Framework7',
3358 lazyModulesPath: null,
3359 initOnDeviceReady: true,
3360 init: true,
3361 autoDarkTheme: false,
3362 iosTranslucentBars: true,
3363 iosTranslucentModals: true,
3364 component: undefined,
3365 componentUrl: undefined,
3366 userAgent: null,
3367 url: null
3368 }; // Extend defaults with modules params
3369
3370 app.useModulesParams(defaults); // Extend defaults with passed params
3371
3372 app.params = extend(defaults, params);
3373 extend(app, {
3374 // App Id
3375 id: app.params.id,
3376 // App Name
3377 name: app.params.name,
3378 // App version
3379 version: app.params.version,
3380 // Routes
3381 routes: app.params.routes,
3382 // Lang
3383 language: app.params.language,
3384 // Theme
3385 theme: function getTheme() {
3386 if (app.params.theme === 'auto') {
3387 if (device.ios) return 'ios';
3388 if (device.desktop && device.electron) return 'aurora';
3389 return 'md';
3390 }
3391
3392 return app.params.theme;
3393 }(),
3394 // Initially passed parameters
3395 passedParams: passedParams,
3396 online: w.navigator.onLine
3397 });
3398 if (params.store) app.params.store = params.store; // Save Root
3399
3400 if (app.$el && app.$el[0]) {
3401 app.$el[0].f7 = app;
3402 } // Install Modules
3403
3404
3405 app.useModules(); // Init Store
3406
3407 app.initStore(); // Init
3408
3409 if (app.params.init) {
3410 if (device.cordova && app.params.initOnDeviceReady) {
3411 $(d).on('deviceready', function () {
3412 app.init();
3413 });
3414 } else {
3415 app.init();
3416 }
3417 } // Return app instance
3418
3419
3420 return app || _assertThisInitialized(_this);
3421 }
3422
3423 var _proto = Framework7.prototype;
3424
3425 _proto.mount = function mount(rootEl) {
3426 var app = this;
3427 var window = getWindow();
3428 var document = getDocument();
3429 var $rootEl = $(rootEl || app.params.el).eq(0);
3430 app.$el = $rootEl;
3431
3432 if (app.$el && app.$el[0]) {
3433 app.el = app.$el[0];
3434 app.el.f7 = app;
3435 app.rtl = $rootEl.css('direction') === 'rtl';
3436 } // Auto Dark Theme
3437
3438
3439 var DARK = '(prefers-color-scheme: dark)';
3440 var LIGHT = '(prefers-color-scheme: light)';
3441 app.mq = {};
3442
3443 if (window.matchMedia) {
3444 app.mq.dark = window.matchMedia(DARK);
3445 app.mq.light = window.matchMedia(LIGHT);
3446 }
3447
3448 app.colorSchemeListener = function colorSchemeListener(_ref) {
3449 var matches = _ref.matches,
3450 media = _ref.media;
3451
3452 if (!matches) {
3453 return;
3454 }
3455
3456 var html = document.querySelector('html');
3457
3458 if (media === DARK) {
3459 html.classList.add('theme-dark');
3460 app.darkTheme = true;
3461 app.emit('darkThemeChange', true);
3462 } else if (media === LIGHT) {
3463 html.classList.remove('theme-dark');
3464 app.darkTheme = false;
3465 app.emit('darkThemeChange', false);
3466 }
3467 };
3468
3469 app.emit('mount');
3470 };
3471
3472 _proto.initStore = function initStore() {
3473 var app = this;
3474
3475 if (typeof app.params.store !== 'undefined' && app.params.store.__store) {
3476 app.store = app.params.store;
3477 } else {
3478 app.store = app.createStore(app.params.store);
3479 }
3480 };
3481
3482 _proto.enableAutoDarkTheme = function enableAutoDarkTheme() {
3483 var window = getWindow();
3484 var document = getDocument();
3485 if (!window.matchMedia) return;
3486 var app = this;
3487 var html = document.querySelector('html');
3488
3489 if (app.mq.dark && app.mq.light) {
3490 app.mq.dark.addListener(app.colorSchemeListener);
3491 app.mq.light.addListener(app.colorSchemeListener);
3492 }
3493
3494 if (app.mq.dark && app.mq.dark.matches) {
3495 html.classList.add('theme-dark');
3496 app.darkTheme = true;
3497 app.emit('darkThemeChange', true);
3498 } else if (app.mq.light && app.mq.light.matches) {
3499 html.classList.remove('theme-dark');
3500 app.darkTheme = false;
3501 app.emit('darkThemeChange', false);
3502 }
3503 };
3504
3505 _proto.disableAutoDarkTheme = function disableAutoDarkTheme() {
3506 var window = getWindow();
3507 if (!window.matchMedia) return;
3508 var app = this;
3509 if (app.mq.dark) app.mq.dark.removeListener(app.colorSchemeListener);
3510 if (app.mq.light) app.mq.light.removeListener(app.colorSchemeListener);
3511 };
3512
3513 _proto.initAppComponent = function initAppComponent(callback) {
3514 var app = this;
3515 app.router.componentLoader(app.params.component, app.params.componentUrl, {
3516 componentOptions: {
3517 el: app.$el[0]
3518 }
3519 }, function (el) {
3520 app.$el = $(el);
3521 app.$el[0].f7 = app;
3522 app.$elComponent = el.f7Component;
3523 app.el = app.$el[0];
3524 if (callback) callback();
3525 }, function () {});
3526 };
3527
3528 _proto.init = function init(rootEl) {
3529 var app = this;
3530 app.mount(rootEl);
3531
3532 var init = function init() {
3533 if (app.initialized) return;
3534 app.$el.addClass('framework7-initializing'); // RTL attr
3535
3536 if (app.rtl) {
3537 $('html').attr('dir', 'rtl');
3538 } // Auto Dark Theme
3539
3540
3541 if (app.params.autoDarkTheme) {
3542 app.enableAutoDarkTheme();
3543 } // Watch for online/offline state
3544
3545
3546 var window = getWindow();
3547 window.addEventListener('offline', function () {
3548 app.online = false;
3549 app.emit('offline');
3550 app.emit('connection', false);
3551 });
3552 window.addEventListener('online', function () {
3553 app.online = true;
3554 app.emit('online');
3555 app.emit('connection', true);
3556 }); // Root class
3557
3558 app.$el.addClass('framework7-root'); // Theme class
3559
3560 $('html').removeClass('ios md aurora').addClass(app.theme); // iOS Translucent
3561
3562 var device = app.device;
3563
3564 if (app.params.iosTranslucentBars && app.theme === 'ios' && device.ios) {
3565 $('html').addClass('ios-translucent-bars');
3566 }
3567
3568 if (app.params.iosTranslucentModals && app.theme === 'ios' && device.ios) {
3569 $('html').addClass('ios-translucent-modals');
3570 } // Init class
3571
3572
3573 nextFrame$1(function () {
3574 app.$el.removeClass('framework7-initializing');
3575 }); // Emit, init other modules
3576
3577 app.initialized = true;
3578 app.emit('init');
3579 };
3580
3581 if (app.params.component || app.params.componentUrl) {
3582 app.initAppComponent(function () {
3583 init();
3584 });
3585 } else {
3586 init();
3587 }
3588
3589 return app;
3590 } // eslint-disable-next-line
3591 ;
3592
3593 _proto.loadModule = function loadModule() {
3594 return Framework7.loadModule.apply(Framework7, arguments);
3595 } // eslint-disable-next-line
3596 ;
3597
3598 _proto.loadModules = function loadModules() {
3599 return Framework7.loadModules.apply(Framework7, arguments);
3600 };
3601
3602 _proto.getVnodeHooks = function getVnodeHooks(hook, id) {
3603 var app = this;
3604 if (!app.vnodeHooks || !app.vnodeHooks[hook]) return [];
3605 return app.vnodeHooks[hook][id] || [];
3606 } // eslint-disable-next-line
3607 ;
3608
3609 _createClass(Framework7, [{
3610 key: "$",
3611 get: function get() {
3612 return $;
3613 }
3614 }], [{
3615 key: "Dom7",
3616 get: function get() {
3617 return $;
3618 }
3619 }, {
3620 key: "$",
3621 get: function get() {
3622 return $;
3623 }
3624 }, {
3625 key: "device",
3626 get: function get() {
3627 return getDevice();
3628 }
3629 }, {
3630 key: "support",
3631 get: function get() {
3632 return getSupport();
3633 }
3634 }, {
3635 key: "Class",
3636 get: function get() {
3637 return Framework7Class;
3638 }
3639 }, {
3640 key: "Events",
3641 get: function get() {
3642 return EventsClass;
3643 }
3644 }]);
3645
3646 return Framework7;
3647 }(Framework7Class);
3648
3649 Framework7.ModalMethods = ModalMethods;
3650 Framework7.ConstructorMethods = ConstructorMethods;
3651 Framework7.loadModule = loadModule;
3652
3653 Framework7.loadModules = function loadModules(modules) {
3654 return Promise.all(modules.map(function (module) {
3655 return Framework7.loadModule(module);
3656 }));
3657 };
3658
3659 var DeviceModule = {
3660 name: 'device',
3661 static: {
3662 getDevice: getDevice
3663 },
3664 on: {
3665 init: function init() {
3666 var document = getDocument();
3667 var device = getDevice();
3668 var classNames = [];
3669 var html = document.querySelector('html');
3670 var metaStatusbar = document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');
3671 if (!html) return;
3672
3673 if (device.standalone && device.ios && metaStatusbar && metaStatusbar.content === 'black-translucent') {
3674 classNames.push('device-full-viewport');
3675 } // Pixel Ratio
3676
3677
3678 classNames.push("device-pixel-ratio-" + Math.floor(device.pixelRatio)); // OS classes
3679
3680 if (device.os && !device.desktop) {
3681 classNames.push("device-" + device.os);
3682 } else if (device.desktop) {
3683 classNames.push('device-desktop');
3684
3685 if (device.os) {
3686 classNames.push("device-" + device.os);
3687 }
3688 }
3689
3690 if (device.cordova || device.phonegap) {
3691 classNames.push('device-cordova');
3692 }
3693
3694 if (device.capacitor) {
3695 classNames.push('device-capacitor');
3696 } // Add html classes
3697
3698
3699 classNames.forEach(function (className) {
3700 html.classList.add(className);
3701 });
3702 }
3703 }
3704 };
3705
3706 var SupportModule = {
3707 name: 'support',
3708 static: {
3709 getSupport: getSupport
3710 }
3711 };
3712
3713 var UtilsModule = {
3714 name: 'utils',
3715 proto: {
3716 utils: utils
3717 },
3718 static: {
3719 utils: utils
3720 }
3721 };
3722
3723 var ResizeModule = {
3724 name: 'resize',
3725 create: function create() {
3726 var app = this;
3727
3728 app.getSize = function () {
3729 if (!app.el) return {
3730 width: 0,
3731 height: 0,
3732 left: 0,
3733 top: 0
3734 };
3735 var offset = app.$el.offset();
3736 var _ref = [app.el.offsetWidth, app.el.offsetHeight, offset.left, offset.top],
3737 width = _ref[0],
3738 height = _ref[1],
3739 left = _ref[2],
3740 top = _ref[3];
3741 app.width = width;
3742 app.height = height;
3743 app.left = left;
3744 app.top = top;
3745 return {
3746 width: width,
3747 height: height,
3748 left: left,
3749 top: top
3750 };
3751 };
3752 },
3753 on: {
3754 init: function init() {
3755 var app = this;
3756 var window = getWindow(); // Get Size
3757
3758 app.getSize(); // Emit resize
3759
3760 window.addEventListener('resize', function () {
3761 app.emit('resize');
3762 }, false); // Emit orientationchange
3763
3764 window.addEventListener('orientationchange', function () {
3765 app.emit('orientationchange');
3766 });
3767 },
3768 orientationchange: function orientationchange() {
3769 var document = getDocument();
3770 var device = getDevice(); // Fix iPad weird body scroll
3771
3772 if (device.ipad) {
3773 document.body.scrollLeft = 0;
3774 setTimeout(function () {
3775 document.body.scrollLeft = 0;
3776 }, 0);
3777 }
3778 },
3779 resize: function resize() {
3780 var app = this;
3781 app.getSize();
3782 }
3783 }
3784 };
3785
3786 var globals = {};
3787 var jsonpRequests = 0;
3788
3789 var RequestResponse = function RequestResponse(obj) {
3790 Object.assign(this, obj);
3791 };
3792
3793 var RequestError = /*#__PURE__*/function (_Error) {
3794 _inheritsLoose(RequestError, _Error);
3795
3796 function RequestError(obj) {
3797 var _this;
3798
3799 _this = _Error.call(this) || this;
3800 Object.assign(_assertThisInitialized(_this), obj);
3801 return _this;
3802 }
3803
3804 return RequestError;
3805 }( /*#__PURE__*/_wrapNativeSuper(Error));
3806
3807 var request = function request(requestOptions) {
3808 return new Promise(function (resolve, reject) {
3809 var window = getWindow();
3810 var document = getDocument();
3811 var globalsNoCallbacks = extend({}, globals);
3812 'beforeCreate beforeOpen beforeSend error complete success statusCode'.split(' ').forEach(function (callbackName) {
3813 delete globalsNoCallbacks[callbackName];
3814 });
3815 var defaults = extend({
3816 url: window.location.toString(),
3817 method: 'GET',
3818 data: false,
3819 async: true,
3820 cache: true,
3821 user: '',
3822 password: '',
3823 headers: {},
3824 xhrFields: {},
3825 statusCode: {},
3826 processData: true,
3827 dataType: 'text',
3828 contentType: 'application/x-www-form-urlencoded',
3829 timeout: 0
3830 }, globalsNoCallbacks);
3831 var proceedRequest;
3832 var options = extend({}, defaults, requestOptions);
3833
3834 if (requestOptions.abortController) {
3835 options.abortController = requestOptions.abortController;
3836 }
3837
3838 if (options.abortController && options.abortController.canceled) {
3839 reject(new RequestError({
3840 options: options,
3841 status: 'canceled',
3842 message: 'canceled'
3843 }));
3844 return;
3845 } // Function to run XHR callbacks and events
3846
3847
3848 function fireCallback(callbackName) {
3849 /*
3850 Callbacks:
3851 beforeCreate (options),
3852 beforeOpen (xhr, options),
3853 beforeSend (xhr, options),
3854 error (xhr, status, message),
3855 complete (xhr, status),
3856 success (response, status, xhr),
3857 statusCode ()
3858 */
3859 var globalCallbackValue;
3860 var optionCallbackValue;
3861
3862 for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
3863 data[_key - 1] = arguments[_key];
3864 }
3865
3866 if (globals[callbackName]) {
3867 globalCallbackValue = globals[callbackName].apply(globals, data);
3868 }
3869
3870 if (options[callbackName]) {
3871 optionCallbackValue = options[callbackName].apply(options, data);
3872 }
3873
3874 if (typeof globalCallbackValue !== 'boolean') globalCallbackValue = true;
3875 if (typeof optionCallbackValue !== 'boolean') optionCallbackValue = true;
3876
3877 if (options.abortController && options.abortController.canceled && (callbackName === 'beforeCreate' || callbackName === 'beforeOpen' || callbackName === 'beforeSend')) {
3878 return false;
3879 }
3880
3881 return globalCallbackValue && optionCallbackValue;
3882 } // Before create callback
3883
3884
3885 proceedRequest = fireCallback('beforeCreate', options);
3886
3887 if (proceedRequest === false) {
3888 reject(new RequestError({
3889 options: options,
3890 status: 'canceled',
3891 message: 'canceled'
3892 }));
3893 return;
3894 } // For jQuery guys
3895
3896
3897 if (options.type) options.method = options.type; // Parameters Prefix
3898
3899 var paramsPrefix = options.url.indexOf('?') >= 0 ? '&' : '?'; // UC method
3900
3901 var method = options.method.toUpperCase(); // Data to modify GET URL
3902
3903 if ((method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') && options.data) {
3904 var stringData;
3905
3906 if (typeof options.data === 'string') {
3907 // Should be key=value string
3908 if (options.data.indexOf('?') >= 0) stringData = options.data.split('?')[1];else stringData = options.data;
3909 } else {
3910 // Should be key=value object
3911 stringData = serializeObject(options.data);
3912 }
3913
3914 if (stringData.length) {
3915 options.url += paramsPrefix + stringData;
3916 if (paramsPrefix === '?') paramsPrefix = '&';
3917 }
3918 } // JSONP
3919
3920
3921 if (options.dataType === 'json' && options.url.indexOf('callback=') >= 0) {
3922 var callbackName = "f7jsonp_" + (Date.now() + (jsonpRequests += 1));
3923 var abortTimeout;
3924 var callbackSplit = options.url.split('callback=');
3925 var requestUrl = callbackSplit[0] + "callback=" + callbackName;
3926
3927 if (callbackSplit[1].indexOf('&') >= 0) {
3928 var addVars = callbackSplit[1].split('&').filter(function (el) {
3929 return el.indexOf('=') > 0;
3930 }).join('&');
3931 if (addVars.length > 0) requestUrl += "&" + addVars;
3932 } // Create script
3933
3934
3935 var script = document.createElement('script');
3936 script.type = 'text/javascript';
3937
3938 script.onerror = function onerror() {
3939 clearTimeout(abortTimeout);
3940 fireCallback('error', null, 'scripterror', 'scripterror');
3941 reject(new RequestError({
3942 options: options,
3943 status: 'scripterror',
3944 message: 'scripterror'
3945 }));
3946 fireCallback('complete', null, 'scripterror');
3947 };
3948
3949 script.src = requestUrl; // Handler
3950
3951 window[callbackName] = function jsonpCallback(data) {
3952 clearTimeout(abortTimeout);
3953 fireCallback('success', data);
3954 script.parentNode.removeChild(script);
3955 script = null;
3956 delete window[callbackName];
3957 resolve(new RequestResponse({
3958 options: options,
3959 data: data
3960 }));
3961 };
3962
3963 document.querySelector('head').appendChild(script);
3964
3965 if (options.timeout > 0) {
3966 abortTimeout = setTimeout(function () {
3967 script.parentNode.removeChild(script);
3968 script = null;
3969 fireCallback('error', null, 'timeout', 'timeout');
3970 reject(new RequestError({
3971 options: options,
3972 status: 'timeout',
3973 message: 'timeout'
3974 }));
3975 }, options.timeout);
3976 }
3977
3978 return;
3979 } // Cache for GET/HEAD requests
3980
3981
3982 if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS' || method === 'DELETE') {
3983 if (options.cache === false) {
3984 options.url += paramsPrefix + "_nocache" + Date.now();
3985 }
3986 } // Create XHR
3987
3988
3989 var xhr = new XMLHttpRequest();
3990
3991 if (options.abortController) {
3992 var aborted = false;
3993
3994 options.abortController.onAbort = function () {
3995 if (aborted) return;
3996 aborted = true;
3997 xhr.abort();
3998 reject(new RequestError({
3999 options: options,
4000 xhr: xhr,
4001 status: 'canceled',
4002 message: 'canceled'
4003 }));
4004 };
4005 } // Save Request URL
4006
4007
4008 xhr.requestUrl = options.url;
4009 xhr.requestParameters = options; // Before open callback
4010
4011 proceedRequest = fireCallback('beforeOpen', xhr, options);
4012
4013 if (proceedRequest === false) {
4014 reject(new RequestError({
4015 options: options,
4016 xhr: xhr,
4017 status: 'canceled',
4018 message: 'canceled'
4019 }));
4020 return;
4021 } // Open XHR
4022
4023
4024 xhr.open(method, options.url, options.async, options.user, options.password); // Create POST Data
4025
4026 var postData = null;
4027
4028 if ((method === 'POST' || method === 'PUT' || method === 'PATCH') && options.data) {
4029 if (options.processData) {
4030 var postDataInstances = [ArrayBuffer, Blob, Document, FormData]; // Post Data
4031
4032 if (postDataInstances.indexOf(options.data.constructor) >= 0) {
4033 postData = options.data;
4034 } else {
4035 // POST Headers
4036 var boundary = "---------------------------" + Date.now().toString(16);
4037
4038 if (options.contentType === 'multipart/form-data') {
4039 xhr.setRequestHeader('Content-Type', "multipart/form-data; boundary=" + boundary);
4040 } else {
4041 xhr.setRequestHeader('Content-Type', options.contentType);
4042 }
4043
4044 postData = '';
4045 var data = serializeObject(options.data);
4046
4047 if (options.contentType === 'multipart/form-data') {
4048 data = data.split('&');
4049 var newData = [];
4050
4051 for (var i = 0; i < data.length; i += 1) {
4052 newData.push("Content-Disposition: form-data; name=\"" + data[i].split('=')[0] + "\"\r\n\r\n" + data[i].split('=')[1] + "\r\n");
4053 }
4054
4055 postData = "--" + boundary + "\r\n" + newData.join("--" + boundary + "\r\n") + "--" + boundary + "--\r\n";
4056 } else if (options.contentType === 'application/json') {
4057 postData = JSON.stringify(options.data);
4058 } else {
4059 postData = data;
4060 }
4061 }
4062 } else {
4063 postData = options.data;
4064 xhr.setRequestHeader('Content-Type', options.contentType);
4065 }
4066 }
4067
4068 if (options.dataType === 'json' && (!options.headers || !options.headers.Accept)) {
4069 xhr.setRequestHeader('Accept', 'application/json');
4070 } // Additional headers
4071
4072
4073 if (options.headers) {
4074 Object.keys(options.headers).forEach(function (headerName) {
4075 if (typeof options.headers[headerName] === 'undefined') return;
4076 xhr.setRequestHeader(headerName, options.headers[headerName]);
4077 });
4078 } // Check for crossDomain
4079
4080
4081 if (typeof options.crossDomain === 'undefined') {
4082 options.crossDomain = // eslint-disable-next-line
4083 /^([\w-]+:)?\/\/([^\/]+)/.test(options.url) && RegExp.$2 !== window.location.host;
4084 }
4085
4086 if (!options.crossDomain) {
4087 xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
4088 }
4089
4090 if (options.xhrFields) {
4091 extend(xhr, options.xhrFields);
4092 } // Handle XHR
4093
4094
4095 xhr.onload = function onload() {
4096 if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 0) {
4097 var responseData;
4098
4099 if (options.dataType === 'json') {
4100 var parseError;
4101
4102 try {
4103 responseData = JSON.parse(xhr.responseText);
4104 } catch (err) {
4105 parseError = true;
4106 }
4107
4108 if (!parseError) {
4109 fireCallback('success', responseData, xhr.status, xhr);
4110 resolve(new RequestResponse({
4111 options: options,
4112 data: responseData,
4113 status: xhr.status,
4114 xhr: xhr
4115 }));
4116 } else {
4117 fireCallback('error', xhr, 'parseerror', 'parseerror');
4118 reject(new RequestError({
4119 options: options,
4120 xhr: xhr,
4121 status: 'parseerror',
4122 message: 'parseerror'
4123 }));
4124 }
4125 } else {
4126 responseData = xhr.responseType === 'text' || xhr.responseType === '' ? xhr.responseText : xhr.response;
4127 fireCallback('success', responseData, xhr.status, xhr);
4128 resolve(new RequestResponse({
4129 options: options,
4130 data: responseData,
4131 status: xhr.status,
4132 xhr: xhr
4133 }));
4134 }
4135 } else {
4136 fireCallback('error', xhr, xhr.status, xhr.statusText);
4137 reject(new RequestError({
4138 options: options,
4139 xhr: xhr,
4140 status: xhr.status,
4141 message: xhr.statusText
4142 }));
4143 }
4144
4145 if (options.statusCode) {
4146 if (globals.statusCode && globals.statusCode[xhr.status]) globals.statusCode[xhr.status](xhr);
4147 if (options.statusCode[xhr.status]) options.statusCode[xhr.status](xhr);
4148 }
4149
4150 fireCallback('complete', xhr, xhr.status);
4151 };
4152
4153 xhr.onerror = function onerror() {
4154 fireCallback('error', xhr, xhr.status, xhr.status);
4155 reject(new RequestError({
4156 options: options,
4157 xhr: xhr,
4158 status: xhr.status,
4159 message: xhr.statusText
4160 }));
4161 fireCallback('complete', xhr, 'error');
4162 }; // Timeout
4163
4164
4165 if (options.timeout > 0) {
4166 xhr.timeout = options.timeout;
4167
4168 xhr.ontimeout = function () {
4169 fireCallback('error', xhr, 'timeout', 'timeout');
4170 reject(new RequestError({
4171 options: options,
4172 xhr: xhr,
4173 status: 'timeout',
4174 message: 'timeout'
4175 }));
4176 fireCallback('complete', xhr, 'timeout');
4177 };
4178 } // Ajax start callback
4179
4180
4181 proceedRequest = fireCallback('beforeSend', xhr, options);
4182
4183 if (proceedRequest === false) {
4184 reject(new RequestError({
4185 options: options,
4186 xhr: xhr,
4187 status: 'canceled',
4188 message: 'canceled'
4189 }));
4190 return;
4191 } // Send XHR
4192
4193
4194 xhr.send(postData);
4195 });
4196 };
4197
4198 function requestShortcut(method) {
4199 var _ref = [],
4200 url = _ref[0],
4201 data = _ref[1],
4202 success = _ref[2],
4203 error = _ref[3],
4204 dataType = _ref[4];
4205
4206 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
4207 args[_key2 - 1] = arguments[_key2];
4208 }
4209
4210 if (typeof args[1] === 'function') {
4211 url = args[0];
4212 success = args[1];
4213 error = args[2];
4214 dataType = args[3];
4215 } else {
4216 url = args[0];
4217 data = args[1];
4218 success = args[2];
4219 error = args[3];
4220 dataType = args[4];
4221 }
4222
4223 [success, error].forEach(function (callback) {
4224 if (typeof callback === 'string') {
4225 dataType = callback;
4226 if (callback === success) success = undefined;else error = undefined;
4227 }
4228 });
4229 dataType = dataType || (method === 'json' || method === 'postJSON' ? 'json' : undefined);
4230 var requestOptions = {
4231 url: url,
4232 method: method === 'post' || method === 'postJSON' ? 'POST' : 'GET',
4233 data: data,
4234 success: success,
4235 error: error,
4236 dataType: dataType
4237 };
4238
4239 if (method === 'postJSON') {
4240 extend(requestOptions, {
4241 contentType: 'application/json',
4242 processData: false,
4243 crossDomain: true,
4244 data: typeof data === 'string' ? data : JSON.stringify(data)
4245 });
4246 }
4247
4248 return request(requestOptions);
4249 }
4250
4251 Object.assign(request, {
4252 get: function get() {
4253 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
4254 args[_key3] = arguments[_key3];
4255 }
4256
4257 return requestShortcut.apply(void 0, ['get'].concat(args));
4258 },
4259 post: function post() {
4260 for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
4261 args[_key4] = arguments[_key4];
4262 }
4263
4264 return requestShortcut.apply(void 0, ['post'].concat(args));
4265 },
4266 json: function json() {
4267 for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
4268 args[_key5] = arguments[_key5];
4269 }
4270
4271 return requestShortcut.apply(void 0, ['json'].concat(args));
4272 },
4273 getJSON: function getJSON() {
4274 for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
4275 args[_key6] = arguments[_key6];
4276 }
4277
4278 return requestShortcut.apply(void 0, ['json'].concat(args));
4279 },
4280 postJSON: function postJSON() {
4281 for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
4282 args[_key7] = arguments[_key7];
4283 }
4284
4285 return requestShortcut.apply(void 0, ['postJSON'].concat(args));
4286 }
4287 });
4288
4289 request.abortController = function () {
4290 var contoller = {
4291 canceled: false,
4292 onAbort: null,
4293 abort: function abort() {
4294 contoller.canceled = true;
4295 if (contoller.onAbort) contoller.onAbort();
4296 }
4297 };
4298 return contoller;
4299 };
4300
4301 request.setup = function setup(options) {
4302 if (options.type && !options.method) {
4303 extend(options, {
4304 method: options.type
4305 });
4306 }
4307
4308 extend(globals, options);
4309 };
4310
4311 /* eslint no-param-reassign: "off" */
4312 var RequestModule = {
4313 name: 'request',
4314 proto: {
4315 request: request
4316 },
4317 static: {
4318 request: request
4319 }
4320 };
4321
4322 /* eslint-disable no-nested-ternary */
4323
4324 function initTouch() {
4325 var app = this;
4326 var device = getDevice();
4327 var support = getSupport();
4328 var window = getWindow();
4329 var document = getDocument();
4330 var params = app.params.touch;
4331 var useRipple = params[app.theme + "TouchRipple"];
4332
4333 if (device.ios && device.webView) {
4334 // Strange hack required for iOS 8 webview to work on inputs
4335 window.addEventListener('touchstart', function () {});
4336 }
4337
4338 var touchStartX;
4339 var touchStartY;
4340 var targetElement;
4341 var isMoved;
4342 var tapHoldFired;
4343 var tapHoldTimeout;
4344 var preventClick;
4345 var activableElement;
4346 var activeTimeout;
4347 var rippleWave;
4348 var rippleTarget;
4349 var rippleTimeout;
4350
4351 function findActivableElement(el) {
4352 var target = $(el);
4353 var parents = target.parents(params.activeStateElements);
4354
4355 if (target.closest('.no-active-state').length) {
4356 return null;
4357 }
4358
4359 var activable;
4360
4361 if (target.is(params.activeStateElements)) {
4362 activable = target;
4363 }
4364
4365 if (parents.length > 0) {
4366 activable = activable ? activable.add(parents) : parents;
4367 }
4368
4369 if (activable && activable.length > 1) {
4370 var newActivable = [];
4371 var preventPropagation;
4372
4373 for (var i = 0; i < activable.length; i += 1) {
4374 if (!preventPropagation) {
4375 newActivable.push(activable[i]);
4376
4377 if (activable.eq(i).hasClass('prevent-active-state-propagation') || activable.eq(i).hasClass('no-active-state-propagation')) {
4378 preventPropagation = true;
4379 }
4380 }
4381 }
4382
4383 activable = $(newActivable);
4384 }
4385
4386 return activable || target;
4387 }
4388
4389 function isInsideScrollableView(el) {
4390 var pageContent = el.parents('.page-content');
4391 return pageContent.length > 0;
4392 }
4393
4394 function addActive() {
4395 if (!activableElement) return;
4396 activableElement.addClass('active-state');
4397 }
4398
4399 function removeActive() {
4400 if (!activableElement) return;
4401 activableElement.removeClass('active-state');
4402 activableElement = null;
4403 } // Ripple handlers
4404
4405
4406 function findRippleElement(el) {
4407 var rippleElements = params.touchRippleElements;
4408 var $el = $(el);
4409
4410 if ($el.is(rippleElements)) {
4411 if ($el.hasClass('no-ripple')) {
4412 return false;
4413 }
4414
4415 return $el;
4416 }
4417
4418 if ($el.parents(rippleElements).length > 0) {
4419 var rippleParent = $el.parents(rippleElements).eq(0);
4420
4421 if (rippleParent.hasClass('no-ripple')) {
4422 return false;
4423 }
4424
4425 return rippleParent;
4426 }
4427
4428 return false;
4429 }
4430
4431 function createRipple($el, x, y) {
4432 if (!$el) return;
4433 rippleWave = app.touchRipple.create(app, $el, x, y);
4434 }
4435
4436 function removeRipple() {
4437 if (!rippleWave) return;
4438 rippleWave.remove();
4439 rippleWave = undefined;
4440 rippleTarget = undefined;
4441 }
4442
4443 function rippleTouchStart(el) {
4444 rippleTarget = findRippleElement(el);
4445
4446 if (!rippleTarget || rippleTarget.length === 0) {
4447 rippleTarget = undefined;
4448 return;
4449 }
4450
4451 var inScrollable = isInsideScrollableView(rippleTarget);
4452
4453 if (!inScrollable) {
4454 removeRipple();
4455 createRipple(rippleTarget, touchStartX, touchStartY);
4456 } else {
4457 clearTimeout(rippleTimeout);
4458 rippleTimeout = setTimeout(function () {
4459 removeRipple();
4460 createRipple(rippleTarget, touchStartX, touchStartY);
4461 }, 80);
4462 }
4463 }
4464
4465 function rippleTouchMove() {
4466 clearTimeout(rippleTimeout);
4467 removeRipple();
4468 }
4469
4470 function rippleTouchEnd() {
4471 if (!rippleWave && rippleTarget && !isMoved) {
4472 clearTimeout(rippleTimeout);
4473 createRipple(rippleTarget, touchStartX, touchStartY);
4474 setTimeout(removeRipple, 0);
4475 } else {
4476 removeRipple();
4477 }
4478 } // Mouse Handlers
4479
4480
4481 function handleMouseDown(e) {
4482 var $activableEl = findActivableElement(e.target);
4483
4484 if ($activableEl) {
4485 $activableEl.addClass('active-state');
4486
4487 if ('which' in e && e.which === 3) {
4488 setTimeout(function () {
4489 $('.active-state').removeClass('active-state');
4490 }, 0);
4491 }
4492 }
4493
4494 if (useRipple) {
4495 touchStartX = e.pageX;
4496 touchStartY = e.pageY;
4497 rippleTouchStart(e.target, e.pageX, e.pageY);
4498 }
4499 }
4500
4501 function handleMouseMove() {
4502 if (!params.activeStateOnMouseMove) {
4503 $('.active-state').removeClass('active-state');
4504 }
4505
4506 if (useRipple) {
4507 rippleTouchMove();
4508 }
4509 }
4510
4511 function handleMouseUp() {
4512 $('.active-state').removeClass('active-state');
4513
4514 if (useRipple) {
4515 rippleTouchEnd();
4516 }
4517 }
4518
4519 function handleTouchCancel() {
4520 targetElement = null; // Remove Active State
4521
4522 clearTimeout(activeTimeout);
4523 clearTimeout(tapHoldTimeout);
4524
4525 if (params.activeState) {
4526 removeActive();
4527 } // Remove Ripple
4528
4529
4530 if (useRipple) {
4531 rippleTouchEnd();
4532 }
4533 }
4534
4535 function handleTouchStart(e) {
4536 isMoved = false;
4537 tapHoldFired = false;
4538 preventClick = false;
4539
4540 if (e.targetTouches.length > 1) {
4541 if (activableElement) removeActive();
4542 return true;
4543 }
4544
4545 if (e.touches.length > 1 && activableElement) {
4546 removeActive();
4547 }
4548
4549 if (params.tapHold) {
4550 if (tapHoldTimeout) clearTimeout(tapHoldTimeout);
4551 tapHoldTimeout = setTimeout(function () {
4552 if (e && e.touches && e.touches.length > 1) return;
4553 tapHoldFired = true;
4554 e.preventDefault();
4555 preventClick = true;
4556 $(e.target).trigger('taphold', e);
4557 app.emit('taphold', e);
4558 }, params.tapHoldDelay);
4559 }
4560
4561 targetElement = e.target;
4562 touchStartX = e.targetTouches[0].pageX;
4563 touchStartY = e.targetTouches[0].pageY;
4564
4565 if (params.activeState) {
4566 activableElement = findActivableElement(targetElement);
4567
4568 if (activableElement && !isInsideScrollableView(activableElement)) {
4569 addActive();
4570 } else if (activableElement) {
4571 activeTimeout = setTimeout(addActive, 80);
4572 }
4573 }
4574
4575 if (useRipple) {
4576 rippleTouchStart(targetElement);
4577 }
4578
4579 return true;
4580 }
4581
4582 function handleTouchMove(e) {
4583 var touch;
4584 var distance;
4585
4586 if (e.type === 'touchmove') {
4587 touch = e.targetTouches[0];
4588 distance = params.touchClicksDistanceThreshold;
4589 }
4590
4591 if (distance && touch) {
4592 var pageX = touch.pageX;
4593 var pageY = touch.pageY;
4594
4595 if (Math.abs(pageX - touchStartX) > distance || Math.abs(pageY - touchStartY) > distance) {
4596 isMoved = true;
4597 }
4598 } else {
4599 isMoved = true;
4600 }
4601
4602 if (isMoved) {
4603 preventClick = true;
4604
4605 if (params.tapHold) {
4606 clearTimeout(tapHoldTimeout);
4607 }
4608
4609 if (params.activeState) {
4610 clearTimeout(activeTimeout);
4611 removeActive();
4612 }
4613
4614 if (useRipple) {
4615 rippleTouchMove();
4616 }
4617 }
4618 }
4619
4620 function handleTouchEnd(e) {
4621 clearTimeout(activeTimeout);
4622 clearTimeout(tapHoldTimeout);
4623
4624 if (document.activeElement === e.target) {
4625 if (params.activeState) removeActive();
4626
4627 if (useRipple) {
4628 rippleTouchEnd();
4629 }
4630
4631 return true;
4632 }
4633
4634 if (params.activeState) {
4635 addActive();
4636 setTimeout(removeActive, 0);
4637 }
4638
4639 if (useRipple) {
4640 rippleTouchEnd();
4641 }
4642
4643 if (params.tapHoldPreventClicks && tapHoldFired || preventClick) {
4644 if (e.cancelable) e.preventDefault();
4645 preventClick = true;
4646 return false;
4647 }
4648
4649 return true;
4650 }
4651
4652 function handleClick(e) {
4653 var isOverswipe = e && e.detail && e.detail === 'f7Overswipe';
4654 var localPreventClick = preventClick;
4655
4656 if (targetElement && e.target !== targetElement) {
4657 if (isOverswipe) {
4658 localPreventClick = false;
4659 } else {
4660 localPreventClick = true;
4661 }
4662 }
4663
4664 if (params.tapHold && params.tapHoldPreventClicks && tapHoldFired) {
4665 localPreventClick = true;
4666 }
4667
4668 if (localPreventClick) {
4669 e.stopImmediatePropagation();
4670 e.stopPropagation();
4671 e.preventDefault();
4672 }
4673
4674 if (params.tapHold) {
4675 tapHoldTimeout = setTimeout(function () {
4676 tapHoldFired = false;
4677 }, device.ios || device.androidChrome ? 100 : 400);
4678 }
4679
4680 preventClick = false;
4681 targetElement = null;
4682 return !localPreventClick;
4683 }
4684
4685 function emitAppTouchEvent(name, e) {
4686 app.emit({
4687 events: name,
4688 data: [e]
4689 });
4690 }
4691
4692 function appClick(e) {
4693 emitAppTouchEvent('click', e);
4694 }
4695
4696 function appTouchStartActive(e) {
4697 emitAppTouchEvent('touchstart touchstart:active', e);
4698 }
4699
4700 function appTouchMoveActive(e) {
4701 emitAppTouchEvent('touchmove touchmove:active', e);
4702 }
4703
4704 function appTouchEndActive(e) {
4705 emitAppTouchEvent('touchend touchend:active', e);
4706 }
4707
4708 function appTouchStartPassive(e) {
4709 emitAppTouchEvent('touchstart:passive', e);
4710 }
4711
4712 function appTouchMovePassive(e) {
4713 emitAppTouchEvent('touchmove:passive', e);
4714 }
4715
4716 function appTouchEndPassive(e) {
4717 emitAppTouchEvent('touchend:passive', e);
4718 }
4719
4720 var passiveListener = support.passiveListener ? {
4721 passive: true
4722 } : false;
4723 var passiveListenerCapture = support.passiveListener ? {
4724 passive: true,
4725 capture: true
4726 } : true;
4727 var activeListener = support.passiveListener ? {
4728 passive: false
4729 } : false;
4730 var activeListenerCapture = support.passiveListener ? {
4731 passive: false,
4732 capture: true
4733 } : true;
4734 document.addEventListener('click', appClick, true);
4735
4736 if (support.passiveListener) {
4737 document.addEventListener(app.touchEvents.start, appTouchStartActive, activeListenerCapture);
4738 document.addEventListener(app.touchEvents.move, appTouchMoveActive, activeListener);
4739 document.addEventListener(app.touchEvents.end, appTouchEndActive, activeListener);
4740 document.addEventListener(app.touchEvents.start, appTouchStartPassive, passiveListenerCapture);
4741 document.addEventListener(app.touchEvents.move, appTouchMovePassive, passiveListener);
4742 document.addEventListener(app.touchEvents.end, appTouchEndPassive, passiveListener);
4743 } else {
4744 document.addEventListener(app.touchEvents.start, function (e) {
4745 appTouchStartActive(e);
4746 appTouchStartPassive(e);
4747 }, true);
4748 document.addEventListener(app.touchEvents.move, function (e) {
4749 appTouchMoveActive(e);
4750 appTouchMovePassive(e);
4751 }, false);
4752 document.addEventListener(app.touchEvents.end, function (e) {
4753 appTouchEndActive(e);
4754 appTouchEndPassive(e);
4755 }, false);
4756 }
4757
4758 if (support.touch) {
4759 app.on('click', handleClick);
4760 app.on('touchstart', handleTouchStart);
4761 app.on('touchmove', handleTouchMove);
4762 app.on('touchend', handleTouchEnd);
4763 document.addEventListener('touchcancel', handleTouchCancel, {
4764 passive: true
4765 });
4766 } else if (params.activeState) {
4767 app.on('touchstart', handleMouseDown);
4768 app.on('touchmove', handleMouseMove);
4769 app.on('touchend', handleMouseUp);
4770 document.addEventListener('pointercancel', handleMouseUp, {
4771 passive: true
4772 });
4773 }
4774
4775 document.addEventListener('contextmenu', function (e) {
4776 if (params.disableContextMenu && (device.ios || device.android || device.cordova || window.Capacitor && window.Capacitor.isNative)) {
4777 e.preventDefault();
4778 }
4779
4780 if (useRipple) {
4781 if (activableElement) removeActive();
4782 rippleTouchEnd();
4783 }
4784 });
4785 }
4786
4787 var TouchModule = {
4788 name: 'touch',
4789 params: {
4790 touch: {
4791 // Clicks
4792 touchClicksDistanceThreshold: 5,
4793 // ContextMenu
4794 disableContextMenu: false,
4795 // Tap Hold
4796 tapHold: false,
4797 tapHoldDelay: 750,
4798 tapHoldPreventClicks: true,
4799 // Active State
4800 activeState: true,
4801 activeStateElements: 'a, button, label, span, .actions-button, .stepper-button, .stepper-button-plus, .stepper-button-minus, .card-expandable, .menu-item, .link, .item-link, .accordion-item-toggle',
4802 activeStateOnMouseMove: false,
4803 mdTouchRipple: true,
4804 iosTouchRipple: false,
4805 auroraTouchRipple: false,
4806 touchRippleElements: '.ripple, .link, .item-link, .list-button, .links-list a, .button, button, .input-clear-button, .dialog-button, .tab-link, .item-radio, .item-checkbox, .actions-button, .searchbar-disable-button, .fab a, .checkbox, .radio, .data-table .sortable-cell:not(.input-cell), .notification-close-button, .stepper-button, .stepper-button-minus, .stepper-button-plus, .menu-item-content, .list.accordion-list .accordion-item-toggle',
4807 touchRippleInsetElements: '.ripple-inset, .icon-only, .searchbar-disable-button, .input-clear-button, .notification-close-button, .md .navbar .link.back'
4808 }
4809 },
4810 create: function create() {
4811 var app = this;
4812 var support = getSupport();
4813 extend(app, {
4814 touchEvents: {
4815 start: support.touch ? 'touchstart' : support.pointerEvents ? 'pointerdown' : 'mousedown',
4816 move: support.touch ? 'touchmove' : support.pointerEvents ? 'pointermove' : 'mousemove',
4817 end: support.touch ? 'touchend' : support.pointerEvents ? 'pointerup' : 'mouseup'
4818 }
4819 });
4820 },
4821 on: {
4822 init: initTouch
4823 }
4824 };
4825
4826 /**
4827 * Tokenize input string.
4828 */
4829 function lexer(str) {
4830 var tokens = [];
4831 var i = 0;
4832
4833 while (i < str.length) {
4834 var char = str[i];
4835
4836 if (char === "*" || char === "+" || char === "?") {
4837 tokens.push({
4838 type: "MODIFIER",
4839 index: i,
4840 value: str[i++]
4841 });
4842 continue;
4843 }
4844
4845 if (char === "\\") {
4846 tokens.push({
4847 type: "ESCAPED_CHAR",
4848 index: i++,
4849 value: str[i++]
4850 });
4851 continue;
4852 }
4853
4854 if (char === "{") {
4855 tokens.push({
4856 type: "OPEN",
4857 index: i,
4858 value: str[i++]
4859 });
4860 continue;
4861 }
4862
4863 if (char === "}") {
4864 tokens.push({
4865 type: "CLOSE",
4866 index: i,
4867 value: str[i++]
4868 });
4869 continue;
4870 }
4871
4872 if (char === ":") {
4873 var name = "";
4874 var j = i + 1;
4875
4876 while (j < str.length) {
4877 var code = str.charCodeAt(j);
4878
4879 if ( // `0-9`
4880 code >= 48 && code <= 57 || // `A-Z`
4881 code >= 65 && code <= 90 || // `a-z`
4882 code >= 97 && code <= 122 || // `_`
4883 code === 95) {
4884 name += str[j++];
4885 continue;
4886 }
4887
4888 break;
4889 }
4890
4891 if (!name) throw new TypeError("Missing parameter name at " + i);
4892 tokens.push({
4893 type: "NAME",
4894 index: i,
4895 value: name
4896 });
4897 i = j;
4898 continue;
4899 }
4900
4901 if (char === "(") {
4902 var count = 1;
4903 var pattern = "";
4904 var j = i + 1;
4905
4906 if (str[j] === "?") {
4907 throw new TypeError("Pattern cannot start with \"?\" at " + j);
4908 }
4909
4910 while (j < str.length) {
4911 if (str[j] === "\\") {
4912 pattern += str[j++] + str[j++];
4913 continue;
4914 }
4915
4916 if (str[j] === ")") {
4917 count--;
4918
4919 if (count === 0) {
4920 j++;
4921 break;
4922 }
4923 } else if (str[j] === "(") {
4924 count++;
4925
4926 if (str[j + 1] !== "?") {
4927 throw new TypeError("Capturing groups are not allowed at " + j);
4928 }
4929 }
4930
4931 pattern += str[j++];
4932 }
4933
4934 if (count) throw new TypeError("Unbalanced pattern at " + i);
4935 if (!pattern) throw new TypeError("Missing pattern at " + i);
4936 tokens.push({
4937 type: "PATTERN",
4938 index: i,
4939 value: pattern
4940 });
4941 i = j;
4942 continue;
4943 }
4944
4945 tokens.push({
4946 type: "CHAR",
4947 index: i,
4948 value: str[i++]
4949 });
4950 }
4951
4952 tokens.push({
4953 type: "END",
4954 index: i,
4955 value: ""
4956 });
4957 return tokens;
4958 }
4959 /**
4960 * Parse a string for the raw tokens.
4961 */
4962
4963
4964 function parse(str, options) {
4965 if (options === void 0) {
4966 options = {};
4967 }
4968
4969 var tokens = lexer(str);
4970 var _a = options.prefixes,
4971 prefixes = _a === void 0 ? "./" : _a;
4972 var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
4973 var result = [];
4974 var key = 0;
4975 var i = 0;
4976 var path = "";
4977
4978 var tryConsume = function tryConsume(type) {
4979 if (i < tokens.length && tokens[i].type === type) return tokens[i++].value;
4980 };
4981
4982 var mustConsume = function mustConsume(type) {
4983 var value = tryConsume(type);
4984 if (value !== undefined) return value;
4985 var _a = tokens[i],
4986 nextType = _a.type,
4987 index = _a.index;
4988 throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type);
4989 };
4990
4991 var consumeText = function consumeText() {
4992 var result = "";
4993 var value; // tslint:disable-next-line
4994
4995 while (value = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
4996 result += value;
4997 }
4998
4999 return result;
5000 };
5001
5002 while (i < tokens.length) {
5003 var char = tryConsume("CHAR");
5004 var name = tryConsume("NAME");
5005 var pattern = tryConsume("PATTERN");
5006
5007 if (name || pattern) {
5008 var prefix = char || "";
5009
5010 if (prefixes.indexOf(prefix) === -1) {
5011 path += prefix;
5012 prefix = "";
5013 }
5014
5015 if (path) {
5016 result.push(path);
5017 path = "";
5018 }
5019
5020 result.push({
5021 name: name || key++,
5022 prefix: prefix,
5023 suffix: "",
5024 pattern: pattern || defaultPattern,
5025 modifier: tryConsume("MODIFIER") || ""
5026 });
5027 continue;
5028 }
5029
5030 var value = char || tryConsume("ESCAPED_CHAR");
5031
5032 if (value) {
5033 path += value;
5034 continue;
5035 }
5036
5037 if (path) {
5038 result.push(path);
5039 path = "";
5040 }
5041
5042 var open = tryConsume("OPEN");
5043
5044 if (open) {
5045 var prefix = consumeText();
5046 var name_1 = tryConsume("NAME") || "";
5047 var pattern_1 = tryConsume("PATTERN") || "";
5048 var suffix = consumeText();
5049 mustConsume("CLOSE");
5050 result.push({
5051 name: name_1 || (pattern_1 ? key++ : ""),
5052 pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
5053 prefix: prefix,
5054 suffix: suffix,
5055 modifier: tryConsume("MODIFIER") || ""
5056 });
5057 continue;
5058 }
5059
5060 mustConsume("END");
5061 }
5062
5063 return result;
5064 }
5065 /**
5066 * Compile a string to a template function for the path.
5067 */
5068
5069 function compile(str, options) {
5070 return tokensToFunction(parse(str, options), options);
5071 }
5072 /**
5073 * Expose a method for transforming tokens into the path function.
5074 */
5075
5076 function tokensToFunction(tokens, options) {
5077 if (options === void 0) {
5078 options = {};
5079 }
5080
5081 var reFlags = flags(options);
5082 var _a = options.encode,
5083 encode = _a === void 0 ? function (x) {
5084 return x;
5085 } : _a,
5086 _b = options.validate,
5087 validate = _b === void 0 ? true : _b; // Compile all the tokens into regexps.
5088
5089 var matches = tokens.map(function (token) {
5090 if (typeof token === "object") {
5091 return new RegExp("^(?:" + token.pattern + ")$", reFlags);
5092 }
5093 });
5094 return function (data) {
5095 var path = "";
5096
5097 for (var i = 0; i < tokens.length; i++) {
5098 var token = tokens[i];
5099
5100 if (typeof token === "string") {
5101 path += token;
5102 continue;
5103 }
5104
5105 var value = data ? data[token.name] : undefined;
5106 var optional = token.modifier === "?" || token.modifier === "*";
5107 var repeat = token.modifier === "*" || token.modifier === "+";
5108
5109 if (Array.isArray(value)) {
5110 if (!repeat) {
5111 throw new TypeError("Expected \"" + token.name + "\" to not repeat, but got an array");
5112 }
5113
5114 if (value.length === 0) {
5115 if (optional) continue;
5116 throw new TypeError("Expected \"" + token.name + "\" to not be empty");
5117 }
5118
5119 for (var j = 0; j < value.length; j++) {
5120 var segment = encode(value[j], token);
5121
5122 if (validate && !matches[i].test(segment)) {
5123 throw new TypeError("Expected all \"" + token.name + "\" to match \"" + token.pattern + "\", but got \"" + segment + "\"");
5124 }
5125
5126 path += token.prefix + segment + token.suffix;
5127 }
5128
5129 continue;
5130 }
5131
5132 if (typeof value === "string" || typeof value === "number") {
5133 var segment = encode(String(value), token);
5134
5135 if (validate && !matches[i].test(segment)) {
5136 throw new TypeError("Expected \"" + token.name + "\" to match \"" + token.pattern + "\", but got \"" + segment + "\"");
5137 }
5138
5139 path += token.prefix + segment + token.suffix;
5140 continue;
5141 }
5142
5143 if (optional) continue;
5144 var typeOfMessage = repeat ? "an array" : "a string";
5145 throw new TypeError("Expected \"" + token.name + "\" to be " + typeOfMessage);
5146 }
5147
5148 return path;
5149 };
5150 }
5151 /**
5152 * Escape a regular expression string.
5153 */
5154
5155 function escapeString(str) {
5156 return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
5157 }
5158 /**
5159 * Get the flags for a regexp from the options.
5160 */
5161
5162
5163 function flags(options) {
5164 return options && options.sensitive ? "" : "i";
5165 }
5166 /**
5167 * Pull out keys from a regexp.
5168 */
5169
5170
5171 function regexpToRegexp(path, keys) {
5172 if (!keys) return path;
5173 var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
5174 var index = 0;
5175 var execResult = groupsRegex.exec(path.source);
5176
5177 while (execResult) {
5178 keys.push({
5179 // Use parenthesized substring match if available, index otherwise
5180 name: execResult[1] || index++,
5181 prefix: "",
5182 suffix: "",
5183 modifier: "",
5184 pattern: ""
5185 });
5186 execResult = groupsRegex.exec(path.source);
5187 }
5188
5189 return path;
5190 }
5191 /**
5192 * Transform an array into a regexp.
5193 */
5194
5195
5196 function arrayToRegexp(paths, keys, options) {
5197 var parts = paths.map(function (path) {
5198 return pathToRegexp(path, keys, options).source;
5199 });
5200 return new RegExp("(?:" + parts.join("|") + ")", flags(options));
5201 }
5202 /**
5203 * Create a path regexp from string input.
5204 */
5205
5206
5207 function stringToRegexp(path, keys, options) {
5208 return tokensToRegexp(parse(path, options), keys, options);
5209 }
5210 /**
5211 * Expose a function for taking tokens and returning a RegExp.
5212 */
5213
5214
5215 function tokensToRegexp(tokens, keys, options) {
5216 if (options === void 0) {
5217 options = {};
5218 }
5219
5220 var _a = options.strict,
5221 strict = _a === void 0 ? false : _a,
5222 _b = options.start,
5223 start = _b === void 0 ? true : _b,
5224 _c = options.end,
5225 end = _c === void 0 ? true : _c,
5226 _d = options.encode,
5227 encode = _d === void 0 ? function (x) {
5228 return x;
5229 } : _d;
5230 var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
5231 var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
5232 var route = start ? "^" : ""; // Iterate over the tokens and create our regexp string.
5233
5234 for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
5235 var token = tokens_1[_i];
5236
5237 if (typeof token === "string") {
5238 route += escapeString(encode(token));
5239 } else {
5240 var prefix = escapeString(encode(token.prefix));
5241 var suffix = escapeString(encode(token.suffix));
5242
5243 if (token.pattern) {
5244 if (keys) keys.push(token);
5245
5246 if (prefix || suffix) {
5247 if (token.modifier === "+" || token.modifier === "*") {
5248 var mod = token.modifier === "*" ? "?" : "";
5249 route += "(?:" + prefix + "((?:" + token.pattern + ")(?:" + suffix + prefix + "(?:" + token.pattern + "))*)" + suffix + ")" + mod;
5250 } else {
5251 route += "(?:" + prefix + "(" + token.pattern + ")" + suffix + ")" + token.modifier;
5252 }
5253 } else {
5254 route += "(" + token.pattern + ")" + token.modifier;
5255 }
5256 } else {
5257 route += "(?:" + prefix + suffix + ")" + token.modifier;
5258 }
5259 }
5260 }
5261
5262 if (end) {
5263 if (!strict) route += delimiter + "?";
5264 route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
5265 } else {
5266 var endToken = tokens[tokens.length - 1];
5267 var isEndDelimited = typeof endToken === "string" ? delimiter.indexOf(endToken[endToken.length - 1]) > -1 : // tslint:disable-next-line
5268 endToken === undefined;
5269
5270 if (!strict) {
5271 route += "(?:" + delimiter + "(?=" + endsWith + "))?";
5272 }
5273
5274 if (!isEndDelimited) {
5275 route += "(?=" + delimiter + "|" + endsWith + ")";
5276 }
5277 }
5278
5279 return new RegExp(route, flags(options));
5280 }
5281 /**
5282 * Normalize the given path string, returning a regular expression.
5283 *
5284 * An empty array can be passed in for the keys, which will hold the
5285 * placeholder key descriptions. For example, using `/user/:id`, `keys` will
5286 * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
5287 */
5288
5289 function pathToRegexp(path, keys, options) {
5290 if (path instanceof RegExp) return regexpToRegexp(path, keys);
5291 if (Array.isArray(path)) return arrayToRegexp(path, keys, options);
5292 return stringToRegexp(path, keys, options);
5293 }
5294
5295 var History = {
5296 queue: [],
5297 clearQueue: function clearQueue() {
5298 if (History.queue.length === 0) return;
5299 var currentQueue = History.queue.shift();
5300 currentQueue();
5301 },
5302 routerQueue: [],
5303 clearRouterQueue: function clearRouterQueue() {
5304 if (History.routerQueue.length === 0) return;
5305 var currentQueue = History.routerQueue.pop();
5306 var router = currentQueue.router,
5307 stateUrl = currentQueue.stateUrl,
5308 action = currentQueue.action;
5309 var animate = router.params.animate;
5310 if (router.params.browserHistoryAnimate === false) animate = false;
5311
5312 if (action === 'back') {
5313 router.back({
5314 animate: animate,
5315 browserHistory: false
5316 });
5317 }
5318
5319 if (action === 'load') {
5320 router.navigate(stateUrl, {
5321 animate: animate,
5322 browserHistory: false
5323 });
5324 }
5325 },
5326 handle: function handle(e) {
5327 if (History.blockPopstate) return;
5328 var app = this; // const mainView = app.views.main;
5329
5330 var state = e.state;
5331 History.previousState = History.state;
5332 History.state = state;
5333 History.allowChange = true;
5334 History.clearQueue();
5335 state = History.state;
5336 if (!state) state = {};
5337 app.views.forEach(function (view) {
5338 var router = view.router;
5339 var viewState = state[view.id];
5340
5341 if (!viewState && view.params.browserHistory) {
5342 viewState = {
5343 url: view.router.history[0]
5344 };
5345 }
5346
5347 if (!viewState) return;
5348 var stateUrl = viewState.url || undefined;
5349 var animate = router.params.animate;
5350 if (router.params.browserHistoryAnimate === false) animate = false;
5351
5352 if (stateUrl !== router.url) {
5353 if (router.history.indexOf(stateUrl) >= 0) {
5354 // Go Back
5355 if (router.allowPageChange) {
5356 router.back({
5357 animate: animate,
5358 browserHistory: false
5359 });
5360 } else {
5361 History.routerQueue.push({
5362 action: 'back',
5363 router: router
5364 });
5365 }
5366 } else if (router.allowPageChange) {
5367 // Load page
5368 router.navigate(stateUrl, {
5369 animate: animate,
5370 browserHistory: false
5371 });
5372 } else {
5373 History.routerQueue.unshift({
5374 action: 'load',
5375 stateUrl: stateUrl,
5376 router: router
5377 });
5378 }
5379 }
5380 });
5381 },
5382 initViewState: function initViewState(viewId, viewState) {
5383 var _extend;
5384
5385 var window = getWindow();
5386 var newState = extend({}, History.state || {}, (_extend = {}, _extend[viewId] = viewState, _extend));
5387 History.state = newState;
5388 window.history.replaceState(newState, '');
5389 },
5390 push: function push(viewId, viewState, url) {
5391 var _extend2;
5392
5393 var window = getWindow();
5394
5395 if (url.substr(-3) === '#!/') {
5396 // eslint-disable-next-line
5397 url = url.replace('#!/', '');
5398 }
5399
5400 if (!History.allowChange) {
5401 History.queue.push(function () {
5402 History.push(viewId, viewState, url);
5403 });
5404 return;
5405 }
5406
5407 History.previousState = History.state;
5408 var newState = extend({}, History.previousState || {}, (_extend2 = {}, _extend2[viewId] = viewState, _extend2));
5409 History.state = newState;
5410 window.history.pushState(newState, '', url);
5411 },
5412 replace: function replace(viewId, viewState, url) {
5413 var _extend3;
5414
5415 var window = getWindow();
5416
5417 if (url.substr(-3) === '#!/') {
5418 // eslint-disable-next-line
5419 url = url.replace('#!/', '');
5420 }
5421
5422 if (!History.allowChange) {
5423 History.queue.push(function () {
5424 History.replace(viewId, viewState, url);
5425 });
5426 return;
5427 }
5428
5429 History.previousState = History.state;
5430 var newState = extend({}, History.previousState || {}, (_extend3 = {}, _extend3[viewId] = viewState, _extend3));
5431 History.state = newState;
5432 window.history.replaceState(newState, '', url);
5433 },
5434 go: function go(index) {
5435 var window = getWindow();
5436 History.allowChange = false;
5437 window.history.go(index);
5438 },
5439 back: function back() {
5440 var window = getWindow();
5441 History.allowChange = false;
5442 window.history.back();
5443 },
5444 allowChange: true,
5445 previousState: {},
5446 state: {},
5447 blockPopstate: true,
5448 init: function init(app) {
5449 var window = getWindow();
5450 var document = getDocument();
5451 History.state = window.history.state;
5452 $(window).on('load', function () {
5453 setTimeout(function () {
5454 History.blockPopstate = false;
5455 }, 0);
5456 });
5457
5458 if (document.readyState && document.readyState === 'complete') {
5459 History.blockPopstate = false;
5460 }
5461
5462 $(window).on('popstate', History.handle.bind(app));
5463 }
5464 };
5465
5466 function SwipeBack(r) {
5467 var router = r;
5468 var $el = router.$el,
5469 $navbarsEl = router.$navbarsEl,
5470 app = router.app,
5471 params = router.params;
5472 var support = getSupport();
5473 var device = getDevice();
5474 var isTouched = false;
5475 var isMoved = false;
5476 var touchesStart = {};
5477 var isScrolling;
5478 var $currentPageEl = [];
5479 var $previousPageEl = [];
5480 var viewContainerWidth;
5481 var touchesDiff;
5482 var allowViewTouchMove = true;
5483 var touchStartTime;
5484 var $currentNavbarEl = [];
5485 var $previousNavbarEl = [];
5486 var dynamicNavbar;
5487 var $pageShadowEl;
5488 var $pageOpacityEl;
5489 var animatableNavEls;
5490 var paramsSwipeBackAnimateShadow = params[app.theme + "SwipeBackAnimateShadow"];
5491 var paramsSwipeBackAnimateOpacity = params[app.theme + "SwipeBackAnimateOpacity"];
5492 var paramsSwipeBackActiveArea = params[app.theme + "SwipeBackActiveArea"];
5493 var paramsSwipeBackThreshold = params[app.theme + "SwipeBackThreshold"];
5494 var transformOrigin = app.rtl ? 'right center' : 'left center';
5495 var transformOriginTitleLarge = app.rtl ? 'calc(100% - var(--f7-navbar-large-title-padding-left) - var(--f7-safe-area-left)) center' : 'calc(var(--f7-navbar-large-title-padding-left) + var(--f7-safe-area-left)) center';
5496
5497 function animatableNavElements() {
5498 var els = [];
5499 var inverter = app.rtl ? -1 : 1;
5500 var currentNavIsTransparent = $currentNavbarEl.hasClass('navbar-transparent') && !$currentNavbarEl.hasClass('navbar-large') && !$currentNavbarEl.hasClass('navbar-transparent-visible');
5501 var currentNavIsLarge = $currentNavbarEl.hasClass('navbar-large');
5502 var currentNavIsCollapsed = $currentNavbarEl.hasClass('navbar-large-collapsed');
5503 var currentNavIsLargeTransparent = $currentNavbarEl.hasClass('navbar-large-transparent') || $currentNavbarEl.hasClass('navbar-large') && $currentNavbarEl.hasClass('navbar-transparent');
5504 var previousNavIsTransparent = $previousNavbarEl.hasClass('navbar-transparent') && !$previousNavbarEl.hasClass('navbar-large') && !$previousNavbarEl.hasClass('navbar-transparent-visible');
5505 var previousNavIsLarge = $previousNavbarEl.hasClass('navbar-large');
5506 var previousNavIsCollapsed = $previousNavbarEl.hasClass('navbar-large-collapsed');
5507 var previousNavIsLargeTransparent = $previousNavbarEl.hasClass('navbar-large-transparent') || $previousNavbarEl.hasClass('navbar-large') && $previousNavbarEl.hasClass('navbar-transparent');
5508 var fromLarge = currentNavIsLarge && !currentNavIsCollapsed;
5509 var toLarge = previousNavIsLarge && !previousNavIsCollapsed;
5510 var $currentNavElements = $currentNavbarEl.find('.left, .title, .right, .subnavbar, .fading, .title-large, .navbar-bg');
5511 var $previousNavElements = $previousNavbarEl.find('.left, .title, .right, .subnavbar, .fading, .title-large, .navbar-bg');
5512 var activeNavBackIconText;
5513 var previousNavBackIconText;
5514
5515 if (params.iosAnimateNavbarBackIcon) {
5516 if ($currentNavbarEl.hasClass('sliding') || $currentNavbarEl.find('.navbar-inner.sliding').length) {
5517 activeNavBackIconText = $currentNavbarEl.find('.left').find('.back .icon + span').eq(0);
5518 } else {
5519 activeNavBackIconText = $currentNavbarEl.find('.left.sliding').find('.back .icon + span').eq(0);
5520 }
5521
5522 if ($previousNavbarEl.hasClass('sliding') || $previousNavbarEl.find('.navbar-inner.sliding').length) {
5523 previousNavBackIconText = $previousNavbarEl.find('.left').find('.back .icon + span').eq(0);
5524 } else {
5525 previousNavBackIconText = $previousNavbarEl.find('.left.sliding').find('.back .icon + span').eq(0);
5526 }
5527
5528 if (activeNavBackIconText.length) {
5529 $previousNavElements.each(function (el) {
5530 if (!$(el).hasClass('title')) return;
5531 el.f7NavbarLeftOffset += activeNavBackIconText.prev('.icon')[0].offsetWidth;
5532 });
5533 }
5534 }
5535
5536 $currentNavElements.each(function (navEl) {
5537 var $navEl = $(navEl);
5538 var isSubnavbar = $navEl.hasClass('subnavbar');
5539 var isLeft = $navEl.hasClass('left');
5540 var isTitle = $navEl.hasClass('title');
5541 var isBg = $navEl.hasClass('navbar-bg');
5542 if ((isTitle || isBg) && currentNavIsTransparent) return;
5543 if (!fromLarge && $navEl.hasClass('.title-large')) return;
5544 var el = {
5545 el: navEl
5546 };
5547
5548 if (fromLarge) {
5549 if (isTitle) return;
5550
5551 if ($navEl.hasClass('title-large')) {
5552 if (els.indexOf(el) < 0) els.push(el);
5553 el.overflow = 'visible';
5554 $navEl.find('.title-large-text').each(function (subNavEl) {
5555 els.push({
5556 el: subNavEl,
5557 transform: function transform(progress) {
5558 return "translateX(" + progress * 100 * inverter + "%)";
5559 }
5560 });
5561 });
5562 return;
5563 }
5564 }
5565
5566 if (toLarge) {
5567 if (!fromLarge) {
5568 if ($navEl.hasClass('title-large')) {
5569 if (els.indexOf(el) < 0) els.push(el);
5570 el.opacity = 0;
5571 }
5572 }
5573
5574 if (isLeft) {
5575 if (els.indexOf(el) < 0) els.push(el);
5576
5577 el.opacity = function (progress) {
5578 return 1 - Math.pow(progress, 0.33);
5579 };
5580
5581 $navEl.find('.back span').each(function (subNavEl) {
5582 els.push({
5583 el: subNavEl,
5584 'transform-origin': transformOrigin,
5585 transform: function transform(progress) {
5586 return "translateX(calc(" + progress + " * (var(--f7-navbarTitleLargeOffset) - var(--f7-navbarLeftTextOffset)))) translateY(calc(" + progress + " * (var(--f7-navbar-large-title-height) - var(--f7-navbar-large-title-padding-vertical) / 2))) scale(" + (1 + 1 * progress) + ")";
5587 }
5588 });
5589 });
5590 return;
5591 }
5592 }
5593
5594 if (isBg) {
5595 if (els.indexOf(el) < 0) els.push(el);
5596
5597 if (!fromLarge && !toLarge) {
5598 if (currentNavIsCollapsed) {
5599 if (currentNavIsLargeTransparent) {
5600 el.className = 'ios-swipeback-navbar-bg-large';
5601 }
5602
5603 el.transform = function (progress) {
5604 return "translateX(" + 100 * progress * inverter + "%) translateY(calc(-1 * var(--f7-navbar-large-title-height)))";
5605 };
5606 } else {
5607 el.transform = function (progress) {
5608 return "translateX(" + 100 * progress * inverter + "%)";
5609 };
5610 }
5611 }
5612
5613 if (!fromLarge && toLarge) {
5614 el.className = 'ios-swipeback-navbar-bg-large';
5615
5616 el.transform = function (progress) {
5617 return "translateX(" + 100 * progress * inverter + "%) translateY(calc(-1 * " + (1 - progress) + " * var(--f7-navbar-large-title-height)))";
5618 };
5619 }
5620
5621 if (fromLarge && toLarge) {
5622 el.transform = function (progress) {
5623 return "translateX(" + 100 * progress * inverter + "%)";
5624 };
5625 }
5626
5627 if (fromLarge && !toLarge) {
5628 el.transform = function (progress) {
5629 return "translateX(" + 100 * progress * inverter + "%) translateY(calc(-" + progress + " * var(--f7-navbar-large-title-height)))";
5630 };
5631 }
5632
5633 return;
5634 }
5635
5636 if ($navEl.hasClass('title-large')) return;
5637 var isSliding = $navEl.hasClass('sliding') || $navEl.parents('.navbar-inner.sliding').length;
5638 if (els.indexOf(el) < 0) els.push(el);
5639
5640 if (!isSubnavbar || isSubnavbar && !isSliding) {
5641 el.opacity = function (progress) {
5642 return 1 - Math.pow(progress, 0.33);
5643 };
5644 }
5645
5646 if (isSliding) {
5647 var transformTarget = el;
5648
5649 if (isLeft && activeNavBackIconText.length && params.iosAnimateNavbarBackIcon) {
5650 var textEl = {
5651 el: activeNavBackIconText[0]
5652 };
5653 transformTarget = textEl;
5654 els.push(textEl);
5655 }
5656
5657 transformTarget.transform = function (progress) {
5658 var activeNavTranslate = progress * transformTarget.el.f7NavbarRightOffset;
5659 if (device.pixelRatio === 1) activeNavTranslate = Math.round(activeNavTranslate);
5660
5661 if (isSubnavbar && currentNavIsLarge) {
5662 return "translate3d(" + activeNavTranslate + "px, calc(-1 * var(--f7-navbar-large-collapse-progress) * var(--f7-navbar-large-title-height)), 0)";
5663 }
5664
5665 return "translate3d(" + activeNavTranslate + "px,0,0)";
5666 };
5667 }
5668 });
5669 $previousNavElements.each(function (navEl) {
5670 var $navEl = $(navEl);
5671 var isSubnavbar = $navEl.hasClass('subnavbar');
5672 var isLeft = $navEl.hasClass('left');
5673 var isTitle = $navEl.hasClass('title');
5674 var isBg = $navEl.hasClass('navbar-bg');
5675 if ((isTitle || isBg) && previousNavIsTransparent) return;
5676 var el = {
5677 el: navEl
5678 };
5679
5680 if (toLarge) {
5681 if (isTitle) return;
5682 if (els.indexOf(el) < 0) els.push(el);
5683
5684 if ($navEl.hasClass('title-large')) {
5685 el.opacity = 1;
5686 el.overflow = 'visible';
5687 $navEl.find('.title-large-text').each(function (subNavEl) {
5688 els.push({
5689 el: subNavEl,
5690 'transform-origin': transformOriginTitleLarge,
5691 opacity: function opacity(progress) {
5692 return Math.pow(progress, 3);
5693 },
5694 transform: function transform(progress) {
5695 return "translateX(calc(" + (1 - progress) + " * (var(--f7-navbarLeftTextOffset) - var(--f7-navbarTitleLargeOffset)))) translateY(calc(" + (progress - 1) + " * var(--f7-navbar-large-title-height) + " + (1 - progress) + " * var(--f7-navbar-large-title-padding-vertical))) scale(" + (0.5 + progress * 0.5) + ")";
5696 }
5697 });
5698 });
5699 return;
5700 }
5701 }
5702
5703 if (isBg) {
5704 if (els.indexOf(el) < 0) els.push(el);
5705
5706 if (!fromLarge && !toLarge) {
5707 if (previousNavIsCollapsed) {
5708 if (previousNavIsLargeTransparent) {
5709 el.className = 'ios-swipeback-navbar-bg-large';
5710 }
5711
5712 el.transform = function (progress) {
5713 return "translateX(" + (-100 + 100 * progress) * inverter + "%) translateY(calc(-1 * var(--f7-navbar-large-title-height)))";
5714 };
5715 } else {
5716 el.transform = function (progress) {
5717 return "translateX(" + (-100 + 100 * progress) * inverter + "%)";
5718 };
5719 }
5720 }
5721
5722 if (!fromLarge && toLarge) {
5723 el.transform = function (progress) {
5724 return "translateX(" + (-100 + 100 * progress) * inverter + "%) translateY(calc(-1 * " + (1 - progress) + " * var(--f7-navbar-large-title-height)))";
5725 };
5726 }
5727
5728 if (fromLarge && !toLarge) {
5729 el.className = 'ios-swipeback-navbar-bg-large';
5730
5731 el.transform = function (progress) {
5732 return "translateX(" + (-100 + 100 * progress) * inverter + "%) translateY(calc(-" + progress + " * var(--f7-navbar-large-title-height)))";
5733 };
5734 }
5735
5736 if (fromLarge && toLarge) {
5737 el.transform = function (progress) {
5738 return "translateX(" + (-100 + 100 * progress) * inverter + "%)";
5739 };
5740 }
5741
5742 return;
5743 }
5744
5745 if ($navEl.hasClass('title-large')) return;
5746 var isSliding = $navEl.hasClass('sliding') || $previousNavbarEl.children('.navbar-inner.sliding').length;
5747 if (els.indexOf(el) < 0) els.push(el);
5748
5749 if (!isSubnavbar || isSubnavbar && !isSliding) {
5750 el.opacity = function (progress) {
5751 return Math.pow(progress, 3);
5752 };
5753 }
5754
5755 if (isSliding) {
5756 var transformTarget = el;
5757
5758 if (isLeft && previousNavBackIconText.length && params.iosAnimateNavbarBackIcon) {
5759 var textEl = {
5760 el: previousNavBackIconText[0]
5761 };
5762 transformTarget = textEl;
5763 els.push(textEl);
5764 }
5765
5766 transformTarget.transform = function (progress) {
5767 var previousNavTranslate = transformTarget.el.f7NavbarLeftOffset * (1 - progress);
5768 if (device.pixelRatio === 1) previousNavTranslate = Math.round(previousNavTranslate);
5769
5770 if (isSubnavbar && previousNavIsLarge) {
5771 return "translate3d(" + previousNavTranslate + "px, calc(-1 * var(--f7-navbar-large-collapse-progress) * var(--f7-navbar-large-title-height)), 0)";
5772 }
5773
5774 return "translate3d(" + previousNavTranslate + "px,0,0)";
5775 };
5776 }
5777 });
5778 return els;
5779 }
5780
5781 function setAnimatableNavElements(_temp) {
5782 var _ref = _temp === void 0 ? {} : _temp,
5783 progress = _ref.progress,
5784 reset = _ref.reset,
5785 transition = _ref.transition,
5786 reflow = _ref.reflow;
5787
5788 var styles = ['overflow', 'transform', 'transform-origin', 'opacity'];
5789
5790 if (transition === true || transition === false) {
5791 for (var i = 0; i < animatableNavEls.length; i += 1) {
5792 var el = animatableNavEls[i];
5793
5794 if (el && el.el) {
5795 if (transition === true) el.el.classList.add('navbar-page-transitioning');
5796 if (transition === false) el.el.classList.remove('navbar-page-transitioning');
5797 }
5798 }
5799 }
5800
5801 if (reflow && animatableNavEls.length && animatableNavEls[0] && animatableNavEls[0].el) {
5802 // eslint-disable-next-line
5803 animatableNavEls[0].el._clientLeft = animatableNavEls[0].el.clientLeft;
5804 }
5805
5806 for (var _i = 0; _i < animatableNavEls.length; _i += 1) {
5807 var _el = animatableNavEls[_i];
5808
5809 if (_el && _el.el) {
5810 if (_el.className && !_el.classNameSet && !reset) {
5811 _el.el.classList.add(_el.className);
5812
5813 _el.classNameSet = true;
5814 }
5815
5816 if (_el.className && reset) {
5817 _el.el.classList.remove(_el.className);
5818 }
5819
5820 for (var j = 0; j < styles.length; j += 1) {
5821 var styleProp = styles[j];
5822
5823 if (_el[styleProp]) {
5824 if (reset) {
5825 _el.el.style[styleProp] = '';
5826 } else if (typeof _el[styleProp] === 'function') {
5827 _el.el.style[styleProp] = _el[styleProp](progress);
5828 } else {
5829 _el.el.style[styleProp] = _el[styleProp];
5830 }
5831 }
5832 }
5833 }
5834 }
5835 }
5836
5837 function handleTouchStart(e) {
5838 var swipeBackEnabled = params[app.theme + "SwipeBack"];
5839 if (!allowViewTouchMove || !swipeBackEnabled || isTouched || app.swipeout && app.swipeout.el || !router.allowPageChange) return;
5840 if ($(e.target).closest('.range-slider, .calendar-months').length > 0) return;
5841 if ($(e.target).closest('.page-master, .page-master-detail').length > 0 && params.masterDetailBreakpoint > 0 && app.width >= params.masterDetailBreakpoint) return;
5842 isMoved = false;
5843 isTouched = true;
5844 isScrolling = undefined;
5845 touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
5846 touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
5847 touchStartTime = now();
5848 dynamicNavbar = router.dynamicNavbar;
5849 }
5850
5851 function handleTouchMove(e) {
5852 if (!isTouched) return;
5853 var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
5854 var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
5855
5856 if (typeof isScrolling === 'undefined') {
5857 isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x)) || pageX < touchesStart.x && !app.rtl || pageX > touchesStart.x && app.rtl;
5858 }
5859
5860 if (isScrolling || e.f7PreventSwipeBack || app.preventSwipeBack) {
5861 isTouched = false;
5862 return;
5863 }
5864
5865 if (!isMoved) {
5866 // Calc values during first move fired
5867 var cancel = false;
5868 var target = $(e.target);
5869 var swipeout = target.closest('.swipeout');
5870
5871 if (swipeout.length > 0) {
5872 if (!app.rtl && swipeout.find('.swipeout-actions-left').length > 0) cancel = true;
5873 if (app.rtl && swipeout.find('.swipeout-actions-right').length > 0) cancel = true;
5874 }
5875
5876 $currentPageEl = target.closest('.page');
5877 if ($currentPageEl.hasClass('no-swipeback') || target.closest('.no-swipeback, .card-opened').length > 0) cancel = true;
5878 $previousPageEl = $el.find('.page-previous:not(.stacked)');
5879
5880 if ($previousPageEl.length > 1) {
5881 $previousPageEl = $previousPageEl.eq($previousPageEl.length - 1);
5882 }
5883
5884 var notFromBorder = touchesStart.x - $el.offset().left > paramsSwipeBackActiveArea;
5885 viewContainerWidth = $el.width();
5886
5887 if (app.rtl) {
5888 notFromBorder = touchesStart.x < $el.offset().left - $el[0].scrollLeft + (viewContainerWidth - paramsSwipeBackActiveArea);
5889 } else {
5890 notFromBorder = touchesStart.x - $el.offset().left > paramsSwipeBackActiveArea;
5891 }
5892
5893 if (notFromBorder) cancel = true;
5894 if ($previousPageEl.length === 0 || $currentPageEl.length === 0) cancel = true;
5895
5896 if (cancel) {
5897 isTouched = false;
5898 return;
5899 }
5900
5901 if (paramsSwipeBackAnimateShadow) {
5902 $pageShadowEl = $currentPageEl.find('.page-shadow-effect');
5903
5904 if ($pageShadowEl.length === 0) {
5905 $pageShadowEl = $('<div class="page-shadow-effect"></div>');
5906 $currentPageEl.append($pageShadowEl);
5907 }
5908 }
5909
5910 if (paramsSwipeBackAnimateOpacity) {
5911 $pageOpacityEl = $previousPageEl.find('.page-opacity-effect');
5912
5913 if ($pageOpacityEl.length === 0) {
5914 $pageOpacityEl = $('<div class="page-opacity-effect"></div>');
5915 $previousPageEl.append($pageOpacityEl);
5916 }
5917 }
5918
5919 if (dynamicNavbar) {
5920 $currentNavbarEl = $navbarsEl.find('.navbar-current:not(.stacked)');
5921 $previousNavbarEl = $navbarsEl.find('.navbar-previous:not(.stacked)');
5922
5923 if ($previousNavbarEl.length > 1) {
5924 $previousNavbarEl = $previousNavbarEl.eq($previousNavbarEl.length - 1);
5925 }
5926
5927 animatableNavEls = animatableNavElements();
5928 } // Close/Hide Any Picker
5929
5930
5931 if ($('.sheet.modal-in').length > 0 && app.sheet) {
5932 app.sheet.close($('.sheet.modal-in'));
5933 }
5934 }
5935
5936 e.f7PreventSwipePanel = true;
5937 isMoved = true;
5938 app.preventSwipePanelBySwipeBack = true;
5939 e.preventDefault(); // RTL inverter
5940
5941 var inverter = app.rtl ? -1 : 1; // Touches diff
5942
5943 touchesDiff = (pageX - touchesStart.x - paramsSwipeBackThreshold) * inverter;
5944 if (touchesDiff < 0) touchesDiff = 0;
5945 var percentage = Math.min(Math.max(touchesDiff / viewContainerWidth, 0), 1); // Swipe Back Callback
5946
5947 var callbackData = {
5948 percentage: percentage,
5949 progress: percentage,
5950 currentPageEl: $currentPageEl[0],
5951 previousPageEl: $previousPageEl[0],
5952 currentNavbarEl: $currentNavbarEl[0],
5953 previousNavbarEl: $previousNavbarEl[0]
5954 };
5955 $el.trigger('swipeback:move', callbackData);
5956 router.emit('swipebackMove', callbackData); // Transform pages
5957
5958 var currentPageTranslate = touchesDiff * inverter;
5959 var previousPageTranslate = (touchesDiff / 5 - viewContainerWidth / 5) * inverter;
5960
5961 if (!app.rtl) {
5962 currentPageTranslate = Math.min(currentPageTranslate, viewContainerWidth);
5963 previousPageTranslate = Math.min(previousPageTranslate, 0);
5964 } else {
5965 currentPageTranslate = Math.max(currentPageTranslate, -viewContainerWidth);
5966 previousPageTranslate = Math.max(previousPageTranslate, 0);
5967 }
5968
5969 if (device.pixelRatio === 1) {
5970 currentPageTranslate = Math.round(currentPageTranslate);
5971 previousPageTranslate = Math.round(previousPageTranslate);
5972 }
5973
5974 router.swipeBackActive = true;
5975 $([$currentPageEl[0], $previousPageEl[0]]).addClass('page-swipeback-active');
5976 $currentPageEl.transform("translate3d(" + currentPageTranslate + "px,0,0)");
5977 if (paramsSwipeBackAnimateShadow) $pageShadowEl[0].style.opacity = 1 - 1 * percentage;
5978
5979 if (app.theme === 'ios') {
5980 $previousPageEl.transform("translate3d(" + previousPageTranslate + "px,0,0)");
5981 }
5982
5983 if (paramsSwipeBackAnimateOpacity) $pageOpacityEl[0].style.opacity = 1 - 1 * percentage; // Dynamic Navbars Animation
5984
5985 if (!dynamicNavbar) return;
5986 setAnimatableNavElements({
5987 progress: percentage
5988 });
5989 }
5990
5991 function handleTouchEnd() {
5992 app.preventSwipePanelBySwipeBack = false;
5993
5994 if (!isTouched || !isMoved) {
5995 isTouched = false;
5996 isMoved = false;
5997 return;
5998 }
5999
6000 isTouched = false;
6001 isMoved = false;
6002 router.swipeBackActive = false;
6003 var $pages = $([$currentPageEl[0], $previousPageEl[0]]);
6004 $pages.removeClass('page-swipeback-active');
6005
6006 if (touchesDiff === 0) {
6007 $pages.transform('');
6008 if ($pageShadowEl && $pageShadowEl.length > 0) $pageShadowEl.remove();
6009 if ($pageOpacityEl && $pageOpacityEl.length > 0) $pageOpacityEl.remove();
6010
6011 if (dynamicNavbar) {
6012 setAnimatableNavElements({
6013 reset: true
6014 });
6015 }
6016
6017 return;
6018 }
6019
6020 var timeDiff = now() - touchStartTime;
6021 var pageChanged = false; // Swipe back to previous page
6022
6023 if (timeDiff < 300 && touchesDiff > 10 || timeDiff >= 300 && touchesDiff > viewContainerWidth / 2) {
6024 $currentPageEl.removeClass('page-current').addClass("page-next" + (app.theme !== 'ios' ? ' page-next-on-right' : ''));
6025 $previousPageEl.removeClass('page-previous').addClass('page-current').removeAttr('aria-hidden');
6026 if ($pageShadowEl) $pageShadowEl[0].style.opacity = '';
6027 if ($pageOpacityEl) $pageOpacityEl[0].style.opacity = '';
6028
6029 if (dynamicNavbar) {
6030 router.setNavbarPosition($currentNavbarEl, 'next');
6031 router.setNavbarPosition($previousNavbarEl, 'current', false);
6032 }
6033
6034 pageChanged = true;
6035 } // Reset custom styles
6036 // Add transitioning class for transition-duration
6037
6038
6039 $pages.addClass('page-transitioning page-transitioning-swipeback');
6040
6041 if (device.ios) {
6042 // eslint-disable-next-line
6043 $currentPageEl[0]._clientLeft = $currentPageEl[0].clientLeft;
6044 }
6045
6046 $pages.transform('');
6047
6048 if (dynamicNavbar) {
6049 setAnimatableNavElements({
6050 progress: pageChanged ? 1 : 0,
6051 transition: true,
6052 reflow: !!device.ios
6053 });
6054 }
6055
6056 allowViewTouchMove = false;
6057 router.allowPageChange = false; // Swipe Back Callback
6058
6059 var callbackData = {
6060 currentPageEl: $currentPageEl[0],
6061 previousPageEl: $previousPageEl[0],
6062 currentNavbarEl: $currentNavbarEl[0],
6063 previousNavbarEl: $previousNavbarEl[0]
6064 };
6065
6066 if (pageChanged) {
6067 // Update Route
6068 router.currentRoute = $previousPageEl[0].f7Page.route;
6069 router.currentPage = $previousPageEl[0]; // Page before animation callback
6070
6071 router.pageCallback('beforeOut', $currentPageEl, $currentNavbarEl, 'current', 'next', {
6072 route: $currentPageEl[0].f7Page.route,
6073 swipeBack: true
6074 });
6075 router.pageCallback('beforeIn', $previousPageEl, $previousNavbarEl, 'previous', 'current', {
6076 route: $previousPageEl[0].f7Page.route,
6077 swipeBack: true
6078 }, $currentPageEl[0]);
6079 $el.trigger('swipeback:beforechange', callbackData);
6080 router.emit('swipebackBeforeChange', callbackData);
6081 } else {
6082 $el.trigger('swipeback:beforereset', callbackData);
6083 router.emit('swipebackBeforeReset', callbackData);
6084 }
6085
6086 $currentPageEl.transitionEnd(function () {
6087 $pages.removeClass('page-transitioning page-transitioning-swipeback');
6088
6089 if (dynamicNavbar) {
6090 setAnimatableNavElements({
6091 reset: true,
6092 transition: false
6093 });
6094 }
6095
6096 allowViewTouchMove = true;
6097 router.allowPageChange = true;
6098
6099 if (pageChanged) {
6100 // Update History
6101 if (router.history.length === 1) {
6102 router.history.unshift(router.url);
6103 }
6104
6105 router.history.pop();
6106 router.saveHistory(); // Update push state
6107
6108 if (params.browserHistory) {
6109 History.back();
6110 } // Page after animation callback
6111
6112
6113 router.pageCallback('afterOut', $currentPageEl, $currentNavbarEl, 'current', 'next', {
6114 route: $currentPageEl[0].f7Page.route,
6115 swipeBack: true
6116 });
6117 router.pageCallback('afterIn', $previousPageEl, $previousNavbarEl, 'previous', 'current', {
6118 route: $previousPageEl[0].f7Page.route,
6119 swipeBack: true
6120 }); // Remove Old Page
6121
6122 if (params.stackPages && router.initialPages.indexOf($currentPageEl[0]) >= 0) {
6123 $currentPageEl.addClass('stacked');
6124
6125 if (dynamicNavbar) {
6126 $currentNavbarEl.addClass('stacked');
6127 }
6128 } else {
6129 router.pageCallback('beforeRemove', $currentPageEl, $currentNavbarEl, 'next', {
6130 swipeBack: true
6131 });
6132 router.removePage($currentPageEl);
6133
6134 if (dynamicNavbar) {
6135 router.removeNavbar($currentNavbarEl);
6136 }
6137 }
6138
6139 $el.trigger('swipeback:afterchange', callbackData);
6140 router.emit('swipebackAfterChange', callbackData);
6141 router.emit('routeChanged', router.currentRoute, router.previousRoute, router);
6142
6143 if (params.preloadPreviousPage) {
6144 router.back(router.history[router.history.length - 2], {
6145 preload: true
6146 });
6147 }
6148 } else {
6149 $el.trigger('swipeback:afterreset', callbackData);
6150 router.emit('swipebackAfterReset', callbackData);
6151 }
6152
6153 if ($pageShadowEl && $pageShadowEl.length > 0) $pageShadowEl.remove();
6154 if ($pageOpacityEl && $pageOpacityEl.length > 0) $pageOpacityEl.remove();
6155 });
6156 }
6157
6158 function attachEvents() {
6159 var passiveListener = app.touchEvents.start === 'touchstart' && support.passiveListener ? {
6160 passive: true,
6161 capture: false
6162 } : false;
6163 $el.on(app.touchEvents.start, handleTouchStart, passiveListener);
6164 app.on('touchmove:active', handleTouchMove);
6165 app.on('touchend:passive', handleTouchEnd);
6166 }
6167
6168 function detachEvents() {
6169 var passiveListener = app.touchEvents.start === 'touchstart' && support.passiveListener ? {
6170 passive: true,
6171 capture: false
6172 } : false;
6173 $el.off(app.touchEvents.start, handleTouchStart, passiveListener);
6174 app.off('touchmove:active', handleTouchMove);
6175 app.off('touchend:passive', handleTouchEnd);
6176 }
6177
6178 attachEvents();
6179 router.on('routerDestroy', detachEvents);
6180 }
6181
6182 function redirect(direction, route, options) {
6183 var router = this;
6184 var r = route.route.redirect;
6185 var method = direction === 'forward' ? 'navigate' : 'back';
6186
6187 if (options.initial && router.params.browserHistory) {
6188 options.replaceState = true; // eslint-disable-line
6189
6190 options.history = true; // eslint-disable-line
6191 }
6192
6193 function redirectResolve(redirectUrl, redirectOptions) {
6194 if (redirectOptions === void 0) {
6195 redirectOptions = {};
6196 }
6197
6198 router.allowPageChange = true;
6199 router[method](redirectUrl, extend({}, options, redirectOptions));
6200 }
6201
6202 function redirectReject() {
6203 router.allowPageChange = true;
6204 }
6205
6206 if (typeof r === 'function') {
6207 router.allowPageChange = false;
6208 var redirectUrl = r.call(router, {
6209 router: router,
6210 to: route,
6211 resolve: redirectResolve,
6212 reject: redirectReject,
6213 direction: direction,
6214 app: router.app
6215 });
6216
6217 if (redirectUrl && typeof redirectUrl === 'string') {
6218 router.allowPageChange = true;
6219 return router[method](redirectUrl, options);
6220 }
6221
6222 return router;
6223 }
6224
6225 return router[method](r, options);
6226 }
6227
6228 function processQueue(router, routerQueue, routeQueue, to, from, resolve, _reject, direction) {
6229 var queue = [];
6230
6231 if (Array.isArray(routeQueue)) {
6232 queue.push.apply(queue, routeQueue);
6233 } else if (routeQueue && typeof routeQueue === 'function') {
6234 queue.push(routeQueue);
6235 }
6236
6237 if (routerQueue) {
6238 if (Array.isArray(routerQueue)) {
6239 queue.push.apply(queue, routerQueue);
6240 } else {
6241 queue.push(routerQueue);
6242 }
6243 }
6244
6245 function next() {
6246 if (queue.length === 0) {
6247 resolve();
6248 return;
6249 }
6250
6251 var queueItem = queue.shift();
6252 queueItem.call(router, {
6253 router: router,
6254 to: to,
6255 from: from,
6256 resolve: function resolve() {
6257 next();
6258 },
6259 reject: function reject() {
6260 _reject();
6261 },
6262 direction: direction,
6263 app: router.app
6264 });
6265 }
6266
6267 next();
6268 }
6269
6270 function processRouteQueue(to, from, resolve, reject, direction) {
6271 var router = this;
6272
6273 function enterNextRoute() {
6274 if (to && to.route && (router.params.routesBeforeEnter || to.route.beforeEnter)) {
6275 router.allowPageChange = false;
6276 processQueue(router, router.params.routesBeforeEnter, to.route.beforeEnter, to, from, function () {
6277 router.allowPageChange = true;
6278 resolve();
6279 }, function () {
6280 reject();
6281 }, direction);
6282 } else {
6283 resolve();
6284 }
6285 }
6286
6287 function leaveCurrentRoute() {
6288 if (from && from.route && (router.params.routesBeforeLeave || from.route.beforeLeave)) {
6289 router.allowPageChange = false;
6290 processQueue(router, router.params.routesBeforeLeave, from.route.beforeLeave, to, from, function () {
6291 router.allowPageChange = true;
6292 enterNextRoute();
6293 }, function () {
6294 reject();
6295 }, direction);
6296 } else {
6297 enterNextRoute();
6298 }
6299 }
6300
6301 leaveCurrentRoute();
6302 }
6303
6304 function appRouterCheck(router, method) {
6305 if (!router.view) {
6306 throw new Error("Framework7: it is not allowed to use router methods on global app router. Use router methods only on related View, e.g. app.views.main.router." + method + "(...)");
6307 }
6308 }
6309
6310 function asyncComponent(router, component, resolve, reject) {
6311 function resolvePromise(componentPromise) {
6312 componentPromise.then(function (c) {
6313 // eslint-disable-next-line
6314 resolve({
6315 component: c.default || c._default || c
6316 });
6317 }).catch(function (err) {
6318 reject();
6319 throw new Error(err);
6320 });
6321 }
6322
6323 if (component instanceof Promise) {
6324 resolvePromise(component);
6325 return;
6326 }
6327
6328 var asyncComponentResult = component.call(router);
6329
6330 if (asyncComponentResult instanceof Promise) {
6331 resolvePromise(asyncComponentResult);
6332 } else {
6333 resolve({
6334 component: asyncComponentResult
6335 });
6336 }
6337 }
6338
6339 function refreshPage() {
6340 var router = this;
6341 appRouterCheck(router, 'refreshPage');
6342 return router.navigate(router.currentRoute.url, {
6343 ignoreCache: true,
6344 reloadCurrent: true
6345 });
6346 }
6347
6348 function forward(router, el, forwardOptions) {
6349 if (forwardOptions === void 0) {
6350 forwardOptions = {};
6351 }
6352
6353 var document = getDocument();
6354 var $el = $(el);
6355 var app = router.app;
6356 var view = router.view;
6357 var options = extend(false, {
6358 animate: router.params.animate,
6359 browserHistory: true,
6360 replaceState: false,
6361 history: true,
6362 reloadCurrent: router.params.reloadPages,
6363 reloadPrevious: false,
6364 reloadAll: false,
6365 clearPreviousHistory: false,
6366 reloadDetail: router.params.reloadDetail,
6367 on: {}
6368 }, forwardOptions);
6369 var masterDetailEnabled = router.params.masterDetailBreakpoint > 0;
6370 var isMaster = masterDetailEnabled && options.route && options.route.route && (options.route.route.master === true || typeof options.route.route.master === 'function' && options.route.route.master(app, router));
6371 var masterPageEl;
6372 var otherDetailPageEl;
6373 var detailsInBetweenRemoved = 0;
6374 var currentRouteIsModal = router.currentRoute.modal;
6375 var modalType;
6376
6377 if (!currentRouteIsModal) {
6378 'popup popover sheet loginScreen actions customModal panel'.split(' ').forEach(function (modalLoadProp) {
6379 if (router.currentRoute && router.currentRoute.route && router.currentRoute.route[modalLoadProp]) {
6380 currentRouteIsModal = true;
6381 modalType = modalLoadProp;
6382 }
6383 });
6384 }
6385
6386 if (currentRouteIsModal) {
6387 var modalToClose = router.currentRoute.modal || router.currentRoute.route.modalInstance || app[modalType].get();
6388 var previousUrl = router.history[router.history.length - 2];
6389 var previousRoute = router.findMatchingRoute(previousUrl);
6390
6391 if (!previousRoute && previousUrl) {
6392 previousRoute = {
6393 url: previousUrl,
6394 path: previousUrl.split('?')[0],
6395 query: parseUrlQuery(previousUrl),
6396 route: {
6397 path: previousUrl.split('?')[0],
6398 url: previousUrl
6399 }
6400 };
6401 }
6402
6403 router.modalRemove(modalToClose);
6404 }
6405
6406 var dynamicNavbar = router.dynamicNavbar;
6407 var $viewEl = router.$el;
6408 var $newPage = $el;
6409 var reload = options.reloadPrevious || options.reloadCurrent || options.reloadAll;
6410 var $oldPage;
6411 var $navbarsEl;
6412 var $newNavbarEl;
6413 var $oldNavbarEl;
6414 router.allowPageChange = false;
6415
6416 if ($newPage.length === 0) {
6417 router.allowPageChange = true;
6418 return router;
6419 }
6420
6421 if ($newPage.length) {
6422 // Remove theme elements
6423 router.removeThemeElements($newPage);
6424 }
6425
6426 if (dynamicNavbar) {
6427 $newNavbarEl = $newPage.children('.navbar');
6428 $navbarsEl = router.$navbarsEl;
6429
6430 if ($newNavbarEl.length === 0 && $newPage[0] && $newPage[0].f7Page) {
6431 // Try from pageData
6432 $newNavbarEl = $newPage[0].f7Page.$navbarEl;
6433 }
6434 } // Save Keep Alive Cache
6435
6436
6437 if (options.route && options.route.route && options.route.route.keepAlive && !options.route.route.keepAliveData) {
6438 options.route.route.keepAliveData = {
6439 pageEl: $el[0]
6440 };
6441 } // Pages In View
6442
6443
6444 var $pagesInView = $viewEl.children('.page:not(.stacked)').filter(function (pageInView) {
6445 return pageInView !== $newPage[0];
6446 }); // Navbars In View
6447
6448 var $navbarsInView;
6449
6450 if (dynamicNavbar) {
6451 $navbarsInView = $navbarsEl.children('.navbar:not(.stacked)').filter(function (navbarInView) {
6452 return navbarInView !== $newNavbarEl[0];
6453 });
6454 } // Exit when reload previous and only 1 page in view so nothing ro reload
6455
6456
6457 if (options.reloadPrevious && $pagesInView.length < 2) {
6458 router.allowPageChange = true;
6459 return router;
6460 } // Find Detail' master page
6461
6462
6463 var isDetail;
6464 var reloadDetail;
6465 var isDetailRoot;
6466
6467 if (masterDetailEnabled && !options.reloadAll) {
6468 for (var i = 0; i < $pagesInView.length; i += 1) {
6469 if (!masterPageEl && $pagesInView[i].classList.contains('page-master')) {
6470 masterPageEl = $pagesInView[i];
6471 continue; // eslint-disable-line
6472 }
6473 }
6474
6475 isDetail = !isMaster && masterPageEl;
6476
6477 if (isDetail) {
6478 // Find Other Detail
6479 if (masterPageEl) {
6480 for (var _i = 0; _i < $pagesInView.length; _i += 1) {
6481 if ($pagesInView[_i].classList.contains('page-master-detail')) {
6482 otherDetailPageEl = $pagesInView[_i];
6483 continue; // eslint-disable-line
6484 }
6485 }
6486 }
6487 }
6488
6489 reloadDetail = isDetail && options.reloadDetail && app.width >= router.params.masterDetailBreakpoint && masterPageEl;
6490 }
6491
6492 if (isDetail) {
6493 isDetailRoot = !otherDetailPageEl || reloadDetail || options.reloadAll || options.reloadCurrent;
6494 } // New Page
6495
6496
6497 var newPagePosition = 'next';
6498
6499 if (options.reloadCurrent || options.reloadAll || reloadDetail) {
6500 newPagePosition = 'current';
6501 } else if (options.reloadPrevious) {
6502 newPagePosition = 'previous';
6503 }
6504
6505 $newPage.removeClass('page-previous page-current page-next').addClass("page-" + newPagePosition + (isMaster ? ' page-master' : '') + (isDetail ? ' page-master-detail' : '') + (isDetailRoot ? ' page-master-detail-root' : '')).removeClass('stacked').trigger('page:unstack').trigger('page:position', {
6506 position: newPagePosition
6507 });
6508 router.emit('pageUnstack', $newPage[0]);
6509 router.emit('pagePosition', $newPage[0], newPagePosition);
6510
6511 if (isMaster || isDetail) {
6512 $newPage.trigger('page:role', {
6513 role: isMaster ? 'master' : 'detail',
6514 root: !!isDetailRoot
6515 });
6516 router.emit('pageRole', $newPage[0], {
6517 role: isMaster ? 'master' : 'detail',
6518 detailRoot: !!isDetailRoot
6519 });
6520 }
6521
6522 if (dynamicNavbar && $newNavbarEl.length) {
6523 $newNavbarEl.removeClass('navbar-previous navbar-current navbar-next').addClass("navbar-" + newPagePosition + (isMaster ? ' navbar-master' : '') + (isDetail ? ' navbar-master-detail' : '') + (isDetailRoot ? ' navbar-master-detail-root' : '')).removeClass('stacked');
6524 $newNavbarEl.trigger('navbar:position', {
6525 position: newPagePosition
6526 });
6527 router.emit('navbarPosition', $newNavbarEl[0], newPagePosition);
6528
6529 if (isMaster || isDetail) {
6530 router.emit('navbarRole', $newNavbarEl[0], {
6531 role: isMaster ? 'master' : 'detail',
6532 detailRoot: !!isDetailRoot
6533 });
6534 }
6535 } // Find Old Page
6536
6537
6538 if (options.reloadCurrent || reloadDetail) {
6539 if (reloadDetail) {
6540 $oldPage = $pagesInView.filter(function (pageEl) {
6541 return !pageEl.classList.contains('page-master');
6542 });
6543
6544 if (dynamicNavbar) {
6545 $oldNavbarEl = $($oldPage.map(function (pageEl) {
6546 return app.navbar.getElByPage(pageEl);
6547 }));
6548 }
6549
6550 if ($oldPage.length > 1 && masterPageEl) {
6551 detailsInBetweenRemoved = $oldPage.length - 1;
6552 $(masterPageEl).removeClass('page-master-stacked').trigger('page:masterunstack');
6553 router.emit('pageMasterUnstack', masterPageEl);
6554
6555 if (dynamicNavbar) {
6556 $(app.navbar.getElByPage(masterPageEl)).removeClass('navbar-master-stacked');
6557 router.emit('navbarMasterUnstack', app.navbar.getElByPage(masterPageEl));
6558 }
6559 }
6560 } else {
6561 $oldPage = $pagesInView.eq($pagesInView.length - 1);
6562
6563 if (dynamicNavbar) {
6564 $oldNavbarEl = $(app.navbar.getElByPage($oldPage));
6565 }
6566 }
6567 } else if (options.reloadPrevious) {
6568 $oldPage = $pagesInView.eq($pagesInView.length - 2);
6569
6570 if (dynamicNavbar) {
6571 // $oldNavbarEl = $navbarsInView.eq($pagesInView.length - 2);
6572 $oldNavbarEl = $(app.navbar.getElByPage($oldPage));
6573 }
6574 } else if (options.reloadAll) {
6575 $oldPage = $pagesInView.filter(function (pageEl) {
6576 return pageEl !== $newPage[0];
6577 });
6578
6579 if (dynamicNavbar) {
6580 $oldNavbarEl = $navbarsInView.filter(function (navbarEl) {
6581 return navbarEl !== $newNavbarEl[0];
6582 });
6583 }
6584 } else {
6585 var removedPageEls = [];
6586 var removedNavbarEls = [];
6587
6588 if ($pagesInView.length > 1) {
6589 var _i2 = 0;
6590
6591 for (_i2 = 0; _i2 < $pagesInView.length - 1; _i2 += 1) {
6592 if (masterPageEl && $pagesInView[_i2] === masterPageEl) {
6593 $pagesInView.eq(_i2).addClass('page-master-stacked');
6594 $pagesInView.eq(_i2).trigger('page:masterstack');
6595 router.emit('pageMasterStack', $pagesInView[_i2]);
6596
6597 if (dynamicNavbar) {
6598 $(app.navbar.getElByPage(masterPageEl)).addClass('navbar-master-stacked');
6599 router.emit('navbarMasterStack', app.navbar.getElByPage(masterPageEl));
6600 }
6601
6602 continue; // eslint-disable-line
6603 }
6604
6605 var oldNavbarEl = app.navbar.getElByPage($pagesInView.eq(_i2));
6606
6607 if (router.params.stackPages) {
6608 $pagesInView.eq(_i2).addClass('stacked');
6609 $pagesInView.eq(_i2).trigger('page:stack');
6610 router.emit('pageStack', $pagesInView[_i2]);
6611
6612 if (dynamicNavbar) {
6613 $(oldNavbarEl).addClass('stacked');
6614 }
6615 } else {
6616 // Page remove event
6617 removedPageEls.push($pagesInView[_i2]);
6618 router.pageCallback('beforeRemove', $pagesInView[_i2], $navbarsInView && $navbarsInView[_i2], 'previous', undefined, options);
6619 router.removePage($pagesInView[_i2]);
6620
6621 if (dynamicNavbar && oldNavbarEl) {
6622 removedNavbarEls.push(oldNavbarEl);
6623 router.removeNavbar(oldNavbarEl);
6624 }
6625 }
6626 }
6627 }
6628
6629 $oldPage = $viewEl.children('.page:not(.stacked)').filter(function (pageEl) {
6630 return pageEl !== $newPage[0] && removedPageEls.indexOf(pageEl) < 0;
6631 });
6632
6633 if (dynamicNavbar) {
6634 $oldNavbarEl = $navbarsEl.children('.navbar:not(.stacked)').filter(function (navbarEl) {
6635 return navbarEl !== $newNavbarEl[0] && removedNavbarEls.indexOf(removedNavbarEls) < 0;
6636 });
6637 }
6638
6639 removedPageEls = [];
6640 removedNavbarEls = [];
6641 }
6642
6643 if (isDetail && !options.reloadAll) {
6644 if ($oldPage.length > 1 || reloadDetail) {
6645 $oldPage = $oldPage.filter(function (pageEl) {
6646 return !pageEl.classList.contains('page-master');
6647 });
6648 }
6649
6650 if ($oldNavbarEl && ($oldNavbarEl.length > 1 || reloadDetail)) {
6651 $oldNavbarEl = $oldNavbarEl.filter(function (navbarEl) {
6652 return !navbarEl.classList.contains('navbar-master');
6653 });
6654 }
6655 } // Push State
6656
6657
6658 if (router.params.browserHistory && (options.browserHistory || options.replaceState) && !options.reloadPrevious) {
6659 var browserHistoryRoot = router.params.browserHistoryRoot || '';
6660 History[options.reloadCurrent || reloadDetail && otherDetailPageEl || options.reloadAll || options.replaceState ? 'replace' : 'push'](view.id, {
6661 url: options.route.url
6662 }, browserHistoryRoot + router.params.browserHistorySeparator + options.route.url);
6663 }
6664
6665 if (!options.reloadPrevious) {
6666 // Current Page & Navbar
6667 router.currentPageEl = $newPage[0];
6668
6669 if (dynamicNavbar && $newNavbarEl.length) {
6670 router.currentNavbarEl = $newNavbarEl[0];
6671 } else {
6672 delete router.currentNavbarEl;
6673 } // Current Route
6674
6675
6676 router.currentRoute = options.route;
6677 } // Update router history
6678
6679
6680 var url = options.route.url;
6681
6682 if (options.history) {
6683 if (((options.reloadCurrent || reloadDetail && otherDetailPageEl) && router.history.length) > 0 || options.replaceState) {
6684 if (reloadDetail && detailsInBetweenRemoved > 0) {
6685 router.history = router.history.slice(0, router.history.length - detailsInBetweenRemoved);
6686 }
6687
6688 router.history[router.history.length - (options.reloadPrevious ? 2 : 1)] = url;
6689 } else if (options.reloadPrevious) {
6690 router.history[router.history.length - 2] = url;
6691 } else if (options.reloadAll) {
6692 router.history = [url];
6693 } else {
6694 router.history.push(url);
6695 }
6696 }
6697
6698 router.saveHistory(); // Insert new page and navbar
6699
6700 var newPageInDom = $newPage.parents(document).length > 0;
6701 var f7Component = $newPage[0].f7Component;
6702
6703 if (options.reloadPrevious) {
6704 if (f7Component && !newPageInDom) {
6705 f7Component.mount(function (componentEl) {
6706 $(componentEl).insertBefore($oldPage);
6707 });
6708 } else {
6709 $newPage.insertBefore($oldPage);
6710 }
6711
6712 if (dynamicNavbar && $newNavbarEl.length) {
6713 if ($newNavbarEl.find('.title-large').length) {
6714 $newNavbarEl.addClass('navbar-large');
6715 }
6716
6717 if ($oldNavbarEl.length) {
6718 $newNavbarEl.insertBefore($oldNavbarEl);
6719 } else {
6720 if (!router.$navbarsEl.parents(document).length) {
6721 router.$el.prepend(router.$navbarsEl);
6722 }
6723
6724 $navbarsEl.append($newNavbarEl);
6725 }
6726 }
6727 } else {
6728 if ($oldPage.next('.page')[0] !== $newPage[0]) {
6729 if (f7Component && !newPageInDom) {
6730 f7Component.mount(function (componentEl) {
6731 $viewEl.append(componentEl);
6732 });
6733 } else {
6734 $viewEl.append($newPage[0]);
6735 }
6736 }
6737
6738 if (dynamicNavbar && $newNavbarEl.length) {
6739 if ($newNavbarEl.find('.title-large').length) {
6740 $newNavbarEl.addClass('navbar-large');
6741 }
6742
6743 if (!router.$navbarsEl.parents(document).length) {
6744 router.$el.prepend(router.$navbarsEl);
6745 }
6746
6747 $navbarsEl.append($newNavbarEl[0]);
6748 }
6749 }
6750
6751 if (!newPageInDom) {
6752 router.pageCallback('mounted', $newPage, $newNavbarEl, newPagePosition, reload ? newPagePosition : 'current', options, $oldPage);
6753 } else if (options.route && options.route.route && options.route.route.keepAlive && !$newPage[0].f7PageMounted) {
6754 $newPage[0].f7PageMounted = true;
6755 router.pageCallback('mounted', $newPage, $newNavbarEl, newPagePosition, reload ? newPagePosition : 'current', options, $oldPage);
6756 } // Remove old page
6757
6758
6759 if ((options.reloadCurrent || reloadDetail) && $oldPage.length > 0) {
6760 if (router.params.stackPages && router.initialPages.indexOf($oldPage[0]) >= 0) {
6761 $oldPage.addClass('stacked');
6762 $oldPage.trigger('page:stack');
6763 router.emit('pageStack', $oldPage[0]);
6764
6765 if (dynamicNavbar) {
6766 $oldNavbarEl.addClass('stacked');
6767 }
6768 } else {
6769 // Page remove event
6770 router.pageCallback('beforeOut', $oldPage, $oldNavbarEl, 'current', undefined, options);
6771 router.pageCallback('afterOut', $oldPage, $oldNavbarEl, 'current', undefined, options);
6772 router.pageCallback('beforeRemove', $oldPage, $oldNavbarEl, 'current', undefined, options);
6773 router.removePage($oldPage);
6774
6775 if (dynamicNavbar && $oldNavbarEl && $oldNavbarEl.length) {
6776 router.removeNavbar($oldNavbarEl);
6777 }
6778 }
6779 } else if (options.reloadAll) {
6780 $oldPage.each(function (pageEl, index) {
6781 var $oldPageEl = $(pageEl);
6782 var $oldNavbarElEl = $(app.navbar.getElByPage($oldPageEl));
6783
6784 if (router.params.stackPages && router.initialPages.indexOf($oldPageEl[0]) >= 0) {
6785 $oldPageEl.addClass('stacked');
6786 $oldPageEl.trigger('page:stack');
6787 router.emit('pageStack', $oldPageEl[0]);
6788
6789 if (dynamicNavbar) {
6790 $oldNavbarElEl.addClass('stacked');
6791 }
6792 } else {
6793 // Page remove event
6794 if ($oldPageEl.hasClass('page-current')) {
6795 router.pageCallback('beforeOut', $oldPage, $oldNavbarEl, 'current', undefined, options);
6796 router.pageCallback('afterOut', $oldPage, $oldNavbarEl, 'current', undefined, options);
6797 }
6798
6799 router.pageCallback('beforeRemove', $oldPageEl, $oldNavbarEl && $oldNavbarEl.eq(index), 'previous', undefined, options);
6800 router.removePage($oldPageEl);
6801
6802 if (dynamicNavbar && $oldNavbarElEl.length) {
6803 router.removeNavbar($oldNavbarElEl);
6804 }
6805 }
6806 });
6807 } else if (options.reloadPrevious) {
6808 if (router.params.stackPages && router.initialPages.indexOf($oldPage[0]) >= 0) {
6809 $oldPage.addClass('stacked');
6810 $oldPage.trigger('page:stack');
6811 router.emit('pageStack', $oldPage[0]);
6812
6813 if (dynamicNavbar) {
6814 $oldNavbarEl.addClass('stacked');
6815 }
6816 } else {
6817 // Page remove event
6818 router.pageCallback('beforeRemove', $oldPage, $oldNavbarEl, 'previous', undefined, options);
6819 router.removePage($oldPage);
6820
6821 if (dynamicNavbar && $oldNavbarEl && $oldNavbarEl.length) {
6822 router.removeNavbar($oldNavbarEl);
6823 }
6824 }
6825 } // Load Tab
6826
6827
6828 if (options.route.route.tab) {
6829 router.tabLoad(options.route.route.tab, extend({}, options, {
6830 history: false,
6831 browserHistory: false
6832 }));
6833 } // Check master detail
6834
6835
6836 if (masterDetailEnabled) {
6837 view.checkMasterDetailBreakpoint();
6838 } // Page init and before init events
6839
6840
6841 router.pageCallback('init', $newPage, $newNavbarEl, newPagePosition, reload ? newPagePosition : 'current', options, $oldPage);
6842
6843 if (options.reloadCurrent || options.reloadAll || reloadDetail) {
6844 router.allowPageChange = true;
6845 router.pageCallback('beforeIn', $newPage, $newNavbarEl, newPagePosition, 'current', options);
6846 $newPage.removeAttr('aria-hidden');
6847
6848 if (dynamicNavbar && $newNavbarEl) {
6849 $newNavbarEl.removeAttr('aria-hidden');
6850 }
6851
6852 router.pageCallback('afterIn', $newPage, $newNavbarEl, newPagePosition, 'current', options);
6853 if (options.reloadCurrent && options.clearPreviousHistory) router.clearPreviousHistory();
6854
6855 if (reloadDetail) {
6856 router.setPagePosition($(masterPageEl), 'previous');
6857
6858 if (masterPageEl.f7Page && masterPageEl.f7Page.navbarEl) {
6859 router.setNavbarPosition($(masterPageEl.f7Page.navbarEl), 'previous');
6860 }
6861 }
6862
6863 return router;
6864 }
6865
6866 if (options.reloadPrevious) {
6867 router.allowPageChange = true;
6868 return router;
6869 } // Before animation event
6870
6871
6872 router.pageCallback('beforeOut', $oldPage, $oldNavbarEl, 'current', 'previous', options);
6873 router.pageCallback('beforeIn', $newPage, $newNavbarEl, 'next', 'current', options); // Animation
6874
6875 function afterAnimation() {
6876 router.setPagePosition($newPage, 'current', false);
6877 router.setPagePosition($oldPage, 'previous', !$oldPage.hasClass('page-master'));
6878
6879 if (dynamicNavbar) {
6880 router.setNavbarPosition($newNavbarEl, 'current', false);
6881 router.setNavbarPosition($oldNavbarEl, 'previous', !$oldNavbarEl.hasClass('navbar-master'));
6882 } // After animation event
6883
6884
6885 router.allowPageChange = true;
6886 router.pageCallback('afterOut', $oldPage, $oldNavbarEl, 'current', 'previous', options);
6887 router.pageCallback('afterIn', $newPage, $newNavbarEl, 'next', 'current', options);
6888 var keepOldPage = (router.params.preloadPreviousPage || router.params[app.theme + "SwipeBack"]) && !isMaster;
6889
6890 if (!keepOldPage) {
6891 if ($newPage.hasClass('smart-select-page') || $newPage.hasClass('photo-browser-page') || $newPage.hasClass('autocomplete-page') || $newPage.hasClass('color-picker-page')) {
6892 keepOldPage = true;
6893 }
6894 }
6895
6896 if (!keepOldPage) {
6897 if (router.params.stackPages) {
6898 $oldPage.addClass('stacked');
6899 $oldPage.trigger('page:stack');
6900 router.emit('pageStack', $oldPage[0]);
6901
6902 if (dynamicNavbar) {
6903 $oldNavbarEl.addClass('stacked');
6904 }
6905 } else if (!($newPage.attr('data-name') && $newPage.attr('data-name') === 'smart-select-page')) {
6906 // Remove event
6907 router.pageCallback('beforeRemove', $oldPage, $oldNavbarEl, 'previous', undefined, options);
6908 router.removePage($oldPage);
6909
6910 if (dynamicNavbar && $oldNavbarEl.length) {
6911 router.removeNavbar($oldNavbarEl);
6912 }
6913 }
6914 }
6915
6916 if (options.clearPreviousHistory) router.clearPreviousHistory();
6917 router.emit('routeChanged', router.currentRoute, router.previousRoute, router);
6918
6919 if (router.params.browserHistory) {
6920 History.clearRouterQueue();
6921 }
6922 }
6923
6924 function setPositionClasses() {
6925 router.setPagePosition($oldPage, 'current', false);
6926 router.setPagePosition($newPage, 'next', false);
6927
6928 if (dynamicNavbar) {
6929 router.setNavbarPosition($oldNavbarEl, 'current', false);
6930 router.setNavbarPosition($newNavbarEl, 'next', false);
6931 }
6932 }
6933
6934 if (options.animate && !(isMaster && app.width >= router.params.masterDetailBreakpoint)) {
6935 var delay = router.params[router.app.theme + "PageLoadDelay"];
6936 var transition = router.params.transition;
6937 if (options.transition) transition = options.transition;
6938
6939 if (!transition && router.currentRoute && router.currentRoute.route) {
6940 transition = router.currentRoute.route.transition;
6941 }
6942
6943 if (!transition && router.currentRoute && router.currentRoute.route.options) {
6944 transition = router.currentRoute.route.options.transition;
6945 }
6946
6947 if (transition) {
6948 $newPage[0].f7PageTransition = transition;
6949 }
6950
6951 if (delay) {
6952 setTimeout(function () {
6953 setPositionClasses();
6954 router.animate($oldPage, $newPage, $oldNavbarEl, $newNavbarEl, 'forward', transition, function () {
6955 afterAnimation();
6956 });
6957 }, delay);
6958 } else {
6959 setPositionClasses();
6960 router.animate($oldPage, $newPage, $oldNavbarEl, $newNavbarEl, 'forward', transition, function () {
6961 afterAnimation();
6962 });
6963 }
6964 } else {
6965 afterAnimation();
6966 }
6967
6968 return router;
6969 }
6970
6971 function load(router, loadParams, loadOptions, ignorePageChange) {
6972 if (loadParams === void 0) {
6973 loadParams = {};
6974 }
6975
6976 if (loadOptions === void 0) {
6977 loadOptions = {};
6978 }
6979
6980 if (!router.allowPageChange && !ignorePageChange) return router;
6981 var params = loadParams;
6982 var options = loadOptions;
6983 var url = params.url,
6984 content = params.content,
6985 el = params.el,
6986 pageName = params.pageName,
6987 component = params.component,
6988 componentUrl = params.componentUrl;
6989
6990 if (!options.reloadCurrent && options.route && options.route.route && options.route.route.parentPath && router.currentRoute.route && router.currentRoute.route.parentPath === options.route.route.parentPath) {
6991 // Do something nested
6992 if (options.route.url === router.url) {
6993 router.allowPageChange = true;
6994 return false;
6995 } // Check for same params
6996
6997
6998 var sameParams = Object.keys(options.route.params).length === Object.keys(router.currentRoute.params).length;
6999
7000 if (sameParams) {
7001 // Check for equal params name
7002 Object.keys(options.route.params).forEach(function (paramName) {
7003 if (!(paramName in router.currentRoute.params) || router.currentRoute.params[paramName] !== options.route.params[paramName]) {
7004 sameParams = false;
7005 }
7006 });
7007 }
7008
7009 if (sameParams) {
7010 if (options.route.route.tab) {
7011 return router.tabLoad(options.route.route.tab, options);
7012 }
7013
7014 return false;
7015 }
7016
7017 if (!sameParams && options.route.route.tab && router.currentRoute.route.tab && router.currentRoute.parentPath === options.route.parentPath) {
7018 return router.tabLoad(options.route.route.tab, options);
7019 }
7020 }
7021
7022 if (options.route && options.route.url && router.url === options.route.url && !(options.reloadCurrent || options.reloadPrevious) && !router.params.allowDuplicateUrls) {
7023 router.allowPageChange = true;
7024 return false;
7025 }
7026
7027 if (!options.route && url) {
7028 options.route = router.parseRouteUrl(url);
7029 extend(options.route, {
7030 route: {
7031 url: url,
7032 path: url
7033 }
7034 });
7035 } // Component Callbacks
7036
7037
7038 function resolve(pageEl, newOptions) {
7039 return forward(router, pageEl, extend(options, newOptions));
7040 }
7041
7042 function reject() {
7043 router.allowPageChange = true;
7044 return router;
7045 }
7046
7047 if (url || componentUrl || component) {
7048 router.allowPageChange = false;
7049 } // Proceed
7050
7051
7052 if (content) {
7053 forward(router, router.getPageEl(content), options);
7054 } else if (el) {
7055 // Load page from specified HTMLElement or by page name in pages container
7056 forward(router, router.getPageEl(el), options);
7057 } else if (pageName) {
7058 // Load page by page name in pages container
7059 forward(router, router.$el.children(".page[data-name=\"" + pageName + "\"]").eq(0), options);
7060 } else if (component || componentUrl) {
7061 // Load from component (F7/Vue/React/...)
7062 try {
7063 router.pageComponentLoader({
7064 routerEl: router.el,
7065 component: component,
7066 componentUrl: componentUrl,
7067 options: options,
7068 resolve: resolve,
7069 reject: reject
7070 });
7071 } catch (err) {
7072 router.allowPageChange = true;
7073 throw err;
7074 }
7075 } else if (url) {
7076 // Load using XHR
7077 if (router.xhrAbortController) {
7078 router.xhrAbortController.abort();
7079 router.xhrAbortController = false;
7080 }
7081
7082 router.xhrRequest(url, options).then(function (pageContent) {
7083 forward(router, router.getPageEl(pageContent), options);
7084 }).catch(function () {
7085 router.allowPageChange = true;
7086 });
7087 }
7088
7089 return router;
7090 }
7091
7092 function openIn(router, url, options) {
7093 var navigateOptions = {
7094 url: url,
7095 route: {
7096 path: url,
7097 options: _extends({}, options, {
7098 openIn: undefined
7099 })
7100 }
7101 };
7102
7103 var params = _extends({}, options);
7104
7105 if (options.openIn === 'popup') {
7106 params.content = "<div class=\"popup popup-router-open-in\" data-url=\"" + url + "\"><div class=\"view view-init\" data-links-view=\"" + router.view.selector + "\" data-url=\"" + url + "\" data-ignore-open-in=\"true\"></div></div>";
7107 navigateOptions.route.popup = params;
7108 }
7109
7110 if (options.openIn === 'loginScreen') {
7111 params.content = "<div class=\"login-screen login-screen-router-open-in\" data-url=\"" + url + "\"><div class=\"view view-init\" data-links-view=\"" + router.view.selector + "\" data-url=\"" + url + "\" data-ignore-open-in=\"true\"></div></div>";
7112 navigateOptions.route.loginScreen = params;
7113 }
7114
7115 if (options.openIn === 'sheet') {
7116 params.content = "<div class=\"sheet-modal sheet-modal-router-open-in\" data-url=\"" + url + "\"><div class=\"sheet-modal-inner\"><div class=\"view view-init\" data-links-view=\"" + router.view.selector + "\" data-url=\"" + url + "\" data-ignore-open-in=\"true\"></div></div></div>";
7117 navigateOptions.route.sheet = params;
7118 }
7119
7120 if (options.openIn === 'popover') {
7121 params.targetEl = options.clickedEl || options.targetEl;
7122 params.content = "<div class=\"popover popover-router-open-in\" data-url=\"" + url + "\"><div class=\"popover-inner\"><div class=\"view view-init\" data-links-view=\"" + router.view.selector + "\" data-url=\"" + url + "\" data-ignore-open-in=\"true\"></div></div></div>";
7123 navigateOptions.route.popover = params;
7124 }
7125
7126 if (options.openIn.indexOf('panel') >= 0) {
7127 var parts = options.openIn.split(':');
7128 var side = parts[1] || 'left';
7129 var effect = parts[2] || 'cover';
7130 params.targetEl = options.clickedEl || options.targetEl;
7131 params.content = "<div class=\"panel panel-router-open-in panel-" + side + " panel-" + effect + "\" data-url=\"" + url + "\"><div class=\"view view-init\" data-links-view=\"" + router.view.selector + "\" data-url=\"" + url + "\" data-ignore-open-in=\"true\"></div></div>";
7132 navigateOptions.route.panel = params;
7133 }
7134
7135 return router.navigate(navigateOptions);
7136 }
7137
7138 function navigate(navigateParams, navigateOptions) {
7139 if (navigateOptions === void 0) {
7140 navigateOptions = {};
7141 }
7142
7143 var router = this;
7144 if (router.swipeBackActive) return router;
7145 var url;
7146 var createRoute;
7147 var name;
7148 var path;
7149 var query;
7150 var params;
7151 var route;
7152
7153 if (typeof navigateParams === 'string') {
7154 url = navigateParams;
7155 } else {
7156 url = navigateParams.url;
7157 createRoute = navigateParams.route;
7158 name = navigateParams.name;
7159 path = navigateParams.path;
7160 query = navigateParams.query;
7161 params = navigateParams.params;
7162 }
7163
7164 if (name || path) {
7165 url = router.generateUrl({
7166 path: path,
7167 name: name,
7168 params: params,
7169 query: query
7170 });
7171
7172 if (url) {
7173 return router.navigate(url, navigateOptions);
7174 }
7175
7176 return router;
7177 }
7178
7179 var app = router.app;
7180 appRouterCheck(router, 'navigate');
7181
7182 if (url === '#' || url === '') {
7183 return router;
7184 }
7185
7186 var navigateUrl = url.replace('./', '');
7187
7188 if (navigateUrl[0] !== '/' && navigateUrl.indexOf('#') !== 0) {
7189 var currentPath = router.currentRoute.parentPath || router.currentRoute.path;
7190 navigateUrl = ((currentPath ? currentPath + "/" : '/') + navigateUrl).replace('///', '/').replace('//', '/');
7191 }
7192
7193 if (createRoute) {
7194 route = extend(router.parseRouteUrl(navigateUrl), {
7195 route: extend({}, createRoute)
7196 });
7197 } else {
7198 route = router.findMatchingRoute(navigateUrl);
7199 }
7200
7201 if (!route) {
7202 return router;
7203 }
7204
7205 if (route.route && route.route.viewName) {
7206 var anotherViewName = route.route.viewName;
7207 var anotherView = app.views[anotherViewName];
7208
7209 if (!anotherView) {
7210 throw new Error("Framework7: There is no View with \"" + anotherViewName + "\" name that was specified in this route");
7211 }
7212
7213 if (anotherView !== router.view) {
7214 return anotherView.router.navigate(navigateParams, navigateOptions);
7215 }
7216 }
7217
7218 if (route.route.redirect) {
7219 return redirect.call(router, 'forward', route, navigateOptions);
7220 }
7221
7222 var options = {};
7223
7224 if (route.route.options) {
7225 extend(options, route.route.options, navigateOptions);
7226 } else {
7227 extend(options, navigateOptions);
7228 }
7229
7230 if (options.openIn && (!router.params.ignoreOpenIn || router.params.ignoreOpenIn && router.history.length > 0)) {
7231 return openIn(router, navigateUrl, options);
7232 }
7233
7234 options.route = route;
7235
7236 function resolve() {
7237 var routerLoaded = false;
7238 'popup popover sheet loginScreen actions customModal panel'.split(' ').forEach(function (modalLoadProp) {
7239 if (route.route[modalLoadProp] && !routerLoaded) {
7240 routerLoaded = true;
7241 router.modalLoad(modalLoadProp, route, options, 'forward');
7242 }
7243 });
7244
7245 if (route.route.keepAlive && route.route.keepAliveData) {
7246 load(router, {
7247 el: route.route.keepAliveData.pageEl
7248 }, options, false);
7249 routerLoaded = true;
7250 }
7251
7252 'url content component pageName el componentUrl'.split(' ').forEach(function (pageLoadProp) {
7253 if (route.route[pageLoadProp] && !routerLoaded) {
7254 var _load;
7255
7256 routerLoaded = true;
7257 load(router, (_load = {}, _load[pageLoadProp] = route.route[pageLoadProp], _load), options, false);
7258 }
7259 });
7260 if (routerLoaded) return; // Async
7261
7262 function asyncResolve(resolveParams, resolveOptions) {
7263 router.allowPageChange = false;
7264 var resolvedAsModal = false;
7265 'popup popover sheet loginScreen actions customModal panel'.split(' ').forEach(function (modalLoadProp) {
7266 if (resolveParams[modalLoadProp]) {
7267 resolvedAsModal = true;
7268 var modalRoute = extend({}, route, {
7269 route: resolveParams
7270 });
7271 router.allowPageChange = true;
7272 router.modalLoad(modalLoadProp, modalRoute, extend(options, resolveOptions), 'forward');
7273 }
7274 });
7275 if (resolvedAsModal) return;
7276 load(router, resolveParams, extend(options, resolveOptions), true);
7277 }
7278
7279 function asyncReject() {
7280 router.allowPageChange = true;
7281 }
7282
7283 if (route.route.async) {
7284 router.allowPageChange = false;
7285 route.route.async.call(router, {
7286 router: router,
7287 to: options.route,
7288 from: router.currentRoute,
7289 resolve: asyncResolve,
7290 reject: asyncReject,
7291 direction: 'forward',
7292 app: app
7293 });
7294 }
7295
7296 if (route.route.asyncComponent) {
7297 asyncComponent(router, route.route.asyncComponent, asyncResolve, asyncReject);
7298 }
7299 }
7300
7301 function reject() {
7302 router.allowPageChange = true;
7303 }
7304
7305 if (router.params.masterDetailBreakpoint > 0 && route.route.masterRoute) {
7306 // load detail route
7307 var preloadMaster = true;
7308 var masterLoaded = false;
7309
7310 if (router.currentRoute && router.currentRoute.route) {
7311 if ((router.currentRoute.route.master === true || typeof router.currentRoute.route.master === 'function' && router.currentRoute.route.master(app, router)) && (router.currentRoute.route === route.route.masterRoute || router.currentRoute.route.path === route.route.masterRoute.path)) {
7312 preloadMaster = false;
7313 }
7314
7315 if (router.currentRoute.route.masterRoute && (router.currentRoute.route.masterRoute === route.route.masterRoute || router.currentRoute.route.masterRoute.path === route.route.masterRoute.path)) {
7316 preloadMaster = false;
7317 masterLoaded = true;
7318 }
7319 }
7320
7321 if (preloadMaster || masterLoaded && navigateOptions.reloadAll) {
7322 router.navigate({
7323 path: route.route.masterRoute.path,
7324 params: route.params || {}
7325 }, {
7326 animate: false,
7327 reloadAll: navigateOptions.reloadAll,
7328 reloadCurrent: navigateOptions.reloadCurrent,
7329 reloadPrevious: navigateOptions.reloadPrevious,
7330 browserHistory: !navigateOptions.initial,
7331 history: !navigateOptions.initial,
7332 once: {
7333 pageAfterIn: function pageAfterIn() {
7334 router.navigate(navigateParams, extend({}, navigateOptions, {
7335 animate: false,
7336 reloadAll: false,
7337 reloadCurrent: false,
7338 reloadPrevious: false,
7339 history: !navigateOptions.initial,
7340 browserHistory: !navigateOptions.initial
7341 }));
7342 }
7343 }
7344 });
7345 return router;
7346 }
7347 }
7348
7349 processRouteQueue.call(router, route, router.currentRoute, function () {
7350 if (route.route.modules) {
7351 app.loadModules(Array.isArray(route.route.modules) ? route.route.modules : [route.route.modules]).then(function () {
7352 resolve();
7353 }).catch(function () {
7354 reject();
7355 });
7356 } else {
7357 resolve();
7358 }
7359 }, function () {
7360 reject();
7361 }, 'forward'); // Return Router
7362
7363 return router;
7364 }
7365
7366 function tabLoad(tabRoute, loadOptions) {
7367 if (loadOptions === void 0) {
7368 loadOptions = {};
7369 }
7370
7371 var router = this;
7372 var options = extend({
7373 animate: router.params.animate,
7374 browserHistory: true,
7375 history: true,
7376 parentPageEl: null,
7377 preload: false,
7378 on: {}
7379 }, loadOptions);
7380 var currentRoute;
7381 var previousRoute;
7382
7383 if (options.route) {
7384 // Set Route
7385 if (!options.preload && options.route !== router.currentRoute) {
7386 previousRoute = router.previousRoute;
7387 router.currentRoute = options.route;
7388 }
7389
7390 if (options.preload) {
7391 currentRoute = options.route;
7392 previousRoute = router.currentRoute;
7393 } else {
7394 currentRoute = router.currentRoute;
7395 if (!previousRoute) previousRoute = router.previousRoute;
7396 } // Update Browser History
7397
7398
7399 if (router.params.browserHistory && options.browserHistory && !options.reloadPrevious) {
7400 History.replace(router.view.id, {
7401 url: options.route.url
7402 }, (router.params.browserHistoryRoot || '') + router.params.browserHistorySeparator + options.route.url);
7403 } // Update Router History
7404
7405
7406 if (options.history) {
7407 router.history[Math.max(router.history.length - 1, 0)] = options.route.url;
7408 router.saveHistory();
7409 }
7410 } // Show Tab
7411
7412
7413 var $parentPageEl = $(options.parentPageEl || router.currentPageEl);
7414 var tabEl;
7415
7416 if ($parentPageEl.length && $parentPageEl.find("#" + tabRoute.id).length) {
7417 tabEl = $parentPageEl.find("#" + tabRoute.id).eq(0);
7418 } else if (router.view.selector) {
7419 tabEl = router.view.selector + " #" + tabRoute.id;
7420 } else {
7421 tabEl = "#" + tabRoute.id;
7422 }
7423
7424 var tabShowResult = router.app.tab.show({
7425 tabEl: tabEl,
7426 animate: options.animate,
7427 tabRoute: options.route
7428 });
7429 var $newTabEl = tabShowResult.$newTabEl,
7430 $oldTabEl = tabShowResult.$oldTabEl,
7431 animated = tabShowResult.animated,
7432 onTabsChanged = tabShowResult.onTabsChanged;
7433
7434 if ($newTabEl && $newTabEl.parents('.page').length > 0 && options.route) {
7435 var tabParentPageData = $newTabEl.parents('.page')[0].f7Page;
7436
7437 if (tabParentPageData && options.route) {
7438 tabParentPageData.route = options.route;
7439 }
7440 } // Tab Content Loaded
7441
7442
7443 function onTabLoaded(contentEl) {
7444 // Remove theme elements
7445 router.removeThemeElements($newTabEl);
7446 var tabEventTarget = $newTabEl;
7447 if (typeof contentEl !== 'string') tabEventTarget = $(contentEl);
7448 tabEventTarget.trigger('tab:init tab:mounted', tabRoute);
7449 router.emit('tabInit tabMounted', $newTabEl[0], tabRoute);
7450
7451 if ($oldTabEl && $oldTabEl.length) {
7452 if (animated) {
7453 onTabsChanged(function () {
7454 router.emit('routeChanged', router.currentRoute, router.previousRoute, router);
7455
7456 if (router.params.unloadTabContent) {
7457 router.tabRemove($oldTabEl, $newTabEl, tabRoute);
7458 }
7459 });
7460 } else {
7461 router.emit('routeChanged', router.currentRoute, router.previousRoute, router);
7462
7463 if (router.params.unloadTabContent) {
7464 router.tabRemove($oldTabEl, $newTabEl, tabRoute);
7465 }
7466 }
7467 }
7468 }
7469
7470 if ($newTabEl[0].f7RouterTabLoaded) {
7471 if (!$oldTabEl || !$oldTabEl.length) return router;
7472
7473 if (animated) {
7474 onTabsChanged(function () {
7475 router.emit('routeChanged', router.currentRoute, router.previousRoute, router);
7476 });
7477 } else {
7478 router.emit('routeChanged', router.currentRoute, router.previousRoute, router);
7479 }
7480
7481 return router;
7482 } // Load Tab Content
7483
7484
7485 function loadTab(loadTabParams, loadTabOptions) {
7486 // Load Tab Props
7487 var url = loadTabParams.url,
7488 content = loadTabParams.content,
7489 el = loadTabParams.el,
7490 component = loadTabParams.component,
7491 componentUrl = loadTabParams.componentUrl; // Component/Template Callbacks
7492
7493 function resolve(contentEl) {
7494 router.allowPageChange = true;
7495 if (!contentEl) return;
7496
7497 if (typeof contentEl === 'string') {
7498 $newTabEl.html(contentEl);
7499 } else {
7500 $newTabEl.html('');
7501
7502 if (contentEl.f7Component) {
7503 contentEl.f7Component.mount(function (componentEl) {
7504 $newTabEl.append(componentEl);
7505 });
7506 } else {
7507 $newTabEl.append(contentEl);
7508 }
7509 }
7510
7511 $newTabEl[0].f7RouterTabLoaded = true;
7512 onTabLoaded(contentEl);
7513 }
7514
7515 function reject() {
7516 router.allowPageChange = true;
7517 return router;
7518 }
7519
7520 if (content) {
7521 resolve(content);
7522 } else if (el) {
7523 resolve(el);
7524 } else if (component || componentUrl) {
7525 // Load from component (F7/Vue/React/...)
7526 try {
7527 router.tabComponentLoader({
7528 tabEl: $newTabEl[0],
7529 component: component,
7530 componentUrl: componentUrl,
7531 options: loadTabOptions,
7532 resolve: resolve,
7533 reject: reject
7534 });
7535 } catch (err) {
7536 router.allowPageChange = true;
7537 throw err;
7538 }
7539 } else if (url) {
7540 // Load using XHR
7541 if (router.xhrAbortController) {
7542 router.xhrAbortController.abort();
7543 router.xhrAbortController = false;
7544 }
7545
7546 router.xhrRequest(url, loadTabOptions).then(function (tabContent) {
7547 resolve(tabContent);
7548 }).catch(function () {
7549 router.allowPageChange = true;
7550 });
7551 }
7552 }
7553
7554 var hasContentLoadProp;
7555 'url content component el componentUrl'.split(' ').forEach(function (tabLoadProp) {
7556 if (tabRoute[tabLoadProp]) {
7557 var _loadTab;
7558
7559 hasContentLoadProp = true;
7560 loadTab((_loadTab = {}, _loadTab[tabLoadProp] = tabRoute[tabLoadProp], _loadTab), options);
7561 }
7562 }); // Async
7563
7564 function asyncResolve(resolveParams, resolveOptions) {
7565 loadTab(resolveParams, extend(options, resolveOptions));
7566 }
7567
7568 function asyncReject() {
7569 router.allowPageChange = true;
7570 }
7571
7572 if (tabRoute.async) {
7573 tabRoute.async.call(router, {
7574 router: router,
7575 to: currentRoute,
7576 from: previousRoute,
7577 resolve: asyncResolve,
7578 reject: asyncReject,
7579 app: router.app
7580 });
7581 } else if (tabRoute.asyncComponent) {
7582 asyncComponent(router, tabRoute.asyncComponent, asyncResolve, asyncReject);
7583 } else if (!hasContentLoadProp) {
7584 router.allowPageChange = true;
7585 }
7586
7587 return router;
7588 }
7589
7590 function tabRemove($oldTabEl, $newTabEl, tabRoute) {
7591 var router = this;
7592 var hasTabComponentChild;
7593
7594 if ($oldTabEl[0]) {
7595 $oldTabEl[0].f7RouterTabLoaded = false;
7596 delete $oldTabEl[0].f7RouterTabLoaded;
7597 }
7598
7599 $oldTabEl.children().each(function (tabChild) {
7600 if (tabChild.f7Component) {
7601 hasTabComponentChild = true;
7602 $(tabChild).trigger('tab:beforeremove', tabRoute);
7603 tabChild.f7Component.destroy();
7604 }
7605 });
7606
7607 if (!hasTabComponentChild) {
7608 $oldTabEl.trigger('tab:beforeremove', tabRoute);
7609 }
7610
7611 router.emit('tabBeforeRemove', $oldTabEl[0], $newTabEl[0], tabRoute);
7612 router.removeTabContent($oldTabEl[0], tabRoute);
7613 }
7614
7615 function modalLoad(modalType, route, loadOptions, direction) {
7616 if (loadOptions === void 0) {
7617 loadOptions = {};
7618 }
7619
7620 var router = this;
7621 var app = router.app;
7622 var isPanel = modalType === 'panel';
7623 var modalOrPanel = isPanel ? 'panel' : 'modal';
7624 var options = extend({
7625 animate: router.params.animate,
7626 browserHistory: true,
7627 history: true,
7628 on: {},
7629 once: {}
7630 }, loadOptions);
7631 var modalParams = extend({}, route.route[modalType]);
7632 var modalRoute = route.route;
7633
7634 var routeCallback = function routeCallback(modal, name) {
7635 var on = options.on,
7636 once = options.once;
7637 var callback;
7638
7639 if (name === 'open') {
7640 callback = on.modalOpen || once.modalOpen || on.panelOpen || once.panelOpen;
7641 }
7642
7643 if (name === 'close') {
7644 callback = on.modalClose || once.modalClose || on.panelClose || once.panelClose;
7645 }
7646
7647 if (name === 'closed') {
7648 callback = on.modalClosed || once.modalClosed || on.panelClosed || once.panelClosed;
7649 }
7650
7651 if (callback) callback(modal);
7652 };
7653
7654 function onModalLoaded() {
7655 // Create Modal
7656 var modal = app[modalType].create(modalParams);
7657 modalRoute.modalInstance = modal;
7658 var hasEl = modal.el;
7659
7660 function closeOnSwipeBack() {
7661 modal.close();
7662 }
7663
7664 modal.on(modalOrPanel + "Open", function () {
7665 if (!hasEl) {
7666 // Remove theme elements
7667 router.removeThemeElements(modal.el); // Emit events
7668
7669 modal.$el.trigger(modalType.toLowerCase() + ":init " + modalType.toLowerCase() + ":mounted", route, modal);
7670 router.emit((!isPanel ? 'modalInit' : '') + " " + modalType + "Init " + modalType + "Mounted", modal.el, route, modal);
7671 }
7672
7673 router.once('swipeBackMove', closeOnSwipeBack);
7674 routeCallback(modal, 'open');
7675 });
7676 modal.on(modalOrPanel + "Close", function () {
7677 router.off('swipeBackMove', closeOnSwipeBack);
7678
7679 if (!modal.closeByRouter) {
7680 router.back();
7681 }
7682
7683 routeCallback(modal, 'close');
7684 });
7685 modal.on(modalOrPanel + "Closed", function () {
7686 modal.$el.trigger(modalType.toLowerCase() + ":beforeremove", route, modal);
7687 modal.emit("" + (!isPanel ? 'modalBeforeRemove ' : '') + modalType + "BeforeRemove", modal.el, route, modal);
7688 var modalComponent = modal.el.f7Component;
7689 routeCallback(modal, 'closed');
7690
7691 if (modalComponent) {
7692 modalComponent.destroy();
7693 }
7694
7695 nextTick(function () {
7696 if (modalComponent || modalParams.component) {
7697 router.removeModal(modal.el);
7698 }
7699
7700 modal.destroy();
7701 delete modal.route;
7702 delete modalRoute.modalInstance;
7703 });
7704 });
7705
7706 if (options.route) {
7707 // Update Browser History
7708 if (router.params.browserHistory && options.browserHistory) {
7709 History.push(router.view.id, {
7710 url: options.route.url,
7711 modal: modalType
7712 }, (router.params.browserHistoryRoot || '') + router.params.browserHistorySeparator + options.route.url);
7713 } // Set Route
7714
7715
7716 if (options.route !== router.currentRoute) {
7717 modal.route = extend(options.route, {
7718 modal: modal
7719 });
7720 router.currentRoute = modal.route;
7721 } // Update Router History
7722
7723
7724 if (options.history && !options.reloadCurrent) {
7725 router.history.push(options.route.url);
7726 router.saveHistory();
7727 }
7728 }
7729
7730 if (hasEl) {
7731 // Remove theme elements
7732 router.removeThemeElements(modal.el); // Emit events
7733
7734 modal.$el.trigger(modalType.toLowerCase() + ":init " + modalType.toLowerCase() + ":mounted", route, modal);
7735 router.emit(modalOrPanel + "Init " + modalType + "Init " + modalType + "Mounted", modal.el, route, modal);
7736 } // Open
7737
7738
7739 modal.open(options.animate === false || options.animate === true ? options.animate : undefined);
7740 } // Load Modal Content
7741
7742
7743 function loadModal(loadModalParams, loadModalOptions) {
7744 // Load Modal Props
7745 var url = loadModalParams.url,
7746 content = loadModalParams.content,
7747 component = loadModalParams.component,
7748 componentUrl = loadModalParams.componentUrl; // Component/Template Callbacks
7749
7750 function resolve(contentEl) {
7751 if (contentEl) {
7752 if (typeof contentEl === 'string') {
7753 modalParams.content = contentEl;
7754 } else if (contentEl.f7Component) {
7755 contentEl.f7Component.mount(function (componentEl) {
7756 modalParams.el = componentEl;
7757 app.$el.append(componentEl);
7758 });
7759 } else {
7760 modalParams.el = contentEl;
7761 }
7762
7763 onModalLoaded();
7764 }
7765 }
7766
7767 function reject() {
7768 router.allowPageChange = true;
7769 return router;
7770 }
7771
7772 if (content) {
7773 resolve(content);
7774 } else if (component || componentUrl) {
7775 // Load from component (F7/Vue/React/...)
7776 try {
7777 router.modalComponentLoader({
7778 rootEl: app.el,
7779 component: component,
7780 componentUrl: componentUrl,
7781 options: loadModalOptions,
7782 resolve: resolve,
7783 reject: reject
7784 });
7785 } catch (err) {
7786 router.allowPageChange = true;
7787 throw err;
7788 }
7789 } else if (url) {
7790 // Load using XHR
7791 if (router.xhrAbortController) {
7792 router.xhrAbortController.abort();
7793 router.xhrAbortController = false;
7794 }
7795
7796 router.xhrRequest(url, loadModalOptions).then(function (modalContent) {
7797 modalParams.content = modalContent;
7798 onModalLoaded();
7799 }).catch(function () {
7800 router.allowPageChange = true;
7801 });
7802 } else {
7803 onModalLoaded();
7804 }
7805 }
7806
7807 var foundLoadProp;
7808 'url content component el componentUrl template'.split(' ').forEach(function (modalLoadProp) {
7809 if (modalParams[modalLoadProp] && !foundLoadProp) {
7810 var _loadModal;
7811
7812 foundLoadProp = true;
7813 loadModal((_loadModal = {}, _loadModal[modalLoadProp] = modalParams[modalLoadProp], _loadModal), options);
7814 }
7815 });
7816
7817 if (!foundLoadProp && modalType === 'actions') {
7818 onModalLoaded();
7819 } // Async
7820
7821
7822 function asyncResolve(resolveParams, resolveOptions) {
7823 loadModal(resolveParams, extend(options, resolveOptions));
7824 }
7825
7826 function asyncReject() {
7827 router.allowPageChange = true;
7828 }
7829
7830 if (modalParams.async) {
7831 modalParams.async.call(router, {
7832 router: router,
7833 to: options.route,
7834 from: router.currentRoute,
7835 resolve: asyncResolve,
7836 reject: asyncReject,
7837 direction: direction,
7838 app: app
7839 });
7840 }
7841
7842 if (modalParams.asyncComponent) {
7843 asyncComponent(router, modalParams.asyncComponent, asyncResolve, asyncReject);
7844 }
7845
7846 return router;
7847 }
7848
7849 function modalRemove(modal) {
7850 extend(modal, {
7851 closeByRouter: true
7852 });
7853 modal.close();
7854 }
7855
7856 function backward(router, el, backwardOptions) {
7857 var device = getDevice();
7858 var document = getDocument();
7859 var $el = $(el);
7860 var app = router.app;
7861 var view = router.view;
7862 var options = extend({
7863 animate: router.params.animate,
7864 browserHistory: true,
7865 replaceState: false
7866 }, backwardOptions);
7867 var masterDetailEnabled = router.params.masterDetailBreakpoint > 0;
7868 var isMaster = masterDetailEnabled && options.route && options.route.route && (options.route.route.master === true || typeof options.route.route.master === 'function' && options.route.route.master(app, router));
7869 var masterPageEl;
7870 var masterPageRemoved;
7871 var dynamicNavbar = router.dynamicNavbar;
7872 var $newPage = $el;
7873 var $oldPage = router.$el.children('.page-current');
7874 var initialPreload = $oldPage.length === 0 && options.preload;
7875 var currentIsMaster = masterDetailEnabled && $oldPage.hasClass('page-master');
7876
7877 if ($newPage.length) {
7878 // Remove theme elements
7879 router.removeThemeElements($newPage);
7880 }
7881
7882 var $navbarsEl;
7883 var $newNavbarEl;
7884 var $oldNavbarEl;
7885
7886 if (dynamicNavbar) {
7887 $newNavbarEl = $newPage.children('.navbar');
7888 $navbarsEl = router.$navbarsEl;
7889
7890 if ($newNavbarEl.length === 0 && $newPage[0] && $newPage[0].f7Page) {
7891 // Try from pageData
7892 $newNavbarEl = $newPage[0].f7Page.$navbarEl;
7893 }
7894
7895 $oldNavbarEl = $navbarsEl.find('.navbar-current');
7896 }
7897
7898 router.allowPageChange = false;
7899
7900 if ($newPage.length === 0 || $oldPage.length === 0 && !options.preload) {
7901 router.allowPageChange = true;
7902 return router;
7903 } // Remove theme elements
7904
7905
7906 router.removeThemeElements($newPage); // Save Keep Alive Cache
7907
7908 if (options.route && options.route.route && options.route.route.keepAlive && !options.route.route.keepAliveData) {
7909 options.route.route.keepAliveData = {
7910 pageEl: $el[0]
7911 };
7912 } // Pages In View
7913
7914
7915 var isDetail;
7916 var isDetailRoot;
7917
7918 if (masterDetailEnabled) {
7919 var $pagesInView = router.$el.children('.page:not(.stacked)').filter(function (pageInView) {
7920 return pageInView !== $newPage[0];
7921 }); // Find Detail' master page
7922
7923 for (var i = 0; i < $pagesInView.length; i += 1) {
7924 if (!masterPageEl && $pagesInView[i].classList.contains('page-master')) {
7925 masterPageEl = $pagesInView[i];
7926 continue; // eslint-disable-line
7927 }
7928 }
7929
7930 isDetail = !isMaster && masterPageEl && router.history.indexOf(options.route.url) > router.history.indexOf(masterPageEl.f7Page.route.url);
7931
7932 if (!isDetail && !isMaster && masterPageEl && masterPageEl.f7Page && options.route.route.masterRoute) {
7933 isDetail = options.route.route.masterRoute.path === masterPageEl.f7Page.route.route.path;
7934 }
7935 }
7936
7937 if (isDetail && masterPageEl && masterPageEl.f7Page) {
7938 isDetailRoot = router.history.indexOf(options.route.url) - router.history.indexOf(masterPageEl.f7Page.route.url) === 1;
7939 } // New Page
7940
7941
7942 $newPage.addClass("page-" + (initialPreload ? 'current' : 'previous') + (isMaster ? ' page-master' : '') + (isDetail ? ' page-master-detail' : '') + (isDetailRoot ? ' page-master-detail-root' : '')).removeClass('stacked').removeAttr('aria-hidden').trigger('page:unstack').trigger('page:position', {
7943 position: initialPreload ? 'current' : 'previous'
7944 });
7945 router.emit('pageUnstack', $newPage[0]);
7946 router.emit('pagePosition', $newPage[0], initialPreload ? 'current' : 'previous');
7947
7948 if (isMaster || isDetail) {
7949 $newPage.trigger('page:role', {
7950 role: isMaster ? 'master' : 'detail',
7951 root: !!isDetailRoot
7952 });
7953 router.emit('pageRole', $newPage[0], {
7954 role: isMaster ? 'master' : 'detail',
7955 detailRoot: !!isDetailRoot
7956 });
7957 }
7958
7959 if (dynamicNavbar && $newNavbarEl.length > 0) {
7960 $newNavbarEl.addClass("navbar-" + (initialPreload ? 'current' : 'previous') + (isMaster ? ' navbar-master' : '') + (isDetail ? ' navbar-master-detail' : '') + (isDetailRoot ? ' navbar-master-detail-root' : '')).removeClass('stacked').removeAttr('aria-hidden');
7961 $newNavbarEl.trigger('navbar:position', {
7962 position: initialPreload ? 'current' : 'previous'
7963 });
7964 router.emit('navbarPosition', $newNavbarEl[0], initialPreload ? 'current' : 'previous');
7965
7966 if (isMaster || isDetailRoot) {
7967 router.emit('navbarRole', $newNavbarEl[0], {
7968 role: isMaster ? 'master' : 'detail',
7969 detailRoot: !!isDetailRoot
7970 });
7971 }
7972 } // Remove previous page in case of "forced"
7973
7974
7975 var backIndex;
7976
7977 if (options.force) {
7978 if ($oldPage.prev('.page-previous:not(.stacked)').length > 0 || $oldPage.prev('.page-previous').length === 0) {
7979 if (router.history.indexOf(options.route.url) >= 0) {
7980 backIndex = router.history.length - router.history.indexOf(options.route.url) - 1;
7981 router.history = router.history.slice(0, router.history.indexOf(options.route.url) + 2);
7982 view.history = router.history;
7983 } else if (router.history[[router.history.length - 2]]) {
7984 router.history[router.history.length - 2] = options.route.url;
7985 } else {
7986 router.history.unshift(router.url);
7987 }
7988
7989 if (backIndex && router.params.stackPages) {
7990 $oldPage.prevAll('.page-previous').each(function (pageToRemove) {
7991 var $pageToRemove = $(pageToRemove);
7992 var $navbarToRemove;
7993
7994 if (dynamicNavbar) {
7995 // $navbarToRemove = $oldNavbarEl.prevAll('.navbar-previous').eq(index);
7996 $navbarToRemove = $(app.navbar.getElByPage($pageToRemove));
7997 }
7998
7999 if ($pageToRemove[0] !== $newPage[0] && $pageToRemove.index() > $newPage.index()) {
8000 if (router.initialPages.indexOf($pageToRemove[0]) >= 0) {
8001 $pageToRemove.addClass('stacked');
8002 $pageToRemove.trigger('page:stack');
8003 router.emit('pageStack', $pageToRemove[0]);
8004
8005 if (dynamicNavbar) {
8006 $navbarToRemove.addClass('stacked');
8007 }
8008 } else {
8009 router.pageCallback('beforeRemove', $pageToRemove, $navbarToRemove, 'previous', undefined, options);
8010
8011 if ($pageToRemove[0] === masterPageEl) {
8012 masterPageRemoved = true;
8013 }
8014
8015 router.removePage($pageToRemove);
8016
8017 if (dynamicNavbar && $navbarToRemove.length > 0) {
8018 router.removeNavbar($navbarToRemove);
8019 }
8020 }
8021 }
8022 });
8023 } else {
8024 var $pageToRemove = $oldPage.prev('.page-previous:not(.stacked)');
8025 var $navbarToRemove;
8026
8027 if (dynamicNavbar) {
8028 // $navbarToRemove = $oldNavbarEl.prev('.navbar-inner:not(.stacked)');
8029 $navbarToRemove = $(app.navbar.getElByPage($pageToRemove));
8030 }
8031
8032 if (router.params.stackPages && router.initialPages.indexOf($pageToRemove[0]) >= 0) {
8033 $pageToRemove.addClass('stacked');
8034 $pageToRemove.trigger('page:stack');
8035 router.emit('pageStack', $pageToRemove[0]);
8036 $navbarToRemove.addClass('stacked');
8037 } else if ($pageToRemove.length > 0) {
8038 router.pageCallback('beforeRemove', $pageToRemove, $navbarToRemove, 'previous', undefined, options);
8039
8040 if ($pageToRemove[0] === masterPageEl) {
8041 masterPageRemoved = true;
8042 }
8043
8044 router.removePage($pageToRemove);
8045
8046 if (dynamicNavbar && $navbarToRemove.length) {
8047 router.removeNavbar($navbarToRemove);
8048 }
8049 }
8050 }
8051 }
8052 } // Insert new page
8053
8054
8055 var newPageInDom = $newPage.parents(document).length > 0;
8056 var f7Component = $newPage[0].f7Component;
8057
8058 function insertPage() {
8059 if (initialPreload) {
8060 if (!newPageInDom && f7Component) {
8061 f7Component.mount(function (componentEl) {
8062 router.$el.append(componentEl);
8063 });
8064 } else {
8065 router.$el.append($newPage);
8066 }
8067 }
8068
8069 if ($newPage.next($oldPage).length === 0) {
8070 if (!newPageInDom && f7Component) {
8071 f7Component.mount(function (componentEl) {
8072 $(componentEl).insertBefore($oldPage);
8073 });
8074 } else {
8075 $newPage.insertBefore($oldPage);
8076 }
8077 }
8078
8079 if (dynamicNavbar && $newNavbarEl.length) {
8080 if ($newNavbarEl.find('.title-large').length) {
8081 $newNavbarEl.addClass('navbar-large');
8082 }
8083
8084 $newNavbarEl.insertBefore($oldNavbarEl);
8085
8086 if ($oldNavbarEl.length > 0) {
8087 $newNavbarEl.insertBefore($oldNavbarEl);
8088 } else {
8089 if (!router.$navbarsEl.parents(document).length) {
8090 router.$el.prepend(router.$navbarsEl);
8091 }
8092
8093 $navbarsEl.append($newNavbarEl);
8094 }
8095 }
8096
8097 if (!newPageInDom) {
8098 router.pageCallback('mounted', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage);
8099 } else if (options.route && options.route.route && options.route.route.keepAlive && !$newPage[0].f7PageMounted) {
8100 $newPage[0].f7PageMounted = true;
8101 router.pageCallback('mounted', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage);
8102 }
8103 }
8104
8105 if (options.preload) {
8106 // Insert Page
8107 insertPage(); // Tab route
8108
8109 if (options.route.route.tab) {
8110 router.tabLoad(options.route.route.tab, extend({}, options, {
8111 history: false,
8112 browserHistory: false,
8113 preload: true
8114 }));
8115 }
8116
8117 if (isMaster) {
8118 $newPage.removeClass('page-master-stacked').trigger('page:masterunstack');
8119 router.emit('pageMasterUnstack', $newPage[0]);
8120
8121 if (dynamicNavbar) {
8122 $(app.navbar.getElByPage($newPage)).removeClass('navbar-master-stacked');
8123 router.emit('navbarMasterUnstack', app.navbar.getElByPage($newPage));
8124 }
8125 } // Page init and before init events
8126
8127
8128 router.pageCallback('init', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage);
8129
8130 if (initialPreload) {
8131 router.pageCallback('beforeIn', $newPage, $newNavbarEl, 'current', undefined, options);
8132 router.pageCallback('afterIn', $newPage, $newNavbarEl, 'current', undefined, options);
8133 }
8134
8135 var $previousPages = $newPage.prevAll('.page-previous:not(.stacked):not(.page-master)');
8136
8137 if ($previousPages.length > 0) {
8138 $previousPages.each(function (pageToRemove) {
8139 var $pageToRemove = $(pageToRemove);
8140 var $navbarToRemove;
8141
8142 if (dynamicNavbar) {
8143 // $navbarToRemove = $newNavbarEl.prevAll('.navbar-previous:not(.stacked)').eq(index);
8144 $navbarToRemove = $(app.navbar.getElByPage($pageToRemove));
8145 }
8146
8147 if (router.params.stackPages && router.initialPages.indexOf(pageToRemove) >= 0) {
8148 $pageToRemove.addClass('stacked');
8149 $pageToRemove.trigger('page:stack');
8150 router.emit('pageStack', $pageToRemove[0]);
8151
8152 if (dynamicNavbar) {
8153 $navbarToRemove.addClass('stacked');
8154 }
8155 } else {
8156 router.pageCallback('beforeRemove', $pageToRemove, $navbarToRemove, 'previous', undefined);
8157 router.removePage($pageToRemove);
8158
8159 if (dynamicNavbar && $navbarToRemove.length) {
8160 router.removeNavbar($navbarToRemove);
8161 }
8162 }
8163 });
8164 }
8165
8166 router.allowPageChange = true;
8167 return router;
8168 } // History State
8169
8170
8171 if (!(device.ie || device.edge || device.firefox && !device.ios)) {
8172 if (router.params.browserHistory && options.browserHistory) {
8173 if (options.replaceState) {
8174 var browserHistoryRoot = router.params.browserHistoryRoot || '';
8175 History.replace(view.id, {
8176 url: options.route.url
8177 }, browserHistoryRoot + router.params.browserHistorySeparator + options.route.url);
8178 } else if (backIndex) {
8179 History.go(-backIndex);
8180 } else {
8181 History.back();
8182 }
8183 }
8184 } // Update History
8185
8186
8187 if (options.replaceState) {
8188 router.history[router.history.length - 1] = options.route.url;
8189 } else {
8190 if (router.history.length === 1) {
8191 router.history.unshift(router.url);
8192 }
8193
8194 router.history.pop();
8195 }
8196
8197 router.saveHistory(); // Current Page & Navbar
8198
8199 router.currentPageEl = $newPage[0];
8200
8201 if (dynamicNavbar && $newNavbarEl.length) {
8202 router.currentNavbarEl = $newNavbarEl[0];
8203 } else {
8204 delete router.currentNavbarEl;
8205 } // Current Route
8206
8207
8208 router.currentRoute = options.route; // History State
8209
8210 if (device.ie || device.edge || device.firefox && !device.ios) {
8211 if (router.params.browserHistory && options.browserHistory) {
8212 if (options.replaceState) {
8213 var _browserHistoryRoot = router.params.browserHistoryRoot || '';
8214
8215 History.replace(view.id, {
8216 url: options.route.url
8217 }, _browserHistoryRoot + router.params.browserHistorySeparator + options.route.url);
8218 } else if (backIndex) {
8219 History.go(-backIndex);
8220 } else {
8221 History.back();
8222 }
8223 }
8224 } // Insert Page
8225
8226
8227 insertPage(); // Load Tab
8228
8229 if (options.route.route.tab) {
8230 router.tabLoad(options.route.route.tab, extend({}, options, {
8231 history: false,
8232 browserHistory: false
8233 }));
8234 } // Check master detail
8235
8236
8237 if (masterDetailEnabled && (currentIsMaster || masterPageRemoved)) {
8238 view.checkMasterDetailBreakpoint(false);
8239 } // Page init and before init events
8240
8241
8242 router.pageCallback('init', $newPage, $newNavbarEl, 'previous', 'current', options, $oldPage); // Before animation callback
8243
8244 router.pageCallback('beforeOut', $oldPage, $oldNavbarEl, 'current', 'next', options);
8245 router.pageCallback('beforeIn', $newPage, $newNavbarEl, 'previous', 'current', options); // Animation
8246
8247 function afterAnimation() {
8248 // Set classes
8249 router.setPagePosition($newPage, 'current', false);
8250 router.setPagePosition($oldPage, 'next', true);
8251
8252 if (dynamicNavbar) {
8253 router.setNavbarPosition($newNavbarEl, 'current', false);
8254 router.setNavbarPosition($oldNavbarEl, 'next', true);
8255 } // After animation event
8256
8257
8258 router.pageCallback('afterOut', $oldPage, $oldNavbarEl, 'current', 'next', options);
8259 router.pageCallback('afterIn', $newPage, $newNavbarEl, 'previous', 'current', options); // Remove Old Page
8260
8261 if (router.params.stackPages && router.initialPages.indexOf($oldPage[0]) >= 0) {
8262 $oldPage.addClass('stacked');
8263 $oldPage.trigger('page:stack');
8264 router.emit('pageStack', $oldPage[0]);
8265
8266 if (dynamicNavbar) {
8267 $oldNavbarEl.addClass('stacked');
8268 }
8269 } else {
8270 router.pageCallback('beforeRemove', $oldPage, $oldNavbarEl, 'next', undefined, options);
8271 router.removePage($oldPage);
8272
8273 if (dynamicNavbar && $oldNavbarEl.length) {
8274 router.removeNavbar($oldNavbarEl);
8275 }
8276 }
8277
8278 router.allowPageChange = true;
8279 router.emit('routeChanged', router.currentRoute, router.previousRoute, router); // Preload previous page
8280
8281 var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + "SwipeBack"];
8282
8283 if (preloadPreviousPage && router.history[router.history.length - 2] && !isMaster) {
8284 router.back(router.history[router.history.length - 2], {
8285 preload: true
8286 });
8287 }
8288
8289 if (router.params.browserHistory) {
8290 History.clearRouterQueue();
8291 }
8292 }
8293
8294 function setPositionClasses() {
8295 router.setPagePosition($oldPage, 'current');
8296 router.setPagePosition($newPage, 'previous', false);
8297
8298 if (dynamicNavbar) {
8299 router.setNavbarPosition($oldNavbarEl, 'current');
8300 router.setNavbarPosition($newNavbarEl, 'previous', false);
8301 }
8302 }
8303
8304 if (options.animate && !(currentIsMaster && app.width >= router.params.masterDetailBreakpoint)) {
8305 var transition = router.params.transition;
8306
8307 if ($oldPage[0] && $oldPage[0].f7PageTransition) {
8308 transition = $oldPage[0].f7PageTransition;
8309 delete $oldPage[0].f7PageTransition;
8310 }
8311
8312 if (options.transition) transition = options.transition;
8313
8314 if (!transition && router.previousRoute && router.previousRoute.route) {
8315 transition = router.previousRoute.route.transition;
8316 }
8317
8318 if (!transition && router.previousRoute && router.previousRoute.route && router.previousRoute.route.options) {
8319 transition = router.previousRoute.route.options.transition;
8320 }
8321
8322 setPositionClasses();
8323 router.animate($oldPage, $newPage, $oldNavbarEl, $newNavbarEl, 'backward', transition, function () {
8324 afterAnimation();
8325 });
8326 } else {
8327 afterAnimation();
8328 }
8329
8330 return router;
8331 }
8332
8333 function loadBack(router, backParams, backOptions, ignorePageChange) {
8334 if (!router.allowPageChange && !ignorePageChange) return router;
8335 var params = backParams;
8336 var options = backOptions;
8337 var url = params.url,
8338 content = params.content,
8339 el = params.el,
8340 pageName = params.pageName,
8341 component = params.component,
8342 componentUrl = params.componentUrl;
8343
8344 if (options.route.url && router.url === options.route.url && !(options.reloadCurrent || options.reloadPrevious) && !router.params.allowDuplicateUrls) {
8345 return false;
8346 }
8347
8348 if (!options.route && url) {
8349 options.route = router.parseRouteUrl(url);
8350 } // Component Callbacks
8351
8352
8353 function resolve(pageEl, newOptions) {
8354 return backward(router, pageEl, extend(options, newOptions));
8355 }
8356
8357 function reject() {
8358 router.allowPageChange = true;
8359 return router;
8360 }
8361
8362 if (url || componentUrl || component) {
8363 router.allowPageChange = false;
8364 } // Proceed
8365
8366
8367 if (content) {
8368 backward(router, router.getPageEl(content), options);
8369 } else if (el) {
8370 // Load page from specified HTMLElement or by page name in pages container
8371 backward(router, router.getPageEl(el), options);
8372 } else if (pageName) {
8373 // Load page by page name in pages container
8374 backward(router, router.$el.children(".page[data-name=\"" + pageName + "\"]").eq(0), options);
8375 } else if (component || componentUrl) {
8376 // Load from component (F7/Vue/React/...)
8377 try {
8378 router.pageComponentLoader({
8379 routerEl: router.el,
8380 component: component,
8381 componentUrl: componentUrl,
8382 options: options,
8383 resolve: resolve,
8384 reject: reject
8385 });
8386 } catch (err) {
8387 router.allowPageChange = true;
8388 throw err;
8389 }
8390 } else if (url) {
8391 // Load using XHR
8392 if (router.xhrAbortController) {
8393 router.xhrAbortController.abort();
8394 router.xhrAbortController = false;
8395 }
8396
8397 router.xhrRequest(url, options).then(function (pageContent) {
8398 backward(router, router.getPageEl(pageContent), options);
8399 }).catch(function () {
8400 router.allowPageChange = true;
8401 });
8402 }
8403
8404 return router;
8405 }
8406
8407 function back() {
8408 var router = this;
8409 var device = getDevice();
8410 if (router.swipeBackActive) return router;
8411 var navigateUrl;
8412 var navigateOptions;
8413 var route;
8414
8415 if (typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'object') {
8416 navigateOptions = (arguments.length <= 0 ? undefined : arguments[0]) || {};
8417 } else {
8418 navigateUrl = arguments.length <= 0 ? undefined : arguments[0];
8419 navigateOptions = (arguments.length <= 1 ? undefined : arguments[1]) || {};
8420 }
8421
8422 var _navigateOptions = navigateOptions,
8423 name = _navigateOptions.name,
8424 params = _navigateOptions.params,
8425 query = _navigateOptions.query;
8426
8427 if (name) {
8428 navigateUrl = router.generateUrl({
8429 name: name,
8430 params: params,
8431 query: query
8432 });
8433
8434 if (navigateUrl) {
8435 return router.back(navigateUrl, extend({}, navigateOptions, {
8436 name: null,
8437 params: null,
8438 query: null
8439 }));
8440 }
8441
8442 return router;
8443 }
8444
8445 var app = router.app;
8446 appRouterCheck(router, 'back');
8447 var currentRouteIsModal = router.currentRoute.modal;
8448 var modalType;
8449
8450 if (!currentRouteIsModal) {
8451 'popup popover sheet loginScreen actions customModal panel'.split(' ').forEach(function (modalLoadProp) {
8452 if (router.currentRoute.route[modalLoadProp]) {
8453 currentRouteIsModal = true;
8454 modalType = modalLoadProp;
8455 }
8456 });
8457 }
8458
8459 if (currentRouteIsModal && !navigateOptions.preload) {
8460 var modalToClose = router.currentRoute.modal || router.currentRoute.route.modalInstance || app[modalType].get();
8461 var previousUrl = router.history[router.history.length - 2];
8462 var previousRoute; // check if previous route is modal too
8463
8464 if (modalToClose && modalToClose.$el) {
8465 var prevOpenedModals = modalToClose.$el.prevAll('.modal-in');
8466
8467 if (prevOpenedModals.length && prevOpenedModals[0].f7Modal) {
8468 var modalEl = prevOpenedModals[0]; // check if current router not inside of the modalEl
8469
8470 if (!router.$el.parents(modalEl).length) {
8471 previousRoute = modalEl.f7Modal.route;
8472 }
8473 }
8474 }
8475
8476 if (!previousRoute) {
8477 previousRoute = router.findMatchingRoute(previousUrl);
8478 }
8479
8480 if (!previousRoute && previousUrl) {
8481 previousRoute = {
8482 url: previousUrl,
8483 path: previousUrl.split('?')[0],
8484 query: parseUrlQuery(previousUrl),
8485 route: {
8486 path: previousUrl.split('?')[0],
8487 url: previousUrl
8488 }
8489 };
8490 }
8491
8492 if (!navigateUrl || navigateUrl.replace(/[# ]/g, '').trim().length === 0) {
8493 if (!previousRoute || !modalToClose) {
8494 return router;
8495 }
8496 }
8497
8498 var forceOtherUrl = navigateOptions.force && previousRoute && navigateUrl;
8499
8500 if (previousRoute && modalToClose) {
8501 var isBrokenBrowserHistory = device.ie || device.edge || device.firefox && !device.ios;
8502 var needHistoryBack = router.params.browserHistory && navigateOptions.browserHistory !== false;
8503 var currentRouteWithoutBrowserHistory = router.currentRoute && router.currentRoute.route && router.currentRoute.route.options && router.currentRoute.route.options.browserHistory === false;
8504
8505 if (needHistoryBack && !isBrokenBrowserHistory && !currentRouteWithoutBrowserHistory) {
8506 History.back();
8507 }
8508
8509 router.currentRoute = previousRoute;
8510 router.history.pop();
8511 router.saveHistory();
8512
8513 if (needHistoryBack && isBrokenBrowserHistory && !currentRouteWithoutBrowserHistory) {
8514 History.back();
8515 }
8516
8517 router.modalRemove(modalToClose);
8518
8519 if (forceOtherUrl) {
8520 router.navigate(navigateUrl, {
8521 reloadCurrent: true
8522 });
8523 }
8524 } else if (modalToClose) {
8525 router.modalRemove(modalToClose);
8526
8527 if (navigateUrl) {
8528 router.navigate(navigateUrl, {
8529 reloadCurrent: true
8530 });
8531 }
8532 }
8533
8534 return router;
8535 }
8536
8537 var $previousPage = router.$el.children('.page-current').prevAll('.page-previous:not(.page-master)').eq(0);
8538 var skipMaster;
8539
8540 if (router.params.masterDetailBreakpoint > 0) {
8541 var classes = [];
8542 router.$el.children('.page').each(function (pageEl) {
8543 classes.push(pageEl.className);
8544 });
8545 var $previousMaster = router.$el.children('.page-current').prevAll('.page-master').eq(0);
8546
8547 if ($previousMaster.length) {
8548 var expectedPreviousPageUrl = router.history[router.history.length - 2];
8549 var expectedPreviousPageRoute = router.findMatchingRoute(expectedPreviousPageUrl);
8550
8551 if (expectedPreviousPageRoute && $previousMaster[0].f7Page && expectedPreviousPageRoute.route === $previousMaster[0].f7Page.route.route) {
8552 $previousPage = $previousMaster;
8553
8554 if (!navigateOptions.preload) {
8555 skipMaster = app.width >= router.params.masterDetailBreakpoint;
8556 }
8557 }
8558 }
8559 }
8560
8561 if (!navigateOptions.force && $previousPage.length && !skipMaster) {
8562 if (router.params.browserHistory && $previousPage[0].f7Page && router.history[router.history.length - 2] !== $previousPage[0].f7Page.route.url) {
8563 router.back(router.history[router.history.length - 2], extend(navigateOptions, {
8564 force: true
8565 }));
8566 return router;
8567 }
8568
8569 var previousPageRoute = $previousPage[0].f7Page.route;
8570 processRouteQueue.call(router, previousPageRoute, router.currentRoute, function () {
8571 loadBack(router, {
8572 el: $previousPage
8573 }, extend(navigateOptions, {
8574 route: previousPageRoute
8575 }));
8576 }, function () {}, 'backward');
8577 return router;
8578 } // Navigate URL
8579
8580
8581 if (navigateUrl === '#') {
8582 navigateUrl = undefined;
8583 }
8584
8585 if (navigateUrl && navigateUrl[0] !== '/' && navigateUrl.indexOf('#') !== 0) {
8586 navigateUrl = ((router.path || '/') + navigateUrl).replace('//', '/');
8587 }
8588
8589 if (!navigateUrl && router.history.length > 1) {
8590 navigateUrl = router.history[router.history.length - 2];
8591 }
8592
8593 if (skipMaster && !navigateOptions.force && router.history[router.history.length - 3]) {
8594 return router.back(router.history[router.history.length - 3], extend({}, navigateOptions || {}, {
8595 force: true,
8596 animate: false
8597 }));
8598 }
8599
8600 if (skipMaster && !navigateOptions.force) {
8601 return router;
8602 } // Find route to load
8603
8604
8605 route = router.findMatchingRoute(navigateUrl);
8606
8607 if (!route) {
8608 if (navigateUrl) {
8609 route = {
8610 url: navigateUrl,
8611 path: navigateUrl.split('?')[0],
8612 query: parseUrlQuery(navigateUrl),
8613 route: {
8614 path: navigateUrl.split('?')[0],
8615 url: navigateUrl
8616 }
8617 };
8618 }
8619 }
8620
8621 if (!route) {
8622 return router;
8623 }
8624
8625 if (route.route.redirect) {
8626 return redirect.call(router, 'backward', route, navigateOptions);
8627 }
8628
8629 var options = {};
8630
8631 if (route.route.options) {
8632 extend(options, route.route.options, navigateOptions);
8633 } else {
8634 extend(options, navigateOptions);
8635 }
8636
8637 options.route = route;
8638 var backForceLoaded;
8639
8640 if (options.force && router.params.stackPages) {
8641 router.$el.children('.page-previous.stacked').each(function (pageEl) {
8642 if (pageEl.f7Page && pageEl.f7Page.route && pageEl.f7Page.route.url === route.url) {
8643 backForceLoaded = true;
8644 loadBack(router, {
8645 el: pageEl
8646 }, options);
8647 }
8648 });
8649
8650 if (backForceLoaded) {
8651 return router;
8652 }
8653 }
8654
8655 function resolve() {
8656 var routerLoaded = false;
8657
8658 if (route.route.keepAlive && route.route.keepAliveData) {
8659 loadBack(router, {
8660 el: route.route.keepAliveData.pageEl
8661 }, options);
8662 routerLoaded = true;
8663 }
8664
8665 'url content component pageName el componentUrl'.split(' ').forEach(function (pageLoadProp) {
8666 if (route.route[pageLoadProp] && !routerLoaded) {
8667 var _loadBack;
8668
8669 routerLoaded = true;
8670 loadBack(router, (_loadBack = {}, _loadBack[pageLoadProp] = route.route[pageLoadProp], _loadBack), options);
8671 }
8672 });
8673 if (routerLoaded) return; // Async
8674
8675 function asyncResolve(resolveParams, resolveOptions) {
8676 router.allowPageChange = false;
8677 loadBack(router, resolveParams, extend(options, resolveOptions), true);
8678 }
8679
8680 function asyncReject() {
8681 router.allowPageChange = true;
8682 }
8683
8684 if (route.route.async) {
8685 router.allowPageChange = false;
8686 route.route.async.call(router, {
8687 router: router,
8688 to: route,
8689 from: router.currentRoute,
8690 resolve: asyncResolve,
8691 reject: asyncReject,
8692 direction: 'backward',
8693 app: app
8694 });
8695 }
8696
8697 if (route.route.asyncComponent) {
8698 asyncComponent(router, route.route.asyncComponent, asyncResolve, asyncReject);
8699 }
8700 }
8701
8702 function reject() {
8703 router.allowPageChange = true;
8704 }
8705
8706 if (options.preload) {
8707 resolve();
8708 } else {
8709 processRouteQueue.call(router, route, router.currentRoute, function () {
8710 if (route.route.modules) {
8711 app.loadModules(Array.isArray(route.route.modules) ? route.route.modules : [route.route.modules]).then(function () {
8712 resolve();
8713 }).catch(function () {
8714 reject();
8715 });
8716 } else {
8717 resolve();
8718 }
8719 }, function () {
8720 reject();
8721 }, 'backward');
8722 } // Return Router
8723
8724
8725 return router;
8726 }
8727
8728 function clearPreviousPages(router) {
8729 appRouterCheck(router, 'clearPreviousPages');
8730 var app = router.app;
8731 var dynamicNavbar = router.dynamicNavbar;
8732 var $pagesToRemove = router.$el.children('.page').filter(function (pageInView) {
8733 if (router.currentRoute && (router.currentRoute.modal || router.currentRoute.panel)) return true;
8734 return pageInView !== router.currentPageEl;
8735 });
8736 $pagesToRemove.each(function (pageEl) {
8737 var $oldPageEl = $(pageEl);
8738 var $oldNavbarEl = $(app.navbar.getElByPage($oldPageEl));
8739
8740 if (router.params.stackPages && router.initialPages.indexOf($oldPageEl[0]) >= 0) {
8741 $oldPageEl.addClass('stacked');
8742
8743 if (dynamicNavbar) {
8744 $oldNavbarEl.addClass('stacked');
8745 }
8746 } else {
8747 // Page remove event
8748 router.pageCallback('beforeRemove', $oldPageEl, $oldNavbarEl, 'previous', undefined, {});
8749 router.removePage($oldPageEl);
8750
8751 if (dynamicNavbar && $oldNavbarEl.length) {
8752 router.removeNavbar($oldNavbarEl);
8753 }
8754 }
8755 });
8756 }
8757
8758 function clearPreviousHistory() {
8759 var router = this;
8760 appRouterCheck(router, 'clearPreviousHistory');
8761 var url = router.history[router.history.length - 1];
8762 clearPreviousPages(router);
8763 router.history = [url];
8764 router.view.history = [url];
8765 router.saveHistory();
8766 }
8767 // eslint-disable-line
8768
8769 var Router = /*#__PURE__*/function (_Framework7Class) {
8770 _inheritsLoose(Router, _Framework7Class);
8771
8772 function Router(app, view) {
8773 var _this;
8774
8775 _this = _Framework7Class.call(this, {}, [typeof view === 'undefined' ? app : view]) || this;
8776
8777 var router = _assertThisInitialized(_this); // Is App Router
8778
8779
8780 router.isAppRouter = typeof view === 'undefined';
8781
8782 if (router.isAppRouter) {
8783 // App Router
8784 extend(false, router, {
8785 app: app,
8786 params: app.params.view,
8787 routes: app.routes || [],
8788 cache: app.cache
8789 });
8790 } else {
8791 // View Router
8792 extend(false, router, {
8793 app: app,
8794 view: view,
8795 viewId: view.id,
8796 id: view.params.routerId,
8797 params: view.params,
8798 routes: view.routes,
8799 history: view.history,
8800 scrollHistory: view.scrollHistory,
8801 cache: app.cache,
8802 dynamicNavbar: app.theme === 'ios' && view.params.iosDynamicNavbar,
8803 initialPages: [],
8804 initialNavbars: []
8805 });
8806 } // Install Modules
8807
8808
8809 router.useModules(); // AllowPageChage
8810
8811 router.allowPageChange = true; // Current Route
8812
8813 var currentRoute = {};
8814 var previousRoute = {};
8815 Object.defineProperty(router, 'currentRoute', {
8816 enumerable: true,
8817 configurable: true,
8818 set: function set(newRoute) {
8819 if (newRoute === void 0) {
8820 newRoute = {};
8821 }
8822
8823 previousRoute = extend({}, currentRoute);
8824 currentRoute = newRoute;
8825 if (!currentRoute) return;
8826 router.url = currentRoute.url;
8827 router.emit('routeChange', newRoute, previousRoute, router);
8828 },
8829 get: function get() {
8830 return currentRoute;
8831 }
8832 });
8833 Object.defineProperty(router, 'previousRoute', {
8834 enumerable: true,
8835 configurable: true,
8836 get: function get() {
8837 return previousRoute;
8838 },
8839 set: function set(newRoute) {
8840 previousRoute = newRoute;
8841 }
8842 });
8843 return router || _assertThisInitialized(_this);
8844 }
8845
8846 var _proto = Router.prototype;
8847
8848 _proto.mount = function mount() {
8849 var router = this;
8850 var view = router.view;
8851 var document = getDocument();
8852 extend(false, router, {
8853 tempDom: document.createElement('div'),
8854 $el: view.$el,
8855 el: view.el,
8856 $navbarsEl: view.$navbarsEl,
8857 navbarsEl: view.navbarsEl
8858 });
8859 router.emit('local::mount routerMount', router);
8860 };
8861
8862 _proto.animatableNavElements = function animatableNavElements($newNavbarEl, $oldNavbarEl, toLarge, fromLarge, direction) {
8863 var router = this;
8864 var dynamicNavbar = router.dynamicNavbar;
8865 var animateIcon = router.params.iosAnimateNavbarBackIcon;
8866 var newNavEls;
8867 var oldNavEls;
8868
8869 function animatableNavEl($el, $navbarInner) {
8870 var isSliding = $el.hasClass('sliding') || $navbarInner.hasClass('sliding');
8871 var isSubnavbar = $el.hasClass('subnavbar');
8872 var needsOpacityTransition = isSliding ? !isSubnavbar : true;
8873 var $iconEl = $el.find('.back .icon');
8874 var isIconLabel;
8875
8876 if (isSliding && animateIcon && $el.hasClass('left') && $iconEl.length > 0 && $iconEl.next('span').length) {
8877 $el = $iconEl.next('span'); // eslint-disable-line
8878
8879 isIconLabel = true;
8880 }
8881
8882 return {
8883 $el: $el,
8884 isIconLabel: isIconLabel,
8885 leftOffset: $el[0].f7NavbarLeftOffset,
8886 rightOffset: $el[0].f7NavbarRightOffset,
8887 isSliding: isSliding,
8888 isSubnavbar: isSubnavbar,
8889 needsOpacityTransition: needsOpacityTransition
8890 };
8891 }
8892
8893 if (dynamicNavbar) {
8894 newNavEls = [];
8895 oldNavEls = [];
8896 $newNavbarEl.children('.navbar-inner').children('.left, .right, .title, .subnavbar').each(function (navEl) {
8897 var $navEl = $(navEl);
8898 if ($navEl.hasClass('left') && fromLarge && direction === 'forward') return;
8899 if ($navEl.hasClass('title') && toLarge) return;
8900 newNavEls.push(animatableNavEl($navEl, $newNavbarEl.children('.navbar-inner')));
8901 });
8902
8903 if (!($oldNavbarEl.hasClass('navbar-master') && router.params.masterDetailBreakpoint > 0 && router.app.width >= router.params.masterDetailBreakpoint)) {
8904 $oldNavbarEl.children('.navbar-inner').children('.left, .right, .title, .subnavbar').each(function (navEl) {
8905 var $navEl = $(navEl);
8906 if ($navEl.hasClass('left') && toLarge && !fromLarge && direction === 'forward') return;
8907 if ($navEl.hasClass('left') && toLarge && direction === 'backward') return;
8908
8909 if ($navEl.hasClass('title') && fromLarge) {
8910 return;
8911 }
8912
8913 oldNavEls.push(animatableNavEl($navEl, $oldNavbarEl.children('.navbar-inner')));
8914 });
8915 }
8916
8917 [oldNavEls, newNavEls].forEach(function (navEls) {
8918 navEls.forEach(function (navEl) {
8919 var n = navEl;
8920 var isSliding = navEl.isSliding,
8921 $el = navEl.$el;
8922 var otherEls = navEls === oldNavEls ? newNavEls : oldNavEls;
8923 if (!(isSliding && $el.hasClass('title') && otherEls)) return;
8924 otherEls.forEach(function (otherNavEl) {
8925 if (otherNavEl.isIconLabel) {
8926 var iconTextEl = otherNavEl.$el[0];
8927 n.leftOffset += iconTextEl ? iconTextEl.offsetLeft || 0 : 0;
8928 }
8929 });
8930 });
8931 });
8932 }
8933
8934 return {
8935 newNavEls: newNavEls,
8936 oldNavEls: oldNavEls
8937 };
8938 };
8939
8940 _proto.animate = function animate($oldPageEl, $newPageEl, $oldNavbarEl, $newNavbarEl, direction, transition, callback) {
8941 var router = this;
8942
8943 if (router.params.animateCustom) {
8944 router.params.animateCustom.apply(router, [$oldPageEl, $newPageEl, $oldNavbarEl, $newNavbarEl, direction, callback]);
8945 return;
8946 }
8947
8948 var dynamicNavbar = router.dynamicNavbar;
8949 var ios = router.app.theme === 'ios';
8950
8951 if (transition) {
8952 var routerCustomTransitionClass = "router-transition-custom router-transition-" + transition + "-" + direction; // Animate
8953
8954 var onCustomTransitionDone = function onCustomTransitionDone() {
8955 router.$el.removeClass(routerCustomTransitionClass);
8956
8957 if (dynamicNavbar && router.$navbarsEl.length) {
8958 if ($newNavbarEl) {
8959 router.$navbarsEl.prepend($newNavbarEl);
8960 }
8961
8962 if ($oldNavbarEl) {
8963 router.$navbarsEl.prepend($oldNavbarEl);
8964 }
8965 }
8966
8967 if (callback) callback();
8968 };
8969
8970 (direction === 'forward' ? $newPageEl : $oldPageEl).animationEnd(onCustomTransitionDone);
8971
8972 if (dynamicNavbar) {
8973 if ($newNavbarEl && $newPageEl) {
8974 router.setNavbarPosition($newNavbarEl, '');
8975 $newNavbarEl.removeClass('navbar-next navbar-previous navbar-current');
8976 $newPageEl.prepend($newNavbarEl);
8977 }
8978
8979 if ($oldNavbarEl && $oldPageEl) {
8980 router.setNavbarPosition($oldNavbarEl, '');
8981 $oldNavbarEl.removeClass('navbar-next navbar-previous navbar-current');
8982 $oldPageEl.prepend($oldNavbarEl);
8983 }
8984 }
8985
8986 router.$el.addClass(routerCustomTransitionClass);
8987 return;
8988 } // Router Animation class
8989
8990
8991 var routerTransitionClass = "router-transition-" + direction + " router-transition";
8992 var newNavEls;
8993 var oldNavEls;
8994 var fromLarge;
8995 var toLarge;
8996 var toDifferent;
8997 var oldIsLarge;
8998 var newIsLarge;
8999
9000 if (ios && dynamicNavbar) {
9001 var betweenMasterAndDetail = router.params.masterDetailBreakpoint > 0 && router.app.width >= router.params.masterDetailBreakpoint && ($oldNavbarEl.hasClass('navbar-master') && $newNavbarEl.hasClass('navbar-master-detail') || $oldNavbarEl.hasClass('navbar-master-detail') && $newNavbarEl.hasClass('navbar-master'));
9002
9003 if (!betweenMasterAndDetail) {
9004 oldIsLarge = $oldNavbarEl && $oldNavbarEl.hasClass('navbar-large');
9005 newIsLarge = $newNavbarEl && $newNavbarEl.hasClass('navbar-large');
9006 fromLarge = oldIsLarge && !$oldNavbarEl.hasClass('navbar-large-collapsed');
9007 toLarge = newIsLarge && !$newNavbarEl.hasClass('navbar-large-collapsed');
9008 toDifferent = fromLarge && !toLarge || toLarge && !fromLarge;
9009 }
9010
9011 var navEls = router.animatableNavElements($newNavbarEl, $oldNavbarEl, toLarge, fromLarge, direction);
9012 newNavEls = navEls.newNavEls;
9013 oldNavEls = navEls.oldNavEls;
9014 }
9015
9016 function animateNavbars(progress) {
9017 if (!(ios && dynamicNavbar)) return;
9018
9019 if (progress === 1) {
9020 if (toLarge) {
9021 $newNavbarEl.addClass('router-navbar-transition-to-large');
9022 $oldNavbarEl.addClass('router-navbar-transition-to-large');
9023 }
9024
9025 if (fromLarge) {
9026 $newNavbarEl.addClass('router-navbar-transition-from-large');
9027 $oldNavbarEl.addClass('router-navbar-transition-from-large');
9028 }
9029 }
9030
9031 newNavEls.forEach(function (navEl) {
9032 var $el = navEl.$el;
9033 var offset = direction === 'forward' ? navEl.rightOffset : navEl.leftOffset;
9034
9035 if (navEl.isSliding) {
9036 if (navEl.isSubnavbar && newIsLarge) {
9037 // prettier-ignore
9038 $el[0].style.setProperty('transform', "translate3d(" + offset * (1 - progress) + "px, calc(-1 * var(--f7-navbar-large-collapse-progress) * var(--f7-navbar-large-title-height)), 0)", 'important');
9039 } else {
9040 $el.transform("translate3d(" + offset * (1 - progress) + "px,0,0)");
9041 }
9042 }
9043 });
9044 oldNavEls.forEach(function (navEl) {
9045 var $el = navEl.$el;
9046 var offset = direction === 'forward' ? navEl.leftOffset : navEl.rightOffset;
9047
9048 if (navEl.isSliding) {
9049 if (navEl.isSubnavbar && oldIsLarge) {
9050 $el.transform("translate3d(" + offset * progress + "px, calc(-1 * var(--f7-navbar-large-collapse-progress) * var(--f7-navbar-large-title-height)), 0)");
9051 } else {
9052 $el.transform("translate3d(" + offset * progress + "px,0,0)");
9053 }
9054 }
9055 });
9056 } // AnimationEnd Callback
9057
9058
9059 function onDone() {
9060 if (router.dynamicNavbar) {
9061 if ($newNavbarEl) {
9062 $newNavbarEl.removeClass('router-navbar-transition-to-large router-navbar-transition-from-large');
9063 $newNavbarEl.addClass('navbar-no-title-large-transition');
9064 nextFrame$1(function () {
9065 $newNavbarEl.removeClass('navbar-no-title-large-transition');
9066 });
9067 }
9068
9069 if ($oldNavbarEl) {
9070 $oldNavbarEl.removeClass('router-navbar-transition-to-large router-navbar-transition-from-large');
9071 }
9072
9073 if ($newNavbarEl.hasClass('sliding') || $newNavbarEl.children('.navbar-inner.sliding').length) {
9074 $newNavbarEl.find('.title, .left, .right, .left .icon, .subnavbar').transform('');
9075 } else {
9076 $newNavbarEl.find('.sliding').transform('');
9077 }
9078
9079 if ($oldNavbarEl.hasClass('sliding') || $oldNavbarEl.children('.navbar-inner.sliding').length) {
9080 $oldNavbarEl.find('.title, .left, .right, .left .icon, .subnavbar').transform('');
9081 } else {
9082 $oldNavbarEl.find('.sliding').transform('');
9083 }
9084 }
9085
9086 router.$el.removeClass(routerTransitionClass);
9087 if (callback) callback();
9088 }
9089
9090 (direction === 'forward' ? $newPageEl : $oldPageEl).animationEnd(function () {
9091 onDone();
9092 }); // Animate
9093
9094 if (dynamicNavbar) {
9095 // Prepare Navbars
9096 animateNavbars(0);
9097 nextFrame$1(function () {
9098 // Add class, start animation
9099 router.$el.addClass(routerTransitionClass);
9100
9101 if (toDifferent) {
9102 // eslint-disable-next-line
9103 router.el._clientLeft = router.el.clientLeft;
9104 }
9105
9106 animateNavbars(1);
9107 });
9108 } else {
9109 // Add class, start animation
9110 router.$el.addClass(routerTransitionClass);
9111 }
9112 };
9113
9114 _proto.removeModal = function removeModal(modalEl) {
9115 var router = this;
9116 router.removeEl(modalEl);
9117 } // eslint-disable-next-line
9118 ;
9119
9120 _proto.removeTabContent = function removeTabContent(tabEl) {
9121 var $tabEl = $(tabEl);
9122 $tabEl.html('');
9123 };
9124
9125 _proto.removeNavbar = function removeNavbar(el) {
9126 var router = this;
9127 router.removeEl(el);
9128 };
9129
9130 _proto.removePage = function removePage(el) {
9131 var $el = $(el);
9132 var f7Page = $el && $el[0] && $el[0].f7Page;
9133 var router = this;
9134
9135 if (f7Page && f7Page.route && f7Page.route.route && f7Page.route.route.keepAlive) {
9136 $el.remove();
9137 return;
9138 }
9139
9140 router.removeEl(el);
9141 };
9142
9143 _proto.removeEl = function removeEl(el) {
9144 if (!el) return;
9145 var router = this;
9146 var $el = $(el);
9147 if ($el.length === 0) return;
9148 $el.find('.tab').each(function (tabEl) {
9149 $(tabEl).children().each(function (tabChild) {
9150 if (tabChild.f7Component) {
9151 $(tabChild).trigger('tab:beforeremove');
9152 tabChild.f7Component.destroy();
9153 }
9154 });
9155 });
9156
9157 if ($el[0].f7Component && $el[0].f7Component.destroy) {
9158 $el[0].f7Component.destroy();
9159 }
9160
9161 if (!router.params.removeElements) {
9162 return;
9163 }
9164
9165 if (router.params.removeElementsWithTimeout) {
9166 setTimeout(function () {
9167 $el.remove();
9168 }, router.params.removeElementsTimeout);
9169 } else {
9170 $el.remove();
9171 }
9172 };
9173
9174 _proto.getPageEl = function getPageEl(content) {
9175 var router = this;
9176
9177 if (typeof content === 'string') {
9178 router.tempDom.innerHTML = content;
9179 } else {
9180 if ($(content).hasClass('page')) {
9181 return content;
9182 }
9183
9184 router.tempDom.innerHTML = '';
9185 $(router.tempDom).append(content);
9186 }
9187
9188 return router.findElement('.page', router.tempDom);
9189 };
9190
9191 _proto.findElement = function findElement(stringSelector, container, notStacked) {
9192 var router = this;
9193 var view = router.view;
9194 var app = router.app; // Modals Selector
9195
9196 var modalsSelector = '.popup, .dialog, .popover, .actions-modal, .sheet-modal, .login-screen, .page';
9197 var $container = $(container);
9198 var selector = stringSelector;
9199 if (notStacked) selector += ':not(.stacked)';
9200 var found = $container.find(selector).filter(function (el) {
9201 return $(el).parents(modalsSelector).length === 0;
9202 });
9203
9204 if (found.length > 1) {
9205 if (typeof view.selector === 'string') {
9206 // Search in related view
9207 found = $container.find(view.selector + " " + selector);
9208 }
9209
9210 if (found.length > 1) {
9211 // Search in main view
9212 found = $container.find("." + app.params.viewMainClass + " " + selector);
9213 }
9214 }
9215
9216 if (found.length === 1) return found; // Try to find not stacked
9217
9218 if (!notStacked) found = router.findElement(selector, $container, true);
9219 if (found && found.length === 1) return found;
9220 if (found && found.length > 1) return $(found[0]);
9221 return undefined;
9222 };
9223
9224 _proto.flattenRoutes = function flattenRoutes(routes) {
9225 if (routes === void 0) {
9226 routes = this.routes;
9227 }
9228
9229 var router = this;
9230 var flattenedRoutes = [];
9231 routes.forEach(function (route) {
9232 var hasTabRoutes = false;
9233
9234 if ('tabs' in route && route.tabs) {
9235 var mergedPathsRoutes = route.tabs.map(function (tabRoute) {
9236 var tRoute = extend({}, route, {
9237 path: (route.path + "/" + tabRoute.path).replace('///', '/').replace('//', '/'),
9238 parentPath: route.path,
9239 tab: tabRoute
9240 });
9241 delete tRoute.tabs;
9242 delete tRoute.routes;
9243 return tRoute;
9244 });
9245 hasTabRoutes = true;
9246 flattenedRoutes = flattenedRoutes.concat(router.flattenRoutes(mergedPathsRoutes));
9247 }
9248
9249 if ('detailRoutes' in route) {
9250 var _mergedPathsRoutes = route.detailRoutes.map(function (detailRoute) {
9251 var dRoute = extend({}, detailRoute);
9252 dRoute.masterRoute = route;
9253 dRoute.masterRoutePath = route.path;
9254 return dRoute;
9255 });
9256
9257 flattenedRoutes = flattenedRoutes.concat(route, router.flattenRoutes(_mergedPathsRoutes));
9258 }
9259
9260 if ('routes' in route) {
9261 var _mergedPathsRoutes2 = route.routes.map(function (childRoute) {
9262 var cRoute = extend({}, childRoute);
9263 cRoute.path = (route.path + "/" + cRoute.path).replace('///', '/').replace('//', '/');
9264 return cRoute;
9265 });
9266
9267 if (hasTabRoutes) {
9268 flattenedRoutes = flattenedRoutes.concat(router.flattenRoutes(_mergedPathsRoutes2));
9269 } else {
9270 flattenedRoutes = flattenedRoutes.concat(route, router.flattenRoutes(_mergedPathsRoutes2));
9271 }
9272 }
9273
9274 if (!('routes' in route) && !('tabs' in route && route.tabs) && !('detailRoutes' in route)) {
9275 flattenedRoutes.push(route);
9276 }
9277 });
9278 return flattenedRoutes;
9279 } // eslint-disable-next-line
9280 ;
9281
9282 _proto.parseRouteUrl = function parseRouteUrl(url) {
9283 if (!url) return {};
9284 var query = parseUrlQuery(url);
9285 var hash = url.split('#')[1];
9286 var params = {};
9287 var path = url.split('#')[0].split('?')[0];
9288 return {
9289 query: query,
9290 hash: hash,
9291 params: params,
9292 url: url,
9293 path: path
9294 };
9295 };
9296
9297 _proto.generateUrl = function generateUrl(parameters) {
9298 if (parameters === void 0) {
9299 parameters = {};
9300 }
9301
9302 if (typeof parameters === 'string') {
9303 return parameters;
9304 }
9305
9306 var _parameters = parameters,
9307 name = _parameters.name,
9308 path = _parameters.path,
9309 params = _parameters.params,
9310 query = _parameters.query;
9311
9312 if (!name && !path) {
9313 throw new Error('Framework7: "name" or "path" parameter is required');
9314 }
9315
9316 var router = this;
9317 var route = name ? router.findRouteByKey('name', name) : router.findRouteByKey('path', path);
9318
9319 if (!route) {
9320 if (name) {
9321 throw new Error("Framework7: route with name \"" + name + "\" not found");
9322 } else {
9323 throw new Error("Framework7: route with path \"" + path + "\" not found");
9324 }
9325 }
9326
9327 var url = router.constructRouteUrl(route, {
9328 params: params,
9329 query: query
9330 });
9331
9332 if (!url) {
9333 throw new Error("Framework7: can't construct URL for route with name \"" + name + "\"");
9334 }
9335
9336 return url;
9337 } // eslint-disable-next-line
9338 ;
9339
9340 _proto.constructRouteUrl = function constructRouteUrl(route, _temp) {
9341 var _ref = _temp === void 0 ? {} : _temp,
9342 params = _ref.params,
9343 query = _ref.query;
9344
9345 var path = route.path;
9346 var toUrl = compile(path);
9347 var url;
9348
9349 try {
9350 url = toUrl(params || {});
9351 } catch (error) {
9352 throw new Error("Framework7: error constructing route URL from passed params:\nRoute: " + path + "\n" + error.toString());
9353 }
9354
9355 if (query) {
9356 if (typeof query === 'string') url += "?" + query;else if (Object.keys(query).length) url += "?" + serializeObject(query);
9357 }
9358
9359 return url;
9360 };
9361
9362 _proto.findTabRouteUrl = function findTabRouteUrl(tabEl) {
9363 var router = this;
9364 var $tabEl = $(tabEl);
9365 var parentPath = router.currentRoute.route.parentPath;
9366 var tabId = $tabEl.attr('id');
9367 var flattenedRoutes = router.flattenRoutes(router.routes);
9368 var foundTabRouteUrl;
9369 flattenedRoutes.forEach(function (route) {
9370 if (route.parentPath === parentPath && route.tab && route.tab.id === tabId) {
9371 if (router.currentRoute.params && Object.keys(router.currentRoute.params).length > 0) {
9372 foundTabRouteUrl = router.constructRouteUrl(route, {
9373 params: router.currentRoute.params,
9374 query: router.currentRoute.query
9375 });
9376 } else {
9377 foundTabRouteUrl = route.path;
9378 }
9379 }
9380 });
9381 return foundTabRouteUrl;
9382 };
9383
9384 _proto.findRouteByKey = function findRouteByKey(key, value) {
9385 var router = this;
9386 var routes = router.routes;
9387 var flattenedRoutes = router.flattenRoutes(routes);
9388 var matchingRoute;
9389 flattenedRoutes.forEach(function (route) {
9390 if (matchingRoute) return;
9391
9392 if (route[key] === value) {
9393 matchingRoute = route;
9394 }
9395 });
9396 return matchingRoute;
9397 };
9398
9399 _proto.findMatchingRoute = function findMatchingRoute(url) {
9400 if (!url) return undefined;
9401 var router = this;
9402 var routes = router.routes;
9403 var flattenedRoutes = router.flattenRoutes(routes);
9404
9405 var _router$parseRouteUrl = router.parseRouteUrl(url),
9406 path = _router$parseRouteUrl.path,
9407 query = _router$parseRouteUrl.query,
9408 hash = _router$parseRouteUrl.hash,
9409 params = _router$parseRouteUrl.params;
9410
9411 var matchingRoute;
9412 flattenedRoutes.forEach(function (route) {
9413 if (matchingRoute) return;
9414 var keys = [];
9415 var pathsToMatch = [route.path];
9416
9417 if (route.alias) {
9418 if (typeof route.alias === 'string') pathsToMatch.push(route.alias);else if (Array.isArray(route.alias)) {
9419 route.alias.forEach(function (aliasPath) {
9420 pathsToMatch.push(aliasPath);
9421 });
9422 }
9423 }
9424
9425 var matched;
9426 pathsToMatch.forEach(function (pathToMatch) {
9427 if (matched) return;
9428 matched = pathToRegexp(pathToMatch, keys).exec(path);
9429 });
9430
9431 if (matched) {
9432 keys.forEach(function (keyObj, index) {
9433 if (typeof keyObj.name === 'number') return;
9434 var paramValue = matched[index + 1];
9435
9436 if (typeof paramValue === 'undefined' || paramValue === null) {
9437 params[keyObj.name] = paramValue;
9438 } else {
9439 params[keyObj.name] = decodeURIComponent(paramValue);
9440 }
9441 });
9442 var parentPath;
9443
9444 if (route.parentPath) {
9445 parentPath = path.split('/').slice(0, route.parentPath.split('/').length - 1).join('/');
9446 }
9447
9448 matchingRoute = {
9449 query: query,
9450 hash: hash,
9451 params: params,
9452 url: url,
9453 path: path,
9454 parentPath: parentPath,
9455 route: route,
9456 name: route.name
9457 };
9458 }
9459 });
9460 return matchingRoute;
9461 } // eslint-disable-next-line
9462 ;
9463
9464 _proto.replaceRequestUrlParams = function replaceRequestUrlParams(url, options) {
9465 if (url === void 0) {
9466 url = '';
9467 }
9468
9469 if (options === void 0) {
9470 options = {};
9471 }
9472
9473 var compiledUrl = url;
9474
9475 if (typeof compiledUrl === 'string' && compiledUrl.indexOf('{{') >= 0 && options && options.route && options.route.params && Object.keys(options.route.params).length) {
9476 Object.keys(options.route.params).forEach(function (paramName) {
9477 var regExp = new RegExp("{{" + paramName + "}}", 'g');
9478 compiledUrl = compiledUrl.replace(regExp, options.route.params[paramName] || '');
9479 });
9480 }
9481
9482 return compiledUrl;
9483 };
9484
9485 _proto.removeFromXhrCache = function removeFromXhrCache(url) {
9486 var router = this;
9487 var xhrCache = router.cache.xhr;
9488 var index = false;
9489
9490 for (var i = 0; i < xhrCache.length; i += 1) {
9491 if (xhrCache[i].url === url) index = i;
9492 }
9493
9494 if (index !== false) xhrCache.splice(index, 1);
9495 };
9496
9497 _proto.xhrRequest = function xhrRequest(requestUrl, options) {
9498 var router = this;
9499 var params = router.params;
9500 var ignoreCache = options.ignoreCache;
9501 var url = requestUrl;
9502 var hasQuery = url.indexOf('?') >= 0;
9503
9504 if (params.passRouteQueryToRequest && options && options.route && options.route.query && Object.keys(options.route.query).length) {
9505 url += "" + (hasQuery ? '&' : '?') + serializeObject(options.route.query);
9506 hasQuery = true;
9507 }
9508
9509 if (params.passRouteParamsToRequest && options && options.route && options.route.params && Object.keys(options.route.params).length) {
9510 url += "" + (hasQuery ? '&' : '?') + serializeObject(options.route.params);
9511 hasQuery = true;
9512 }
9513
9514 if (url.indexOf('{{') >= 0) {
9515 url = router.replaceRequestUrlParams(url, options);
9516 } // should we ignore get params or not
9517
9518
9519 if (params.xhrCacheIgnoreGetParameters && url.indexOf('?') >= 0) {
9520 url = url.split('?')[0];
9521 }
9522
9523 return new Promise(function (resolve, reject) {
9524 if (params.xhrCache && !ignoreCache && url.indexOf('nocache') < 0 && params.xhrCacheIgnore.indexOf(url) < 0) {
9525 for (var i = 0; i < router.cache.xhr.length; i += 1) {
9526 var cachedUrl = router.cache.xhr[i];
9527
9528 if (cachedUrl.url === url) {
9529 // Check expiration
9530 if (now() - cachedUrl.time < params.xhrCacheDuration) {
9531 // Load from cache
9532 resolve(cachedUrl.content);
9533 return;
9534 }
9535 }
9536 }
9537 }
9538
9539 router.xhrAbortController = router.app.request.abortController();
9540 router.app.request({
9541 abortController: router.xhrAbortController,
9542 url: url,
9543 method: 'GET',
9544 beforeSend: function beforeSend(xhr) {
9545 router.emit('routerAjaxStart', xhr, options);
9546 },
9547 complete: function complete(xhr, status) {
9548 router.emit('routerAjaxComplete', xhr);
9549
9550 if (status !== 'error' && status !== 'timeout' && xhr.status >= 200 && xhr.status < 300 || xhr.status === 0) {
9551 if (params.xhrCache && xhr.responseText !== '') {
9552 router.removeFromXhrCache(url);
9553 router.cache.xhr.push({
9554 url: url,
9555 time: now(),
9556 content: xhr.responseText
9557 });
9558 }
9559
9560 router.emit('routerAjaxSuccess', xhr, options);
9561 resolve(xhr.responseText);
9562 } else {
9563 router.emit('routerAjaxError', xhr, options);
9564 reject(xhr);
9565 }
9566 },
9567 error: function error(xhr) {
9568 router.emit('routerAjaxError', xhr, options);
9569 reject(xhr);
9570 }
9571 });
9572 });
9573 };
9574
9575 _proto.setNavbarPosition = function setNavbarPosition($el, position, ariaHidden) {
9576 var router = this;
9577 $el.removeClass('navbar-previous navbar-current navbar-next');
9578
9579 if (position) {
9580 $el.addClass("navbar-" + position);
9581 }
9582
9583 if (ariaHidden === false) {
9584 $el.removeAttr('aria-hidden');
9585 } else if (ariaHidden === true) {
9586 $el.attr('aria-hidden', 'true');
9587 }
9588
9589 $el.trigger('navbar:position', {
9590 position: position
9591 });
9592 router.emit('navbarPosition', $el[0], position);
9593 };
9594
9595 _proto.setPagePosition = function setPagePosition($el, position, ariaHidden) {
9596 var router = this;
9597 $el.removeClass('page-previous page-current page-next');
9598 $el.addClass("page-" + position);
9599
9600 if (ariaHidden === false) {
9601 $el.removeAttr('aria-hidden');
9602 } else if (ariaHidden === true) {
9603 $el.attr('aria-hidden', 'true');
9604 }
9605
9606 $el.trigger('page:position', {
9607 position: position
9608 });
9609 router.emit('pagePosition', $el[0], position);
9610 } // Remove theme elements
9611 ;
9612
9613 _proto.removeThemeElements = function removeThemeElements(el) {
9614 var router = this;
9615 var theme = router.app.theme;
9616 var toRemove;
9617
9618 if (theme === 'ios') {
9619 toRemove = '.md-only, .aurora-only, .if-md, .if-aurora, .if-not-ios, .not-ios';
9620 } else if (theme === 'md') {
9621 toRemove = '.ios-only, .aurora-only, .if-ios, .if-aurora, .if-not-md, .not-md';
9622 } else if (theme === 'aurora') {
9623 toRemove = '.ios-only, .md-only, .if-ios, .if-md, .if-not-aurora, .not-aurora';
9624 }
9625
9626 $(el).find(toRemove).remove();
9627 };
9628
9629 _proto.getPageData = function getPageData(pageEl, navbarEl, from, to, route, pageFromEl) {
9630 if (route === void 0) {
9631 route = {};
9632 }
9633
9634 var router = this;
9635 var $pageEl = $(pageEl).eq(0);
9636 var $navbarEl = $(navbarEl).eq(0);
9637 var currentPage = $pageEl[0].f7Page || {};
9638 var direction;
9639 var pageFrom;
9640 if (from === 'next' && to === 'current' || from === 'current' && to === 'previous') direction = 'forward';
9641 if (from === 'current' && to === 'next' || from === 'previous' && to === 'current') direction = 'backward';
9642
9643 if (currentPage && !currentPage.fromPage) {
9644 var $pageFromEl = $(pageFromEl);
9645
9646 if ($pageFromEl.length) {
9647 pageFrom = $pageFromEl[0].f7Page;
9648 }
9649 }
9650
9651 pageFrom = currentPage.pageFrom || pageFrom;
9652
9653 if (pageFrom && pageFrom.pageFrom) {
9654 pageFrom.pageFrom = null;
9655 }
9656
9657 var page = {
9658 app: router.app,
9659 view: router.view,
9660 router: router,
9661 $el: $pageEl,
9662 el: $pageEl[0],
9663 $pageEl: $pageEl,
9664 pageEl: $pageEl[0],
9665 $navbarEl: $navbarEl,
9666 navbarEl: $navbarEl[0],
9667 name: $pageEl.attr('data-name'),
9668 position: from,
9669 from: from,
9670 to: to,
9671 direction: direction,
9672 route: currentPage.route ? currentPage.route : route,
9673 pageFrom: pageFrom
9674 };
9675 $pageEl[0].f7Page = page;
9676 return page;
9677 } // Callbacks
9678 ;
9679
9680 _proto.pageCallback = function pageCallback(callback, pageEl, navbarEl, from, to, options, pageFromEl) {
9681 if (options === void 0) {
9682 options = {};
9683 }
9684
9685 if (!pageEl) return;
9686 var router = this;
9687 var $pageEl = $(pageEl);
9688 if (!$pageEl.length) return;
9689 var $navbarEl = $(navbarEl);
9690 var _options = options,
9691 route = _options.route;
9692 var restoreScrollTopOnBack = router.params.restoreScrollTopOnBack && !(router.params.masterDetailBreakpoint > 0 && $pageEl.hasClass('page-master') && router.app.width >= router.params.masterDetailBreakpoint);
9693 var keepAlive = $pageEl[0].f7Page && $pageEl[0].f7Page.route && $pageEl[0].f7Page.route.route && $pageEl[0].f7Page.route.route.keepAlive;
9694
9695 if (callback === 'beforeRemove' && keepAlive) {
9696 callback = 'beforeUnmount'; // eslint-disable-line
9697 }
9698
9699 var camelName = "page" + (callback[0].toUpperCase() + callback.slice(1, callback.length));
9700 var colonName = "page:" + callback.toLowerCase();
9701 var page = {};
9702
9703 if (callback === 'beforeRemove' && $pageEl[0].f7Page) {
9704 page = extend($pageEl[0].f7Page, {
9705 from: from,
9706 to: to,
9707 position: from
9708 });
9709 } else {
9710 page = router.getPageData($pageEl[0], $navbarEl[0], from, to, route, pageFromEl);
9711 }
9712
9713 page.swipeBack = !!options.swipeBack;
9714
9715 var _ref2 = options.route ? options.route.route : {},
9716 _ref2$on = _ref2.on,
9717 on = _ref2$on === void 0 ? {} : _ref2$on,
9718 _ref2$once = _ref2.once,
9719 once = _ref2$once === void 0 ? {} : _ref2$once;
9720
9721 if (options.on) {
9722 extend(on, options.on);
9723 }
9724
9725 if (options.once) {
9726 extend(once, options.once);
9727 }
9728
9729 function attachEvents() {
9730 if ($pageEl[0].f7RouteEventsAttached) return;
9731 $pageEl[0].f7RouteEventsAttached = true;
9732
9733 if (on && Object.keys(on).length > 0) {
9734 $pageEl[0].f7RouteEventsOn = on;
9735 Object.keys(on).forEach(function (eventName) {
9736 on[eventName] = on[eventName].bind(router);
9737 $pageEl.on(eventNameToColonCase(eventName), on[eventName]);
9738 });
9739 }
9740
9741 if (once && Object.keys(once).length > 0) {
9742 $pageEl[0].f7RouteEventsOnce = once;
9743 Object.keys(once).forEach(function (eventName) {
9744 once[eventName] = once[eventName].bind(router);
9745 $pageEl.once(eventNameToColonCase(eventName), once[eventName]);
9746 });
9747 }
9748 }
9749
9750 function detachEvents() {
9751 if (!$pageEl[0].f7RouteEventsAttached) return;
9752
9753 if ($pageEl[0].f7RouteEventsOn) {
9754 Object.keys($pageEl[0].f7RouteEventsOn).forEach(function (eventName) {
9755 $pageEl.off(eventNameToColonCase(eventName), $pageEl[0].f7RouteEventsOn[eventName]);
9756 });
9757 }
9758
9759 if ($pageEl[0].f7RouteEventsOnce) {
9760 Object.keys($pageEl[0].f7RouteEventsOnce).forEach(function (eventName) {
9761 $pageEl.off(eventNameToColonCase(eventName), $pageEl[0].f7RouteEventsOnce[eventName]);
9762 });
9763 }
9764
9765 $pageEl[0].f7RouteEventsAttached = null;
9766 $pageEl[0].f7RouteEventsOn = null;
9767 $pageEl[0].f7RouteEventsOnce = null;
9768 delete $pageEl[0].f7RouteEventsAttached;
9769 delete $pageEl[0].f7RouteEventsOn;
9770 delete $pageEl[0].f7RouteEventsOnce;
9771 }
9772
9773 if (callback === 'mounted') {
9774 attachEvents();
9775 }
9776
9777 if (callback === 'init') {
9778 if (restoreScrollTopOnBack && (from === 'previous' || !from) && to === 'current' && router.scrollHistory[page.route.url] && !$pageEl.hasClass('no-restore-scroll')) {
9779 var $pageContent = $pageEl.find('.page-content');
9780
9781 if ($pageContent.length > 0) {
9782 // eslint-disable-next-line
9783 $pageContent = $pageContent.filter(function (pageContentEl) {
9784 return $(pageContentEl).parents('.tab:not(.tab-active)').length === 0 && !$(pageContentEl).is('.tab:not(.tab-active)');
9785 });
9786 }
9787
9788 $pageContent.scrollTop(router.scrollHistory[page.route.url]);
9789 }
9790
9791 attachEvents();
9792
9793 if ($pageEl[0].f7PageInitialized) {
9794 $pageEl.trigger('page:reinit', page);
9795 router.emit('pageReinit', page);
9796 return;
9797 }
9798
9799 $pageEl[0].f7PageInitialized = true;
9800 }
9801
9802 if (restoreScrollTopOnBack && callback === 'beforeOut' && from === 'current' && to === 'previous') {
9803 // Save scroll position
9804 var _$pageContent = $pageEl.find('.page-content');
9805
9806 if (_$pageContent.length > 0) {
9807 // eslint-disable-next-line
9808 _$pageContent = _$pageContent.filter(function (pageContentEl) {
9809 return $(pageContentEl).parents('.tab:not(.tab-active)').length === 0 && !$(pageContentEl).is('.tab:not(.tab-active)');
9810 });
9811 }
9812
9813 router.scrollHistory[page.route.url] = _$pageContent.scrollTop();
9814 }
9815
9816 if (restoreScrollTopOnBack && callback === 'beforeOut' && from === 'current' && to === 'next') {
9817 // Delete scroll position
9818 delete router.scrollHistory[page.route.url];
9819 }
9820
9821 $pageEl.trigger(colonName, page);
9822 router.emit(camelName, page);
9823
9824 if (callback === 'beforeRemove' || callback === 'beforeUnmount') {
9825 detachEvents();
9826
9827 if (!keepAlive) {
9828 if ($pageEl[0].f7Page && $pageEl[0].f7Page.navbarEl) {
9829 delete $pageEl[0].f7Page.navbarEl.f7Page;
9830 }
9831
9832 $pageEl[0].f7Page = null;
9833 }
9834 }
9835 };
9836
9837 _proto.saveHistory = function saveHistory() {
9838 var router = this;
9839 var window = getWindow();
9840 router.view.history = router.history;
9841
9842 if (router.params.browserHistory && router.params.browserHistoryStoreHistory && window.localStorage) {
9843 window.localStorage["f7router-" + router.view.id + "-history"] = JSON.stringify(router.history);
9844 }
9845 };
9846
9847 _proto.restoreHistory = function restoreHistory() {
9848 var router = this;
9849 var window = getWindow();
9850
9851 if (router.params.browserHistory && router.params.browserHistoryStoreHistory && window.localStorage && window.localStorage["f7router-" + router.view.id + "-history"]) {
9852 router.history = JSON.parse(window.localStorage["f7router-" + router.view.id + "-history"]);
9853 router.view.history = router.history;
9854 }
9855 };
9856
9857 _proto.clearHistory = function clearHistory() {
9858 var router = this;
9859 router.history = [];
9860 if (router.view) router.view.history = [];
9861 router.saveHistory();
9862 };
9863
9864 _proto.updateCurrentUrl = function updateCurrentUrl(newUrl) {
9865 var router = this;
9866 appRouterCheck(router, 'updateCurrentUrl'); // Update history
9867
9868 if (router.history.length) {
9869 router.history[router.history.length - 1] = newUrl;
9870 } else {
9871 router.history.push(newUrl);
9872 } // Update current route params
9873
9874
9875 var _router$parseRouteUrl2 = router.parseRouteUrl(newUrl),
9876 query = _router$parseRouteUrl2.query,
9877 hash = _router$parseRouteUrl2.hash,
9878 params = _router$parseRouteUrl2.params,
9879 url = _router$parseRouteUrl2.url,
9880 path = _router$parseRouteUrl2.path;
9881
9882 if (router.currentRoute) {
9883 extend(router.currentRoute, {
9884 query: query,
9885 hash: hash,
9886 params: params,
9887 url: url,
9888 path: path
9889 });
9890 }
9891
9892 if (router.params.browserHistory) {
9893 var browserHistoryRoot = router.params.browserHistoryRoot || '';
9894 History.replace(router.view.id, {
9895 url: newUrl
9896 }, browserHistoryRoot + router.params.browserHistorySeparator + newUrl);
9897 } // Save History
9898
9899
9900 router.saveHistory();
9901 router.emit('routeUrlUpdate', router.currentRoute, router);
9902 };
9903
9904 _proto.getInitialUrl = function getInitialUrl() {
9905 var router = this;
9906
9907 if (router.initialUrl) {
9908 return {
9909 initialUrl: router.initialUrl,
9910 historyRestored: router.historyRestored
9911 };
9912 }
9913
9914 var app = router.app,
9915 view = router.view;
9916 var document = getDocument();
9917 var window = getWindow();
9918 var location = app.params.url && typeof app.params.url === 'string' && typeof URL !== 'undefined' ? new URL(app.params.url) : document.location;
9919 var initialUrl = router.params.url;
9920 var documentUrl = location.href.split(location.origin)[1];
9921 var historyRestored;
9922 var _router$params = router.params,
9923 browserHistory = _router$params.browserHistory,
9924 browserHistoryOnLoad = _router$params.browserHistoryOnLoad,
9925 browserHistorySeparator = _router$params.browserHistorySeparator;
9926 var browserHistoryRoot = router.params.browserHistoryRoot;
9927
9928 if ((window.cordova || window.Capacitor && window.Capacitor.isNative) && browserHistory && !browserHistorySeparator && !browserHistoryRoot && location.pathname.indexOf('index.html')) {
9929 // eslint-disable-next-line
9930 console.warn('Framework7: wrong or not complete browserHistory configuration, trying to guess browserHistoryRoot');
9931 browserHistoryRoot = location.pathname.split('index.html')[0];
9932 }
9933
9934 if (!browserHistory || !browserHistoryOnLoad) {
9935 if (!initialUrl) {
9936 initialUrl = documentUrl;
9937 }
9938
9939 if (location.search && initialUrl.indexOf('?') < 0) {
9940 initialUrl += location.search;
9941 }
9942
9943 if (location.hash && initialUrl.indexOf('#') < 0) {
9944 initialUrl += location.hash;
9945 }
9946 } else {
9947 if (browserHistoryRoot && documentUrl.indexOf(browserHistoryRoot) >= 0) {
9948 documentUrl = documentUrl.split(browserHistoryRoot)[1];
9949 if (documentUrl === '') documentUrl = '/';
9950 }
9951
9952 if (browserHistorySeparator.length > 0 && documentUrl.indexOf(browserHistorySeparator) >= 0) {
9953 initialUrl = documentUrl.split(browserHistorySeparator)[1];
9954 } else {
9955 initialUrl = documentUrl;
9956 }
9957
9958 router.restoreHistory();
9959
9960 if (router.history.indexOf(initialUrl) >= 0) {
9961 router.history = router.history.slice(0, router.history.indexOf(initialUrl) + 1);
9962 } else if (router.params.url === initialUrl) {
9963 router.history = [initialUrl];
9964 } else if (History.state && History.state[view.id] && History.state[view.id].url === router.history[router.history.length - 1]) {
9965 initialUrl = router.history[router.history.length - 1];
9966 } else {
9967 router.history = [documentUrl.split(browserHistorySeparator)[0] || '/', initialUrl];
9968 }
9969
9970 if (router.history.length > 1) {
9971 historyRestored = true;
9972 } else {
9973 router.history = [];
9974 }
9975
9976 router.saveHistory();
9977 }
9978
9979 router.initialUrl = initialUrl;
9980 router.historyRestored = historyRestored;
9981 return {
9982 initialUrl: initialUrl,
9983 historyRestored: historyRestored
9984 };
9985 };
9986
9987 _proto.init = function init() {
9988 var router = this;
9989 var app = router.app,
9990 view = router.view;
9991 var document = getDocument();
9992 router.mount();
9993
9994 var _router$getInitialUrl = router.getInitialUrl(),
9995 initialUrl = _router$getInitialUrl.initialUrl,
9996 historyRestored = _router$getInitialUrl.historyRestored; // Init Swipeback
9997
9998
9999 if (view && router.params.iosSwipeBack && app.theme === 'ios' || view && router.params.mdSwipeBack && app.theme === 'md' || view && router.params.auroraSwipeBack && app.theme === 'aurora') {
10000 SwipeBack(router);
10001 }
10002
10003 var _router$params2 = router.params,
10004 browserHistory = _router$params2.browserHistory,
10005 browserHistoryOnLoad = _router$params2.browserHistoryOnLoad,
10006 browserHistoryAnimateOnLoad = _router$params2.browserHistoryAnimateOnLoad,
10007 browserHistoryInitialMatch = _router$params2.browserHistoryInitialMatch;
10008 var currentRoute;
10009
10010 if (router.history.length > 1) {
10011 // Will load page
10012 var initUrl = browserHistoryInitialMatch ? initialUrl : router.history[0];
10013 currentRoute = router.findMatchingRoute(initUrl);
10014
10015 if (!currentRoute) {
10016 currentRoute = extend(router.parseRouteUrl(initUrl), {
10017 route: {
10018 url: initUrl,
10019 path: initUrl.split('?')[0]
10020 }
10021 });
10022 }
10023 } else {
10024 // Don't load page
10025 currentRoute = router.findMatchingRoute(initialUrl);
10026
10027 if (!currentRoute) {
10028 currentRoute = extend(router.parseRouteUrl(initialUrl), {
10029 route: {
10030 url: initialUrl,
10031 path: initialUrl.split('?')[0]
10032 }
10033 });
10034 }
10035 }
10036
10037 if (router.params.stackPages) {
10038 router.$el.children('.page').each(function (pageEl) {
10039 var $pageEl = $(pageEl);
10040 router.initialPages.push($pageEl[0]);
10041
10042 if (router.dynamicNavbar && $pageEl.children('.navbar').length > 0) {
10043 router.initialNavbars.push($pageEl.children('.navbar')[0]);
10044 }
10045 });
10046 }
10047
10048 if (router.$el.children('.page:not(.stacked)').length === 0 && initialUrl && router.params.loadInitialPage) {
10049 // No pages presented in DOM, reload new page
10050 router.navigate(initialUrl, {
10051 initial: true,
10052 reloadCurrent: true,
10053 browserHistory: false,
10054 animate: false,
10055 once: {
10056 modalOpen: function modalOpen() {
10057 if (!historyRestored) return;
10058 var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + "SwipeBack"];
10059
10060 if (preloadPreviousPage && router.history.length > 1) {
10061 router.back({
10062 preload: true
10063 });
10064 }
10065 },
10066 pageAfterIn: function pageAfterIn() {
10067 if (!historyRestored) return;
10068 var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + "SwipeBack"];
10069
10070 if (preloadPreviousPage && router.history.length > 1) {
10071 router.back({
10072 preload: true
10073 });
10074 }
10075 }
10076 }
10077 });
10078 } else if (router.$el.children('.page:not(.stacked)').length) {
10079 // Init current DOM page
10080 var hasTabRoute;
10081 router.currentRoute = currentRoute;
10082 router.$el.children('.page:not(.stacked)').each(function (pageEl) {
10083 var $pageEl = $(pageEl);
10084 var $navbarEl;
10085 router.setPagePosition($pageEl, 'current');
10086
10087 if (router.dynamicNavbar) {
10088 $navbarEl = $pageEl.children('.navbar');
10089
10090 if ($navbarEl.length > 0) {
10091 if (!router.$navbarsEl.parents(document).length) {
10092 router.$el.prepend(router.$navbarsEl);
10093 }
10094
10095 router.setNavbarPosition($navbarEl, 'current');
10096 router.$navbarsEl.append($navbarEl);
10097
10098 if ($navbarEl.children('.title-large').length) {
10099 $navbarEl.addClass('navbar-large');
10100 }
10101
10102 $pageEl.children('.navbar').remove();
10103 } else {
10104 router.$navbarsEl.addClass('navbar-hidden');
10105
10106 if ($navbarEl.children('.title-large').length) {
10107 router.$navbarsEl.addClass('navbar-hidden navbar-large-hidden');
10108 }
10109 }
10110 }
10111
10112 if (router.currentRoute && router.currentRoute.route && (router.currentRoute.route.master === true || typeof router.currentRoute.route.master === 'function' && router.currentRoute.route.master(app, router)) && router.params.masterDetailBreakpoint > 0) {
10113 $pageEl.addClass('page-master');
10114 $pageEl.trigger('page:role', {
10115 role: 'master'
10116 });
10117
10118 if ($navbarEl && $navbarEl.length) {
10119 $navbarEl.addClass('navbar-master');
10120 }
10121
10122 view.checkMasterDetailBreakpoint();
10123 }
10124
10125 var initOptions = {
10126 route: router.currentRoute
10127 };
10128
10129 if (router.currentRoute && router.currentRoute.route && router.currentRoute.route.options) {
10130 extend(initOptions, router.currentRoute.route.options);
10131 }
10132
10133 router.currentPageEl = $pageEl[0];
10134
10135 if (router.dynamicNavbar && $navbarEl.length) {
10136 router.currentNavbarEl = $navbarEl[0];
10137 }
10138
10139 router.removeThemeElements($pageEl);
10140
10141 if (router.dynamicNavbar && $navbarEl.length) {
10142 router.removeThemeElements($navbarEl);
10143 }
10144
10145 if (initOptions.route.route.tab) {
10146 hasTabRoute = true;
10147 router.tabLoad(initOptions.route.route.tab, extend({}, initOptions));
10148 }
10149
10150 router.pageCallback('init', $pageEl, $navbarEl, 'current', undefined, initOptions);
10151 router.pageCallback('beforeIn', $pageEl, $navbarEl, 'current', undefined, initOptions);
10152 router.pageCallback('afterIn', $pageEl, $navbarEl, 'current', undefined, initOptions);
10153 });
10154
10155 if (historyRestored) {
10156 if (browserHistoryInitialMatch) {
10157 var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + "SwipeBack"];
10158
10159 if (preloadPreviousPage && router.history.length > 1) {
10160 router.back({
10161 preload: true
10162 });
10163 }
10164 } else {
10165 router.navigate(initialUrl, {
10166 initial: true,
10167 browserHistory: false,
10168 history: false,
10169 animate: browserHistoryAnimateOnLoad,
10170 once: {
10171 pageAfterIn: function pageAfterIn() {
10172 var preloadPreviousPage = router.params.preloadPreviousPage || router.params[app.theme + "SwipeBack"];
10173
10174 if (preloadPreviousPage && router.history.length > 2) {
10175 router.back({
10176 preload: true
10177 });
10178 }
10179 }
10180 }
10181 });
10182 }
10183 }
10184
10185 if (!historyRestored && !hasTabRoute) {
10186 router.history.push(initialUrl);
10187 router.saveHistory();
10188 }
10189 }
10190
10191 if (initialUrl && browserHistory && browserHistoryOnLoad && (!History.state || !History.state[view.id])) {
10192 History.initViewState(view.id, {
10193 url: initialUrl
10194 });
10195 }
10196
10197 router.emit('local::init routerInit', router);
10198 };
10199
10200 _proto.destroy = function destroy() {
10201 var router = this;
10202 router.emit('local::destroy routerDestroy', router); // Delete props & methods
10203
10204 Object.keys(router).forEach(function (routerProp) {
10205 router[routerProp] = null;
10206 delete router[routerProp];
10207 });
10208 router = null;
10209 };
10210
10211 return Router;
10212 }(Framework7Class); // Load
10213
10214
10215 Router.prototype.navigate = navigate;
10216 Router.prototype.refreshPage = refreshPage; // Tab
10217
10218 Router.prototype.tabLoad = tabLoad;
10219 Router.prototype.tabRemove = tabRemove; // Modal
10220
10221 Router.prototype.modalLoad = modalLoad;
10222 Router.prototype.modalRemove = modalRemove; // Back
10223
10224 Router.prototype.back = back; // Clear history
10225
10226 Router.prototype.clearPreviousHistory = clearPreviousHistory;
10227
10228 var RouterModule = {
10229 name: 'router',
10230 static: {
10231 Router: Router
10232 },
10233 instance: {
10234 cache: {
10235 xhr: [],
10236 templates: [],
10237 components: []
10238 }
10239 },
10240 create: function create() {
10241 var instance = this;
10242
10243 if (instance.app) {
10244 // View Router
10245 if (instance.params.router) {
10246 instance.router = new Router(instance.app, instance);
10247 }
10248 } else {
10249 // App Router
10250 instance.router = new Router(instance);
10251 }
10252 }
10253 };
10254
10255 function resizableView(view) {
10256 var app = view.app;
10257 var support = getSupport();
10258 if (view.resizableInitialized) return;
10259 extend(view, {
10260 resizable: true,
10261 resizableWidth: null,
10262 resizableInitialized: true
10263 });
10264 var $htmlEl = $('html');
10265 var $el = view.$el;
10266 if (!$el) return;
10267 var $resizeHandlerEl;
10268 var isTouched;
10269 var isMoved;
10270 var touchesStart = {};
10271 var touchesDiff;
10272 var width;
10273 var minWidth;
10274 var maxWidth;
10275
10276 function transformCSSWidth(v) {
10277 if (!v) return null;
10278
10279 if (v.indexOf('%') >= 0 || v.indexOf('vw') >= 0) {
10280 return parseInt(v, 10) / 100 * app.width;
10281 }
10282
10283 var newV = parseInt(v, 10);
10284 if (Number.isNaN(newV)) return null;
10285 return newV;
10286 }
10287
10288 function isResizable() {
10289 return view.resizable && $el.hasClass('view-resizable') && $el.hasClass('view-master-detail');
10290 }
10291
10292 function handleTouchStart(e) {
10293 if (!isResizable()) return;
10294 touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
10295 touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
10296 isMoved = false;
10297 isTouched = true;
10298 var $pageMasterEl = $el.children('.page-master');
10299 minWidth = transformCSSWidth($pageMasterEl.css('min-width'));
10300 maxWidth = transformCSSWidth($pageMasterEl.css('max-width'));
10301 }
10302
10303 function handleTouchMove(e) {
10304 if (!isTouched) return;
10305 e.f7PreventSwipePanel = true;
10306 var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
10307
10308 if (!isMoved) {
10309 width = $resizeHandlerEl[0].offsetLeft + $resizeHandlerEl[0].offsetWidth;
10310 $el.addClass('view-resizing');
10311 $htmlEl.css('cursor', 'col-resize');
10312 }
10313
10314 isMoved = true;
10315 e.preventDefault();
10316 touchesDiff = pageX - touchesStart.x;
10317 var newWidth = width + touchesDiff;
10318
10319 if (minWidth && !Number.isNaN(minWidth)) {
10320 newWidth = Math.max(newWidth, minWidth);
10321 }
10322
10323 if (maxWidth && !Number.isNaN(maxWidth)) {
10324 newWidth = Math.min(newWidth, maxWidth);
10325 }
10326
10327 newWidth = Math.min(Math.max(newWidth, 0), app.width);
10328 view.resizableWidth = newWidth;
10329 $htmlEl[0].style.setProperty('--f7-page-master-width', newWidth + "px");
10330 $el.trigger('view:resize', newWidth);
10331 view.emit('local::resize viewResize', view, newWidth);
10332 }
10333
10334 function handleTouchEnd() {
10335 $('html').css('cursor', '');
10336
10337 if (!isTouched || !isMoved) {
10338 isTouched = false;
10339 isMoved = false;
10340 return;
10341 }
10342
10343 isTouched = false;
10344 isMoved = false;
10345 $htmlEl[0].style.setProperty('--f7-page-master-width', view.resizableWidth + "px");
10346 $el.removeClass('view-resizing');
10347 }
10348
10349 function handleResize() {
10350 if (!view.resizableWidth) return;
10351 minWidth = transformCSSWidth($resizeHandlerEl.css('min-width'));
10352 maxWidth = transformCSSWidth($resizeHandlerEl.css('max-width'));
10353
10354 if (minWidth && !Number.isNaN(minWidth) && view.resizableWidth < minWidth) {
10355 view.resizableWidth = Math.max(view.resizableWidth, minWidth);
10356 }
10357
10358 if (maxWidth && !Number.isNaN(maxWidth) && view.resizableWidth > maxWidth) {
10359 view.resizableWidth = Math.min(view.resizableWidth, maxWidth);
10360 }
10361
10362 view.resizableWidth = Math.min(Math.max(view.resizableWidth, 0), app.width);
10363 $htmlEl[0].style.setProperty('--f7-page-master-width', view.resizableWidth + "px");
10364 }
10365
10366 $resizeHandlerEl = view.$el.children('.view-resize-handler');
10367
10368 if (!$resizeHandlerEl.length) {
10369 view.$el.append('<div class="view-resize-handler"></div>');
10370 $resizeHandlerEl = view.$el.children('.view-resize-handler');
10371 }
10372
10373 view.$resizeHandlerEl = $resizeHandlerEl;
10374 $el.addClass('view-resizable'); // Add Events
10375
10376 var passive = support.passiveListener ? {
10377 passive: true
10378 } : false;
10379 view.$el.on(app.touchEvents.start, '.view-resize-handler', handleTouchStart, passive);
10380 app.on('touchmove:active', handleTouchMove);
10381 app.on('touchend:passive', handleTouchEnd);
10382 app.on('resize', handleResize);
10383 view.on('beforeOpen', handleResize);
10384 view.once('viewDestroy', function () {
10385 $el.removeClass('view-resizable');
10386 view.$resizeHandlerEl.remove();
10387 view.$el.off(app.touchEvents.start, '.view-resize-handler', handleTouchStart, passive);
10388 app.off('touchmove:active', handleTouchMove);
10389 app.off('touchend:passive', handleTouchEnd);
10390 app.off('resize', handleResize);
10391 view.off('beforeOpen', handleResize);
10392 });
10393 }
10394
10395 var View$1 = /*#__PURE__*/function (_Framework7Class) {
10396 _inheritsLoose(View, _Framework7Class);
10397
10398 function View(app, el, viewParams) {
10399 var _this;
10400
10401 if (viewParams === void 0) {
10402 viewParams = {};
10403 }
10404
10405 _this = _Framework7Class.call(this, viewParams, [app]) || this;
10406
10407 var view = _assertThisInitialized(_this);
10408
10409 var ssr = view.params.routerId;
10410 var defaults = {
10411 routes: [],
10412 routesAdd: []
10413 };
10414
10415 if (!ssr) {
10416 var $el = $(el);
10417
10418 if (!$el.length) {
10419 var message = "Framework7: can't create a View instance because ";
10420 message += typeof el === 'string' ? "the selector \"" + el + "\" didn't match any element" : 'el must be an HTMLElement or Dom7 object';
10421 throw new Error(message);
10422 }
10423 } // Default View params
10424
10425
10426 view.params = extend({
10427 el: el
10428 }, defaults, app.params.view, viewParams); // Routes
10429
10430 if (view.params.routes.length > 0) {
10431 view.routes = view.params.routes;
10432 } else {
10433 view.routes = [].concat(app.routes, view.params.routesAdd);
10434 } // View Props
10435
10436
10437 extend(false, view, {
10438 app: app,
10439 name: view.params.name,
10440 main: view.params.main,
10441 history: [],
10442 scrollHistory: {}
10443 }); // Install Modules
10444
10445 view.useModules(); // Add to app
10446
10447 app.views.push(view);
10448
10449 if (view.main) {
10450 app.views.main = view;
10451 }
10452
10453 if (view.name) {
10454 app.views[view.name] = view;
10455 } // Index
10456
10457
10458 view.index = app.views.indexOf(view); // View ID
10459
10460 var viewId;
10461
10462 if (view.name) {
10463 viewId = "view_" + view.name;
10464 } else if (view.main) {
10465 viewId = 'view_main';
10466 } else {
10467 viewId = "view_" + view.index;
10468 }
10469
10470 view.id = viewId;
10471
10472 if (!view.params.init) {
10473 return view || _assertThisInitialized(_this);
10474 } // Init View
10475
10476
10477 if (app.initialized) {
10478 view.init();
10479 } else {
10480 app.on('init', function () {
10481 view.init();
10482 });
10483 }
10484
10485 return view || _assertThisInitialized(_this);
10486 }
10487
10488 var _proto = View.prototype;
10489
10490 _proto.destroy = function destroy() {
10491 var view = this;
10492 var app = view.app;
10493 view.$el.trigger('view:beforedestroy');
10494 view.emit('local::beforeDestroy viewBeforeDestroy', view);
10495 app.off('resize', view.checkMasterDetailBreakpoint);
10496
10497 if (view.main) {
10498 app.views.main = null;
10499 delete app.views.main;
10500 } else if (view.name) {
10501 app.views[view.name] = null;
10502 delete app.views[view.name];
10503 }
10504
10505 view.$el[0].f7View = null;
10506 delete view.$el[0].f7View;
10507 app.views.splice(app.views.indexOf(view), 1); // Destroy Router
10508
10509 if (view.params.router && view.router) {
10510 view.router.destroy();
10511 }
10512
10513 view.emit('local::destroy viewDestroy', view); // Delete props & methods
10514
10515 Object.keys(view).forEach(function (viewProp) {
10516 view[viewProp] = null;
10517 delete view[viewProp];
10518 });
10519 view = null;
10520 };
10521
10522 _proto.checkMasterDetailBreakpoint = function checkMasterDetailBreakpoint(force) {
10523 var view = this;
10524 var app = view.app;
10525 var wasMasterDetail = view.$el.hasClass('view-master-detail');
10526 var isMasterDetail = app.width >= view.params.masterDetailBreakpoint && view.$el.children('.page-master').length;
10527
10528 if (typeof force === 'undefined' && isMasterDetail || force === true) {
10529 view.$el.addClass('view-master-detail');
10530
10531 if (!wasMasterDetail) {
10532 view.emit('local::masterDetailBreakpoint viewMasterDetailBreakpoint', view);
10533 view.$el.trigger('view:masterDetailBreakpoint');
10534 }
10535 } else {
10536 view.$el.removeClass('view-master-detail');
10537
10538 if (wasMasterDetail) {
10539 view.emit('local::masterDetailBreakpoint viewMasterDetailBreakpoint', view);
10540 view.$el.trigger('view:masterDetailBreakpoint');
10541 }
10542 }
10543 };
10544
10545 _proto.initMasterDetail = function initMasterDetail() {
10546 var view = this;
10547 var app = view.app;
10548 view.checkMasterDetailBreakpoint = view.checkMasterDetailBreakpoint.bind(view);
10549 view.checkMasterDetailBreakpoint();
10550
10551 if (view.params.masterDetailResizable) {
10552 resizableView(view);
10553 }
10554
10555 app.on('resize', view.checkMasterDetailBreakpoint);
10556 };
10557
10558 _proto.mount = function mount(viewEl) {
10559 var view = this;
10560 var app = view.app;
10561 var el = view.params.el || viewEl;
10562 var $el = $(el); // Selector
10563
10564 var selector;
10565 if (typeof el === 'string') selector = el;else {
10566 // Supposed to be HTMLElement or Dom7
10567 selector = ($el.attr('id') ? "#" + $el.attr('id') : '') + ($el.attr('class') ? "." + $el.attr('class').replace(/ /g, '.').replace('.active', '') : '');
10568 } // DynamicNavbar
10569
10570 var $navbarsEl;
10571
10572 if (app.theme === 'ios' && view.params.iosDynamicNavbar) {
10573 $navbarsEl = $el.children('.navbars').eq(0);
10574
10575 if ($navbarsEl.length === 0) {
10576 $navbarsEl = $('<div class="navbars"></div>');
10577 }
10578 }
10579
10580 extend(view, {
10581 $el: $el,
10582 el: $el[0],
10583 main: view.main || $el.hasClass('view-main'),
10584 $navbarsEl: $navbarsEl,
10585 navbarsEl: $navbarsEl ? $navbarsEl[0] : undefined,
10586 selector: selector
10587 });
10588
10589 if (view.main) {
10590 app.views.main = view;
10591 } // Save in DOM
10592
10593
10594 if ($el && $el[0]) {
10595 $el[0].f7View = view;
10596 }
10597
10598 view.emit('local::mount viewMount', view);
10599 };
10600
10601 _proto.init = function init(viewEl) {
10602 var view = this;
10603 view.mount(viewEl);
10604
10605 if (view.params.router) {
10606 if (view.params.masterDetailBreakpoint > 0) {
10607 view.initMasterDetail();
10608 }
10609
10610 view.router.init();
10611 view.$el.trigger('view:init');
10612 view.emit('local::init viewInit', view);
10613 }
10614 };
10615
10616 return View;
10617 }(Framework7Class); // Use Router
10618
10619
10620 View$1.use(RouterModule);
10621
10622 function initClicks(app) {
10623 function handleClicks(e) {
10624 var window = getWindow();
10625 var $clickedEl = $(e.target);
10626 var $clickedLinkEl = $clickedEl.closest('a');
10627 var isLink = $clickedLinkEl.length > 0;
10628 var url = isLink && $clickedLinkEl.attr('href'); // Check if link is external
10629
10630 if (isLink) {
10631 if ($clickedLinkEl.is(app.params.clicks.externalLinks) || // eslint-disable-next-line
10632 url && url.indexOf('javascript:') >= 0) {
10633 var target = $clickedLinkEl.attr('target');
10634
10635 if (url && window.cordova && window.cordova.InAppBrowser && (target === '_system' || target === '_blank')) {
10636 e.preventDefault();
10637 window.cordova.InAppBrowser.open(url, target);
10638 } else if (url && window.Capacitor && window.Capacitor.Plugins && window.Capacitor.Plugins.Browser && (target === '_system' || target === '_blank')) {
10639 e.preventDefault();
10640 window.Capacitor.Plugins.Browser.open({
10641 url: url
10642 });
10643 }
10644
10645 return;
10646 }
10647 } // Modules Clicks
10648
10649
10650 Object.keys(app.modules).forEach(function (moduleName) {
10651 var moduleClicks = app.modules[moduleName].clicks;
10652 if (!moduleClicks) return;
10653 if (e.preventF7Router) return;
10654 Object.keys(moduleClicks).forEach(function (clickSelector) {
10655 var matchingClickedElement = $clickedEl.closest(clickSelector).eq(0);
10656
10657 if (matchingClickedElement.length > 0) {
10658 moduleClicks[clickSelector].call(app, matchingClickedElement, matchingClickedElement.dataset(), e);
10659 }
10660 });
10661 }); // Load Page
10662
10663 var clickedLinkData = {};
10664
10665 if (isLink) {
10666 e.preventDefault();
10667 clickedLinkData = $clickedLinkEl.dataset();
10668 }
10669
10670 clickedLinkData.clickedEl = $clickedLinkEl[0]; // Prevent Router
10671
10672 if (e.preventF7Router) return;
10673 if ($clickedLinkEl.hasClass('prevent-router') || $clickedLinkEl.hasClass('router-prevent')) return;
10674 var validUrl = url && url.length > 0 && url[0] !== '#';
10675
10676 if (validUrl || $clickedLinkEl.hasClass('back')) {
10677 var view;
10678
10679 if (clickedLinkData.view && clickedLinkData.view === 'current') {
10680 view = app.views.current;
10681 } else if (clickedLinkData.view) {
10682 view = $(clickedLinkData.view)[0].f7View;
10683 } else {
10684 view = $clickedEl.parents('.view')[0] && $clickedEl.parents('.view')[0].f7View;
10685
10686 if (!$clickedLinkEl.hasClass('back') && view && view.params.linksView) {
10687 if (typeof view.params.linksView === 'string') view = $(view.params.linksView)[0].f7View;else if (view.params.linksView instanceof View$1) view = view.params.linksView;
10688 }
10689 }
10690
10691 if (!view) {
10692 if (app.views.main) view = app.views.main;
10693 }
10694
10695 if (!view || !view.router) return;
10696
10697 if ($clickedLinkEl[0].f7RouteProps) {
10698 clickedLinkData.props = $clickedLinkEl[0].f7RouteProps;
10699 }
10700
10701 if ($clickedLinkEl.hasClass('back')) view.router.back(url, clickedLinkData);else view.router.navigate(url, clickedLinkData);
10702 }
10703 }
10704
10705 app.on('click', handleClicks);
10706 }
10707
10708 var ClicksModule = {
10709 name: 'clicks',
10710 params: {
10711 clicks: {
10712 // External Links
10713 externalLinks: '.external'
10714 }
10715 },
10716 on: {
10717 init: function init() {
10718 var app = this;
10719 initClicks(app);
10720 }
10721 }
10722 };
10723
10724 var RouterComponentLoaderModule = {
10725 name: 'routerComponentLoader',
10726 proto: {
10727 componentLoader: function componentLoader(component, componentUrl, options, resolve, reject) {
10728 if (options === void 0) {
10729 options = {};
10730 }
10731
10732 var router = this;
10733 var app = router.app;
10734 var url = typeof component === 'string' ? component : componentUrl;
10735 var compiledUrl = router.replaceRequestUrlParams(url, options);
10736
10737 function compile(componentFunction) {
10738 var context = options.context || {};
10739 if (typeof context === 'function') context = context.call(router);else if (typeof context === 'string') {
10740 try {
10741 context = JSON.parse(context);
10742 } catch (err) {
10743 reject(err);
10744 throw err;
10745 }
10746 }
10747 var componentContext = merge({}, context, {
10748 f7route: options.route,
10749 f7router: router
10750 });
10751 var componentProps = merge(options.route ? options.route.params || {} : {}, options.props || {}, options.routeProps || {});
10752 var componentEl;
10753 var componentRoot;
10754
10755 if (options.componentOptions && options.componentOptions.el) {
10756 componentEl = options.componentOptions.el;
10757 }
10758
10759 if (options.componentOptions && options.componentOptions.root) {
10760 componentRoot = options.componentOptions.root;
10761 }
10762
10763 app.component.create(componentFunction, componentProps, {
10764 context: componentContext,
10765 el: componentEl,
10766 root: componentRoot
10767 }).then(function (createdComponent) {
10768 resolve(createdComponent.el);
10769 }).catch(function (err) {
10770 reject(err);
10771 throw new Error(err);
10772 });
10773 }
10774
10775 var cachedComponent;
10776
10777 if (compiledUrl && router.params.componentCache) {
10778 router.cache.components.forEach(function (cached) {
10779 if (cached.url === compiledUrl) cachedComponent = cached.component;
10780 });
10781 }
10782
10783 if (compiledUrl && cachedComponent) {
10784 compile(cachedComponent);
10785 } else if (compiledUrl && !cachedComponent) {
10786 // Load via XHR
10787 if (router.xhrAbortController) {
10788 router.xhrAbortController.abort();
10789 router.xhrAbortController = false;
10790 }
10791
10792 router.xhrRequest(url, options).then(function (loadedComponent) {
10793 var parsedComponent = app.component.parse(loadedComponent);
10794
10795 if (router.params.componentCache) {
10796 router.cache.components.push({
10797 url: compiledUrl,
10798 component: parsedComponent
10799 });
10800 }
10801
10802 compile(parsedComponent);
10803 }).catch(function (err) {
10804 reject();
10805 throw err;
10806 });
10807 } else {
10808 compile(component);
10809 }
10810 },
10811 modalComponentLoader: function modalComponentLoader(_temp) {
10812 var _ref = _temp === void 0 ? {} : _temp,
10813 component = _ref.component,
10814 componentUrl = _ref.componentUrl,
10815 options = _ref.options,
10816 resolve = _ref.resolve,
10817 reject = _ref.reject;
10818
10819 var router = this;
10820 router.componentLoader(component, componentUrl, options, function (el) {
10821 resolve(el);
10822 }, reject);
10823 },
10824 tabComponentLoader: function tabComponentLoader(_temp2) {
10825 var _ref2 = _temp2 === void 0 ? {} : _temp2,
10826 component = _ref2.component,
10827 componentUrl = _ref2.componentUrl,
10828 options = _ref2.options,
10829 resolve = _ref2.resolve,
10830 reject = _ref2.reject;
10831
10832 var router = this;
10833 router.componentLoader(component, componentUrl, options, function (el) {
10834 resolve(el);
10835 }, reject);
10836 },
10837 pageComponentLoader: function pageComponentLoader(_temp3) {
10838 var _ref3 = _temp3 === void 0 ? {} : _temp3,
10839 component = _ref3.component,
10840 componentUrl = _ref3.componentUrl,
10841 options = _ref3.options,
10842 resolve = _ref3.resolve,
10843 reject = _ref3.reject;
10844
10845 var router = this;
10846 router.componentLoader(component, componentUrl, options, function (el, newOptions) {
10847 if (newOptions === void 0) {
10848 newOptions = {};
10849 }
10850
10851 resolve(el, newOptions);
10852 }, reject);
10853 }
10854 }
10855 };
10856
10857 var n = function n(t, s, r, e) {
10858 var u;
10859 s[0] = 0;
10860
10861 for (var h = 1; h < s.length; h++) {
10862 var p = s[h++],
10863 a = s[h] ? (s[0] |= p ? 1 : 2, r[s[h++]]) : s[++h];
10864 3 === p ? e[0] = a : 4 === p ? e[1] = Object.assign(e[1] || {}, a) : 5 === p ? (e[1] = e[1] || {})[s[++h]] = a : 6 === p ? e[1][s[++h]] += a + "" : p ? (u = t.apply(a, n(t, a, r, ["", null])), e.push(u), a[0] ? s[0] |= 2 : (s[h - 2] = 0, s[h] = u)) : e.push(a);
10865 }
10866
10867 return e;
10868 },
10869 t = new Map();
10870
10871 function htm (s) {
10872 var r = t.get(this);
10873 return r || (r = new Map(), t.set(this, r)), (r = n(this, r.get(s) || (r.set(s, r = function (n) {
10874 for (var t, s, r = 1, e = "", u = "", h = [0], p = function p(n) {
10875 1 === r && (n || (e = e.replace(/^\s*\n\s*|\s*\n\s*$/g, ""))) ? h.push(0, n, e) : 3 === r && (n || e) ? (h.push(3, n, e), r = 2) : 2 === r && "..." === e && n ? h.push(4, n, 0) : 2 === r && e && !n ? h.push(5, 0, !0, e) : r >= 5 && ((e || !n && 5 === r) && (h.push(r, 0, e, s), r = 6), n && (h.push(r, n, 0, s), r = 6)), e = "";
10876 }, a = 0; a < n.length; a++) {
10877 a && (1 === r && p(), p(a));
10878
10879 for (var l = 0; l < n[a].length; l++) {
10880 t = n[a][l], 1 === r ? "<" === t ? (p(), h = [h], r = 3) : e += t : 4 === r ? "--" === e && ">" === t ? (r = 1, e = "") : e = t + e[0] : u ? t === u ? u = "" : e += t : '"' === t || "'" === t ? u = t : ">" === t ? (p(), r = 1) : r && ("=" === t ? (r = 5, s = e, e = "") : "/" === t && (r < 5 || ">" === n[a][l + 1]) ? (p(), 3 === r && (h = h[0]), r = h, (h = h[0]).push(2, 0, r), r = 0) : " " === t || "\t" === t || "\n" === t || "\r" === t ? (p(), r = 2) : e += t), 3 === r && "!--" === e && (r = 4, h = h[0]);
10881 }
10882 }
10883
10884 return p(), h;
10885 }(s)), r), arguments, [])).length > 1 ? r : r[0];
10886 }
10887
10888 var ignoreChildren = [false, null, '', undefined];
10889
10890 var h$1 = function h(type, props) {
10891 for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
10892 children[_key - 2] = arguments[_key];
10893 }
10894
10895 return {
10896 type: type,
10897 props: props || {},
10898 children: flattenArray(children.filter(function (child) {
10899 return ignoreChildren.indexOf(child) < 0;
10900 }))
10901 };
10902 };
10903
10904 var $h = htm.bind(h$1);
10905
10906 function vnode(sel, data, children, text, elm) {
10907 var key = data === undefined ? undefined : data.key;
10908 return {
10909 sel: sel,
10910 data: data,
10911 children: children,
10912 text: text,
10913 elm: elm,
10914 key: key
10915 };
10916 }
10917
10918 var array = Array.isArray;
10919 function primitive(s) {
10920 return typeof s === 'string' || typeof s === 'number';
10921 }
10922
10923 function addNS(data, children, sel) {
10924 data.ns = 'http://www.w3.org/2000/svg';
10925
10926 if (sel !== 'foreignObject' && children !== undefined) {
10927 for (var i = 0; i < children.length; ++i) {
10928 var childData = children[i].data;
10929
10930 if (childData !== undefined) {
10931 addNS(childData, children[i].children, children[i].sel);
10932 }
10933 }
10934 }
10935 }
10936
10937 function h(sel, b, c) {
10938 var data = {},
10939 children,
10940 text,
10941 i;
10942
10943 if (c !== undefined) {
10944 data = b;
10945
10946 if (array(c)) {
10947 children = c;
10948 } else if (primitive(c)) {
10949 text = c;
10950 } else if (c && c.sel) {
10951 children = [c];
10952 }
10953 } else if (b !== undefined) {
10954 if (array(b)) {
10955 children = b;
10956 } else if (primitive(b)) {
10957 text = b;
10958 } else if (b && b.sel) {
10959 children = [b];
10960 } else {
10961 data = b;
10962 }
10963 }
10964
10965 if (array(children)) {
10966 for (i = 0; i < children.length; ++i) {
10967 if (primitive(children[i])) children[i] = vnode(undefined, undefined, undefined, children[i], undefined);
10968 }
10969 }
10970
10971 if (sel[0] === 's' && sel[1] === 'v' && sel[2] === 'g' && (sel.length === 3 || sel[3] === '.' || sel[3] === '#')) {
10972 addNS(data, children, sel);
10973 }
10974
10975 return vnode(sel, data, children, text, undefined);
10976 }
10977
10978 var customComponents = {};
10979
10980 var SELF_CLOSING = 'area base br col command embed hr img input keygen link menuitem meta param source track wbr'.split(' ');
10981 var PROPS_ATTRS = 'hidden checked disabled readonly selected autofocus autoplay required multiple value indeterminate routeProps innerHTML'.split(' ');
10982 var BOOLEAN_PROPS = 'hidden checked disabled readonly selected autofocus autoplay required multiple readOnly indeterminate'.split(' ');
10983
10984 var getTagName = function getTagName(treeNode) {
10985 return typeof treeNode.type === 'function' ? treeNode.type.name || 'CustomComponent' : treeNode.type;
10986 };
10987
10988 var toCamelCase = function toCamelCase(name) {
10989 return name.split('-').map(function (word, index) {
10990 if (index === 0) return word.toLowerCase();
10991 return word[0].toUpperCase() + word.substr(1);
10992 }).join('');
10993 };
10994
10995 var propsFromAttrs = function propsFromAttrs() {
10996 var context = {};
10997
10998 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10999 args[_key] = arguments[_key];
11000 }
11001
11002 args.forEach(function (obj) {
11003 if (obj === void 0) {
11004 obj = {};
11005 }
11006
11007 Object.keys(obj).forEach(function (key) {
11008 context[toCamelCase(key)] = obj[key];
11009 });
11010 });
11011 return context;
11012 };
11013
11014 var createCustomComponent = function createCustomComponent(_ref) {
11015 var f7 = _ref.f7,
11016 treeNode = _ref.treeNode,
11017 vnode = _ref.vnode,
11018 data = _ref.data;
11019 var component = typeof treeNode.type === 'function' ? treeNode.type : customComponents[treeNode.type];
11020 f7.component.create(component, propsFromAttrs(data.attrs || {}, data.props || {}), {
11021 el: vnode.elm,
11022 children: treeNode.children
11023 }).then(function (c) {
11024 if (vnode.data && vnode.data.on && c && c.$el) {
11025 Object.keys(vnode.data.on).forEach(function (eventName) {
11026 c.$el.on(eventName, vnode.data.on[eventName]);
11027 });
11028 } // eslint-disable-next-line
11029
11030
11031 vnode.elm.__component__ = c;
11032 });
11033 };
11034
11035 var updateCustomComponent = function updateCustomComponent(vnode) {
11036 // eslint-disable-next-line
11037 var component = vnode && vnode.elm && vnode.elm.__component__;
11038 if (!component) return;
11039 var newProps = propsFromAttrs(vnode.data.attrs || {}, vnode.data.props || {});
11040 component.children = vnode.data.treeNode.children;
11041 Object.assign(component.props, newProps);
11042 component.update();
11043 };
11044
11045 var destroyCustomComponent = function destroyCustomComponent(vnode) {
11046 // eslint-disable-next-line
11047 var component = vnode && vnode.elm && vnode.elm.__component__;
11048
11049 if (component) {
11050 var el = component.el,
11051 $el = component.$el;
11052
11053 if (vnode.data && vnode.data.on && $el) {
11054 Object.keys(vnode.data.on).forEach(function (eventName) {
11055 $el.off(eventName, vnode.data.on[eventName]);
11056 });
11057 }
11058
11059 if (component.destroy) component.destroy();
11060 if (el && el.parentNode) el.parentNode.removeChild(el);
11061 delete vnode.elm.__component__; // eslint-disable-line
11062 }
11063 };
11064
11065 var isCustomComponent = function isCustomComponent(treeNodeType) {
11066 return typeof treeNodeType === 'function' || treeNodeType && treeNodeType.indexOf('-') > 0 && customComponents[treeNodeType];
11067 };
11068
11069 function getHooks(treeNode, data, f7, initial, isRoot) {
11070 var hooks = {};
11071 var insert = [];
11072 var destroy = [];
11073 var update = [];
11074 var postpatch = [];
11075 var isFakeElement = false;
11076 var tagName = getTagName(treeNode);
11077
11078 if (data && data.attrs && data.attrs.component) {
11079 // eslint-disable-next-line
11080 data.attrs.component, _readOnlyError("tagName");
11081 delete data.attrs.component;
11082 isFakeElement = true;
11083 }
11084
11085 var isCustom = isCustomComponent(treeNode.type);
11086
11087 if (isCustom) {
11088 insert.push(function (vnode) {
11089 if (vnode.sel !== tagName && !isFakeElement) return;
11090 createCustomComponent({
11091 f7: f7,
11092 treeNode: treeNode,
11093 vnode: vnode,
11094 data: data
11095 });
11096 });
11097 destroy.push(function (vnode) {
11098 destroyCustomComponent(vnode);
11099 });
11100 update.push(function (oldVnode, vnode) {
11101 updateCustomComponent(vnode);
11102 });
11103 }
11104
11105 if (!isCustom) {
11106 if (!data || !data.attrs || !data.attrs.class) return hooks;
11107 var classNames = data.attrs.class;
11108 classNames.split(' ').forEach(function (className) {
11109 if (!initial) {
11110 insert.push.apply(insert, f7.getVnodeHooks('insert', className));
11111 }
11112
11113 destroy.push.apply(destroy, f7.getVnodeHooks('destroy', className));
11114 update.push.apply(update, f7.getVnodeHooks('update', className));
11115 postpatch.push.apply(postpatch, f7.getVnodeHooks('postpatch', className));
11116 });
11117 }
11118
11119 if (isRoot && !initial) {
11120 postpatch.push(function (oldVnode, vnode) {
11121 var vn = vnode || oldVnode;
11122 if (!vn) return;
11123
11124 if (vn.data && vn.data.component) {
11125 vn.data.component.hook('onUpdated');
11126 }
11127 });
11128 }
11129
11130 if (insert.length === 0 && destroy.length === 0 && update.length === 0 && postpatch.length === 0) {
11131 return hooks;
11132 }
11133
11134 if (insert.length) {
11135 hooks.insert = function (vnode) {
11136 insert.forEach(function (f) {
11137 return f(vnode);
11138 });
11139 };
11140 }
11141
11142 if (destroy.length) {
11143 hooks.destroy = function (vnode) {
11144 destroy.forEach(function (f) {
11145 return f(vnode);
11146 });
11147 };
11148 }
11149
11150 if (update.length) {
11151 hooks.update = function (oldVnode, vnode) {
11152 update.forEach(function (f) {
11153 return f(oldVnode, vnode);
11154 });
11155 };
11156 }
11157
11158 if (postpatch.length) {
11159 hooks.postpatch = function (oldVnode, vnode) {
11160 postpatch.forEach(function (f) {
11161 return f(oldVnode, vnode);
11162 });
11163 };
11164 }
11165
11166 return hooks;
11167 }
11168
11169 var getEventHandler = function getEventHandler(eventHandler, _temp) {
11170 var _ref2 = _temp === void 0 ? {} : _temp,
11171 stop = _ref2.stop,
11172 prevent = _ref2.prevent,
11173 once = _ref2.once;
11174
11175 var fired = false;
11176
11177 function handler() {
11178 var e = arguments.length <= 0 ? undefined : arguments[0];
11179 if (once && fired) return;
11180 if (stop) e.stopPropagation();
11181 if (prevent) e.preventDefault();
11182 fired = true;
11183 eventHandler.apply(void 0, arguments);
11184 }
11185
11186 return handler;
11187 };
11188
11189 var getData = function getData(treeNode, component, f7, initial, isRoot) {
11190 var data = {
11191 component: component,
11192 treeNode: treeNode
11193 };
11194 var tagName = getTagName(treeNode);
11195 Object.keys(treeNode.props).forEach(function (attrName) {
11196 var attrValue = treeNode.props[attrName];
11197 if (typeof attrValue === 'undefined') return;
11198
11199 if (PROPS_ATTRS.indexOf(attrName) >= 0) {
11200 // Props
11201 if (!data.props) data.props = {};
11202
11203 if (attrName === 'readonly') {
11204 // eslint-disable-next-line
11205 attrName = 'readOnly';
11206 }
11207
11208 if (attrName === 'routeProps') {
11209 // eslint-disable-next-line
11210 attrName = 'f7RouteProps';
11211 }
11212
11213 if (tagName === 'option' && attrName === 'value') {
11214 if (!data.attrs) data.attrs = {};
11215 data.attrs.value = attrValue;
11216 }
11217
11218 if (BOOLEAN_PROPS.indexOf(attrName) >= 0) {
11219 // eslint-disable-next-line
11220 data.props[attrName] = attrValue === false ? false : true;
11221 } else {
11222 data.props[attrName] = attrValue;
11223 }
11224 } else if (attrName === 'key') {
11225 // Key
11226 data.key = attrValue;
11227 } else if (attrName.indexOf('@') === 0 || attrName.indexOf('on') === 0 && attrName.length > 2) {
11228 // Events
11229 if (!data.on) data.on = {};
11230 var eventName = attrName.indexOf('@') === 0 ? attrName.substr(1) : eventNameToColonCase(attrName.substr(2));
11231 var stop = false;
11232 var prevent = false;
11233 var once = false;
11234
11235 if (eventName.indexOf('.') >= 0) {
11236 eventName.split('.').forEach(function (eventNamePart, eventNameIndex) {
11237 if (eventNameIndex === 0) eventName = eventNamePart;else {
11238 if (eventNamePart === 'stop') stop = true;
11239 if (eventNamePart === 'prevent') prevent = true;
11240 if (eventNamePart === 'once') once = true;
11241 }
11242 });
11243 }
11244
11245 data.on[eventName] = getEventHandler(attrValue, {
11246 stop: stop,
11247 prevent: prevent,
11248 once: once
11249 });
11250 } else if (attrName === 'style') {
11251 // Style
11252 if (typeof attrValue !== 'string') {
11253 data.style = attrValue;
11254 } else {
11255 if (!data.attrs) data.attrs = {};
11256 data.attrs.style = attrValue;
11257 }
11258 } else {
11259 // Rest of attribures
11260 if (!data.attrs) data.attrs = {};
11261 data.attrs[attrName] = attrValue; // ID -> Key
11262
11263 if (attrName === 'id' && !data.key && !isRoot) {
11264 data.key = attrValue;
11265 }
11266 }
11267 });
11268 var hooks = getHooks(treeNode, data, f7, initial, isRoot);
11269
11270 hooks.prepatch = function (oldVnode, vnode) {
11271 if (!oldVnode || !vnode) return;
11272
11273 if (oldVnode && oldVnode.data && oldVnode.data.props) {
11274 Object.keys(oldVnode.data.props).forEach(function (key) {
11275 if (BOOLEAN_PROPS.indexOf(key) < 0) return;
11276 if (!vnode.data) vnode.data = {};
11277 if (!vnode.data.props) vnode.data.props = {};
11278
11279 if (oldVnode.data.props[key] === true && !(key in vnode.data.props)) {
11280 vnode.data.props[key] = false;
11281 }
11282 });
11283 }
11284 };
11285
11286 data.hook = hooks;
11287 return data;
11288 };
11289
11290 var getChildren = function getChildren(treeNode, component, f7, initial) {
11291 if (treeNode && treeNode.type && SELF_CLOSING.indexOf(treeNode.type) >= 0) {
11292 return [];
11293 }
11294
11295 var children = [];
11296 var nodes = treeNode.children;
11297
11298 for (var i = 0; i < nodes.length; i += 1) {
11299 var childNode = nodes[i];
11300 var child = treeNodeToVNode(childNode, component, f7, initial, false);
11301
11302 if (Array.isArray(child)) {
11303 children.push.apply(children, child);
11304 } else if (child) {
11305 children.push(child);
11306 }
11307 }
11308
11309 return children;
11310 };
11311
11312 var getSlots = function getSlots(treeNode, component, f7, initial) {
11313 var slotName = treeNode.props.name || 'default';
11314 var slotNodes = (component.children || []).filter(function (childTreeNode) {
11315 var childSlotName = 'default';
11316
11317 if (childTreeNode.props) {
11318 childSlotName = childTreeNode.props.slot || 'default';
11319 }
11320
11321 return childSlotName === slotName;
11322 });
11323
11324 if (slotNodes.length === 0) {
11325 return getChildren(treeNode, component, f7, initial);
11326 }
11327
11328 return slotNodes.map(function (subTreeNode) {
11329 return treeNodeToVNode(subTreeNode, component, f7, initial);
11330 });
11331 };
11332
11333 var isTreeNode = function isTreeNode(treeNode) {
11334 return isObject(treeNode) && 'props' in treeNode && 'type' in treeNode && 'children' in treeNode;
11335 };
11336
11337 var treeNodeToVNode = function treeNodeToVNode(treeNode, component, f7, initial, isRoot) {
11338 if (!isTreeNode(treeNode)) {
11339 return String(treeNode);
11340 }
11341
11342 if (treeNode.type === 'slot') {
11343 return getSlots(treeNode, component, f7, initial);
11344 }
11345
11346 var data = getData(treeNode, component, f7, initial, isRoot);
11347 var children = isCustomComponent(treeNode.type) ? [] : getChildren(treeNode, component, f7, initial);
11348 return h(getTagName(treeNode), data, children);
11349 };
11350
11351 function vdom(tree, component, initial) {
11352 if (tree === void 0) {
11353 tree = {};
11354 }
11355
11356 return treeNodeToVNode(tree, component, component.f7, initial, true);
11357 }
11358
11359 function createElement(tagName) {
11360 return document.createElement(tagName);
11361 }
11362
11363 function createElementNS(namespaceURI, qualifiedName) {
11364 return document.createElementNS(namespaceURI, qualifiedName);
11365 }
11366
11367 function createTextNode(text) {
11368 return document.createTextNode(text);
11369 }
11370
11371 function createComment(text) {
11372 return document.createComment(text);
11373 }
11374
11375 function insertBefore(parentNode, newNode, referenceNode) {
11376 if (referenceNode && referenceNode.parentNode !== parentNode) {
11377 if (referenceNode.__component__) referenceNode = referenceNode.__component__.el;
11378 }
11379
11380 parentNode.insertBefore(newNode, referenceNode);
11381 }
11382
11383 function removeChild(node, child) {
11384 if (!node) return;
11385 node.removeChild(child);
11386 }
11387
11388 function appendChild(node, child) {
11389 node.appendChild(child);
11390 }
11391
11392 function parentNode(node) {
11393 return node.parentNode;
11394 }
11395
11396 function nextSibling(node) {
11397 return node.nextSibling;
11398 }
11399
11400 function tagName(elm) {
11401 return elm.tagName;
11402 }
11403
11404 function setTextContent(node, text) {
11405 node.textContent = text;
11406 }
11407
11408 function getTextContent(node) {
11409 return node.textContent;
11410 }
11411
11412 function isElement(node) {
11413 return node.nodeType === 1;
11414 }
11415
11416 function isText(node) {
11417 return node.nodeType === 3;
11418 }
11419
11420 function isComment(node) {
11421 return node.nodeType === 8;
11422 }
11423
11424 var htmlDomApi = {
11425 createElement: createElement,
11426 createElementNS: createElementNS,
11427 createTextNode: createTextNode,
11428 createComment: createComment,
11429 insertBefore: insertBefore,
11430 removeChild: removeChild,
11431 appendChild: appendChild,
11432 parentNode: parentNode,
11433 nextSibling: nextSibling,
11434 tagName: tagName,
11435 setTextContent: setTextContent,
11436 getTextContent: getTextContent,
11437 isElement: isElement,
11438 isText: isText,
11439 isComment: isComment
11440 };
11441
11442 function isUndef(s) {
11443 return s === undefined;
11444 }
11445
11446 function isDef(s) {
11447 return s !== undefined;
11448 }
11449
11450 var emptyNode = vnode('', {}, [], undefined, undefined);
11451
11452 function sameVnode(vnode1, vnode2) {
11453 return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
11454 }
11455
11456 function isVnode(vnode) {
11457 return vnode.sel !== undefined;
11458 }
11459
11460 function createKeyToOldIdx(children, beginIdx, endIdx) {
11461 var i,
11462 map = {},
11463 key,
11464 ch;
11465
11466 for (i = beginIdx; i <= endIdx; ++i) {
11467 ch = children[i];
11468
11469 if (ch != null) {
11470 key = ch.key;
11471 if (key !== undefined) map[key] = i;
11472 }
11473 }
11474
11475 return map;
11476 }
11477
11478 var hooks = ['create', 'update', 'remove', 'destroy', 'pre', 'post'];
11479 function init(modules, domApi) {
11480 var i,
11481 j,
11482 cbs = {};
11483 var api = domApi !== undefined ? domApi : htmlDomApi;
11484
11485 for (i = 0; i < hooks.length; ++i) {
11486 cbs[hooks[i]] = [];
11487
11488 for (j = 0; j < modules.length; ++j) {
11489 var hook = modules[j][hooks[i]];
11490
11491 if (hook !== undefined) {
11492 cbs[hooks[i]].push(hook);
11493 }
11494 }
11495 }
11496
11497 function emptyNodeAt(elm) {
11498 var id = elm.id ? '#' + elm.id : '';
11499 var c = elm.className ? '.' + elm.className.split(' ').join('.') : '';
11500 return vnode(api.tagName(elm).toLowerCase() + id + c, {}, [], undefined, elm);
11501 }
11502
11503 function createRmCb(childElm, listeners) {
11504 return function rmCb() {
11505 if (--listeners === 0) {
11506 var parent_1 = api.parentNode(childElm);
11507 api.removeChild(parent_1, childElm);
11508 }
11509 };
11510 }
11511
11512 function createElm(vnode, insertedVnodeQueue) {
11513 var i,
11514 data = vnode.data;
11515
11516 if (data !== undefined) {
11517 if (isDef(i = data.hook) && isDef(i = i.init)) {
11518 i(vnode);
11519 data = vnode.data;
11520 }
11521 }
11522
11523 var children = vnode.children,
11524 sel = vnode.sel;
11525
11526 if (sel === '!') {
11527 if (isUndef(vnode.text)) {
11528 vnode.text = '';
11529 }
11530
11531 vnode.elm = api.createComment(vnode.text);
11532 } else if (sel !== undefined) {
11533 // Parse selector
11534 var hashIdx = sel.indexOf('#');
11535 var dotIdx = sel.indexOf('.', hashIdx);
11536 var hash = hashIdx > 0 ? hashIdx : sel.length;
11537 var dot = dotIdx > 0 ? dotIdx : sel.length;
11538 var tag = hashIdx !== -1 || dotIdx !== -1 ? sel.slice(0, Math.min(hash, dot)) : sel;
11539 var elm = vnode.elm = isDef(data) && isDef(i = data.ns) ? api.createElementNS(i, tag) : api.createElement(tag);
11540 if (hash < dot) elm.setAttribute('id', sel.slice(hash + 1, dot));
11541 if (dotIdx > 0) elm.setAttribute('class', sel.slice(dot + 1).replace(/\./g, ' '));
11542
11543 for (i = 0; i < cbs.create.length; ++i) {
11544 cbs.create[i](emptyNode, vnode);
11545 }
11546
11547 if (array(children)) {
11548 for (i = 0; i < children.length; ++i) {
11549 var ch = children[i];
11550
11551 if (ch != null) {
11552 api.appendChild(elm, createElm(ch, insertedVnodeQueue));
11553 }
11554 }
11555 } else if (primitive(vnode.text)) {
11556 api.appendChild(elm, api.createTextNode(vnode.text));
11557 }
11558
11559 i = vnode.data.hook; // Reuse variable
11560
11561 if (isDef(i)) {
11562 if (i.create) i.create(emptyNode, vnode);
11563 if (i.insert) insertedVnodeQueue.push(vnode);
11564 }
11565 } else {
11566 vnode.elm = api.createTextNode(vnode.text);
11567 }
11568
11569 return vnode.elm;
11570 }
11571
11572 function addVnodes(parentElm, before, vnodes, startIdx, endIdx, insertedVnodeQueue) {
11573 for (; startIdx <= endIdx; ++startIdx) {
11574 var ch = vnodes[startIdx];
11575
11576 if (ch != null) {
11577 api.insertBefore(parentElm, createElm(ch, insertedVnodeQueue), before);
11578 }
11579 }
11580 }
11581
11582 function invokeDestroyHook(vnode) {
11583 var i,
11584 j,
11585 data = vnode.data;
11586
11587 if (data !== undefined) {
11588 if (isDef(i = data.hook) && isDef(i = i.destroy)) i(vnode);
11589
11590 for (i = 0; i < cbs.destroy.length; ++i) {
11591 cbs.destroy[i](vnode);
11592 }
11593
11594 if (vnode.children !== undefined) {
11595 for (j = 0; j < vnode.children.length; ++j) {
11596 i = vnode.children[j];
11597
11598 if (i != null && typeof i !== "string") {
11599 invokeDestroyHook(i);
11600 }
11601 }
11602 }
11603 }
11604 }
11605
11606 function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
11607 for (; startIdx <= endIdx; ++startIdx) {
11608 var i_1 = void 0,
11609 listeners = void 0,
11610 rm = void 0,
11611 ch = vnodes[startIdx];
11612
11613 if (ch != null) {
11614 if (isDef(ch.sel)) {
11615 invokeDestroyHook(ch);
11616 listeners = cbs.remove.length + 1;
11617 rm = createRmCb(ch.elm, listeners);
11618
11619 for (i_1 = 0; i_1 < cbs.remove.length; ++i_1) {
11620 cbs.remove[i_1](ch, rm);
11621 }
11622
11623 if (isDef(i_1 = ch.data) && isDef(i_1 = i_1.hook) && isDef(i_1 = i_1.remove)) {
11624 i_1(ch, rm);
11625 } else {
11626 rm();
11627 }
11628 } else {
11629 api.removeChild(parentElm, ch.elm);
11630 }
11631 }
11632 }
11633 }
11634
11635 function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue) {
11636 var oldStartIdx = 0,
11637 newStartIdx = 0;
11638 var oldEndIdx = oldCh.length - 1;
11639 var oldStartVnode = oldCh[0];
11640 var oldEndVnode = oldCh[oldEndIdx];
11641 var newEndIdx = newCh.length - 1;
11642 var newStartVnode = newCh[0];
11643 var newEndVnode = newCh[newEndIdx];
11644 var oldKeyToIdx;
11645 var idxInOld;
11646 var elmToMove;
11647 var before;
11648
11649 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
11650 if (oldStartVnode == null) {
11651 oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
11652 } else if (oldEndVnode == null) {
11653 oldEndVnode = oldCh[--oldEndIdx];
11654 } else if (newStartVnode == null) {
11655 newStartVnode = newCh[++newStartIdx];
11656 } else if (newEndVnode == null) {
11657 newEndVnode = newCh[--newEndIdx];
11658 } else if (sameVnode(oldStartVnode, newStartVnode)) {
11659 patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
11660 oldStartVnode = oldCh[++oldStartIdx];
11661 newStartVnode = newCh[++newStartIdx];
11662 } else if (sameVnode(oldEndVnode, newEndVnode)) {
11663 patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
11664 oldEndVnode = oldCh[--oldEndIdx];
11665 newEndVnode = newCh[--newEndIdx];
11666 } else if (sameVnode(oldStartVnode, newEndVnode)) {
11667 patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
11668 api.insertBefore(parentElm, oldStartVnode.elm, api.nextSibling(oldEndVnode.elm));
11669 oldStartVnode = oldCh[++oldStartIdx];
11670 newEndVnode = newCh[--newEndIdx];
11671 } else if (sameVnode(oldEndVnode, newStartVnode)) {
11672 patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
11673 api.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
11674 oldEndVnode = oldCh[--oldEndIdx];
11675 newStartVnode = newCh[++newStartIdx];
11676 } else {
11677 if (oldKeyToIdx === undefined) {
11678 oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
11679 }
11680
11681 idxInOld = oldKeyToIdx[newStartVnode.key];
11682
11683 if (isUndef(idxInOld)) {
11684 api.insertBefore(parentElm, createElm(newStartVnode, insertedVnodeQueue), oldStartVnode.elm);
11685 newStartVnode = newCh[++newStartIdx];
11686 } else {
11687 elmToMove = oldCh[idxInOld];
11688
11689 if (elmToMove.sel !== newStartVnode.sel) {
11690 api.insertBefore(parentElm, createElm(newStartVnode, insertedVnodeQueue), oldStartVnode.elm);
11691 } else {
11692 patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
11693 oldCh[idxInOld] = undefined;
11694 api.insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm);
11695 }
11696
11697 newStartVnode = newCh[++newStartIdx];
11698 }
11699 }
11700 }
11701
11702 if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
11703 if (oldStartIdx > oldEndIdx) {
11704 before = newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].elm;
11705 addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
11706 } else {
11707 removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
11708 }
11709 }
11710 }
11711
11712 function patchVnode(oldVnode, vnode, insertedVnodeQueue) {
11713 var i, hook;
11714
11715 if (isDef(i = vnode.data) && isDef(hook = i.hook) && isDef(i = hook.prepatch)) {
11716 i(oldVnode, vnode);
11717 }
11718
11719 var elm = vnode.elm = oldVnode.elm;
11720 var oldCh = oldVnode.children;
11721 var ch = vnode.children;
11722 if (oldVnode === vnode) return;
11723
11724 if (vnode.data !== undefined) {
11725 for (i = 0; i < cbs.update.length; ++i) {
11726 cbs.update[i](oldVnode, vnode);
11727 }
11728
11729 i = vnode.data.hook;
11730 if (isDef(i) && isDef(i = i.update)) i(oldVnode, vnode);
11731 }
11732
11733 if (isUndef(vnode.text)) {
11734 if (isDef(oldCh) && isDef(ch)) {
11735 if (oldCh !== ch) updateChildren(elm, oldCh, ch, insertedVnodeQueue);
11736 } else if (isDef(ch)) {
11737 if (isDef(oldVnode.text)) api.setTextContent(elm, '');
11738 addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
11739 } else if (isDef(oldCh)) {
11740 removeVnodes(elm, oldCh, 0, oldCh.length - 1);
11741 } else if (isDef(oldVnode.text)) {
11742 api.setTextContent(elm, '');
11743 }
11744 } else if (oldVnode.text !== vnode.text) {
11745 api.setTextContent(elm, vnode.text);
11746 }
11747
11748 if (isDef(hook) && isDef(i = hook.postpatch)) {
11749 i(oldVnode, vnode);
11750 }
11751 }
11752
11753 return function patch(oldVnode, vnode) {
11754 var i, elm, parent;
11755 var insertedVnodeQueue = [];
11756
11757 for (i = 0; i < cbs.pre.length; ++i) {
11758 cbs.pre[i]();
11759 }
11760
11761 if (!isVnode(oldVnode)) {
11762 oldVnode = emptyNodeAt(oldVnode);
11763 }
11764
11765 if (sameVnode(oldVnode, vnode)) {
11766 patchVnode(oldVnode, vnode, insertedVnodeQueue);
11767 } else {
11768 elm = oldVnode.elm;
11769 parent = api.parentNode(elm);
11770 createElm(vnode, insertedVnodeQueue);
11771
11772 if (parent !== null) {
11773 api.insertBefore(parent, vnode.elm, api.nextSibling(elm));
11774 removeVnodes(parent, [oldVnode], 0, 0);
11775 }
11776 }
11777
11778 for (i = 0; i < insertedVnodeQueue.length; ++i) {
11779 insertedVnodeQueue[i].data.hook.insert(insertedVnodeQueue[i]);
11780 }
11781
11782 for (i = 0; i < cbs.post.length; ++i) {
11783 cbs.post[i]();
11784 }
11785
11786 return vnode;
11787 };
11788 }
11789
11790 var xlinkNS = 'http://www.w3.org/1999/xlink';
11791 var xmlNS = 'http://www.w3.org/XML/1998/namespace';
11792 var colonChar = 58;
11793 var xChar = 120;
11794
11795 function updateAttrs(oldVnode, vnode) {
11796 var key,
11797 elm = vnode.elm,
11798 oldAttrs = oldVnode.data.attrs,
11799 attrs = vnode.data.attrs;
11800 if (!oldAttrs && !attrs) return;
11801 if (oldAttrs === attrs) return;
11802 oldAttrs = oldAttrs || {};
11803 attrs = attrs || {}; // update modified attributes, add new attributes
11804
11805 for (key in attrs) {
11806 var cur = attrs[key];
11807 var old = oldAttrs[key];
11808
11809 if (old !== cur) {
11810 if (cur === true) {
11811 elm.setAttribute(key, "");
11812 } else if (cur === false) {
11813 elm.removeAttribute(key);
11814 } else {
11815 if (key.charCodeAt(0) !== xChar) {
11816 elm.setAttribute(key, cur);
11817 } else if (key.charCodeAt(3) === colonChar) {
11818 // Assume xml namespace
11819 elm.setAttributeNS(xmlNS, key, cur);
11820 } else if (key.charCodeAt(5) === colonChar) {
11821 // Assume xlink namespace
11822 elm.setAttributeNS(xlinkNS, key, cur);
11823 } else {
11824 elm.setAttribute(key, cur);
11825 }
11826 }
11827 }
11828 } // remove removed attributes
11829 // use `in` operator since the previous `for` iteration uses it (.i.e. add even attributes with undefined value)
11830 // the other option is to remove all attributes with value == undefined
11831
11832
11833 for (key in oldAttrs) {
11834 if (!(key in attrs)) {
11835 elm.removeAttribute(key);
11836 }
11837 }
11838 }
11839
11840 var attributesModule = {
11841 create: updateAttrs,
11842 update: updateAttrs
11843 };
11844
11845 function updateProps(oldVnode, vnode) {
11846 var key,
11847 cur,
11848 old,
11849 elm = vnode.elm,
11850 oldProps = oldVnode.data.props,
11851 props = vnode.data.props;
11852 if (!oldProps && !props) return;
11853 if (oldProps === props) return;
11854 oldProps = oldProps || {};
11855 props = props || {};
11856
11857 for (key in oldProps) {
11858 if (!props[key]) {
11859 delete elm[key];
11860 }
11861 }
11862
11863 for (key in props) {
11864 cur = props[key];
11865 old = oldProps[key];
11866
11867 if (old !== cur && (key !== 'value' || elm[key] !== cur)) {
11868 elm[key] = cur;
11869 }
11870 }
11871 }
11872
11873 var propsModule = {
11874 create: updateProps,
11875 update: updateProps
11876 };
11877
11878 var raf = typeof window !== 'undefined' && window.requestAnimationFrame || setTimeout;
11879
11880 var nextFrame = function nextFrame(fn) {
11881 raf(function () {
11882 raf(fn);
11883 });
11884 };
11885
11886 function setNextFrame(obj, prop, val) {
11887 nextFrame(function () {
11888 obj[prop] = val;
11889 });
11890 }
11891
11892 function updateStyle(oldVnode, vnode) {
11893 var cur,
11894 name,
11895 elm = vnode.elm,
11896 oldStyle = oldVnode.data.style,
11897 style = vnode.data.style;
11898 if (!oldStyle && !style) return;
11899 if (oldStyle === style) return;
11900 oldStyle = oldStyle || {};
11901 style = style || {};
11902 var oldHasDel = ('delayed' in oldStyle);
11903
11904 for (name in oldStyle) {
11905 if (!style[name]) {
11906 if (name[0] === '-' && name[1] === '-') {
11907 elm.style.removeProperty(name);
11908 } else {
11909 elm.style[name] = '';
11910 }
11911 }
11912 }
11913
11914 for (name in style) {
11915 cur = style[name];
11916
11917 if (name === 'delayed' && style.delayed) {
11918 for (var name2 in style.delayed) {
11919 cur = style.delayed[name2];
11920
11921 if (!oldHasDel || cur !== oldStyle.delayed[name2]) {
11922 setNextFrame(elm.style, name2, cur);
11923 }
11924 }
11925 } else if (name !== 'remove' && cur !== oldStyle[name]) {
11926 if (name[0] === '-' && name[1] === '-') {
11927 elm.style.setProperty(name, cur);
11928 } else {
11929 elm.style[name] = cur;
11930 }
11931 }
11932 }
11933 }
11934
11935 function applyDestroyStyle(vnode) {
11936 var style,
11937 name,
11938 elm = vnode.elm,
11939 s = vnode.data.style;
11940 if (!s || !(style = s.destroy)) return;
11941
11942 for (name in style) {
11943 elm.style[name] = style[name];
11944 }
11945 }
11946
11947 function applyRemoveStyle(vnode, rm) {
11948 var s = vnode.data.style;
11949
11950 if (!s || !s.remove) {
11951 rm();
11952 return;
11953 }
11954
11955 var name,
11956 elm = vnode.elm,
11957 i = 0,
11958 compStyle,
11959 style = s.remove,
11960 amount = 0,
11961 applied = [];
11962
11963 for (name in style) {
11964 applied.push(name);
11965 elm.style[name] = style[name];
11966 }
11967
11968 compStyle = getComputedStyle(elm);
11969 var props = compStyle['transition-property'].split(', ');
11970
11971 for (; i < props.length; ++i) {
11972 if (applied.indexOf(props[i]) !== -1) amount++;
11973 }
11974
11975 elm.addEventListener('transitionend', function (ev) {
11976 if (ev.target === elm) --amount;
11977 if (amount === 0) rm();
11978 });
11979 }
11980
11981 var styleModule = {
11982 create: updateStyle,
11983 update: updateStyle,
11984 destroy: applyDestroyStyle,
11985 remove: applyRemoveStyle
11986 };
11987
11988 function invokeHandler(handler, event, args) {
11989 if (typeof handler === 'function') {
11990 // call function handler
11991 handler.apply(void 0, [event].concat(args));
11992 }
11993 }
11994
11995 function handleEvent(event, args, vnode) {
11996 var name = event.type;
11997 var on = vnode.data.on; // call event handler(s) if exists
11998
11999 if (on && on[name]) {
12000 invokeHandler(on[name], event, args);
12001 }
12002 }
12003
12004 function createListener() {
12005 return function handler(event) {
12006 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
12007 args[_key - 1] = arguments[_key];
12008 }
12009
12010 handleEvent(event, args, handler.vnode);
12011 };
12012 }
12013
12014 function updateEvents(oldVnode, vnode) {
12015 var oldOn = oldVnode.data.on;
12016 var oldListener = oldVnode.listener;
12017 var oldElm = oldVnode.elm;
12018 var on = vnode && vnode.data.on;
12019 var elm = vnode && vnode.elm; // optimization for reused immutable handlers
12020
12021 if (oldOn === on) {
12022 return;
12023 } // remove existing listeners which no longer used
12024
12025
12026 if (oldOn && oldListener) {
12027 // if element changed or deleted we remove all existing listeners unconditionally
12028 if (!on) {
12029 Object.keys(oldOn).forEach(function (name) {
12030 $(oldElm).off(name, oldListener);
12031 });
12032 } else {
12033 Object.keys(oldOn).forEach(function (name) {
12034 if (!on[name]) {
12035 $(oldElm).off(name, oldListener);
12036 }
12037 });
12038 }
12039 } // add new listeners which has not already attached
12040
12041
12042 if (on) {
12043 // reuse existing listener or create new
12044 var listener = oldVnode.listener || createListener();
12045 vnode.listener = listener; // update vnode for listener
12046
12047 listener.vnode = vnode; // if element changed or added we add all needed listeners unconditionally
12048
12049 if (!oldOn) {
12050 Object.keys(on).forEach(function (name) {
12051 $(elm).on(name, listener);
12052 });
12053 } else {
12054 Object.keys(on).forEach(function (name) {
12055 if (!oldOn[name]) {
12056 $(elm).on(name, listener);
12057 }
12058 });
12059 }
12060 }
12061 }
12062
12063 var eventListenersModule = {
12064 create: updateEvents,
12065 update: updateEvents,
12066 destroy: updateEvents
12067 };
12068
12069 /* eslint import/no-named-as-default: off */
12070 var patch = init([attributesModule, propsModule, styleModule, eventListenersModule]);
12071
12072 /* eslint no-underscore-dangle: "off" */
12073
12074 var Component = /*#__PURE__*/function () {
12075 function Component(app, component, props, _temp) {
12076 var _this = this;
12077
12078 if (props === void 0) {
12079 props = {};
12080 }
12081
12082 var _ref = _temp === void 0 ? {} : _temp,
12083 el = _ref.el,
12084 context = _ref.context,
12085 children = _ref.children;
12086
12087 var document = getDocument();
12088 merge(this, {
12089 f7: app,
12090 props: props || {},
12091 context: context || {},
12092 id: component.id || id(),
12093 children: children || [],
12094 theme: {
12095 ios: app.theme === 'ios',
12096 md: app.theme === 'md',
12097 aurora: app.theme === 'aurora'
12098 },
12099 style: component.style,
12100 __updateQueue: [],
12101 __eventHandlers: [],
12102 __onceEventHandlers: [],
12103 __onBeforeMount: [],
12104 __onMounted: [],
12105 __onBeforeUpdate: [],
12106 __onUpdated: [],
12107 __onBeforeUnmount: [],
12108 __onUnmounted: []
12109 });
12110
12111 var createComponent = function createComponent() {
12112 return component(_this.props, _this.getComponentContext(true));
12113 };
12114
12115 var getRenderFuncion = function getRenderFuncion(componentResult) {
12116 return new Promise(function (resolve, reject) {
12117 if (typeof componentResult === 'function') {
12118 resolve(componentResult);
12119 } else if (componentResult instanceof Promise) {
12120 componentResult.then(function (render) {
12121 resolve(render);
12122 }).catch(function (err) {
12123 reject(err);
12124 });
12125 } else {
12126 reject(new Error('Framework7: Component render function is not a "function" type. Didn\'t you forget to "return $render"?'));
12127 }
12128 });
12129 };
12130
12131 return new Promise(function (resolve, reject) {
12132 var componentResult = createComponent();
12133 getRenderFuncion(componentResult).then(function (render) {
12134 _this.renderFunction = render;
12135
12136 var tree = _this.render();
12137
12138 if (el) {
12139 _this.vnode = vdom(tree, _this, true);
12140
12141 if (_this.style) {
12142 _this.styleEl = document.createElement('style');
12143 _this.styleEl.innerHTML = _this.style;
12144 }
12145
12146 _this.el = el;
12147 patch(_this.el, _this.vnode);
12148 _this.el = _this.vnode.elm;
12149 _this.$el = $(_this.el);
12150
12151 _this.attachEvents();
12152
12153 _this.el.f7Component = _this;
12154
12155 _this.mount();
12156
12157 resolve(_this);
12158 return;
12159 } // Make Dom
12160
12161
12162 if (tree) {
12163 _this.vnode = vdom(tree, _this, true);
12164 _this.el = document.createElement(_this.vnode.sel || 'div');
12165 patch(_this.el, _this.vnode);
12166 _this.$el = $(_this.el);
12167 }
12168
12169 if (_this.style) {
12170 _this.styleEl = document.createElement('style');
12171 _this.styleEl.innerHTML = _this.style;
12172 }
12173
12174 _this.attachEvents();
12175
12176 if (_this.el) {
12177 _this.el.f7Component = _this;
12178 }
12179
12180 resolve(_this);
12181 }).catch(function (err) {
12182 reject(err);
12183 });
12184 });
12185 }
12186
12187 var _proto = Component.prototype;
12188
12189 _proto.on = function on(eventName, handler) {
12190 if (!this.__eventHandlers) return;
12191
12192 this.__eventHandlers.push({
12193 eventName: eventName,
12194 handler: handler
12195 });
12196 };
12197
12198 _proto.once = function once(eventName, handler) {
12199 if (!this.__eventHandlers) return;
12200
12201 this.__onceEventHandlers.push({
12202 eventName: eventName,
12203 handler: handler
12204 });
12205 };
12206
12207 _proto.getComponentStore = function getComponentStore() {
12208 var _this2 = this;
12209
12210 var _this$f7$store = this.f7.store,
12211 state = _this$f7$store.state,
12212 _gettersPlain = _this$f7$store._gettersPlain,
12213 dispatch = _this$f7$store.dispatch;
12214 var $store = {
12215 state: state,
12216 dispatch: dispatch
12217 };
12218 $store.getters = new Proxy(_gettersPlain, {
12219 get: function get(target, prop) {
12220 var obj = target[prop];
12221
12222 var callback = function callback(v) {
12223 obj.value = v;
12224
12225 _this2.update();
12226 };
12227
12228 obj.onUpdated(callback);
12229 return obj;
12230 }
12231 });
12232 return $store;
12233 };
12234
12235 _proto.getComponentContext = function getComponentContext(includeHooks) {
12236 var _this3 = this;
12237
12238 var ctx = {
12239 $f7route: this.context.f7route,
12240 $f7router: this.context.f7router,
12241 $h: $h,
12242 $: $,
12243 $id: this.id,
12244 $f7: this.f7,
12245 $f7ready: this.f7ready.bind(this),
12246 $theme: this.theme,
12247 $tick: this.tick.bind(this),
12248 $update: this.update.bind(this),
12249 $emit: this.emit.bind(this),
12250 $store: this.getComponentStore(),
12251 $el: {}
12252 };
12253 Object.defineProperty(ctx.$el, 'value', {
12254 get: function get() {
12255 return _this3.$el;
12256 }
12257 });
12258 if (includeHooks) Object.assign(ctx, {
12259 $on: this.on.bind(this),
12260 $once: this.once.bind(this),
12261 $onBeforeMount: function $onBeforeMount(handler) {
12262 return _this3.__onBeforeMount.push(handler);
12263 },
12264 $onMounted: function $onMounted(handler) {
12265 return _this3.__onMounted.push(handler);
12266 },
12267 $onBeforeUpdate: function $onBeforeUpdate(handler) {
12268 return _this3.__onBeforeUpdate.push(handler);
12269 },
12270 $onUpdated: function $onUpdated(handler) {
12271 return _this3.__onUpdated.push(handler);
12272 },
12273 $onBeforeUnmount: function $onBeforeUnmount(handler) {
12274 return _this3.__onBeforeUnmount.push(handler);
12275 },
12276 $onUnmounted: function $onUnmounted(handler) {
12277 return _this3.__onUnmounted.push(handler);
12278 }
12279 });
12280 return ctx;
12281 };
12282
12283 _proto.render = function render() {
12284 return this.renderFunction(this.getComponentContext());
12285 };
12286
12287 _proto.emit = function emit(name, data) {
12288 if (!this.el) return;
12289 this.$el.trigger(name, data);
12290 };
12291
12292 _proto.attachEvents = function attachEvents() {
12293 var $el = this.$el;
12294 if (!this.__eventHandlers) return;
12295
12296 this.__eventHandlers.forEach(function (_ref2) {
12297 var eventName = _ref2.eventName,
12298 handler = _ref2.handler;
12299 $el.on(eventNameToColonCase(eventName), handler);
12300 });
12301
12302 this.__onceEventHandlers.forEach(function (_ref3) {
12303 var eventName = _ref3.eventName,
12304 handler = _ref3.handler;
12305 $el.once(eventNameToColonCase(eventName), handler);
12306 });
12307 };
12308
12309 _proto.detachEvents = function detachEvents() {
12310 var $el = this.$el;
12311 if (!this.__eventHandlers) return;
12312
12313 this.__eventHandlers.forEach(function (_ref4) {
12314 var eventName = _ref4.eventName,
12315 handler = _ref4.handler;
12316 $el.on(eventNameToColonCase(eventName), handler);
12317 });
12318
12319 this.__onceEventHandlers.forEach(function (_ref5) {
12320 var eventName = _ref5.eventName,
12321 handler = _ref5.handler;
12322 $el.once(eventNameToColonCase(eventName), handler);
12323 });
12324 };
12325
12326 _proto.startUpdateQueue = function startUpdateQueue() {
12327 var _this4 = this;
12328
12329 var window = getWindow();
12330 if (this.__requestAnimationFrameId) return;
12331
12332 var update = function update() {
12333 _this4.hook('onBeforeUpdate');
12334
12335 var tree = _this4.render(); // Make Dom
12336
12337
12338 if (tree) {
12339 var newVNode = vdom(tree, _this4, false);
12340 _this4.vnode = patch(_this4.vnode, newVNode);
12341 }
12342 };
12343
12344 this.__requestAnimationFrameId = window.requestAnimationFrame(function () {
12345 if (_this4.__updateIsPending) update();
12346 var resolvers = [].concat(_this4.__updateQueue);
12347 _this4.__updateQueue = [];
12348 _this4.__updateIsPending = false;
12349 window.cancelAnimationFrame(_this4.__requestAnimationFrameId);
12350 delete _this4.__requestAnimationFrameId;
12351 delete _this4.__updateIsPending;
12352 resolvers.forEach(function (resolver) {
12353 return resolver();
12354 });
12355 resolvers = [];
12356 });
12357 };
12358
12359 _proto.tick = function tick(callback) {
12360 var _this5 = this;
12361
12362 return new Promise(function (resolve) {
12363 function resolver() {
12364 resolve();
12365 if (callback) callback();
12366 }
12367
12368 _this5.__updateQueue.push(resolver);
12369
12370 _this5.startUpdateQueue();
12371 });
12372 };
12373
12374 _proto.update = function update(callback) {
12375 var _this6 = this;
12376
12377 if (this.__destroyed) return new Promise(function () {});
12378 return new Promise(function (resolve) {
12379 var resolver = function resolver() {
12380 resolve();
12381 if (callback) callback();
12382 };
12383
12384 _this6.__updateIsPending = true;
12385
12386 _this6.__updateQueue.push(resolver);
12387
12388 _this6.startUpdateQueue();
12389 });
12390 };
12391
12392 _proto.setState = function setState(callback) {
12393 return this.update(callback);
12394 };
12395
12396 _proto.f7ready = function f7ready(callback) {
12397 var _this7 = this;
12398
12399 if (this.f7.initialized) {
12400 callback(this.f7);
12401 return;
12402 }
12403
12404 this.f7.once('init', function () {
12405 callback(_this7.f7);
12406 });
12407 };
12408
12409 _proto.mount = function mount(mountMethod) {
12410 this.hook('onBeforeMount', this.$el);
12411 if (this.styleEl) $('head').append(this.styleEl);
12412 if (mountMethod) mountMethod(this.el);
12413 this.hook('onMounted', this.$el);
12414 };
12415
12416 _proto.destroy = function destroy() {
12417 if (this.__destroyed) return;
12418 var window = getWindow();
12419 this.hook('onBeforeUnmount');
12420 if (this.styleEl) $(this.styleEl).remove();
12421 this.detachEvents();
12422 this.hook('onUnmounted'); // Delete component instance
12423
12424 if (this.el && this.el.f7Component) {
12425 this.el.f7Component = null;
12426 delete this.el.f7Component;
12427 } // Patch with empty node
12428
12429
12430 if (this.vnode) {
12431 this.vnode = patch(this.vnode, {
12432 sel: this.vnode.sel,
12433 data: {}
12434 });
12435 } // Clear update queue
12436
12437
12438 window.cancelAnimationFrame(this.__requestAnimationFrameId);
12439 this.__updateQueue = [];
12440 this.__eventHandlers = [];
12441 this.__onceEventHandlers = [];
12442 this.__onBeforeMount = [];
12443 this.__onMounted = [];
12444 this.__onBeforeUpdate = [];
12445 this.__onUpdated = [];
12446 this.__onBeforeUnmount = [];
12447 this.__onUnmounted = []; // Delete all props
12448
12449 deleteProps(this);
12450 this.__destroyed = true;
12451 };
12452
12453 _proto.hook = function hook(name) {
12454 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
12455 args[_key - 1] = arguments[_key];
12456 }
12457
12458 if (this.__destroyed) return;
12459 this["__" + name].forEach(function (handler) {
12460 handler.apply(void 0, args);
12461 });
12462 };
12463
12464 return Component;
12465 }();
12466
12467 function parseComponent(componentString) {
12468 var window = getWindow();
12469 var document = getDocument();
12470 var componentId = id();
12471 var callbackCreateName = "f7_component_create_callback_" + componentId; // Template
12472
12473 var template;
12474 var hasTemplate = componentString.match(/<template([ ]?)([a-z0-9-]*)>/);
12475
12476 if (hasTemplate) {
12477 template = componentString.split(/<template[ ]?[a-z0-9-]*>/).filter(function (item, index) {
12478 return index > 0;
12479 }).join('<template>').split('</template>').filter(function (item, index, arr) {
12480 return index < arr.length - 1;
12481 }).join('</template>').replace(/{{#raw}}([ \n]*)<template/g, '{{#raw}}<template').replace(/\/template>([ \n]*){{\/raw}}/g, '/template>{{/raw}}').replace(/([ \n])<template/g, '$1{{#raw}}<template').replace(/\/template>([ \n])/g, '/template>{{/raw}}$1');
12482 } // Parse Styles
12483
12484
12485 var style = null;
12486
12487 if (componentString.indexOf('<style>') >= 0) {
12488 style = componentString.split('<style>')[1].split('</style>')[0];
12489 }
12490
12491 if (componentString.indexOf('<style scoped>') >= 0) {
12492 style = componentString.split('<style scoped>')[1].split('</style>')[0];
12493 } // Parse Script
12494
12495
12496 var scriptContent;
12497
12498 if (componentString.indexOf('<script>') >= 0) {
12499 var scripts = componentString.split('<script>');
12500 scriptContent = scripts[scripts.length - 1].split('</script>')[0].trim();
12501 } else {
12502 scriptContent = 'return () => {return $render}';
12503 }
12504
12505 if (!scriptContent || !scriptContent.trim()) scriptContent = 'return () => {return $render}'; // Parse Template
12506
12507 if (template) {
12508 scriptContent = scriptContent.replace('$render', "function ($$ctx) {\n var $ = $$ctx.$$;\n var $h = $$ctx.$h;\n var $root = $$ctx.$root;\n var $f7 = $$ctx.$f7;\n var $f7route = $$ctx.$f7route;\n var $f7router = $$ctx.$f7router;\n var $theme = $$ctx.$theme;\n var $update = $$ctx.$update;\n var $store = $$ctx.$store;\n\n return $h`" + template + "`\n }\n ").replace(/export default/g, 'return');
12509 } // Execute Script
12510
12511
12512 scriptContent = "window." + callbackCreateName + " = function () {" + scriptContent + "}"; // Insert Script El
12513
12514 var scriptEl = document.createElement('script');
12515 scriptEl.innerHTML = scriptContent;
12516 $('head').append(scriptEl);
12517 var component = window[callbackCreateName](); // Remove Script El
12518
12519 $(scriptEl).remove();
12520 window[callbackCreateName] = null;
12521 delete window[callbackCreateName]; // Assign Style
12522
12523 if (style) {
12524 component.style = style;
12525 } // Component ID
12526
12527
12528 component.id = componentId;
12529 return component;
12530 }
12531
12532 function registerComponent(tagName, component) {
12533 customComponents[tagName] = component;
12534 }
12535
12536 function unregisterComponent(tagName) {
12537 delete customComponents[tagName];
12538 }
12539 var ComponentModule = {
12540 name: 'component',
12541 static: {
12542 Component: Component,
12543 registerComponent: registerComponent,
12544 unregisterComponent: unregisterComponent
12545 },
12546 create: function create() {
12547 var app = this;
12548 app.component = {
12549 registerComponent: registerComponent,
12550 unregisterComponent: unregisterComponent,
12551 parse: function parse(componentString) {
12552 return parseComponent(componentString);
12553 },
12554 create: function create(component, props, _ref) {
12555 var root = _ref.root,
12556 el = _ref.el,
12557 context = _ref.context,
12558 children = _ref.children;
12559 return new Component(app, component, props, {
12560 root: root,
12561 el: el,
12562 context: context,
12563 children: children
12564 });
12565 }
12566 };
12567 }
12568 };
12569
12570 var HistoryModule = {
12571 name: 'history',
12572 static: {
12573 history: History
12574 },
12575 on: {
12576 init: function init() {
12577 History.init(this);
12578 }
12579 }
12580 };
12581
12582 var SW = {
12583 registrations: [],
12584 register: function register(path, scope) {
12585 var app = this;
12586 var window = getWindow();
12587
12588 if (!('serviceWorker' in window.navigator) || !app.serviceWorker.container) {
12589 return new Promise(function (resolve, reject) {
12590 reject(new Error('Service worker is not supported'));
12591 });
12592 }
12593
12594 return new Promise(function (resolve, reject) {
12595 app.serviceWorker.container.register(path, scope ? {
12596 scope: scope
12597 } : {}).then(function (reg) {
12598 SW.registrations.push(reg);
12599 app.emit('serviceWorkerRegisterSuccess', reg);
12600 resolve(reg);
12601 }).catch(function (error) {
12602 app.emit('serviceWorkerRegisterError', error);
12603 reject(error);
12604 });
12605 });
12606 },
12607 unregister: function unregister(registration) {
12608 var app = this;
12609 var window = getWindow();
12610
12611 if (!('serviceWorker' in window.navigator) || !app.serviceWorker.container) {
12612 return new Promise(function (resolve, reject) {
12613 reject(new Error('Service worker is not supported'));
12614 });
12615 }
12616
12617 var registrations;
12618 if (!registration) registrations = SW.registrations;else if (Array.isArray(registration)) registrations = registration;else registrations = [registration];
12619 return Promise.all(registrations.map(function (reg) {
12620 return new Promise(function (resolve, reject) {
12621 reg.unregister().then(function () {
12622 if (SW.registrations.indexOf(reg) >= 0) {
12623 SW.registrations.splice(SW.registrations.indexOf(reg), 1);
12624 }
12625
12626 app.emit('serviceWorkerUnregisterSuccess', reg);
12627 resolve();
12628 }).catch(function (error) {
12629 app.emit('serviceWorkerUnregisterError', reg, error);
12630 reject(error);
12631 });
12632 });
12633 }));
12634 }
12635 };
12636 var ServiceWorkerModule = {
12637 name: 'sw',
12638 params: {
12639 serviceWorker: {
12640 path: undefined,
12641 scope: undefined
12642 }
12643 },
12644 create: function create() {
12645 var app = this;
12646 var window = getWindow();
12647 extend(app, {
12648 serviceWorker: {
12649 container: 'serviceWorker' in window.navigator ? window.navigator.serviceWorker : undefined,
12650 registrations: SW.registrations,
12651 register: SW.register.bind(app),
12652 unregister: SW.unregister.bind(app)
12653 }
12654 });
12655 },
12656 on: {
12657 init: function init() {
12658 var window = getWindow();
12659 if (!('serviceWorker' in window.navigator)) return;
12660 var app = this;
12661 if (app.device.cordova || window.Capacitor && window.Capacitor.isNative) return;
12662 if (!app.serviceWorker.container) return;
12663 var paths = app.params.serviceWorker.path;
12664 var scope = app.params.serviceWorker.scope;
12665 if (!paths || Array.isArray(paths) && !paths.length) return;
12666 var toRegister = Array.isArray(paths) ? paths : [paths];
12667 toRegister.forEach(function (path) {
12668 app.serviceWorker.register(path, scope);
12669 });
12670 }
12671 }
12672 };
12673
12674 function createStore(storeParams) {
12675 if (storeParams === void 0) {
12676 storeParams = {};
12677 }
12678
12679 var store = {
12680 __store: true
12681 };
12682
12683 var originalState = _extends({}, storeParams.state || {});
12684
12685 var actions = _extends({}, storeParams.actions || {});
12686
12687 var getters = _extends({}, storeParams.getters || {});
12688
12689 var state = extend({}, originalState);
12690 var propsQueue = [];
12691 var gettersDependencies = {};
12692 var gettersCallbacks = {};
12693 Object.keys(getters).forEach(function (getterKey) {
12694 gettersDependencies[getterKey] = [];
12695 gettersCallbacks[getterKey] = [];
12696 });
12697
12698 var getGetterValue = function getGetterValue(getterKey) {
12699 return getters[getterKey]({
12700 state: store.state
12701 });
12702 };
12703
12704 var addGetterDependencies = function addGetterDependencies(getterKey, deps) {
12705 if (!gettersDependencies[getterKey]) gettersDependencies[getterKey] = [];
12706 deps.forEach(function (dep) {
12707 if (gettersDependencies[getterKey].indexOf(dep) < 0) {
12708 gettersDependencies[getterKey].push(dep);
12709 }
12710 });
12711 };
12712
12713 var addGetterCallback = function addGetterCallback(getterKey, callback) {
12714 if (!gettersCallbacks[getterKey]) gettersCallbacks[getterKey] = [];
12715 gettersCallbacks[getterKey].push(callback);
12716 };
12717
12718 var runGetterCallbacks = function runGetterCallbacks(stateKey) {
12719 var keys = Object.keys(gettersDependencies).filter(function (getterKey) {
12720 return gettersDependencies[getterKey].indexOf(stateKey) >= 0;
12721 });
12722 keys.forEach(function (getterKey) {
12723 if (!gettersCallbacks[getterKey] || !gettersCallbacks[getterKey].length) return;
12724 gettersCallbacks[getterKey].forEach(function (callback) {
12725 callback(getGetterValue(getterKey));
12726 });
12727 });
12728 };
12729
12730 var removeGetterCallback = function removeGetterCallback(callback) {
12731 Object.keys(gettersCallbacks).forEach(function (stateKey) {
12732 var callbacks = gettersCallbacks[stateKey];
12733
12734 if (callbacks.indexOf(callback) >= 0) {
12735 callbacks.splice(callbacks.indexOf(callback), 1);
12736 }
12737 });
12738 }; // eslint-disable-next-line
12739
12740
12741 store.__removeCallback = function (callback) {
12742 removeGetterCallback(callback);
12743 };
12744
12745 var getterValue = function getterValue(getterKey, addCallback) {
12746 if (addCallback === void 0) {
12747 addCallback = true;
12748 }
12749
12750 if (getterKey === 'constructor') return undefined;
12751 propsQueue = [];
12752 var value = getGetterValue(getterKey);
12753 addGetterDependencies(getterKey, propsQueue);
12754
12755 var onUpdated = function onUpdated(callback) {
12756 addGetterCallback(getterKey, callback);
12757 };
12758
12759 var obj = {
12760 value: value,
12761 onUpdated: onUpdated
12762 };
12763
12764 if (!addCallback) {
12765 return obj;
12766 }
12767
12768 var callback = function callback(v) {
12769 obj.value = v;
12770 };
12771
12772 obj.__callback = callback;
12773 addGetterCallback(getterKey, callback); // eslint-disable-next-line
12774
12775 return obj;
12776 };
12777
12778 store.state = new Proxy(state, {
12779 set: function set(target, prop, value) {
12780 target[prop] = value;
12781 runGetterCallbacks(prop);
12782 return true;
12783 },
12784 get: function get(target, prop) {
12785 propsQueue.push(prop);
12786 return target[prop];
12787 }
12788 });
12789 store.getters = new Proxy(getters, {
12790 set: function set() {
12791 return false;
12792 },
12793 get: function get(target, prop) {
12794 if (!target[prop]) {
12795 return undefined;
12796 }
12797
12798 return getterValue(prop, true);
12799 }
12800 });
12801 store._gettersPlain = new Proxy(getters, {
12802 set: function set() {
12803 return false;
12804 },
12805 get: function get(target, prop) {
12806 if (!target[prop]) {
12807 return undefined;
12808 }
12809
12810 return getterValue(prop, false);
12811 }
12812 });
12813
12814 store.dispatch = function (actionName, data) {
12815 return new Promise(function (resolve, reject) {
12816 if (!actions[actionName]) {
12817 reject();
12818 throw new Error("Framework7: Store action \"" + actionName + "\" is not found");
12819 }
12820
12821 var result = actions[actionName]({
12822 state: store.state,
12823 dispatch: store.dispatch
12824 }, data);
12825 resolve(result);
12826 });
12827 };
12828
12829 return store;
12830 }
12831
12832 var StoreModule = {
12833 name: 'store',
12834 static: {
12835 createStore: createStore
12836 },
12837 proto: {
12838 createStore: createStore
12839 }
12840 };
12841
12842 var isCapacitor = function isCapacitor() {
12843 var window = getWindow();
12844 return window.Capacitor && window.Capacitor.isNative && window.Capacitor.Plugins && window.Capacitor.Plugins.StatusBar;
12845 };
12846
12847 var Statusbar = {
12848 hide: function hide() {
12849 var window = getWindow();
12850 var device = getDevice();
12851
12852 if (device.cordova && window.StatusBar) {
12853 window.StatusBar.hide();
12854 }
12855
12856 if (isCapacitor()) {
12857 window.Capacitor.Plugins.StatusBar.hide();
12858 }
12859 },
12860 show: function show() {
12861 var window = getWindow();
12862 var device = getDevice();
12863
12864 if (device.cordova && window.StatusBar) {
12865 window.StatusBar.show();
12866 }
12867
12868 if (isCapacitor()) {
12869 window.Capacitor.Plugins.StatusBar.show();
12870 }
12871 },
12872 onClick: function onClick() {
12873 var app = this;
12874 var pageContent;
12875
12876 if ($('.popup.modal-in').length > 0) {
12877 // Check for opened popup
12878 pageContent = $('.popup.modal-in').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content');
12879 } else if ($('.panel.panel-in').length > 0) {
12880 // Check for opened panel
12881 pageContent = $('.panel.panel-in').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content');
12882 } else if ($('.views > .view.tab-active').length > 0) {
12883 // View in tab bar app layout
12884 pageContent = $('.views > .view.tab-active').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content');
12885 } else if ($('.views').length > 0) {
12886 pageContent = $('.views').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content');
12887 } else {
12888 pageContent = app.$el.children('.view').find('.page:not(.page-previous):not(.page-next):not(.cached)').find('.page-content');
12889 }
12890
12891 if (pageContent && pageContent.length > 0) {
12892 // Check for tab
12893 if (pageContent.hasClass('tab')) {
12894 pageContent = pageContent.parent('.tabs').children('.page-content.tab-active');
12895 }
12896
12897 if (pageContent.length > 0) pageContent.scrollTop(0, 300);
12898 }
12899 },
12900 setTextColor: function setTextColor(color) {
12901 var window = getWindow();
12902 var device = getDevice();
12903
12904 if (device.cordova && window.StatusBar) {
12905 if (color === 'white') {
12906 window.StatusBar.styleLightContent();
12907 } else {
12908 window.StatusBar.styleDefault();
12909 }
12910 }
12911
12912 if (isCapacitor()) {
12913 if (color === 'white') {
12914 window.Capacitor.Plugins.StatusBar.setStyle({
12915 style: 'DARK'
12916 });
12917 } else {
12918 window.Capacitor.Plugins.StatusBar.setStyle({
12919 style: 'LIGHT'
12920 });
12921 }
12922 }
12923 },
12924 setBackgroundColor: function setBackgroundColor(color) {
12925 var window = getWindow();
12926 var device = getDevice();
12927
12928 if (device.cordova && window.StatusBar) {
12929 window.StatusBar.backgroundColorByHexString(color);
12930 }
12931
12932 if (isCapacitor()) {
12933 window.Capacitor.Plugins.StatusBar.setBackgroundColor({
12934 color: color
12935 });
12936 }
12937 },
12938 isVisible: function isVisible() {
12939 var window = getWindow();
12940 var device = getDevice();
12941 return new Promise(function (resolve) {
12942 if (device.cordova && window.StatusBar) {
12943 resolve(window.StatusBar.isVisible);
12944 }
12945
12946 if (isCapacitor()) {
12947 window.Capacitor.Plugins.StatusBar.getInfo().then(function (info) {
12948 resolve(info.visible);
12949 });
12950 }
12951
12952 resolve(false);
12953 });
12954 },
12955 overlaysWebView: function overlaysWebView(overlays) {
12956 if (overlays === void 0) {
12957 overlays = true;
12958 }
12959
12960 var window = getWindow();
12961 var device = getDevice();
12962
12963 if (device.cordova && window.StatusBar) {
12964 window.StatusBar.overlaysWebView(overlays);
12965 }
12966
12967 if (isCapacitor()) {
12968 window.Capacitor.Plugins.StatusBar.setOverlaysWebView({
12969 overlay: overlays
12970 });
12971 }
12972 },
12973 init: function init() {
12974 var app = this;
12975 var window = getWindow();
12976 var device = getDevice();
12977 var params = app.params.statusbar;
12978 if (!params.enabled) return;
12979 var isCordova = device.cordova && window.StatusBar;
12980 var isCap = isCapacitor();
12981
12982 if (isCordova || isCap) {
12983 if (params.scrollTopOnClick) {
12984 $(window).on('statusTap', Statusbar.onClick.bind(app));
12985 }
12986
12987 if (device.ios) {
12988 if (params.iosOverlaysWebView) {
12989 Statusbar.overlaysWebView(true);
12990 } else {
12991 Statusbar.overlaysWebView(false);
12992 }
12993
12994 if (params.iosTextColor === 'white') {
12995 Statusbar.setTextColor('white');
12996 } else {
12997 Statusbar.setTextColor('black');
12998 }
12999 }
13000
13001 if (device.android) {
13002 if (params.androidOverlaysWebView) {
13003 Statusbar.overlaysWebView(true);
13004 } else {
13005 Statusbar.overlaysWebView(false);
13006 }
13007
13008 if (params.androidTextColor === 'white') {
13009 Statusbar.setTextColor('white');
13010 } else {
13011 Statusbar.setTextColor('black');
13012 }
13013 }
13014 }
13015
13016 if (params.iosBackgroundColor && device.ios) {
13017 Statusbar.setBackgroundColor(params.iosBackgroundColor);
13018 }
13019
13020 if (params.androidBackgroundColor && device.android) {
13021 Statusbar.setBackgroundColor(params.androidBackgroundColor);
13022 }
13023 }
13024 };
13025 var Statusbar$1 = {
13026 name: 'statusbar',
13027 params: {
13028 statusbar: {
13029 enabled: true,
13030 scrollTopOnClick: true,
13031 iosOverlaysWebView: true,
13032 iosTextColor: 'black',
13033 iosBackgroundColor: null,
13034 androidOverlaysWebView: false,
13035 androidTextColor: 'black',
13036 androidBackgroundColor: null
13037 }
13038 },
13039 create: function create() {
13040 var app = this;
13041 bindMethods(app, {
13042 statusbar: Statusbar
13043 });
13044 },
13045 on: {
13046 init: function init() {
13047 var app = this;
13048 Statusbar.init.call(app);
13049 }
13050 }
13051 };
13052
13053 function getCurrentView(app) {
13054 var $popoverView = $('.popover.modal-in .view');
13055 var $popupView = $('.popup.modal-in .view');
13056 var $panelView = $('.panel.panel-in .view');
13057 var $viewsEl = $('.views');
13058 if ($viewsEl.length === 0) $viewsEl = app.$el; // Find active view as tab
13059
13060 var $viewEl = $viewsEl.children('.view');
13061
13062 if ($viewEl.length === 0) {
13063 $viewEl = $viewsEl.children('.tabs').children('.view');
13064 } // Propably in tabs or split view
13065
13066
13067 if ($viewEl.length > 1) {
13068 if ($viewEl.hasClass('tab')) {
13069 // Tabs
13070 $viewEl = $viewsEl.children('.view.tab-active');
13071
13072 if ($viewEl.length === 0) {
13073 $viewEl = $viewsEl.children('.tabs').children('.view.tab-active');
13074 }
13075 }
13076 }
13077
13078 if ($popoverView.length > 0 && $popoverView[0].f7View) return $popoverView[0].f7View;
13079 if ($popupView.length > 0 && $popupView[0].f7View) return $popupView[0].f7View;
13080 if ($panelView.length > 0 && $panelView[0].f7View) return $panelView[0].f7View;
13081
13082 if ($viewEl.length > 0) {
13083 if ($viewEl.length === 1 && $viewEl[0].f7View) return $viewEl[0].f7View;
13084
13085 if ($viewEl.length > 1) {
13086 return app.views.main;
13087 }
13088 }
13089
13090 return undefined;
13091 }
13092
13093 var View = {
13094 name: 'view',
13095 params: {
13096 view: {
13097 init: true,
13098 name: undefined,
13099 main: false,
13100 router: true,
13101 linksView: null,
13102 stackPages: false,
13103 xhrCache: true,
13104 xhrCacheIgnore: [],
13105 xhrCacheIgnoreGetParameters: false,
13106 xhrCacheDuration: 1000 * 60 * 10,
13107 // Ten minutes
13108 componentCache: true,
13109 preloadPreviousPage: true,
13110 allowDuplicateUrls: false,
13111 reloadPages: false,
13112 reloadDetail: false,
13113 masterDetailBreakpoint: 0,
13114 masterDetailResizable: false,
13115 removeElements: true,
13116 removeElementsWithTimeout: false,
13117 removeElementsTimeout: 0,
13118 restoreScrollTopOnBack: true,
13119 unloadTabContent: true,
13120 passRouteQueryToRequest: true,
13121 passRouteParamsToRequest: false,
13122 loadInitialPage: true,
13123 // Swipe Back
13124 iosSwipeBack: true,
13125 iosSwipeBackAnimateShadow: true,
13126 iosSwipeBackAnimateOpacity: true,
13127 iosSwipeBackActiveArea: 30,
13128 iosSwipeBackThreshold: 0,
13129 mdSwipeBack: false,
13130 mdSwipeBackAnimateShadow: true,
13131 mdSwipeBackAnimateOpacity: false,
13132 mdSwipeBackActiveArea: 30,
13133 mdSwipeBackThreshold: 0,
13134 auroraSwipeBack: false,
13135 auroraSwipeBackAnimateShadow: false,
13136 auroraSwipeBackAnimateOpacity: true,
13137 auroraSwipeBackActiveArea: 30,
13138 auroraSwipeBackThreshold: 0,
13139 // Push State
13140 browserHistory: false,
13141 browserHistoryRoot: undefined,
13142 browserHistoryAnimate: true,
13143 browserHistoryAnimateOnLoad: false,
13144 browserHistorySeparator: '#!',
13145 browserHistoryOnLoad: true,
13146 browserHistoryInitialMatch: false,
13147 browserHistoryStoreHistory: true,
13148 // Animate Pages
13149 animate: true,
13150 // iOS Dynamic Navbar
13151 iosDynamicNavbar: true,
13152 // Animate iOS Navbar Back Icon
13153 iosAnimateNavbarBackIcon: true,
13154 // Delays
13155 iosPageLoadDelay: 0,
13156 mdPageLoadDelay: 0,
13157 auroraPageLoadDelay: 0,
13158 // Routes hooks
13159 routesBeforeEnter: null,
13160 routesBeforeLeave: null
13161 }
13162 },
13163 static: {
13164 View: View$1
13165 },
13166 create: function create() {
13167 var app = this;
13168 extend(app, {
13169 views: extend([], {
13170 create: function create(el, params) {
13171 return new View$1(app, el, params);
13172 },
13173 get: function get(viewEl) {
13174 var $viewEl = $(viewEl);
13175 if ($viewEl.length && $viewEl[0].f7View) return $viewEl[0].f7View;
13176 return undefined;
13177 }
13178 })
13179 });
13180 Object.defineProperty(app.views, 'current', {
13181 enumerable: true,
13182 configurable: true,
13183 get: function get() {
13184 return getCurrentView(app);
13185 }
13186 }); // Alias
13187
13188 app.view = app.views;
13189 },
13190 on: {
13191 init: function init() {
13192 var app = this;
13193 $('.view-init').each(function (viewEl) {
13194 if (viewEl.f7View) return;
13195 var viewParams = $(viewEl).dataset();
13196 app.views.create(viewEl, viewParams);
13197 });
13198 },
13199 'modalOpen panelOpen': function onOpen(instance) {
13200 var app = this;
13201 instance.$el.find('.view-init').each(function (viewEl) {
13202 if (viewEl.f7View) return;
13203 var viewParams = $(viewEl).dataset();
13204 app.views.create(viewEl, viewParams);
13205 });
13206 },
13207 'modalBeforeDestroy panelBeforeDestroy': function onClose(instance) {
13208 if (!instance || !instance.$el) return;
13209 instance.$el.find('.view-init').each(function (viewEl) {
13210 var view = viewEl.f7View;
13211 if (!view) return;
13212 view.destroy();
13213 });
13214 }
13215 },
13216 vnode: {
13217 'view-init': {
13218 insert: function insert(vnode) {
13219 var app = this;
13220 var viewEl = vnode.elm;
13221 if (viewEl.f7View) return;
13222 var viewParams = $(viewEl).dataset();
13223 app.views.create(viewEl, viewParams);
13224 },
13225 destroy: function destroy(vnode) {
13226 var viewEl = vnode.elm;
13227 var view = viewEl.f7View;
13228 if (!view) return;
13229 view.destroy();
13230 }
13231 }
13232 }
13233 };
13234
13235 var Navbar = {
13236 size: function size(el) {
13237 var app = this;
13238 var $el = $(el);
13239
13240 if ($el.hasClass('navbars')) {
13241 $el = $el.children('.navbar').each(function (navbarEl) {
13242 app.navbar.size(navbarEl);
13243 });
13244 return;
13245 }
13246
13247 var $innerEl = $el.children('.navbar-inner');
13248 if (!$innerEl.length) return;
13249 var needCenterTitle = $innerEl.hasClass('navbar-inner-centered-title') || app.params.navbar[app.theme + "CenterTitle"];
13250 var needLeftTitle = app.theme === 'ios' && !app.params.navbar[app.theme + "CenterTitle"];
13251 if (!needCenterTitle && !needLeftTitle) return;
13252
13253 if ($el.hasClass('stacked') || $el.parents('.stacked').length > 0 || $el.parents('.tab:not(.tab-active)').length > 0 || $el.parents('.popup:not(.modal-in)').length > 0) {
13254 return;
13255 }
13256
13257 if (app.theme !== 'ios' && app.params.navbar[app.theme + "CenterTitle"]) {
13258 $innerEl.addClass('navbar-inner-centered-title');
13259 }
13260
13261 if (app.theme === 'ios' && !app.params.navbar.iosCenterTitle) {
13262 $innerEl.addClass('navbar-inner-left-title');
13263 }
13264
13265 var $viewEl = $el.parents('.view').eq(0);
13266 var left = app.rtl ? $innerEl.children('.right') : $innerEl.children('.left');
13267 var right = app.rtl ? $innerEl.children('.left') : $innerEl.children('.right');
13268 var title = $innerEl.children('.title');
13269 var subnavbar = $innerEl.children('.subnavbar');
13270 var noLeft = left.length === 0;
13271 var noRight = right.length === 0;
13272 var leftWidth = noLeft ? 0 : left.outerWidth(true);
13273 var rightWidth = noRight ? 0 : right.outerWidth(true);
13274 var titleWidth = title.outerWidth(true);
13275 var navbarStyles = $innerEl.styles();
13276 var navbarWidth = $innerEl[0].offsetWidth;
13277 var navbarInnerWidth = navbarWidth - parseInt(navbarStyles.paddingLeft, 10) - parseInt(navbarStyles.paddingRight, 10);
13278 var isPrevious = $el.hasClass('navbar-previous');
13279 var sliding = $innerEl.hasClass('sliding');
13280 var router;
13281 var dynamicNavbar;
13282
13283 if ($viewEl.length > 0 && $viewEl[0].f7View) {
13284 router = $viewEl[0].f7View.router;
13285 dynamicNavbar = router && router.dynamicNavbar;
13286 }
13287
13288 var currLeft;
13289 var diff;
13290
13291 if (noRight) {
13292 currLeft = navbarInnerWidth - titleWidth;
13293 }
13294
13295 if (noLeft) {
13296 currLeft = 0;
13297 }
13298
13299 if (!noLeft && !noRight) {
13300 currLeft = (navbarInnerWidth - rightWidth - titleWidth + leftWidth) / 2;
13301 }
13302
13303 var requiredLeft = (navbarInnerWidth - titleWidth) / 2;
13304
13305 if (navbarInnerWidth - leftWidth - rightWidth > titleWidth) {
13306 if (requiredLeft < leftWidth) {
13307 requiredLeft = leftWidth;
13308 }
13309
13310 if (requiredLeft + titleWidth > navbarInnerWidth - rightWidth) {
13311 requiredLeft = navbarInnerWidth - rightWidth - titleWidth;
13312 }
13313
13314 diff = requiredLeft - currLeft;
13315 } else {
13316 diff = 0;
13317 } // RTL inverter
13318
13319
13320 var inverter = app.rtl ? -1 : 1;
13321
13322 if (dynamicNavbar && app.theme === 'ios') {
13323 if (title.hasClass('sliding') || title.length > 0 && sliding) {
13324 var titleLeftOffset = -(currLeft + diff) * inverter;
13325 var titleRightOffset = (navbarInnerWidth - currLeft - diff - titleWidth) * inverter;
13326
13327 if (isPrevious) {
13328 if (router && router.params.iosAnimateNavbarBackIcon) {
13329 var activeNavbarBackLink = $el.parent().find('.navbar-current').children('.left.sliding').find('.back .icon ~ span');
13330
13331 if (activeNavbarBackLink.length > 0) {
13332 titleLeftOffset += activeNavbarBackLink[0].offsetLeft;
13333 }
13334 }
13335 }
13336
13337 title[0].f7NavbarLeftOffset = titleLeftOffset;
13338 title[0].f7NavbarRightOffset = titleRightOffset;
13339 }
13340
13341 if (!noLeft && (left.hasClass('sliding') || sliding)) {
13342 if (app.rtl) {
13343 left[0].f7NavbarLeftOffset = -(navbarInnerWidth - left[0].offsetWidth) / 2 * inverter;
13344 left[0].f7NavbarRightOffset = leftWidth * inverter;
13345 } else {
13346 left[0].f7NavbarLeftOffset = -leftWidth;
13347 left[0].f7NavbarRightOffset = (navbarInnerWidth - left[0].offsetWidth) / 2;
13348
13349 if (router && router.params.iosAnimateNavbarBackIcon && left.find('.back .icon').length > 0) {
13350 if (left.find('.back .icon ~ span').length) {
13351 var leftOffset = left[0].f7NavbarLeftOffset;
13352 var rightOffset = left[0].f7NavbarRightOffset;
13353 left[0].f7NavbarLeftOffset = 0;
13354 left[0].f7NavbarRightOffset = 0;
13355 left.find('.back .icon ~ span')[0].f7NavbarLeftOffset = leftOffset;
13356 left.find('.back .icon ~ span')[0].f7NavbarRightOffset = rightOffset - left.find('.back .icon')[0].offsetWidth;
13357 }
13358 }
13359 }
13360 }
13361
13362 if (!noRight && (right.hasClass('sliding') || sliding)) {
13363 if (app.rtl) {
13364 right[0].f7NavbarLeftOffset = -rightWidth * inverter;
13365 right[0].f7NavbarRightOffset = (navbarInnerWidth - right[0].offsetWidth) / 2 * inverter;
13366 } else {
13367 right[0].f7NavbarLeftOffset = -(navbarInnerWidth - right[0].offsetWidth) / 2;
13368 right[0].f7NavbarRightOffset = rightWidth;
13369 }
13370 }
13371
13372 if (subnavbar.length && (subnavbar.hasClass('sliding') || sliding)) {
13373 subnavbar[0].f7NavbarLeftOffset = app.rtl ? subnavbar[0].offsetWidth : -subnavbar[0].offsetWidth;
13374 subnavbar[0].f7NavbarRightOffset = -subnavbar[0].f7NavbarLeftOffset;
13375 }
13376 } // Center title
13377
13378
13379 if (needCenterTitle) {
13380 var titleLeft = diff;
13381 if (app.rtl && noLeft && noRight && title.length > 0) titleLeft = -titleLeft;
13382 title.css({
13383 left: titleLeft + "px"
13384 });
13385 }
13386 },
13387 hide: function hide(el, animate, hideStatusbar, hideOnlyCurrent) {
13388 if (animate === void 0) {
13389 animate = true;
13390 }
13391
13392 if (hideStatusbar === void 0) {
13393 hideStatusbar = false;
13394 }
13395
13396 if (hideOnlyCurrent === void 0) {
13397 hideOnlyCurrent = false;
13398 }
13399
13400 var app = this;
13401 var $el = $(el);
13402 var isDynamic = $el.hasClass('navbar') && $el.parent('.navbars').length && !hideOnlyCurrent;
13403 if (isDynamic) $el = $el.parents('.navbars');
13404 if (!$el.length) return;
13405 if ($el.hasClass('navbar-hidden')) return;
13406 var className = "navbar-hidden" + (animate ? ' navbar-transitioning' : '');
13407 var currentIsLarge = isDynamic ? $el.find('.navbar-current .title-large').length : $el.find('.title-large').length;
13408
13409 if (currentIsLarge) {
13410 className += ' navbar-large-hidden';
13411 }
13412
13413 if (hideStatusbar) {
13414 className += ' navbar-hidden-statusbar';
13415 }
13416
13417 $el.transitionEnd(function () {
13418 $el.removeClass('navbar-transitioning');
13419 });
13420 $el.addClass(className);
13421
13422 if (isDynamic) {
13423 $el.children('.navbar').each(function (subEl) {
13424 $(subEl).trigger('navbar:hide');
13425 app.emit('navbarHide', subEl);
13426 });
13427 } else {
13428 $el.trigger('navbar:hide');
13429 app.emit('navbarHide', $el[0]);
13430 }
13431 },
13432 show: function show(el, animate, hideOnlyCurrent) {
13433 if (el === void 0) {
13434 el = '.navbar-hidden';
13435 }
13436
13437 if (animate === void 0) {
13438 animate = true;
13439 }
13440
13441 if (hideOnlyCurrent === void 0) {
13442 hideOnlyCurrent = false;
13443 }
13444
13445 var app = this;
13446 var $el = $(el);
13447 var isDynamic = $el.hasClass('navbar') && $el.parent('.navbars').length && !hideOnlyCurrent;
13448 if (isDynamic) $el = $el.parents('.navbars');
13449 if (!$el.length) return;
13450 if (!$el.hasClass('navbar-hidden')) return;
13451
13452 if (animate) {
13453 $el.addClass('navbar-transitioning');
13454 $el.transitionEnd(function () {
13455 $el.removeClass('navbar-transitioning');
13456 });
13457 }
13458
13459 $el.removeClass('navbar-hidden navbar-large-hidden navbar-hidden-statusbar');
13460
13461 if (isDynamic) {
13462 $el.children('.navbar').each(function (subEl) {
13463 $(subEl).trigger('navbar:show');
13464 app.emit('navbarShow', subEl);
13465 });
13466 } else {
13467 $el.trigger('navbar:show');
13468 app.emit('navbarShow', $el[0]);
13469 }
13470 },
13471 getElByPage: function getElByPage(page) {
13472 var $pageEl;
13473 var $navbarEl;
13474 var pageData;
13475
13476 if (page.$navbarEl || page.$el) {
13477 pageData = page;
13478 $pageEl = page.$el;
13479 } else {
13480 $pageEl = $(page);
13481 if ($pageEl.length > 0) pageData = $pageEl[0].f7Page;
13482 }
13483
13484 if (pageData && pageData.$navbarEl && pageData.$navbarEl.length > 0) {
13485 $navbarEl = pageData.$navbarEl;
13486 } else if ($pageEl) {
13487 $navbarEl = $pageEl.children('.navbar');
13488 }
13489
13490 if (!$navbarEl || $navbarEl && $navbarEl.length === 0) return undefined;
13491 return $navbarEl[0];
13492 },
13493 getPageByEl: function getPageByEl(navbarEl) {
13494 var $navbarEl = $(navbarEl);
13495
13496 if ($navbarEl.parents('.page').length) {
13497 return $navbarEl.parents('.page')[0];
13498 }
13499
13500 var pageEl;
13501 $navbarEl.parents('.view').find('.page').each(function (el) {
13502 if (el && el.f7Page && el.f7Page.navbarEl && $navbarEl[0] === el.f7Page.navbarEl) {
13503 pageEl = el;
13504 }
13505 });
13506 return pageEl;
13507 },
13508 collapseLargeTitle: function collapseLargeTitle(navbarEl) {
13509 var app = this;
13510 var $navbarEl = $(navbarEl);
13511
13512 if ($navbarEl.hasClass('navbars')) {
13513 $navbarEl = $navbarEl.find('.navbar');
13514
13515 if ($navbarEl.length > 1) {
13516 $navbarEl = $(navbarEl).find('.navbar-large.navbar-current');
13517 }
13518
13519 if ($navbarEl.length > 1 || !$navbarEl.length) {
13520 return;
13521 }
13522 }
13523
13524 var $pageEl = $(app.navbar.getPageByEl($navbarEl));
13525 $navbarEl.addClass('navbar-large-collapsed');
13526 $pageEl.eq(0).addClass('page-with-navbar-large-collapsed').trigger('page:navbarlargecollapsed');
13527 app.emit('pageNavbarLargeCollapsed', $pageEl[0]);
13528 $navbarEl.trigger('navbar:collapse');
13529 app.emit('navbarCollapse', $navbarEl[0]);
13530 },
13531 expandLargeTitle: function expandLargeTitle(navbarEl) {
13532 var app = this;
13533 var $navbarEl = $(navbarEl);
13534
13535 if ($navbarEl.hasClass('navbars')) {
13536 $navbarEl = $navbarEl.find('.navbar-large');
13537
13538 if ($navbarEl.length > 1) {
13539 $navbarEl = $(navbarEl).find('.navbar-large.navbar-current');
13540 }
13541
13542 if ($navbarEl.length > 1 || !$navbarEl.length) {
13543 return;
13544 }
13545 }
13546
13547 var $pageEl = $(app.navbar.getPageByEl($navbarEl));
13548 $navbarEl.removeClass('navbar-large-collapsed');
13549 $pageEl.eq(0).removeClass('page-with-navbar-large-collapsed').trigger('page:navbarlargeexpanded');
13550 app.emit('pageNavbarLargeExpanded', $pageEl[0]);
13551 $navbarEl.trigger('navbar:expand');
13552 app.emit('navbarExpand', $navbarEl[0]);
13553 },
13554 toggleLargeTitle: function toggleLargeTitle(navbarEl) {
13555 var app = this;
13556 var $navbarEl = $(navbarEl);
13557
13558 if ($navbarEl.hasClass('navbars')) {
13559 $navbarEl = $navbarEl.find('.navbar-large');
13560
13561 if ($navbarEl.length > 1) {
13562 $navbarEl = $(navbarEl).find('.navbar-large.navbar-current');
13563 }
13564
13565 if ($navbarEl.length > 1 || !$navbarEl.length) {
13566 return;
13567 }
13568 }
13569
13570 if ($navbarEl.hasClass('navbar-large-collapsed')) {
13571 app.navbar.expandLargeTitle($navbarEl);
13572 } else {
13573 app.navbar.collapseLargeTitle($navbarEl);
13574 }
13575 },
13576 initNavbarOnScroll: function initNavbarOnScroll(pageEl, navbarEl, needHide, needCollapse, needTransparent) {
13577 var app = this;
13578 var support = getSupport();
13579 var $pageEl = $(pageEl);
13580 var $navbarEl = $(navbarEl);
13581 var $titleLargeEl = $navbarEl.find('.title-large');
13582 var isLarge = $titleLargeEl.length || $navbarEl.hasClass('.navbar-large');
13583 var navbarHideHeight = 44;
13584 var snapPageScrollToLargeTitle = app.params.navbar.snapPageScrollToLargeTitle;
13585 var snapPageScrollToTransparentNavbar = app.params.navbar.snapPageScrollToTransparentNavbar;
13586 var previousScrollTop;
13587 var currentScrollTop;
13588 var scrollHeight;
13589 var offsetHeight;
13590 var reachEnd;
13591 var action;
13592 var navbarHidden;
13593 var navbarCollapsed;
13594 var navbarTitleLargeHeight;
13595 var navbarOffsetHeight;
13596
13597 if (needCollapse || needHide && isLarge) {
13598 navbarTitleLargeHeight = $navbarEl.css('--f7-navbar-large-title-height');
13599
13600 if (navbarTitleLargeHeight && navbarTitleLargeHeight.indexOf('px') >= 0) {
13601 navbarTitleLargeHeight = parseInt(navbarTitleLargeHeight, 10);
13602
13603 if (Number.isNaN(navbarTitleLargeHeight) && $titleLargeEl.length) {
13604 navbarTitleLargeHeight = $titleLargeEl[0].offsetHeight;
13605 } else if (Number.isNaN(navbarTitleLargeHeight)) {
13606 if (app.theme === 'ios') navbarTitleLargeHeight = 52;else if (app.theme === 'md') navbarTitleLargeHeight = 48;else if (app.theme === 'aurora') navbarTitleLargeHeight = 38;
13607 }
13608 } else if ($titleLargeEl.length) {
13609 navbarTitleLargeHeight = $titleLargeEl[0].offsetHeight;
13610 } else {
13611 // eslint-disable-next-line
13612 if (app.theme === 'ios') navbarTitleLargeHeight = 52;else if (app.theme === 'md') navbarTitleLargeHeight = 48;else if (app.theme === 'aurora') navbarTitleLargeHeight = 38;
13613 }
13614 }
13615
13616 if (needHide && isLarge) {
13617 navbarHideHeight += navbarTitleLargeHeight;
13618 }
13619
13620 var scrollChanged;
13621 var scrollContent;
13622 var scrollTimeoutId;
13623 var touchEndTimeoutId;
13624 var touchSnapTimeout = 70;
13625 var desktopSnapTimeout = 300;
13626
13627 function calcScrollableDistance() {
13628 $pageEl.find('.page-content').each(function (pageContentEl) {
13629 pageContentEl.f7ScrollableDistance = pageContentEl.scrollHeight - pageContentEl.offsetHeight;
13630 });
13631 }
13632
13633 function snapLargeNavbar() {
13634 var inSearchbarExpanded = $navbarEl.hasClass('with-searchbar-expandable-enabled');
13635 if (inSearchbarExpanded) return;
13636 if (!scrollContent || currentScrollTop < 0) return;
13637
13638 if (currentScrollTop >= navbarTitleLargeHeight / 2 && currentScrollTop < navbarTitleLargeHeight) {
13639 $(scrollContent).scrollTop(navbarTitleLargeHeight, 100);
13640 } else if (currentScrollTop < navbarTitleLargeHeight) {
13641 $(scrollContent).scrollTop(0, 200);
13642 }
13643 }
13644
13645 function snapTransparentNavbar() {
13646 var inSearchbarExpanded = $navbarEl.hasClass('with-searchbar-expandable-enabled');
13647 if (inSearchbarExpanded) return;
13648 if (!scrollContent || currentScrollTop < 0) return;
13649
13650 if (currentScrollTop >= navbarOffsetHeight / 2 && currentScrollTop < navbarOffsetHeight) {
13651 $(scrollContent).scrollTop(navbarOffsetHeight, 100);
13652 } else if (currentScrollTop < navbarOffsetHeight) {
13653 $(scrollContent).scrollTop(0, 200);
13654 }
13655 }
13656
13657 function handleNavbarTransparent() {
13658 var isHidden = $navbarEl.hasClass('navbar-hidden') || $navbarEl.parent('.navbars').hasClass('navbar-hidden');
13659 var inSearchbarExpanded = $navbarEl.hasClass('with-searchbar-expandable-enabled');
13660 if (inSearchbarExpanded || isHidden) return;
13661
13662 if (!navbarOffsetHeight) {
13663 navbarOffsetHeight = navbarEl.offsetHeight;
13664 }
13665
13666 var opacity = currentScrollTop / navbarOffsetHeight;
13667 var notTransparent = $navbarEl.hasClass('navbar-transparent-visible');
13668 opacity = Math.max(Math.min(opacity, 1), 0);
13669
13670 if (notTransparent && opacity === 1 || !notTransparent && opacity === 0) {
13671 $navbarEl.find('.navbar-bg, .title').css('opacity', '');
13672 return;
13673 }
13674
13675 if (notTransparent && opacity === 0) {
13676 $navbarEl.trigger('navbar:transparenthide');
13677 app.emit('navbarTransparentHide', $navbarEl[0]);
13678 $navbarEl.removeClass('navbar-transparent-visible');
13679 $navbarEl.find('.navbar-bg, .title').css('opacity', '');
13680 return;
13681 }
13682
13683 if (!notTransparent && opacity === 1) {
13684 $navbarEl.trigger('navbar:transparentshow');
13685 app.emit('navbarTransparentShow', $navbarEl[0]);
13686 $navbarEl.addClass('navbar-transparent-visible');
13687 $navbarEl.find('.navbar-bg, .title').css('opacity', '');
13688 return;
13689 }
13690
13691 $navbarEl.find('.navbar-bg, .title').css('opacity', opacity);
13692
13693 if (snapPageScrollToTransparentNavbar) {
13694 if (!support.touch) {
13695 clearTimeout(scrollTimeoutId);
13696 scrollTimeoutId = setTimeout(function () {
13697 snapTransparentNavbar();
13698 }, desktopSnapTimeout);
13699 } else if (touchEndTimeoutId) {
13700 clearTimeout(touchEndTimeoutId);
13701 touchEndTimeoutId = null;
13702 touchEndTimeoutId = setTimeout(function () {
13703 snapTransparentNavbar();
13704 clearTimeout(touchEndTimeoutId);
13705 touchEndTimeoutId = null;
13706 }, touchSnapTimeout);
13707 }
13708 }
13709 }
13710
13711 var previousCollapseProgress = null;
13712 var collapseProgress = null;
13713
13714 function handleLargeNavbarCollapse(pageContentEl) {
13715 var isHidden = $navbarEl.hasClass('navbar-hidden') || $navbarEl.parent('.navbars').hasClass('navbar-hidden');
13716 if (isHidden) return;
13717 var isLargeTransparent = $navbarEl.hasClass('navbar-large-transparent') || $navbarEl.hasClass('navbar-large') && $navbarEl.hasClass('navbar-transparent');
13718 previousCollapseProgress = collapseProgress;
13719 var scrollableDistance = Math.min(navbarTitleLargeHeight, pageContentEl.f7ScrollableDistance || navbarTitleLargeHeight);
13720 collapseProgress = Math.min(Math.max(currentScrollTop / scrollableDistance, 0), 1);
13721 var previousCollapseWasInMiddle = previousCollapseProgress > 0 && previousCollapseProgress < 1;
13722 var inSearchbarExpanded = $navbarEl.hasClass('with-searchbar-expandable-enabled');
13723 if (inSearchbarExpanded) return;
13724 navbarCollapsed = $navbarEl.hasClass('navbar-large-collapsed');
13725
13726 if (collapseProgress === 0 && navbarCollapsed) {
13727 app.navbar.expandLargeTitle($navbarEl[0]);
13728 } else if (collapseProgress === 1 && !navbarCollapsed) {
13729 app.navbar.collapseLargeTitle($navbarEl[0]);
13730 }
13731
13732 if (collapseProgress === 0 && navbarCollapsed || collapseProgress === 0 && previousCollapseWasInMiddle || collapseProgress === 1 && !navbarCollapsed || collapseProgress === 1 && previousCollapseWasInMiddle) {
13733 if (app.theme === 'md') {
13734 $navbarEl.find('.navbar-inner').css('overflow', '');
13735 }
13736
13737 $navbarEl.find('.title').css('opacity', '');
13738 $navbarEl.find('.title-large-text, .subnavbar').css('transform', '');
13739
13740 if (isLargeTransparent) {
13741 $navbarEl.find('.navbar-bg').css('opacity', '');
13742 } else {
13743 $navbarEl.find('.navbar-bg').css('transform', '');
13744 }
13745 } else if (collapseProgress > 0 && collapseProgress < 1) {
13746 if (app.theme === 'md') {
13747 $navbarEl.find('.navbar-inner').css('overflow', 'visible');
13748 }
13749
13750 $navbarEl.find('.title').css('opacity', collapseProgress);
13751 $navbarEl.find('.title-large-text, .subnavbar').css('transform', "translate3d(0px, " + -1 * collapseProgress * navbarTitleLargeHeight + "px, 0)");
13752
13753 if (isLargeTransparent) {
13754 $navbarEl.find('.navbar-bg').css('opacity', collapseProgress);
13755 } else {
13756 $navbarEl.find('.navbar-bg').css('transform', "translate3d(0px, " + -1 * collapseProgress * navbarTitleLargeHeight + "px, 0)");
13757 }
13758 }
13759
13760 if (snapPageScrollToLargeTitle) {
13761 if (!support.touch) {
13762 clearTimeout(scrollTimeoutId);
13763 scrollTimeoutId = setTimeout(function () {
13764 snapLargeNavbar();
13765 }, desktopSnapTimeout);
13766 } else if (touchEndTimeoutId) {
13767 clearTimeout(touchEndTimeoutId);
13768 touchEndTimeoutId = null;
13769 touchEndTimeoutId = setTimeout(function () {
13770 snapLargeNavbar();
13771 clearTimeout(touchEndTimeoutId);
13772 touchEndTimeoutId = null;
13773 }, touchSnapTimeout);
13774 }
13775 }
13776 }
13777
13778 function handleTitleHideShow() {
13779 if ($pageEl.hasClass('page-with-card-opened')) return;
13780 scrollHeight = scrollContent.scrollHeight;
13781 offsetHeight = scrollContent.offsetHeight;
13782 reachEnd = currentScrollTop + offsetHeight >= scrollHeight;
13783 navbarHidden = $navbarEl.hasClass('navbar-hidden') || $navbarEl.parent('.navbars').hasClass('navbar-hidden');
13784
13785 if (reachEnd) {
13786 if (app.params.navbar.showOnPageScrollEnd) {
13787 action = 'show';
13788 }
13789 } else if (previousScrollTop > currentScrollTop) {
13790 if (app.params.navbar.showOnPageScrollTop || currentScrollTop <= navbarHideHeight) {
13791 action = 'show';
13792 } else {
13793 action = 'hide';
13794 }
13795 } else if (currentScrollTop > navbarHideHeight) {
13796 action = 'hide';
13797 } else {
13798 action = 'show';
13799 }
13800
13801 if (action === 'show' && navbarHidden) {
13802 app.navbar.show($navbarEl, true, true);
13803 navbarHidden = false;
13804 } else if (action === 'hide' && !navbarHidden) {
13805 app.navbar.hide($navbarEl, true, false, true);
13806 navbarHidden = true;
13807 }
13808
13809 previousScrollTop = currentScrollTop;
13810 }
13811
13812 function handleScroll(e) {
13813 scrollContent = this;
13814
13815 if (e && e.target && e.target !== scrollContent) {
13816 return;
13817 }
13818
13819 currentScrollTop = scrollContent.scrollTop;
13820 scrollChanged = currentScrollTop;
13821
13822 if (needCollapse) {
13823 handleLargeNavbarCollapse(scrollContent);
13824 } else if (needTransparent) {
13825 handleNavbarTransparent();
13826 }
13827
13828 if ($pageEl.hasClass('page-previous')) return;
13829
13830 if (needHide) {
13831 handleTitleHideShow();
13832 }
13833 }
13834
13835 function handeTouchStart() {
13836 scrollChanged = false;
13837 }
13838
13839 function handleTouchEnd() {
13840 clearTimeout(touchEndTimeoutId);
13841 touchEndTimeoutId = null;
13842 touchEndTimeoutId = setTimeout(function () {
13843 if (scrollChanged !== false) {
13844 if (needTransparent && !needCollapse) {
13845 snapTransparentNavbar();
13846 } else {
13847 snapLargeNavbar();
13848 }
13849
13850 clearTimeout(touchEndTimeoutId);
13851 touchEndTimeoutId = null;
13852 }
13853 }, touchSnapTimeout);
13854 }
13855
13856 $pageEl.on('scroll', '.page-content', handleScroll, true);
13857
13858 if (support.touch && (needCollapse && snapPageScrollToLargeTitle || needTransparent && snapPageScrollToTransparentNavbar)) {
13859 app.on('touchstart:passive', handeTouchStart);
13860 app.on('touchend:passive', handleTouchEnd);
13861 }
13862
13863 calcScrollableDistance();
13864
13865 if (needCollapse || needTransparent) {
13866 $pageEl.find('.page-content').each(function (pageContentEl) {
13867 if (pageContentEl.scrollTop > 0) handleScroll.call(pageContentEl);
13868 });
13869 }
13870
13871 app.on('resize', calcScrollableDistance);
13872
13873 $pageEl[0].f7DetachNavbarScrollHandlers = function f7DetachNavbarScrollHandlers() {
13874 app.off('resize', calcScrollableDistance);
13875 delete $pageEl[0].f7DetachNavbarScrollHandlers;
13876 $pageEl.off('scroll', '.page-content', handleScroll, true);
13877
13878 if (support.touch && (needCollapse && snapPageScrollToLargeTitle || needTransparent && snapPageScrollToTransparentNavbar)) {
13879 app.off('touchstart:passive', handeTouchStart);
13880 app.off('touchend:passive', handleTouchEnd);
13881 }
13882 };
13883 }
13884 };
13885 var Navbar$1 = {
13886 name: 'navbar',
13887 create: function create() {
13888 var app = this;
13889 bindMethods(app, {
13890 navbar: Navbar
13891 });
13892 },
13893 params: {
13894 navbar: {
13895 scrollTopOnTitleClick: true,
13896 iosCenterTitle: true,
13897 mdCenterTitle: false,
13898 auroraCenterTitle: true,
13899 hideOnPageScroll: false,
13900 showOnPageScrollEnd: true,
13901 showOnPageScrollTop: true,
13902 collapseLargeTitleOnScroll: true,
13903 snapPageScrollToLargeTitle: true,
13904 snapPageScrollToTransparentNavbar: true
13905 }
13906 },
13907 on: {
13908 'panelBreakpoint panelCollapsedBreakpoint panelResize viewResize resize viewMasterDetailBreakpoint': function onPanelResize() {
13909 var app = this;
13910 $('.navbar').each(function (navbarEl) {
13911 app.navbar.size(navbarEl);
13912 });
13913 },
13914 pageBeforeRemove: function pageBeforeRemove(page) {
13915 if (page.$el[0].f7DetachNavbarScrollHandlers) {
13916 page.$el[0].f7DetachNavbarScrollHandlers();
13917 }
13918 },
13919 pageBeforeIn: function pageBeforeIn(page) {
13920 var app = this;
13921 if (app.theme !== 'ios') return;
13922 var $navbarsEl;
13923 var view = page.$el.parents('.view')[0].f7View;
13924 var navbarEl = app.navbar.getElByPage(page);
13925
13926 if (!navbarEl) {
13927 $navbarsEl = page.$el.parents('.view').children('.navbars');
13928 } else {
13929 $navbarsEl = $(navbarEl).parents('.navbars');
13930 }
13931
13932 if (page.$el.hasClass('no-navbar') || view.router.dynamicNavbar && !navbarEl) {
13933 var animate = !!(page.pageFrom && page.router.history.length > 0);
13934 app.navbar.hide($navbarsEl, animate);
13935 } else {
13936 app.navbar.show($navbarsEl);
13937 }
13938 },
13939 pageReinit: function pageReinit(page) {
13940 var app = this;
13941 var $navbarEl = $(app.navbar.getElByPage(page));
13942 if (!$navbarEl || $navbarEl.length === 0) return;
13943 app.navbar.size($navbarEl);
13944 },
13945 pageInit: function pageInit(page) {
13946 var app = this;
13947 var $navbarEl = $(app.navbar.getElByPage(page));
13948 if (!$navbarEl || $navbarEl.length === 0) return; // Size
13949
13950 app.navbar.size($navbarEl); // Need Collapse On Scroll
13951
13952 var needCollapseOnScrollHandler;
13953
13954 if ($navbarEl.find('.title-large').length > 0) {
13955 $navbarEl.addClass('navbar-large');
13956 }
13957
13958 if ($navbarEl.hasClass('navbar-large')) {
13959 if (app.params.navbar.collapseLargeTitleOnScroll) needCollapseOnScrollHandler = true;
13960 page.$el.addClass('page-with-navbar-large');
13961 } // Need transparent on scroll
13962
13963
13964 var needTransparentOnScroll;
13965
13966 if (!needCollapseOnScrollHandler && $navbarEl.hasClass('navbar-transparent')) {
13967 needTransparentOnScroll = true;
13968 } // Need Hide On Scroll
13969
13970
13971 var needHideOnScrollHandler;
13972
13973 if (app.params.navbar.hideOnPageScroll || page.$el.find('.hide-navbar-on-scroll').length || page.$el.hasClass('hide-navbar-on-scroll') || page.$el.find('.hide-bars-on-scroll').length || page.$el.hasClass('hide-bars-on-scroll')) {
13974 if (page.$el.find('.keep-navbar-on-scroll').length || page.$el.hasClass('keep-navbar-on-scroll') || page.$el.find('.keep-bars-on-scroll').length || page.$el.hasClass('keep-bars-on-scroll')) {
13975 needHideOnScrollHandler = false;
13976 } else {
13977 needHideOnScrollHandler = true;
13978 }
13979 }
13980
13981 if (needCollapseOnScrollHandler || needHideOnScrollHandler || needTransparentOnScroll) {
13982 app.navbar.initNavbarOnScroll(page.el, $navbarEl[0], needHideOnScrollHandler, needCollapseOnScrollHandler, needTransparentOnScroll);
13983 }
13984 },
13985 'panelOpen panelSwipeOpen modalOpen': function onPanelModalOpen(instance) {
13986 var app = this;
13987 instance.$el.find('.navbar:not(.navbar-previous):not(.stacked)').each(function (navbarEl) {
13988 app.navbar.size(navbarEl);
13989 });
13990 },
13991 tabShow: function tabShow(tabEl) {
13992 var app = this;
13993 $(tabEl).find('.navbar:not(.navbar-previous):not(.stacked)').each(function (navbarEl) {
13994 app.navbar.size(navbarEl);
13995 });
13996 }
13997 },
13998 clicks: {
13999 '.navbar .title': function onTitleClick($clickedEl) {
14000 var app = this;
14001 if (!app.params.navbar.scrollTopOnTitleClick) return;
14002
14003 if ($clickedEl.closest('a').length > 0) {
14004 return;
14005 }
14006
14007 var $pageContentEl; // Find active page
14008
14009 var $navbarEl = $clickedEl.parents('.navbar');
14010 var $navbarsEl = $navbarEl.parents('.navbars'); // Static Layout
14011
14012 $pageContentEl = $navbarEl.parents('.page-content');
14013
14014 if ($pageContentEl.length === 0) {
14015 // Fixed Layout
14016 if ($navbarEl.parents('.page').length > 0) {
14017 $pageContentEl = $navbarEl.parents('.page').find('.page-content');
14018 } // Through Layout iOS
14019
14020
14021 if ($pageContentEl.length === 0 && $navbarsEl.length) {
14022 if ($navbarsEl.nextAll('.page-current:not(.stacked)').length > 0) {
14023 $pageContentEl = $navbarsEl.nextAll('.page-current:not(.stacked)').find('.page-content');
14024 }
14025 } // Through Layout
14026
14027
14028 if ($pageContentEl.length === 0) {
14029 if ($navbarEl.nextAll('.page-current:not(.stacked)').length > 0) {
14030 $pageContentEl = $navbarEl.nextAll('.page-current:not(.stacked)').find('.page-content');
14031 }
14032 }
14033 }
14034
14035 if ($pageContentEl && $pageContentEl.length > 0) {
14036 // Check for tab
14037 if ($pageContentEl.hasClass('tab')) {
14038 $pageContentEl = $pageContentEl.parent('.tabs').children('.page-content.tab-active');
14039 }
14040
14041 if ($pageContentEl.length > 0) $pageContentEl.scrollTop(0, 300);
14042 }
14043 }
14044 },
14045 vnode: {
14046 navbar: {
14047 postpatch: function postpatch(vnode) {
14048 var app = this;
14049 app.navbar.size(vnode.elm);
14050 }
14051 }
14052 }
14053 };
14054
14055 var Toolbar = {
14056 setHighlight: function setHighlight(tabbarEl) {
14057 var app = this;
14058 if (app.theme === 'ios') return;
14059 var $tabbarEl = $(tabbarEl);
14060 if ($tabbarEl.length === 0 || !($tabbarEl.hasClass('tabbar') || $tabbarEl.hasClass('tabbar-labels'))) return;
14061 var $highlightEl = $tabbarEl.find('.tab-link-highlight');
14062 var tabLinksCount = $tabbarEl.find('.tab-link').length;
14063
14064 if (tabLinksCount === 0) {
14065 $highlightEl.remove();
14066 return;
14067 }
14068
14069 if ($highlightEl.length === 0) {
14070 $tabbarEl.children('.toolbar-inner').append('<span class="tab-link-highlight"></span>');
14071 $highlightEl = $tabbarEl.find('.tab-link-highlight');
14072 } else if ($highlightEl.next().length) {
14073 $tabbarEl.children('.toolbar-inner').append($highlightEl);
14074 }
14075
14076 var $activeLink = $tabbarEl.find('.tab-link-active');
14077 var highlightWidth;
14078 var highlightTranslate;
14079
14080 if ($tabbarEl.hasClass('tabbar-scrollable') && $activeLink && $activeLink[0]) {
14081 highlightWidth = $activeLink[0].offsetWidth + "px";
14082 highlightTranslate = $activeLink[0].offsetLeft + "px";
14083 } else {
14084 var activeIndex = $activeLink.index();
14085 highlightWidth = 100 / tabLinksCount + "%";
14086 highlightTranslate = (app.rtl ? -activeIndex : activeIndex) * 100 + "%";
14087 }
14088
14089 nextFrame$1(function () {
14090 $highlightEl.css('width', highlightWidth).transform("translate3d(" + highlightTranslate + ",0,0)");
14091 });
14092 },
14093 init: function init(tabbarEl) {
14094 var app = this;
14095 app.toolbar.setHighlight(tabbarEl);
14096 },
14097 hide: function hide(el, animate) {
14098 if (animate === void 0) {
14099 animate = true;
14100 }
14101
14102 var app = this;
14103 var $el = $(el);
14104 if ($el.hasClass('toolbar-hidden')) return;
14105 var className = "toolbar-hidden" + (animate ? ' toolbar-transitioning' : '');
14106 $el.transitionEnd(function () {
14107 $el.removeClass('toolbar-transitioning');
14108 });
14109 $el.addClass(className);
14110 $el.trigger('toolbar:hide');
14111 app.emit('toolbarHide', $el[0]);
14112 },
14113 show: function show(el, animate) {
14114 if (animate === void 0) {
14115 animate = true;
14116 }
14117
14118 var app = this;
14119 var $el = $(el);
14120 if (!$el.hasClass('toolbar-hidden')) return;
14121
14122 if (animate) {
14123 $el.addClass('toolbar-transitioning');
14124 $el.transitionEnd(function () {
14125 $el.removeClass('toolbar-transitioning');
14126 });
14127 }
14128
14129 $el.removeClass('toolbar-hidden');
14130 $el.trigger('toolbar:show');
14131 app.emit('toolbarShow', $el[0]);
14132 },
14133 initToolbarOnScroll: function initToolbarOnScroll(pageEl) {
14134 var app = this;
14135 var $pageEl = $(pageEl);
14136 var $toolbarEl = $pageEl.parents('.view').children('.toolbar');
14137
14138 if ($toolbarEl.length === 0) {
14139 $toolbarEl = $pageEl.find('.toolbar');
14140 }
14141
14142 if ($toolbarEl.length === 0) {
14143 $toolbarEl = $pageEl.parents('.views').children('.tabbar, .tabbar-labels');
14144 }
14145
14146 if ($toolbarEl.length === 0) {
14147 return;
14148 }
14149
14150 var previousScrollTop;
14151 var currentScrollTop;
14152 var scrollHeight;
14153 var offsetHeight;
14154 var reachEnd;
14155 var action;
14156 var toolbarHidden;
14157
14158 function handleScroll(e) {
14159 if ($pageEl.hasClass('page-with-card-opened')) return;
14160 if ($pageEl.hasClass('page-previous')) return;
14161 var scrollContent = this;
14162
14163 if (e && e.target && e.target !== scrollContent) {
14164 return;
14165 }
14166
14167 currentScrollTop = scrollContent.scrollTop;
14168 scrollHeight = scrollContent.scrollHeight;
14169 offsetHeight = scrollContent.offsetHeight;
14170 reachEnd = currentScrollTop + offsetHeight >= scrollHeight;
14171 toolbarHidden = $toolbarEl.hasClass('toolbar-hidden');
14172
14173 if (reachEnd) {
14174 if (app.params.toolbar.showOnPageScrollEnd) {
14175 action = 'show';
14176 }
14177 } else if (previousScrollTop > currentScrollTop) {
14178 if (app.params.toolbar.showOnPageScrollTop || currentScrollTop <= 44) {
14179 action = 'show';
14180 } else {
14181 action = 'hide';
14182 }
14183 } else if (currentScrollTop > 44) {
14184 action = 'hide';
14185 } else {
14186 action = 'show';
14187 }
14188
14189 if (action === 'show' && toolbarHidden) {
14190 app.toolbar.show($toolbarEl);
14191 toolbarHidden = false;
14192 } else if (action === 'hide' && !toolbarHidden) {
14193 app.toolbar.hide($toolbarEl);
14194 toolbarHidden = true;
14195 }
14196
14197 previousScrollTop = currentScrollTop;
14198 }
14199
14200 $pageEl.on('scroll', '.page-content', handleScroll, true);
14201 $pageEl[0].f7ScrollToolbarHandler = handleScroll;
14202 }
14203 };
14204 var Toolbar$1 = {
14205 name: 'toolbar',
14206 create: function create() {
14207 var app = this;
14208 bindMethods(app, {
14209 toolbar: Toolbar
14210 });
14211 },
14212 params: {
14213 toolbar: {
14214 hideOnPageScroll: false,
14215 showOnPageScrollEnd: true,
14216 showOnPageScrollTop: true
14217 }
14218 },
14219 on: {
14220 pageBeforeRemove: function pageBeforeRemove(page) {
14221 if (page.$el[0].f7ScrollToolbarHandler) {
14222 page.$el.off('scroll', '.page-content', page.$el[0].f7ScrollToolbarHandler, true);
14223 }
14224 },
14225 pageBeforeIn: function pageBeforeIn(page) {
14226 var app = this;
14227 var $toolbarEl = page.$el.parents('.view').children('.toolbar');
14228
14229 if ($toolbarEl.length === 0) {
14230 $toolbarEl = page.$el.parents('.views').children('.tabbar, .tabbar-labels');
14231 }
14232
14233 if ($toolbarEl.length === 0) {
14234 $toolbarEl = page.$el.find('.toolbar');
14235 }
14236
14237 if ($toolbarEl.length === 0) {
14238 return;
14239 }
14240
14241 if (page.$el.hasClass('no-toolbar')) {
14242 app.toolbar.hide($toolbarEl);
14243 } else {
14244 app.toolbar.show($toolbarEl);
14245 }
14246 },
14247 pageInit: function pageInit(page) {
14248 var app = this;
14249 page.$el.find('.tabbar, .tabbar-labels').each(function (tabbarEl) {
14250 app.toolbar.init(tabbarEl);
14251 });
14252
14253 if (app.params.toolbar.hideOnPageScroll || page.$el.find('.hide-toolbar-on-scroll').length || page.$el.hasClass('hide-toolbar-on-scroll') || page.$el.find('.hide-bars-on-scroll').length || page.$el.hasClass('hide-bars-on-scroll')) {
14254 if (page.$el.find('.keep-toolbar-on-scroll').length || page.$el.hasClass('keep-toolbar-on-scroll') || page.$el.find('.keep-bars-on-scroll').length || page.$el.hasClass('keep-bars-on-scroll')) {
14255 return;
14256 }
14257
14258 app.toolbar.initToolbarOnScroll(page.el);
14259 }
14260 },
14261 init: function init() {
14262 var app = this;
14263 app.$el.find('.tabbar, .tabbar-labels').each(function (tabbarEl) {
14264 app.toolbar.init(tabbarEl);
14265 });
14266 }
14267 },
14268 vnode: {
14269 tabbar: {
14270 insert: function insert(vnode) {
14271 var app = this;
14272 app.toolbar.init(vnode.elm);
14273 }
14274 }
14275 }
14276 };
14277
14278 var Subnavbar = {
14279 name: 'subnavbar',
14280 on: {
14281 pageInit: function pageInit(page) {
14282 if (page.$navbarEl && page.$navbarEl.length && page.$navbarEl.find('.subnavbar').length) {
14283 page.$el.addClass('page-with-subnavbar');
14284 }
14285
14286 var $innerSubnavbars = page.$el.find('.subnavbar').filter(function (subnavbarEl) {
14287 return $(subnavbarEl).parents('.page')[0] === page.$el[0];
14288 });
14289
14290 if ($innerSubnavbars.length) {
14291 page.$el.addClass('page-with-subnavbar');
14292 }
14293 }
14294 }
14295 };
14296
14297 var TouchRipple$1 = /*#__PURE__*/function () {
14298 function TouchRipple(app, $el, x, y) {
14299 var ripple = this;
14300 if (!$el) return undefined;
14301
14302 var _$el$0$getBoundingCli = $el[0].getBoundingClientRect(),
14303 left = _$el$0$getBoundingCli.left,
14304 top = _$el$0$getBoundingCli.top,
14305 width = _$el$0$getBoundingCli.width,
14306 height = _$el$0$getBoundingCli.height;
14307
14308 var center = {
14309 x: x - left,
14310 y: y - top
14311 };
14312 var diameter = Math.max(Math.pow(Math.pow(height, 2) + Math.pow(width, 2), 0.5), 48);
14313 var isInset = false;
14314 var insetElements = app.params.touch.touchRippleInsetElements || '';
14315
14316 if (insetElements && $el.is(insetElements)) {
14317 isInset = true;
14318 }
14319
14320 if (isInset) {
14321 diameter = Math.max(Math.min(width, height), 48);
14322 }
14323
14324 if (!isInset && $el.css('overflow') === 'hidden') {
14325 var distanceFromCenter = Math.pow(Math.pow(center.x - width / 2, 2) + Math.pow(center.y - height / 2, 2), 0.5);
14326 var scale = (diameter / 2 + distanceFromCenter) / (diameter / 2);
14327 ripple.rippleTransform = "translate3d(0px, 0px, 0) scale(" + scale + ")";
14328 } else {
14329 // prettier-ignore
14330 ripple.rippleTransform = "translate3d(" + (-center.x + width / 2) + "px, " + (-center.y + height / 2) + "px, 0) scale(1)";
14331 }
14332
14333 if (isInset) {
14334 $el.addClass('ripple-inset');
14335 }
14336
14337 ripple.$rippleWaveEl = $("<div class=\"ripple-wave\" style=\"width: " + diameter + "px; height: " + diameter + "px; margin-top:-" + diameter / 2 + "px; margin-left:-" + diameter / 2 + "px; left:" + center.x + "px; top:" + center.y + "px; --f7-ripple-transform: " + ripple.rippleTransform + "\"></div>");
14338 $el.prepend(ripple.$rippleWaveEl);
14339 ripple.$rippleWaveEl.animationEnd(function () {
14340 if (!ripple.$rippleWaveEl) return;
14341 if (ripple.$rippleWaveEl.hasClass('ripple-wave-out')) return;
14342 ripple.$rippleWaveEl.addClass('ripple-wave-in');
14343
14344 if (ripple.shouldBeRemoved) {
14345 ripple.out();
14346 }
14347 });
14348 return ripple;
14349 }
14350
14351 var _proto = TouchRipple.prototype;
14352
14353 _proto.destroy = function destroy() {
14354 var ripple = this;
14355
14356 if (ripple.$rippleWaveEl) {
14357 ripple.$rippleWaveEl.remove();
14358 }
14359
14360 Object.keys(ripple).forEach(function (key) {
14361 ripple[key] = null;
14362 delete ripple[key];
14363 });
14364 ripple = null;
14365 };
14366
14367 _proto.out = function out() {
14368 var ripple = this;
14369 var $rippleWaveEl = this.$rippleWaveEl;
14370 clearTimeout(ripple.removeTimeout);
14371 $rippleWaveEl.addClass('ripple-wave-out');
14372 ripple.removeTimeout = setTimeout(function () {
14373 ripple.destroy();
14374 }, 300);
14375 $rippleWaveEl.animationEnd(function () {
14376 clearTimeout(ripple.removeTimeout);
14377 ripple.destroy();
14378 });
14379 };
14380
14381 _proto.remove = function remove() {
14382 var ripple = this;
14383 if (ripple.shouldBeRemoved) return;
14384 ripple.removeTimeout = setTimeout(function () {
14385 ripple.destroy();
14386 }, 400);
14387 ripple.shouldBeRemoved = true;
14388
14389 if (ripple.$rippleWaveEl.hasClass('ripple-wave-in')) {
14390 ripple.out();
14391 }
14392 };
14393
14394 return TouchRipple;
14395 }();
14396
14397 var TouchRipple = {
14398 name: 'touch-ripple',
14399 static: {
14400 TouchRipple: TouchRipple$1
14401 },
14402 create: function create() {
14403 var app = this;
14404 app.touchRipple = {
14405 create: function create() {
14406 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
14407 args[_key] = arguments[_key];
14408 }
14409
14410 return _construct(TouchRipple$1, args);
14411 }
14412 };
14413 }
14414 };
14415
14416 var openedModals = [];
14417 var dialogsQueue = [];
14418
14419 function clearDialogsQueue() {
14420 if (dialogsQueue.length === 0) return;
14421 var dialog = dialogsQueue.shift();
14422 dialog.open();
14423 }
14424
14425 var Modal$1 = /*#__PURE__*/function (_Framework7Class) {
14426 _inheritsLoose(Modal, _Framework7Class);
14427
14428 function Modal(app, params) {
14429 var _this;
14430
14431 _this = _Framework7Class.call(this, params, [app]) || this;
14432
14433 var modal = _assertThisInitialized(_this);
14434
14435 var defaults = {}; // Extend defaults with modules params
14436
14437 modal.useModulesParams(defaults);
14438 modal.params = extend(defaults, params);
14439 modal.opened = false;
14440 var $containerEl = modal.params.containerEl ? $(modal.params.containerEl).eq(0) : app.$el;
14441 if (!$containerEl.length) $containerEl = app.$el;
14442 modal.$containerEl = $containerEl;
14443 modal.containerEl = $containerEl[0]; // Install Modules
14444
14445 modal.useModules();
14446 return _assertThisInitialized(_this) || _assertThisInitialized(_this);
14447 }
14448
14449 var _proto = Modal.prototype;
14450
14451 _proto.onOpen = function onOpen() {
14452 var modal = this;
14453 modal.opened = true;
14454 openedModals.push(modal);
14455 $('html').addClass("with-modal-" + modal.type.toLowerCase());
14456 modal.$el.trigger("modal:open " + modal.type.toLowerCase() + ":open");
14457 modal.emit("local::open modalOpen " + modal.type + "Open", modal);
14458 };
14459
14460 _proto.onOpened = function onOpened() {
14461 var modal = this;
14462 modal.$el.trigger("modal:opened " + modal.type.toLowerCase() + ":opened");
14463 modal.emit("local::opened modalOpened " + modal.type + "Opened", modal);
14464 };
14465
14466 _proto.onClose = function onClose() {
14467 var modal = this;
14468 modal.opened = false;
14469 if (!modal.type || !modal.$el) return;
14470 openedModals.splice(openedModals.indexOf(modal), 1);
14471 $('html').removeClass("with-modal-" + modal.type.toLowerCase());
14472 modal.$el.trigger("modal:close " + modal.type.toLowerCase() + ":close");
14473 modal.emit("local::close modalClose " + modal.type + "Close", modal);
14474 };
14475
14476 _proto.onClosed = function onClosed() {
14477 var modal = this;
14478 if (!modal.type || !modal.$el) return;
14479 modal.$el.removeClass('modal-out');
14480 modal.$el.hide();
14481 modal.$el.trigger("modal:closed " + modal.type.toLowerCase() + ":closed");
14482 modal.emit("local::closed modalClosed " + modal.type + "Closed", modal);
14483 };
14484
14485 _proto.open = function open(animateModal) {
14486 var modal = this;
14487 var document = getDocument();
14488 var app = modal.app;
14489 var $el = modal.$el;
14490 var $backdropEl = modal.$backdropEl;
14491 var type = modal.type;
14492 var animate = true;
14493 if (typeof animateModal !== 'undefined') animate = animateModal;else if (typeof modal.params.animate !== 'undefined') {
14494 animate = modal.params.animate;
14495 }
14496
14497 if (!$el || $el.hasClass('modal-in')) {
14498 if (animateModal === false && $el[0] && type !== 'dialog') {
14499 $el[0].style.display = 'block';
14500 }
14501
14502 return modal;
14503 }
14504
14505 if (type === 'dialog' && app.params.modal.queueDialogs) {
14506 var pushToQueue;
14507
14508 if ($('.dialog.modal-in').length > 0) {
14509 pushToQueue = true;
14510 } else if (openedModals.length > 0) {
14511 openedModals.forEach(function (openedModal) {
14512 if (openedModal.type === 'dialog') pushToQueue = true;
14513 });
14514 }
14515
14516 if (pushToQueue) {
14517 dialogsQueue.push(modal);
14518 return modal;
14519 }
14520 }
14521
14522 var $modalParentEl = $el.parent();
14523 var wasInDom = $el.parents(document).length > 0;
14524
14525 if (!$modalParentEl.is(modal.$containerEl)) {
14526 modal.$containerEl.append($el);
14527 modal.once(type + "Closed", function () {
14528 if (wasInDom) {
14529 $modalParentEl.append($el);
14530 } else {
14531 $el.remove();
14532 }
14533 });
14534 } // Show Modal
14535
14536
14537 $el.show();
14538 /* eslint no-underscore-dangle: ["error", { "allow": ["_clientLeft"] }] */
14539
14540 modal._clientLeft = $el[0].clientLeft; // Modal
14541
14542 function transitionEnd() {
14543 if ($el.hasClass('modal-out')) {
14544 modal.onClosed();
14545 } else if ($el.hasClass('modal-in')) {
14546 modal.onOpened();
14547 }
14548 }
14549
14550 if (animate) {
14551 if ($backdropEl) {
14552 $backdropEl.removeClass('not-animated');
14553 $backdropEl.addClass('backdrop-in');
14554 }
14555
14556 $el.animationEnd(function () {
14557 transitionEnd();
14558 });
14559 $el.transitionEnd(function () {
14560 transitionEnd();
14561 });
14562 $el.removeClass('modal-out not-animated').addClass('modal-in');
14563 modal.onOpen();
14564 } else {
14565 if ($backdropEl) {
14566 $backdropEl.addClass('backdrop-in not-animated');
14567 }
14568
14569 $el.removeClass('modal-out').addClass('modal-in not-animated');
14570 modal.onOpen();
14571 modal.onOpened();
14572 }
14573
14574 return modal;
14575 };
14576
14577 _proto.close = function close(animateModal) {
14578 var modal = this;
14579 var $el = modal.$el;
14580 var $backdropEl = modal.$backdropEl;
14581 var animate = true;
14582 if (typeof animateModal !== 'undefined') animate = animateModal;else if (typeof modal.params.animate !== 'undefined') {
14583 animate = modal.params.animate;
14584 }
14585
14586 if (!$el || !$el.hasClass('modal-in')) {
14587 if (dialogsQueue.indexOf(modal) >= 0) {
14588 dialogsQueue.splice(dialogsQueue.indexOf(modal), 1);
14589 }
14590
14591 return modal;
14592 } // backdrop
14593
14594
14595 if ($backdropEl) {
14596 var needToHideBackdrop = true;
14597
14598 if (modal.type === 'popup') {
14599 modal.$el.prevAll('.popup.modal-in').add(modal.$el.nextAll('.popup.modal-in')).each(function (popupEl) {
14600 var popupInstance = popupEl.f7Modal;
14601 if (!popupInstance) return;
14602
14603 if (popupInstance.params.closeByBackdropClick && popupInstance.params.backdrop && popupInstance.backdropEl === modal.backdropEl) {
14604 needToHideBackdrop = false;
14605 }
14606 });
14607 }
14608
14609 if (needToHideBackdrop) {
14610 $backdropEl[animate ? 'removeClass' : 'addClass']('not-animated');
14611 $backdropEl.removeClass('backdrop-in');
14612 }
14613 } // Modal
14614
14615
14616 $el[animate ? 'removeClass' : 'addClass']('not-animated');
14617
14618 function transitionEnd() {
14619 if ($el.hasClass('modal-out')) {
14620 modal.onClosed();
14621 } else if ($el.hasClass('modal-in')) {
14622 modal.onOpened();
14623 }
14624 }
14625
14626 if (animate) {
14627 $el.animationEnd(function () {
14628 transitionEnd();
14629 });
14630 $el.transitionEnd(function () {
14631 transitionEnd();
14632 });
14633 $el.removeClass('modal-in').addClass('modal-out'); // Emit close
14634
14635 modal.onClose();
14636 } else {
14637 $el.addClass('not-animated').removeClass('modal-in').addClass('modal-out'); // Emit close
14638
14639 modal.onClose();
14640 modal.onClosed();
14641 }
14642
14643 if (modal.type === 'dialog') {
14644 clearDialogsQueue();
14645 }
14646
14647 return modal;
14648 };
14649
14650 _proto.destroy = function destroy() {
14651 var modal = this;
14652 if (modal.destroyed) return;
14653 modal.emit("local::beforeDestroy modalBeforeDestroy " + modal.type + "BeforeDestroy", modal);
14654
14655 if (modal.$el) {
14656 modal.$el.trigger("modal:beforedestroy " + modal.type.toLowerCase() + ":beforedestroy");
14657
14658 if (modal.$el.length && modal.$el[0].f7Modal) {
14659 delete modal.$el[0].f7Modal;
14660 }
14661 }
14662
14663 deleteProps(modal);
14664 modal.destroyed = true;
14665 };
14666
14667 return Modal;
14668 }(Framework7Class);
14669
14670 var CustomModal = /*#__PURE__*/function (_Modal) {
14671 _inheritsLoose(CustomModal, _Modal);
14672
14673 function CustomModal(app, params) {
14674 var _this;
14675
14676 var extendedParams = extend({
14677 backdrop: true,
14678 closeByBackdropClick: true,
14679 on: {}
14680 }, params); // Extends with open/close Modal methods;
14681
14682 _this = _Modal.call(this, app, extendedParams) || this;
14683
14684 var customModal = _assertThisInitialized(_this);
14685
14686 customModal.params = extendedParams; // Find Element
14687
14688 var $el;
14689
14690 if (!customModal.params.el) {
14691 $el = $(customModal.params.content);
14692 } else {
14693 $el = $(customModal.params.el);
14694 }
14695
14696 if ($el && $el.length > 0 && $el[0].f7Modal) {
14697 return $el[0].f7Modal || _assertThisInitialized(_this);
14698 }
14699
14700 if ($el.length === 0) {
14701 return customModal.destroy() || _assertThisInitialized(_this);
14702 }
14703
14704 var $backdropEl;
14705
14706 if (customModal.params.backdrop) {
14707 $backdropEl = app.$el.children('.custom-modal-backdrop');
14708
14709 if ($backdropEl.length === 0) {
14710 $backdropEl = $('<div class="custom-modal-backdrop"></div>');
14711 app.$el.append($backdropEl);
14712 }
14713 }
14714
14715 function handleClick(e) {
14716 if (!customModal || customModal.destroyed) return;
14717
14718 if ($backdropEl && e.target === $backdropEl[0]) {
14719 customModal.close();
14720 }
14721 }
14722
14723 customModal.on('customModalOpened', function () {
14724 if (customModal.params.closeByBackdropClick && customModal.params.backdrop) {
14725 app.on('click', handleClick);
14726 }
14727 });
14728 customModal.on('customModalClose', function () {
14729 if (customModal.params.closeByBackdropClick && customModal.params.backdrop) {
14730 app.off('click', handleClick);
14731 }
14732 });
14733 extend(customModal, {
14734 app: app,
14735 $el: $el,
14736 el: $el[0],
14737 $backdropEl: $backdropEl,
14738 backdropEl: $backdropEl && $backdropEl[0],
14739 type: 'customModal'
14740 });
14741 $el[0].f7Modal = customModal;
14742 return customModal || _assertThisInitialized(_this);
14743 }
14744
14745 return CustomModal;
14746 }(Modal$1);
14747
14748 var Modal = {
14749 name: 'modal',
14750 static: {
14751 Modal: Modal$1,
14752 CustomModal: CustomModal
14753 },
14754 create: function create() {
14755 var app = this;
14756 app.customModal = {
14757 create: function create(params) {
14758 return new CustomModal(app, params);
14759 }
14760 };
14761 },
14762 params: {
14763 modal: {
14764 queueDialogs: true
14765 }
14766 }
14767 };
14768
14769 if (typeof window !== 'undefined') {
14770 // Dom7
14771 if (!window.Dom7) window.Dom7 = $;
14772 } // UMD_ONLY_END
14773
14774
14775 Router.use([RouterComponentLoaderModule]);
14776 Framework7.use([DeviceModule, SupportModule, UtilsModule, ResizeModule, RequestModule, TouchModule, ClicksModule, RouterModule, HistoryModule, ComponentModule, ServiceWorkerModule, StoreModule, Statusbar$1, View, Navbar$1, Toolbar$1, Subnavbar, TouchRipple, Modal]);
14777
14778 return Framework7;
14779
14780})));
14781//# sourceMappingURL=framework7.js.map