UNPKG

zmp-core

Version:

Full featured mobile HTML framework for building iOS & Android apps

1,854 lines (1,494 loc) 1.64 MB
/** * ZMP 2.8.10 * Full featured mobile HTML framework for building iOS & Android apps * https://h5.zalo.me/ * * Copyright 2014-2023 Vladimir Kharlampidi * * Released under the MIT License * * Released on: May 16, 2023 */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ZMP = factory()); }(this, (function () { 'use strict'; /** * SSR Window 3.0.0 * Better handling for window object in SSR environment * https://github.com/nolimits4web/ssr-window * * Copyright 2020, Vladimir Kharlampidi * * Licensed under MIT * * Released on: November 9, 2020 */ /* eslint-disable no-param-reassign */ function isObject$2(obj) { return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object; } function extend$2(target, src) { if (target === void 0) { target = {}; } if (src === void 0) { src = {}; } Object.keys(src).forEach(function (key) { if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject$2(src[key]) && isObject$2(target[key]) && Object.keys(src[key]).length > 0) { extend$2(target[key], src[key]); } }); } var ssrDocument = { body: {}, addEventListener: function addEventListener() {}, removeEventListener: function removeEventListener() {}, activeElement: { blur: function blur() {}, nodeName: '' }, querySelector: function querySelector() { return null; }, querySelectorAll: function querySelectorAll() { return []; }, getElementById: function getElementById() { return null; }, createEvent: function createEvent() { return { initEvent: function initEvent() {} }; }, createElement: function createElement() { return { children: [], childNodes: [], style: {}, setAttribute: function setAttribute() {}, getElementsByTagName: function getElementsByTagName() { return []; } }; }, createElementNS: function createElementNS() { return {}; }, importNode: function importNode() { return null; }, location: { hash: '', host: '', hostname: '', href: '', origin: '', pathname: '', protocol: '', search: '' } }; function getDocument() { var doc = typeof document !== 'undefined' ? document : {}; extend$2(doc, ssrDocument); return doc; } var ssrWindow = { document: ssrDocument, navigator: { userAgent: '' }, location: { hash: '', host: '', hostname: '', href: '', origin: '', pathname: '', protocol: '', search: '' }, history: { replaceState: function replaceState() {}, pushState: function pushState() {}, go: function go() {}, back: function back() {} }, CustomEvent: function CustomEvent() { return this; }, addEventListener: function addEventListener() {}, removeEventListener: function removeEventListener() {}, getComputedStyle: function getComputedStyle() { return { getPropertyValue: function getPropertyValue() { return ''; } }; }, Image: function Image() {}, Date: function Date() {}, screen: {}, setTimeout: function setTimeout() {}, clearTimeout: function clearTimeout() {}, matchMedia: function matchMedia() { return {}; }, requestAnimationFrame: function requestAnimationFrame(callback) { if (typeof setTimeout === 'undefined') { callback(); return null; } return setTimeout(callback, 0); }, cancelAnimationFrame: function cancelAnimationFrame(id) { if (typeof setTimeout === 'undefined') { return; } clearTimeout(id); } }; function getWindow() { var win = typeof window !== 'undefined' ? window : {}; extend$2(win, ssrWindow); return win; } /** * zmp-dom 1.0.0 * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API * https://h5.zalo.me/zmp/docs/zmp-dom.html * * Copyright 2021, Vladimir Kharlampidi * * Licensed under MIT * * Released on: February 19, 2021 */ function _inheritsLoose$2(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf$2(subClass, superClass); } function _getPrototypeOf$2(o) { _getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$2(o); } function _setPrototypeOf$2(o, p) { _setPrototypeOf$2 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$2(o, p); } function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _construct$2(Parent, args, Class) { if (_isNativeReflectConstruct$2()) { _construct$2 = Reflect.construct; } else { _construct$2 = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf$2(instance, Class.prototype); return instance; }; } return _construct$2.apply(null, arguments); } function _isNativeFunction$2(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } function _wrapNativeSuper$2(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper$2 = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction$2(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct$2(Class, arguments, _getPrototypeOf$2(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf$2(Wrapper, Class); }; return _wrapNativeSuper$2(Class); } function _assertThisInitialized$2(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } /* eslint-disable no-proto */ function makeReactive$1(obj) { var proto = obj.__proto__; Object.defineProperty(obj, '__proto__', { get: function get() { return proto; }, set: function set(value) { proto.__proto__ = value; } }); } var Dom7$1 = /*#__PURE__*/function (_Array) { _inheritsLoose$2(Dom7, _Array); function Dom7(items) { var _this; _this = _Array.call.apply(_Array, [this].concat(items)) || this; makeReactive$1(_assertThisInitialized$2(_this)); return _this; } return Dom7; }( /*#__PURE__*/_wrapNativeSuper$2(Array)); function arrayFlat$1(arr) { if (arr === void 0) { arr = []; } var res = []; arr.forEach(function (el) { if (Array.isArray(el)) { res.push.apply(res, arrayFlat$1(el)); } else { res.push(el); } }); return res; } function arrayFilter$1(arr, callback) { return Array.prototype.filter.call(arr, callback); } function arrayUnique$1(arr) { var uniqueArray = []; for (var i = 0; i < arr.length; i += 1) { if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]); } return uniqueArray; } function toCamelCase$2(string) { return string.toLowerCase().replace(/-(.)/g, function (match, group) { return group.toUpperCase(); }); } function qsa$1(selector, context) { if (typeof selector !== 'string') { return [selector]; } var a = []; var res = context.querySelectorAll(selector); for (var i = 0; i < res.length; i += 1) { a.push(res[i]); } return a; } function $$2(selector, context) { var window = getWindow(); var document = getDocument(); var arr = []; if (!context && selector instanceof Dom7$1) { return selector; } if (!selector) { return new Dom7$1(arr); } if (typeof selector === 'string') { var html = selector.trim(); if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) { var toCreate = 'div'; if (html.indexOf('<li') === 0) toCreate = 'ul'; if (html.indexOf('<tr') === 0) toCreate = 'tbody'; if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr'; if (html.indexOf('<tbody') === 0) toCreate = 'table'; if (html.indexOf('<option') === 0) toCreate = 'select'; var tempParent = document.createElement(toCreate); tempParent.innerHTML = html; for (var i = 0; i < tempParent.childNodes.length; i += 1) { arr.push(tempParent.childNodes[i]); } } else { arr = qsa$1(selector.trim(), context || document); } // arr = qsa(selector, document); } else if (selector.nodeType || selector === window || selector === document) { arr.push(selector); } else if (Array.isArray(selector)) { if (selector instanceof Dom7$1) return selector; arr = selector; } return new Dom7$1(arrayUnique$1(arr)); } $$2.fn = Dom7$1.prototype; function addClass$1() { for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) { classes[_key] = arguments[_key]; } var classNames = arrayFlat$1(classes.map(function (c) { return c.split(' '); })); this.forEach(function (el) { var _el$classList; (_el$classList = el.classList).add.apply(_el$classList, classNames); }); return this; } function removeClass$1() { for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { classes[_key2] = arguments[_key2]; } var classNames = arrayFlat$1(classes.map(function (c) { return c.split(' '); })); this.forEach(function (el) { var _el$classList2; (_el$classList2 = el.classList).remove.apply(_el$classList2, classNames); }); return this; } function toggleClass$1() { for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { classes[_key3] = arguments[_key3]; } var classNames = arrayFlat$1(classes.map(function (c) { return c.split(' '); })); this.forEach(function (el) { classNames.forEach(function (className) { el.classList.toggle(className); }); }); } function hasClass$1() { for (var _len4 = arguments.length, classes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { classes[_key4] = arguments[_key4]; } var classNames = arrayFlat$1(classes.map(function (c) { return c.split(' '); })); return arrayFilter$1(this, function (el) { return classNames.filter(function (className) { return el.classList.contains(className); }).length > 0; }).length > 0; } function attr$1(attrs, value) { if (arguments.length === 1 && typeof attrs === 'string') { // Get attr if (this[0]) return this[0].getAttribute(attrs); return undefined; } // Set attrs for (var i = 0; i < this.length; i += 1) { if (arguments.length === 2) { // String this[i].setAttribute(attrs, value); } else { // Object for (var attrName in attrs) { this[i][attrName] = attrs[attrName]; this[i].setAttribute(attrName, attrs[attrName]); } } } return this; } function removeAttr$1(attr) { for (var i = 0; i < this.length; i += 1) { this[i].removeAttribute(attr); } return this; } function prop$1(props, value) { if (arguments.length === 1 && typeof props === 'string') { // Get prop if (this[0]) return this[0][props]; } else { // Set props for (var i = 0; i < this.length; i += 1) { if (arguments.length === 2) { // String this[i][props] = value; } else { // Object for (var propName in props) { this[i][propName] = props[propName]; } } } return this; } return this; } function data$1(key, value) { var el; if (typeof value === 'undefined') { el = this[0]; if (!el) return undefined; // Get value if (el.zmpDOMElementDataStorage && key in el.zmpDOMElementDataStorage) { return el.zmpDOMElementDataStorage[key]; } var dataKey = el.getAttribute("data-" + key); if (dataKey) { return dataKey; } return undefined; } // Set value for (var i = 0; i < this.length; i += 1) { el = this[i]; if (!el.zmpDOMElementDataStorage) el.zmpDOMElementDataStorage = {}; el.zmpDOMElementDataStorage[key] = value; } return this; } function removeData$1(key) { for (var i = 0; i < this.length; i += 1) { var el = this[i]; if (el.zmpDOMElementDataStorage && el.zmpDOMElementDataStorage[key]) { el.zmpDOMElementDataStorage[key] = null; delete el.zmpDOMElementDataStorage[key]; } } } function dataset$1() { var el = this[0]; if (!el) return undefined; var dataset = {}; // eslint-disable-line if (el.dataset) { for (var dataKey in el.dataset) { dataset[dataKey] = el.dataset[dataKey]; } } else { for (var i = 0; i < el.attributes.length; i += 1) { var _attr = el.attributes[i]; if (_attr.name.indexOf('data-') >= 0) { dataset[toCamelCase$2(_attr.name.split('data-')[1])] = _attr.value; } } } for (var key in dataset) { 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; } return dataset; } function val$1(value) { if (typeof value === 'undefined') { // get value var el = this[0]; if (!el) return undefined; if (el.multiple && el.nodeName.toLowerCase() === 'select') { var values = []; for (var i = 0; i < el.selectedOptions.length; i += 1) { values.push(el.selectedOptions[i].value); } return values; } return el.value; } // set value for (var _i = 0; _i < this.length; _i += 1) { var _el = this[_i]; if (Array.isArray(value) && _el.multiple && _el.nodeName.toLowerCase() === 'select') { for (var j = 0; j < _el.options.length; j += 1) { _el.options[j].selected = value.indexOf(_el.options[j].value) >= 0; } } else { _el.value = value; } } return this; } function value$1(value) { return this.val(value); } function transform$1(transform) { for (var i = 0; i < this.length; i += 1) { this[i].style.transform = transform; } return this; } function transition$2(duration) { for (var i = 0; i < this.length; i += 1) { this[i].style.transitionDuration = typeof duration !== 'string' ? duration + "ms" : duration; } return this; } function on$1() { for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { args[_key5] = arguments[_key5]; } var eventType = args[0], targetSelector = args[1], listener = args[2], capture = args[3]; if (typeof args[1] === 'function') { eventType = args[0]; listener = args[1]; capture = args[2]; targetSelector = undefined; } if (!capture) capture = false; function handleLiveEvent(e) { var target = e.target; if (!target) return; var eventData = e.target.zmpDOMEventData || []; if (eventData.indexOf(e) < 0) { eventData.unshift(e); } if ($$2(target).is(targetSelector)) listener.apply(target, eventData);else { var _parents = $$2(target).parents(); // eslint-disable-line for (var k = 0; k < _parents.length; k += 1) { if ($$2(_parents[k]).is(targetSelector)) listener.apply(_parents[k], eventData); } } } function handleEvent(e) { var eventData = e && e.target ? e.target.zmpDOMEventData || [] : []; if (eventData.indexOf(e) < 0) { eventData.unshift(e); } listener.apply(this, eventData); } var events = eventType.split(' '); var j; for (var i = 0; i < this.length; i += 1) { var el = this[i]; if (!targetSelector) { for (j = 0; j < events.length; j += 1) { var event = events[j]; if (!el.zmpDOMListeners) el.zmpDOMListeners = {}; if (!el.zmpDOMListeners[event]) el.zmpDOMListeners[event] = []; el.zmpDOMListeners[event].push({ listener: listener, proxyListener: handleEvent }); el.addEventListener(event, handleEvent, capture); } } else { // Live events for (j = 0; j < events.length; j += 1) { var _event = events[j]; if (!el.zmpDOMLiveListeners) el.zmpDOMLiveListeners = {}; if (!el.zmpDOMLiveListeners[_event]) el.zmpDOMLiveListeners[_event] = []; el.zmpDOMLiveListeners[_event].push({ listener: listener, proxyListener: handleLiveEvent }); el.addEventListener(_event, handleLiveEvent, capture); } } } return this; } function off$1() { for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { args[_key6] = arguments[_key6]; } var eventType = args[0], targetSelector = args[1], listener = args[2], capture = args[3]; if (typeof args[1] === 'function') { eventType = args[0]; listener = args[1]; capture = args[2]; targetSelector = undefined; } if (!capture) capture = false; var events = eventType.split(' '); for (var i = 0; i < events.length; i += 1) { var event = events[i]; for (var j = 0; j < this.length; j += 1) { var el = this[j]; var handlers = void 0; if (!targetSelector && el.zmpDOMListeners) { handlers = el.zmpDOMListeners[event]; } else if (targetSelector && el.zmpDOMLiveListeners) { handlers = el.zmpDOMLiveListeners[event]; } if (handlers && handlers.length) { for (var k = handlers.length - 1; k >= 0; k -= 1) { var handler = handlers[k]; if (listener && handler.listener === listener) { el.removeEventListener(event, handler.proxyListener, capture); handlers.splice(k, 1); } else if (listener && handler.listener && handler.listener.zmpDOMproxy && handler.listener.zmpDOMproxy === listener) { el.removeEventListener(event, handler.proxyListener, capture); handlers.splice(k, 1); } else if (!listener) { el.removeEventListener(event, handler.proxyListener, capture); handlers.splice(k, 1); } } } } } return this; } function once$1() { var dom = this; for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { args[_key7] = arguments[_key7]; } var eventName = args[0], targetSelector = args[1], listener = args[2], capture = args[3]; if (typeof args[1] === 'function') { eventName = args[0]; listener = args[1]; capture = args[2]; targetSelector = undefined; } function onceHandler() { for (var _len8 = arguments.length, eventArgs = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { eventArgs[_key8] = arguments[_key8]; } listener.apply(this, eventArgs); dom.off(eventName, targetSelector, onceHandler, capture); if (onceHandler.zmpDOMproxy) { delete onceHandler.zmpDOMproxy; } } onceHandler.zmpDOMproxy = listener; return dom.on(eventName, targetSelector, onceHandler, capture); } function trigger$1() { var window = getWindow(); for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { args[_key9] = arguments[_key9]; } var events = args[0].split(' '); var eventData = args[1]; for (var i = 0; i < events.length; i += 1) { var event = events[i]; for (var j = 0; j < this.length; j += 1) { var el = this[j]; if (window.CustomEvent) { var evt = new window.CustomEvent(event, { detail: eventData, bubbles: true, cancelable: true }); el.zmpDOMEventData = args.filter(function (data, dataIndex) { return dataIndex > 0; }); el.dispatchEvent(evt); el.zmpDOMEventData = []; delete el.zmpDOMEventData; } } } return this; } function transitionEnd$2(callback) { var dom = this; function fireCallBack(e) { if (e.target !== this) return; callback.call(this, e); dom.off('transitionend', fireCallBack); } if (callback) { dom.on('transitionend', fireCallBack); } return this; } function animationEnd$1(callback) { var dom = this; function fireCallBack(e) { if (e.target !== this) return; callback.call(this, e); dom.off('animationend', fireCallBack); } if (callback) { dom.on('animationend', fireCallBack); } return this; } function width$1() { var window = getWindow(); if (this[0] === window) { return window.innerWidth; } if (this.length > 0) { return parseFloat(this.css('width')); } return null; } function outerWidth$1(includeMargins) { if (this.length > 0) { if (includeMargins) { var _styles = this.styles(); return this[0].offsetWidth + parseFloat(_styles.getPropertyValue('margin-right')) + parseFloat(_styles.getPropertyValue('margin-left')); } return this[0].offsetWidth; } return null; } function height$1() { var window = getWindow(); if (this[0] === window) { return window.innerHeight; } if (this.length > 0) { return parseFloat(this.css('height')); } return null; } function outerHeight$1(includeMargins) { if (this.length > 0) { if (includeMargins) { var _styles2 = this.styles(); return this[0].offsetHeight + parseFloat(_styles2.getPropertyValue('margin-top')) + parseFloat(_styles2.getPropertyValue('margin-bottom')); } return this[0].offsetHeight; } return null; } function offset$1() { if (this.length > 0) { var window = getWindow(); var document = getDocument(); var el = this[0]; var box = el.getBoundingClientRect(); var body = document.body; var clientTop = el.clientTop || body.clientTop || 0; var clientLeft = el.clientLeft || body.clientLeft || 0; var scrollTop = el === window ? window.scrollY : el.scrollTop; var scrollLeft = el === window ? window.scrollX : el.scrollLeft; return { top: box.top + scrollTop - clientTop, left: box.left + scrollLeft - clientLeft }; } return null; } function hide$1() { for (var i = 0; i < this.length; i += 1) { this[i].style.display = 'none'; } return this; } function show$1() { var window = getWindow(); for (var i = 0; i < this.length; i += 1) { var el = this[i]; if (el.style.display === 'none') { el.style.display = ''; } if (window.getComputedStyle(el, null).getPropertyValue('display') === 'none') { // Still not visible el.style.display = 'block'; } } return this; } function styles$1() { var window = getWindow(); if (this[0]) return window.getComputedStyle(this[0], null); return {}; } function css$1(props, value) { var window = getWindow(); var i; if (arguments.length === 1) { if (typeof props === 'string') { // .css('width') if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props); } else { // .css({ width: '100px' }) for (i = 0; i < this.length; i += 1) { for (var _prop in props) { this[i].style[_prop] = props[_prop]; } } return this; } } if (arguments.length === 2 && typeof props === 'string') { // .css('width', '100px') for (i = 0; i < this.length; i += 1) { this[i].style[props] = value; } return this; } return this; } function each$1(callback) { if (!callback) return this; this.forEach(function (el, index) { callback.apply(el, [el, index]); }); return this; } function filter$1(callback) { var result = arrayFilter$1(this, callback); return $$2(result); } function html$1(html) { if (typeof html === 'undefined') { return this[0] ? this[0].innerHTML : null; } for (var i = 0; i < this.length; i += 1) { this[i].innerHTML = html; } return this; } function text$1(text) { if (typeof text === 'undefined') { return this[0] ? this[0].textContent.trim() : null; } for (var i = 0; i < this.length; i += 1) { this[i].textContent = text; } return this; } function is$1(selector) { var window = getWindow(); var document = getDocument(); var el = this[0]; var compareWith; var i; if (!el || typeof selector === 'undefined') return false; if (typeof selector === 'string') { if (el.matches) return el.matches(selector); if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector); if (el.msMatchesSelector) return el.msMatchesSelector(selector); compareWith = $$2(selector); for (i = 0; i < compareWith.length; i += 1) { if (compareWith[i] === el) return true; } return false; } if (selector === document) { return el === document; } if (selector === window) { return el === window; } if (selector.nodeType || selector instanceof Dom7$1) { compareWith = selector.nodeType ? [selector] : selector; for (i = 0; i < compareWith.length; i += 1) { if (compareWith[i] === el) return true; } return false; } return false; } function index$1() { var child = this[0]; var i; if (child) { i = 0; // eslint-disable-next-line while ((child = child.previousSibling) !== null) { if (child.nodeType === 1) i += 1; } return i; } return undefined; } function eq$1(index) { if (typeof index === 'undefined') return this; var length = this.length; if (index > length - 1) { return $$2([]); } if (index < 0) { var returnIndex = length + index; if (returnIndex < 0) return $$2([]); return $$2([this[returnIndex]]); } return $$2([this[index]]); } function append$1() { var newChild; var document = getDocument(); for (var k = 0; k < arguments.length; k += 1) { newChild = k < 0 || arguments.length <= k ? undefined : arguments[k]; for (var i = 0; i < this.length; i += 1) { if (typeof newChild === 'string') { var tempDiv = document.createElement('div'); tempDiv.innerHTML = newChild; while (tempDiv.firstChild) { this[i].appendChild(tempDiv.firstChild); } } else if (newChild instanceof Dom7$1) { for (var j = 0; j < newChild.length; j += 1) { this[i].appendChild(newChild[j]); } } else { this[i].appendChild(newChild); } } } return this; } function appendTo$1(parent) { $$2(parent).append(this); return this; } function prepend$1(newChild) { var document = getDocument(); var i; var j; for (i = 0; i < this.length; i += 1) { if (typeof newChild === 'string') { var tempDiv = document.createElement('div'); tempDiv.innerHTML = newChild; for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) { this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]); } } else if (newChild instanceof Dom7$1) { for (j = 0; j < newChild.length; j += 1) { this[i].insertBefore(newChild[j], this[i].childNodes[0]); } } else { this[i].insertBefore(newChild, this[i].childNodes[0]); } } return this; } function prependTo$1(parent) { $$2(parent).prepend(this); return this; } function insertBefore$2(selector) { var before = $$2(selector); for (var i = 0; i < this.length; i += 1) { if (before.length === 1) { before[0].parentNode.insertBefore(this[i], before[0]); } else if (before.length > 1) { for (var j = 0; j < before.length; j += 1) { before[j].parentNode.insertBefore(this[i].cloneNode(true), before[j]); } } } } function insertAfter$1(selector) { var after = $$2(selector); for (var i = 0; i < this.length; i += 1) { if (after.length === 1) { after[0].parentNode.insertBefore(this[i], after[0].nextSibling); } else if (after.length > 1) { for (var j = 0; j < after.length; j += 1) { after[j].parentNode.insertBefore(this[i].cloneNode(true), after[j].nextSibling); } } } } function next$1(selector) { if (this.length > 0) { if (selector) { if (this[0].nextElementSibling && $$2(this[0].nextElementSibling).is(selector)) { return $$2([this[0].nextElementSibling]); } return $$2([]); } if (this[0].nextElementSibling) return $$2([this[0].nextElementSibling]); return $$2([]); } return $$2([]); } function nextAll$1(selector) { var nextEls = []; var el = this[0]; if (!el) return $$2([]); while (el.nextElementSibling) { var _next = el.nextElementSibling; // eslint-disable-line if (selector) { if ($$2(_next).is(selector)) nextEls.push(_next); } else nextEls.push(_next); el = _next; } return $$2(nextEls); } function prev$1(selector) { if (this.length > 0) { var el = this[0]; if (selector) { if (el.previousElementSibling && $$2(el.previousElementSibling).is(selector)) { return $$2([el.previousElementSibling]); } return $$2([]); } if (el.previousElementSibling) return $$2([el.previousElementSibling]); return $$2([]); } return $$2([]); } function prevAll$1(selector) { var prevEls = []; var el = this[0]; if (!el) return $$2([]); while (el.previousElementSibling) { var _prev = el.previousElementSibling; // eslint-disable-line if (selector) { if ($$2(_prev).is(selector)) prevEls.push(_prev); } else prevEls.push(_prev); el = _prev; } return $$2(prevEls); } function siblings$1(selector) { return this.nextAll(selector).add(this.prevAll(selector)); } function parent$1(selector) { var parents = []; // eslint-disable-line for (var i = 0; i < this.length; i += 1) { if (this[i].parentNode !== null) { if (selector) { if ($$2(this[i].parentNode).is(selector)) parents.push(this[i].parentNode); } else { parents.push(this[i].parentNode); } } } return $$2(parents); } function parents$1(selector) { var parents = []; // eslint-disable-line for (var i = 0; i < this.length; i += 1) { var _parent = this[i].parentNode; // eslint-disable-line while (_parent) { if (selector) { if ($$2(_parent).is(selector)) parents.push(_parent); } else { parents.push(_parent); } _parent = _parent.parentNode; } } return $$2(parents); } function closest$1(selector) { var closest = this; // eslint-disable-line if (typeof selector === 'undefined') { return $$2([]); } if (!closest.is(selector)) { closest = closest.parents(selector).eq(0); } return closest; } function find$1(selector) { var foundElements = []; for (var i = 0; i < this.length; i += 1) { var found = this[i].querySelectorAll(selector); for (var j = 0; j < found.length; j += 1) { foundElements.push(found[j]); } } return $$2(foundElements); } function children$1(selector) { var children = []; // eslint-disable-line for (var i = 0; i < this.length; i += 1) { var childNodes = this[i].children; for (var j = 0; j < childNodes.length; j += 1) { if (!selector || $$2(childNodes[j]).is(selector)) { children.push(childNodes[j]); } } } return $$2(children); } function remove$1() { for (var i = 0; i < this.length; i += 1) { if (this[i].parentNode) this[i].parentNode.removeChild(this[i]); } return this; } function detach$1() { return this.remove(); } function add$1() { var dom = this; var i; var j; for (var _len10 = arguments.length, els = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { els[_key10] = arguments[_key10]; } for (i = 0; i < els.length; i += 1) { var toAdd = $$2(els[i]); for (j = 0; j < toAdd.length; j += 1) { dom.push(toAdd[j]); } } return dom; } function empty$1() { for (var i = 0; i < this.length; i += 1) { var el = this[i]; if (el.nodeType === 1) { for (var j = 0; j < el.childNodes.length; j += 1) { if (el.childNodes[j].parentNode) { el.childNodes[j].parentNode.removeChild(el.childNodes[j]); } } el.textContent = ''; } } return this; } function scrollTo$1() { var window = getWindow(); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var left = args[0], top = args[1], duration = args[2], easing = args[3], callback = args[4]; if (args.length === 4 && typeof easing === 'function') { callback = easing; left = args[0]; top = args[1]; duration = args[2]; callback = args[3]; easing = args[4]; } if (typeof easing === 'undefined') easing = 'swing'; return this.each(function animate() { var el = this; var currentTop; var currentLeft; var maxTop; var maxLeft; var newTop; var newLeft; var scrollTop; // eslint-disable-line var scrollLeft; // eslint-disable-line var animateTop = top > 0 || top === 0; var animateLeft = left > 0 || left === 0; if (typeof easing === 'undefined') { easing = 'swing'; } if (animateTop) { currentTop = el.scrollTop; if (!duration) { el.scrollTop = top; } } if (animateLeft) { currentLeft = el.scrollLeft; if (!duration) { el.scrollLeft = left; } } if (!duration) return; if (animateTop) { maxTop = el.scrollHeight - el.offsetHeight; newTop = Math.max(Math.min(top, maxTop), 0); } if (animateLeft) { maxLeft = el.scrollWidth - el.offsetWidth; newLeft = Math.max(Math.min(left, maxLeft), 0); } var startTime = null; if (animateTop && newTop === currentTop) animateTop = false; if (animateLeft && newLeft === currentLeft) animateLeft = false; function render(time) { if (time === void 0) { time = new Date().getTime(); } if (startTime === null) { startTime = time; } var progress = Math.max(Math.min((time - startTime) / duration, 1), 0); var easeProgress = easing === 'linear' ? progress : 0.5 - Math.cos(progress * Math.PI) / 2; var done; if (animateTop) scrollTop = currentTop + easeProgress * (newTop - currentTop); if (animateLeft) scrollLeft = currentLeft + easeProgress * (newLeft - currentLeft); if (animateTop && newTop > currentTop && scrollTop >= newTop) { el.scrollTop = newTop; done = true; } if (animateTop && newTop < currentTop && scrollTop <= newTop) { el.scrollTop = newTop; done = true; } if (animateLeft && newLeft > currentLeft && scrollLeft >= newLeft) { el.scrollLeft = newLeft; done = true; } if (animateLeft && newLeft < currentLeft && scrollLeft <= newLeft) { el.scrollLeft = newLeft; done = true; } if (done) { if (callback) callback(); return; } if (animateTop) el.scrollTop = scrollTop; if (animateLeft) el.scrollLeft = scrollLeft; window.requestAnimationFrame(render); } window.requestAnimationFrame(render); }); } // scrollTop(top, duration, easing, callback) { function scrollTop$1() { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } var top = args[0], duration = args[1], easing = args[2], callback = args[3]; if (args.length === 3 && typeof easing === 'function') { top = args[0]; duration = args[1]; callback = args[2]; easing = args[3]; } var dom = this; if (typeof top === 'undefined') { if (dom.length > 0) return dom[0].scrollTop; return null; } return dom.scrollTo(undefined, top, duration, easing, callback); } function scrollLeft$1() { for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { args[_key3] = arguments[_key3]; } var left = args[0], duration = args[1], easing = args[2], callback = args[3]; if (args.length === 3 && typeof easing === 'function') { left = args[0]; duration = args[1]; callback = args[2]; easing = args[3]; } var dom = this; if (typeof left === 'undefined') { if (dom.length > 0) return dom[0].scrollLeft; return null; } return dom.scrollTo(left, undefined, duration, easing, callback); } function animate$1(initialProps, initialParams) { var window = getWindow(); var els = this; var a = { props: Object.assign({}, initialProps), params: Object.assign({ duration: 300, easing: 'swing' // or 'linear' /* Callbacks begin(elements) complete(elements) progress(elements, complete, remaining, start, tweenValue) */ }, initialParams), elements: els, animating: false, que: [], easingProgress: function easingProgress(easing, progress) { if (easing === 'swing') { return 0.5 - Math.cos(progress * Math.PI) / 2; } if (typeof easing === 'function') { return easing(progress); } return progress; }, stop: function stop() { if (a.frameId) { window.cancelAnimationFrame(a.frameId); } a.animating = false; a.elements.each(function (el) { var element = el; delete element.zmpDOMAnimateInstance; }); a.que = []; }, done: function done(complete) { a.animating = false; a.elements.each(function (el) { var element = el; delete element.zmpDOMAnimateInstance; }); if (complete) complete(els); if (a.que.length > 0) { var que = a.que.shift(); a.animate(que[0], que[1]); } }, animate: function animate(props, params) { if (a.animating) { a.que.push([props, params]); return a; } var elements = []; // Define & Cache Initials & Units a.elements.each(function (el, index) { var initialFullValue; var initialValue; var unit; var finalValue; var finalFullValue; if (!el.zmpDOMAnimateInstance) a.elements[index].zmpDOMAnimateInstance = a; elements[index] = { container: el }; Object.keys(props).forEach(function (prop) { initialFullValue = window.getComputedStyle(el, null).getPropertyValue(prop).replace(',', '.'); initialValue = parseFloat(initialFullValue); unit = initialFullValue.replace(initialValue, ''); finalValue = parseFloat(props[prop]); finalFullValue = props[prop] + unit; elements[index][prop] = { initialFullValue: initialFullValue, initialValue: initialValue, unit: unit, finalValue: finalValue, finalFullValue: finalFullValue, currentValue: initialValue }; }); }); var startTime = null; var time; var elementsDone = 0; var propsDone = 0; var done; var began = false; a.animating = true; function render() { time = new Date().getTime(); var progress; var easeProgress; // let el; if (!began) { began = true; if (params.begin) params.begin(els); } if (startTime === null) { startTime = time; } if (params.progress) { // eslint-disable-next-line params.progress(els, Math.max(Math.min((time - startTime) / params.duration, 1), 0), startTime + params.duration - time < 0 ? 0 : startTime + params.duration - time, startTime); } elements.forEach(function (element) { var el = element; if (done || el.done) return; Object.keys(props).forEach(function (prop) { if (done || el.done) return; progress = Math.max(Math.min((time - startTime) / params.duration, 1), 0); easeProgress = a.easingProgress(params.easing, progress); var _el$prop = el[prop], initialValue = _el$prop.initialValue, finalValue = _el$prop.finalValue, unit = _el$prop.unit; el[prop].currentValue = initialValue + easeProgress * (finalValue - initialValue); var currentValue = el[prop].currentValue; if (finalValue > initialValue && currentValue >= finalValue || finalValue < initialValue && currentValue <= finalValue) { el.container.style[prop] = finalValue + unit; propsDone += 1; if (propsDone === Object.keys(props).length) { el.done = true; elementsDone += 1; } if (elementsDone === elements.length) { done = true; } } if (done) { a.done(params.complete); return; } el.container.style[prop] = currentValue + unit; }); }); if (done) return; // Then call a.frameId = window.requestAnimationFrame(render); } a.frameId = window.requestAnimationFrame(render); return a; } }; if (a.elements.length === 0) { return els; } var animateInstance; for (var i = 0; i < a.elements.length; i += 1) { if (a.elements[i].zmpDOMAnimateInstance) { animateInstance = a.elements[i].zmpDOMAnimateInstance; } else a.elements[i].zmpDOMAnimateInstance = a; } if (!animateInstance) { animateInstance = a; } if (initialProps === 'stop') { animateInstance.stop(); } else { animateInstance.animate(a.props, a.params); } return els; } function stop$1() { var els = this; for (var i = 0; i < els.length; i += 1) { if (els[i].zmpDOMAnimateInstance) { els[i].zmpDOMAnimateInstance.stop(); } } } var noTrigger$1 = 'resize scroll'.split(' '); function shortcut$1(name) { function eventHandler() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (typeof args[0] === 'undefined') { for (var i = 0; i < this.length; i += 1) { if (noTrigger$1.indexOf(name) < 0) { if (name in this[i]) this[i][name]();else { $$2(this[i]).trigger(name); } } } return this; } return this.on.apply(this, [name].concat(args)); } return eventHandler; } var click$1 = shortcut$1('click'); var blur$1 = shortcut$1('blur'); var focus$1 = shortcut$1('focus'); var focusin$1 = shortcut$1('focusin'); var focusout$1 = shortcut$1('focusout'); var keyup$1 = shortcut$1('keyup'); var keydown$1 = shortcut$1('keydown'); var keypress$1 = shortcut$1('keypress'); var submit$1 = shortcut$1('submit'); var change$1 = shortcut$1('change'); var mousedown$1 = shortcut$1('mousedown'); var mousemove$1