diff --git a/assets/js/awesomplete.js b/assets/js/awesomplete.js deleted file mode 100644 index 493f9dc..0000000 --- a/assets/js/awesomplete.js +++ /dev/null @@ -1,563 +0,0 @@ -(function () { - 'use strict'; - - function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; - } - - var awesomplete = createCommonjsModule(function (module) { - /** - * Simple, lightweight, usable local autocomplete library for modern browsers - * Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P - * @author Lea Verou http://leaverou.github.io/awesomplete - * MIT license - */ - - (function () { - - var _ = function (input, o) { - var me = this; - - // Keep track of number of instances for unique IDs - _.count = (_.count || 0) + 1; - this.count = _.count; - - // Setup - - this.isOpened = false; - - this.input = $(input); - this.input.setAttribute("autocomplete", "off"); - this.input.setAttribute("aria-expanded", "false"); - this.input.setAttribute("aria-owns", "awesomplete_list_" + this.count); - this.input.setAttribute("role", "combobox"); - - // store constructor options in case we need to distinguish - // between default and customized behavior later on - this.options = o = o || {}; - - configure(this, { - minChars: 2, - maxItems: 10, - autoFirst: false, - data: _.DATA, - filter: _.FILTER_CONTAINS, - sort: o.sort === false ? false : _.SORT_BYLENGTH, - container: _.CONTAINER, - item: _.ITEM, - replace: _.REPLACE, - tabSelect: false - }, o); - - this.index = -1; - - // Create necessary elements - - this.container = this.container(input); - - this.ul = $.create("ul", { - hidden: "hidden", - role: "listbox", - id: "awesomplete_list_" + this.count, - inside: this.container - }); - - this.status = $.create("span", { - className: "visually-hidden", - role: "status", - "aria-live": "assertive", - "aria-atomic": true, - inside: this.container, - textContent: this.minChars != 0 ? ("Type " + this.minChars + " or more characters for results.") : "Begin typing for results." - }); - - // Bind events - - this._events = { - input: { - "input": this.evaluate.bind(this), - "blur": this.close.bind(this, { reason: "blur" }), - "keydown": function(evt) { - var c = evt.keyCode; - - // If the dropdown `ul` is in view, then act on keydown for the following keys: - // Enter / Esc / Up / Down - if(me.opened) { - if (c === 13 && me.selected) { // Enter - evt.preventDefault(); - me.select(undefined, undefined, evt); - } - else if (c === 9 && me.selected && me.tabSelect) { - me.select(undefined, undefined, evt); - } - else if (c === 27) { // Esc - me.close({ reason: "esc" }); - } - else if (c === 38 || c === 40) { // Down/Up arrow - evt.preventDefault(); - me[c === 38? "previous" : "next"](); - } - } - } - }, - form: { - "submit": this.close.bind(this, { reason: "submit" }) - }, - ul: { - // Prevent the default mousedowm, which ensures the input is not blurred. - // The actual selection will happen on click. This also ensures dragging the - // cursor away from the list item will cancel the selection - "mousedown": function(evt) { - evt.preventDefault(); - }, - // The click event is fired even if the corresponding mousedown event has called preventDefault - "click": function(evt) { - var li = evt.target; - - if (li !== this) { - - while (li && !/li/i.test(li.nodeName)) { - li = li.parentNode; - } - - if (li && evt.button === 0) { // Only select on left click - evt.preventDefault(); - me.select(li, evt.target, evt); - } - } - } - } - }; - - $.bind(this.input, this._events.input); - $.bind(this.input.form, this._events.form); - $.bind(this.ul, this._events.ul); - - if (this.input.hasAttribute("list")) { - this.list = "#" + this.input.getAttribute("list"); - this.input.removeAttribute("list"); - } - else { - this.list = this.input.getAttribute("data-list") || o.list || []; - } - - _.all.push(this); - }; - - _.prototype = { - set list(list) { - if (Array.isArray(list)) { - this._list = list; - } - else if (typeof list === "string" && list.indexOf(",") > -1) { - this._list = list.split(/\s*,\s*/); - } - else { // Element or CSS selector - list = $(list); - - if (list && list.children) { - var items = []; - slice.apply(list.children).forEach(function (el) { - if (!el.disabled) { - var text = el.textContent.trim(); - var value = el.value || text; - var label = el.label || text; - if (value !== "") { - items.push({ label: label, value: value }); - } - } - }); - this._list = items; - } - } - - if (document.activeElement === this.input) { - this.evaluate(); - } - }, - - get selected() { - return this.index > -1; - }, - - get opened() { - return this.isOpened; - }, - - close: function (o) { - if (!this.opened) { - return; - } - - this.input.setAttribute("aria-expanded", "false"); - this.ul.setAttribute("hidden", ""); - this.isOpened = false; - this.index = -1; - - this.status.setAttribute("hidden", ""); - - $.fire(this.input, "awesomplete-close", o || {}); - }, - - open: function () { - this.input.setAttribute("aria-expanded", "true"); - this.ul.removeAttribute("hidden"); - this.isOpened = true; - - this.status.removeAttribute("hidden"); - - if (this.autoFirst && this.index === -1) { - this.goto(0); - } - - $.fire(this.input, "awesomplete-open"); - }, - - destroy: function() { - //remove events from the input and its form - $.unbind(this.input, this._events.input); - $.unbind(this.input.form, this._events.form); - - // cleanup container if it was created by Awesomplete but leave it alone otherwise - if (!this.options.container) { - //move the input out of the awesomplete container and remove the container and its children - var parentNode = this.container.parentNode; - - parentNode.insertBefore(this.input, this.container); - parentNode.removeChild(this.container); - } - - //remove autocomplete and aria-autocomplete attributes - this.input.removeAttribute("autocomplete"); - this.input.removeAttribute("aria-autocomplete"); - - //remove this awesomeplete instance from the global array of instances - var indexOfAwesomplete = _.all.indexOf(this); - - if (indexOfAwesomplete !== -1) { - _.all.splice(indexOfAwesomplete, 1); - } - }, - - next: function () { - var count = this.ul.children.length; - this.goto(this.index < count - 1 ? this.index + 1 : (count ? 0 : -1) ); - }, - - previous: function () { - var count = this.ul.children.length; - var pos = this.index - 1; - - this.goto(this.selected && pos !== -1 ? pos : count - 1); - }, - - // Should not be used, highlights specific item without any checks! - goto: function (i) { - var lis = this.ul.children; - - if (this.selected) { - lis[this.index].setAttribute("aria-selected", "false"); - } - - this.index = i; - - if (i > -1 && lis.length > 0) { - lis[i].setAttribute("aria-selected", "true"); - - this.status.textContent = lis[i].textContent + ", list item " + (i + 1) + " of " + lis.length; - - this.input.setAttribute("aria-activedescendant", this.ul.id + "_item_" + this.index); - - // scroll to highlighted element in case parent's height is fixed - this.ul.scrollTop = lis[i].offsetTop - this.ul.clientHeight + lis[i].clientHeight; - - $.fire(this.input, "awesomplete-highlight", { - text: this.suggestions[this.index] - }); - } - }, - - select: function (selected, origin, originalEvent) { - if (selected) { - this.index = $.siblingIndex(selected); - } else { - selected = this.ul.children[this.index]; - } - - if (selected) { - var suggestion = this.suggestions[this.index]; - - var allowed = $.fire(this.input, "awesomplete-select", { - text: suggestion, - origin: origin || selected, - originalEvent: originalEvent - }); - - if (allowed) { - this.replace(suggestion); - this.close({ reason: "select" }); - $.fire(this.input, "awesomplete-selectcomplete", { - text: suggestion, - originalEvent: originalEvent - }); - } - } - }, - - evaluate: function() { - var me = this; - var value = this.input.value; - - if (value.length >= this.minChars && this._list && this._list.length > 0) { - this.index = -1; - // Populate list with options that match - this.ul.innerHTML = ""; - - this.suggestions = this._list - .map(function(item) { - return new Suggestion(me.data(item, value)); - }) - .filter(function(item) { - return me.filter(item, value); - }); - - if (this.sort !== false) { - this.suggestions = this.suggestions.sort(this.sort); - } - - this.suggestions = this.suggestions.slice(0, this.maxItems); - - this.suggestions.forEach(function(text, index) { - me.ul.appendChild(me.item(text, value, index)); - }); - - if (this.ul.children.length === 0) { - - this.status.textContent = "No results found"; - - this.close({ reason: "nomatches" }); - - } else { - this.open(); - - this.status.textContent = this.ul.children.length + " results found"; - } - } - else { - this.close({ reason: "nomatches" }); - - this.status.textContent = "No results found"; - } - } - }; - - // Static methods/properties - - _.all = []; - - _.FILTER_CONTAINS = function (text, input) { - return RegExp($.regExpEscape(input.trim()), "i").test(text); - }; - - _.FILTER_STARTSWITH = function (text, input) { - return RegExp("^" + $.regExpEscape(input.trim()), "i").test(text); - }; - - _.SORT_BYLENGTH = function (a, b) { - if (a.length !== b.length) { - return a.length - b.length; - } - - return a < b? -1 : 1; - }; - - _.CONTAINER = function (input) { - return $.create("div", { - className: "awesomplete", - around: input - }); - }; - - _.ITEM = function (text, input, item_id) { - var html = input.trim() === "" ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "$&"); - return $.create("li", { - innerHTML: html, - "role": "option", - "aria-selected": "false", - "id": "awesomplete_list_" + this.count + "_item_" + item_id - }); - }; - - _.REPLACE = function (text) { - this.input.value = text.value; - }; - - _.DATA = function (item/*, input*/) { return item; }; - - // Private functions - - function Suggestion(data) { - var o = Array.isArray(data) - ? { label: data[0], value: data[1] } - : typeof data === "object" && "label" in data && "value" in data ? data : { label: data, value: data }; - - this.label = o.label || o.value; - this.value = o.value; - } - Object.defineProperty(Suggestion.prototype = Object.create(String.prototype), "length", { - get: function() { return this.label.length; } - }); - Suggestion.prototype.toString = Suggestion.prototype.valueOf = function () { - return "" + this.label; - }; - - function configure(instance, properties, o) { - for (var i in properties) { - var initial = properties[i], - attrValue = instance.input.getAttribute("data-" + i.toLowerCase()); - - if (typeof initial === "number") { - instance[i] = parseInt(attrValue); - } - else if (initial === false) { // Boolean options must be false by default anyway - instance[i] = attrValue !== null; - } - else if (initial instanceof Function) { - instance[i] = null; - } - else { - instance[i] = attrValue; - } - - if (!instance[i] && instance[i] !== 0) { - instance[i] = (i in o)? o[i] : initial; - } - } - } - - // Helpers - - var slice = Array.prototype.slice; - - function $(expr, con) { - return typeof expr === "string"? (con || document).querySelector(expr) : expr || null; - } - - function $$(expr, con) { - return slice.call((con || document).querySelectorAll(expr)); - } - - $.create = function(tag, o) { - var element = document.createElement(tag); - - for (var i in o) { - var val = o[i]; - - if (i === "inside") { - $(val).appendChild(element); - } - else if (i === "around") { - var ref = $(val); - ref.parentNode.insertBefore(element, ref); - element.appendChild(ref); - - if (ref.getAttribute("autofocus") != null) { - ref.focus(); - } - } - else if (i in element) { - element[i] = val; - } - else { - element.setAttribute(i, val); - } - } - - return element; - }; - - $.bind = function(element, o) { - if (element) { - for (var event in o) { - var callback = o[event]; - - event.split(/\s+/).forEach(function (event) { - element.addEventListener(event, callback); - }); - } - } - }; - - $.unbind = function(element, o) { - if (element) { - for (var event in o) { - var callback = o[event]; - - event.split(/\s+/).forEach(function(event) { - element.removeEventListener(event, callback); - }); - } - } - }; - - $.fire = function(target, type, properties) { - var evt = document.createEvent("HTMLEvents"); - - evt.initEvent(type, true, true ); - - for (var j in properties) { - evt[j] = properties[j]; - } - - return target.dispatchEvent(evt); - }; - - $.regExpEscape = function (s) { - return s.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"); - }; - - $.siblingIndex = function (el) { - /* eslint-disable no-cond-assign */ - for (var i = 0; el = el.previousElementSibling; i++); - return i; - }; - - // Initialization - - function init() { - $$("input.awesomplete").forEach(function (input) { - new _(input); - }); - } - - // Make sure to export Awesomplete on self when in a browser - if (typeof self !== "undefined") { - self.Awesomplete = _; - } - - // Are we in a browser? Check for Document constructor - if (typeof Document !== "undefined") { - // DOM already loaded? - if (document.readyState !== "loading") { - init(); - } - else { - // Wait for it - document.addEventListener("DOMContentLoaded", init); - } - } - - _.$ = $; - _.$$ = $$; - - // Expose Awesomplete as a CJS module - if ( module.exports) { - module.exports = _; - } - - return _; - - }()); - }); - -}()); diff --git a/assets/js/custom.js b/assets/js/custom.js deleted file mode 100644 index c7f3750..0000000 --- a/assets/js/custom.js +++ /dev/null @@ -1,49 +0,0 @@ -(function () { - 'use strict'; - - // Custom scripts - document.addEventListener("DOMContentLoaded", function() { - - // Live Awesomplete Search - var inputHero = document.getElementById("search-hero"); - var inputNavbar = document.getElementById("search-navbar"); - - var list = [ - { label: "How do I enable payment gateway?", value: "doc.html" }, - { label: "What happens if I clear cache?", value: "doc.html" }, - { label: "Which payment methods do you offer?", value: "doc.html" }, - { label: "How long does it take to propagate DNS settings?", value: "doc.html" }, - { label: "How can I force SSL certificate?", value: "doc.html" } - ]; - - if (inputHero) { - inputHero.addEventListener("awesomplete-selectcomplete", function(e) { - window.location.href = e.text.value; - }, false); - - new Awesomplete(inputHero, { - autoFirst: true, - list: list, - replace: function(suggestion) { - this.input.value = suggestion.label; - } - }); - } - - if (inputNavbar) { - inputNavbar.addEventListener("awesomplete-selectcomplete", function(e) { - window.location.href = e.text.value; - }, false); - - new Awesomplete(inputNavbar, { - autoFirst: true, - list: list, - replace: function(suggestion) { - this.input.value = suggestion.label; - } - }); - } - - }); - -}()); diff --git a/assets/js/uikit.js b/assets/js/uikit.js deleted file mode 100644 index 62143ae..0000000 --- a/assets/js/uikit.js +++ /dev/null @@ -1,12323 +0,0 @@ -(function () { - 'use strict'; - - var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; - - function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; - } - - var uikit = createCommonjsModule(function (module, exports) { - /*! UIkit 3.2.3 | http://www.getuikit.com | (c) 2014 - 2019 YOOtheme | MIT License */ - - (function (global, factory) { - module.exports = factory() ; - }(commonjsGlobal, function () { - var objPrototype = Object.prototype; - var hasOwnProperty = objPrototype.hasOwnProperty; - - function hasOwn(obj, key) { - return hasOwnProperty.call(obj, key); - } - - var hyphenateCache = {}; - var hyphenateRe = /([a-z\d])([A-Z])/g; - - function hyphenate(str) { - - if (!(str in hyphenateCache)) { - hyphenateCache[str] = str - .replace(hyphenateRe, '$1-$2') - .toLowerCase(); - } - - return hyphenateCache[str]; - } - - var camelizeRe = /-(\w)/g; - - function camelize(str) { - return str.replace(camelizeRe, toUpper); - } - - function toUpper(_, c) { - return c ? c.toUpperCase() : ''; - } - - function ucfirst(str) { - return str.length ? toUpper(null, str.charAt(0)) + str.slice(1) : ''; - } - - var strPrototype = String.prototype; - var startsWithFn = strPrototype.startsWith || function (search) { return this.lastIndexOf(search, 0) === 0; }; - - function startsWith(str, search) { - return startsWithFn.call(str, search); - } - - var endsWithFn = strPrototype.endsWith || function (search) { return this.substr(-search.length) === search; }; - - function endsWith(str, search) { - return endsWithFn.call(str, search); - } - - var arrPrototype = Array.prototype; - - var includesFn = function (search, i) { return ~this.indexOf(search, i); }; - var includesStr = strPrototype.includes || includesFn; - var includesArray = arrPrototype.includes || includesFn; - - function includes(obj, search) { - return obj && (isString(obj) ? includesStr : includesArray).call(obj, search); - } - - var findIndexFn = arrPrototype.findIndex || function (predicate) { - var arguments$1 = arguments; - - for (var i = 0; i < this.length; i++) { - if (predicate.call(arguments$1[1], this[i], i, this)) { - return i; - } - } - return -1; - }; - - function findIndex(array, predicate) { - return findIndexFn.call(array, predicate); - } - - var isArray = Array.isArray; - - function isFunction(obj) { - return typeof obj === 'function'; - } - - function isObject(obj) { - return obj !== null && typeof obj === 'object'; - } - - var toString = objPrototype.toString; - function isPlainObject(obj) { - return toString.call(obj) === '[object Object]'; - } - - function isWindow(obj) { - return isObject(obj) && obj === obj.window; - } - - function isDocument(obj) { - return isObject(obj) && obj.nodeType === 9; - } - - function isJQuery(obj) { - return isObject(obj) && !!obj.jquery; - } - - function isNode(obj) { - return obj instanceof Node || isObject(obj) && obj.nodeType >= 1; - } - - function isNodeCollection(obj) { - return toString.call(obj).match(/^\[object (NodeList|HTMLCollection)\]$/); - } - - function isBoolean(value) { - return typeof value === 'boolean'; - } - - function isString(value) { - return typeof value === 'string'; - } - - function isNumber(value) { - return typeof value === 'number'; - } - - function isNumeric(value) { - return isNumber(value) || isString(value) && !isNaN(value - parseFloat(value)); - } - - function isEmpty(obj) { - return !(isArray(obj) - ? obj.length - : isObject(obj) - ? Object.keys(obj).length - : false - ); - } - - function isUndefined(value) { - return value === void 0; - } - - function toBoolean(value) { - return isBoolean(value) - ? value - : value === 'true' || value === '1' || value === '' - ? true - : value === 'false' || value === '0' - ? false - : value; - } - - function toNumber(value) { - var number = Number(value); - return !isNaN(number) ? number : false; - } - - function toFloat(value) { - return parseFloat(value) || 0; - } - - function toNode(element) { - return isNode(element) || isWindow(element) || isDocument(element) - ? element - : isNodeCollection(element) || isJQuery(element) - ? element[0] - : isArray(element) - ? toNode(element[0]) - : null; - } - - function toNodes(element) { - return isNode(element) - ? [element] - : isNodeCollection(element) - ? arrPrototype.slice.call(element) - : isArray(element) - ? element.map(toNode).filter(Boolean) - : isJQuery(element) - ? element.toArray() - : []; - } - - function toList(value) { - return isArray(value) - ? value - : isString(value) - ? value.split(/,(?![^(]*\))/).map(function (value) { return isNumeric(value) - ? toNumber(value) - : toBoolean(value.trim()); }) - : [value]; - } - - function toMs(time) { - return !time - ? 0 - : endsWith(time, 'ms') - ? toFloat(time) - : toFloat(time) * 1000; - } - - function isEqual(value, other) { - return value === other - || isObject(value) - && isObject(other) - && Object.keys(value).length === Object.keys(other).length - && each(value, function (val, key) { return val === other[key]; }); - } - - function swap(value, a, b) { - return value.replace(new RegExp((a + "|" + b), 'mg'), function (match) { - return match === a ? b : a; - }); - } - - var assign = Object.assign || function (target) { - var args = [], len = arguments.length - 1; - while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; - - target = Object(target); - for (var i = 0; i < args.length; i++) { - var source = args[i]; - if (source !== null) { - for (var key in source) { - if (hasOwn(source, key)) { - target[key] = source[key]; - } - } - } - } - return target; - }; - - function last(array) { - return array[array.length - 1]; - } - - function each(obj, cb) { - for (var key in obj) { - if (false === cb(obj[key], key)) { - return false; - } - } - return true; - } - - function sortBy(array, prop) { - return array.sort(function (ref, ref$1) { - var propA = ref[prop]; if ( propA === void 0 ) propA = 0; - var propB = ref$1[prop]; if ( propB === void 0 ) propB = 0; - - return propA > propB - ? 1 - : propB > propA - ? -1 - : 0; - } - ); - } - - function uniqueBy(array, prop) { - var seen = new Set(); - return array.filter(function (ref) { - var check = ref[prop]; - - return seen.has(check) - ? false - : seen.add(check) || true; - } // IE 11 does not return the Set object - ); - } - - function clamp(number, min, max) { - if ( min === void 0 ) min = 0; - if ( max === void 0 ) max = 1; - - return Math.min(Math.max(toNumber(number) || 0, min), max); - } - - function noop() {} - - function intersectRect(r1, r2) { - return r1.left < r2.right && - r1.right > r2.left && - r1.top < r2.bottom && - r1.bottom > r2.top; - } - - function pointInRect(point, rect) { - return point.x <= rect.right && - point.x >= rect.left && - point.y <= rect.bottom && - point.y >= rect.top; - } - - var Dimensions = { - - ratio: function(dimensions, prop, value) { - var obj; - - - var aProp = prop === 'width' ? 'height' : 'width'; - - return ( obj = {}, obj[aProp] = dimensions[prop] ? Math.round(value * dimensions[aProp] / dimensions[prop]) : dimensions[aProp], obj[prop] = value, obj ); - }, - - contain: function(dimensions, maxDimensions) { - var this$1 = this; - - dimensions = assign({}, dimensions); - - each(dimensions, function (_, prop) { return dimensions = dimensions[prop] > maxDimensions[prop] - ? this$1.ratio(dimensions, prop, maxDimensions[prop]) - : dimensions; } - ); - - return dimensions; - }, - - cover: function(dimensions, maxDimensions) { - var this$1 = this; - - dimensions = this.contain(dimensions, maxDimensions); - - each(dimensions, function (_, prop) { return dimensions = dimensions[prop] < maxDimensions[prop] - ? this$1.ratio(dimensions, prop, maxDimensions[prop]) - : dimensions; } - ); - - return dimensions; - } - - }; - - function attr(element, name, value) { - - if (isObject(name)) { - for (var key in name) { - attr(element, key, name[key]); - } - return; - } - - if (isUndefined(value)) { - element = toNode(element); - return element && element.getAttribute(name); - } else { - toNodes(element).forEach(function (element) { - - if (isFunction(value)) { - value = value.call(element, attr(element, name)); - } - - if (value === null) { - removeAttr(element, name); - } else { - element.setAttribute(name, value); - } - }); - } - - } - - function hasAttr(element, name) { - return toNodes(element).some(function (element) { return element.hasAttribute(name); }); - } - - function removeAttr(element, name) { - element = toNodes(element); - name.split(' ').forEach(function (name) { return element.forEach(function (element) { return element.hasAttribute(name) && element.removeAttribute(name); } - ); } - ); - } - - function data(element, attribute) { - for (var i = 0, attrs = [attribute, ("data-" + attribute)]; i < attrs.length; i++) { - if (hasAttr(element, attrs[i])) { - return attr(element, attrs[i]); - } - } - } - - /* global DocumentTouch */ - - var isIE = /msie|trident/i.test(window.navigator.userAgent); - var isRtl = attr(document.documentElement, 'dir') === 'rtl'; - - var hasTouchEvents = 'ontouchstart' in window; - var hasPointerEvents = window.PointerEvent; - var hasTouch = hasTouchEvents - || window.DocumentTouch && document instanceof DocumentTouch - || navigator.maxTouchPoints; // IE >=11 - - var pointerDown = hasPointerEvents ? 'pointerdown' : hasTouchEvents ? 'touchstart' : 'mousedown'; - var pointerMove = hasPointerEvents ? 'pointermove' : hasTouchEvents ? 'touchmove' : 'mousemove'; - var pointerUp = hasPointerEvents ? 'pointerup' : hasTouchEvents ? 'touchend' : 'mouseup'; - var pointerEnter = hasPointerEvents ? 'pointerenter' : hasTouchEvents ? '' : 'mouseenter'; - var pointerLeave = hasPointerEvents ? 'pointerleave' : hasTouchEvents ? '' : 'mouseleave'; - var pointerCancel = hasPointerEvents ? 'pointercancel' : 'touchcancel'; - - function query(selector, context) { - return toNode(selector) || find(selector, getContext(selector, context)); - } - - function queryAll(selector, context) { - var nodes = toNodes(selector); - return nodes.length && nodes || findAll(selector, getContext(selector, context)); - } - - function getContext(selector, context) { - if ( context === void 0 ) context = document; - - return isContextSelector(selector) || isDocument(context) - ? context - : context.ownerDocument; - } - - function find(selector, context) { - return toNode(_query(selector, context, 'querySelector')); - } - - function findAll(selector, context) { - return toNodes(_query(selector, context, 'querySelectorAll')); - } - - function _query(selector, context, queryFn) { - if ( context === void 0 ) context = document; - - - if (!selector || !isString(selector)) { - return null; - } - - selector = selector.replace(contextSanitizeRe, '$1 *'); - - var removes; - - if (isContextSelector(selector)) { - - removes = []; - - selector = splitSelector(selector).map(function (selector, i) { - - var ctx = context; - - if (selector[0] === '!') { - - var selectors = selector.substr(1).trim().split(' '); - ctx = closest(context.parentNode, selectors[0]); - selector = selectors.slice(1).join(' ').trim(); - - } - - if (selector[0] === '-') { - - var selectors$1 = selector.substr(1).trim().split(' '); - var prev = (ctx || context).previousElementSibling; - ctx = matches(prev, selector.substr(1)) ? prev : null; - selector = selectors$1.slice(1).join(' '); - - } - - if (!ctx) { - return null; - } - - if (!ctx.id) { - ctx.id = "uk-" + (Date.now()) + i; - removes.push(function () { return removeAttr(ctx, 'id'); }); - } - - return ("#" + (escape(ctx.id)) + " " + selector); - - }).filter(Boolean).join(','); - - context = document; - - } - - try { - - return context[queryFn](selector); - - } catch (e) { - - return null; - - } finally { - - removes && removes.forEach(function (remove) { return remove(); }); - - } - - } - - var contextSelectorRe = /(^|[^\\],)\s*[!>+~-]/; - var contextSanitizeRe = /([!>+~-])(?=\s+[!>+~-]|\s*$)/g; - - function isContextSelector(selector) { - return isString(selector) && selector.match(contextSelectorRe); - } - - var selectorRe = /.*?[^\\](?:,|$)/g; - - function splitSelector(selector) { - return selector.match(selectorRe).map(function (selector) { return selector.replace(/,$/, '').trim(); }); - } - - var elProto = Element.prototype; - var matchesFn = elProto.matches || elProto.webkitMatchesSelector || elProto.msMatchesSelector; - - function matches(element, selector) { - return toNodes(element).some(function (element) { return matchesFn.call(element, selector); }); - } - - var closestFn = elProto.closest || function (selector) { - var ancestor = this; - - do { - - if (matches(ancestor, selector)) { - return ancestor; - } - - ancestor = ancestor.parentNode; - - } while (ancestor && ancestor.nodeType === 1); - }; - - function closest(element, selector) { - - if (startsWith(selector, '>')) { - selector = selector.slice(1); - } - - return isNode(element) - ? closestFn.call(element, selector) - : toNodes(element).map(function (element) { return closest(element, selector); }).filter(Boolean); - } - - function parents(element, selector) { - var elements = []; - element = toNode(element); - - while ((element = element.parentNode) && element.nodeType === 1) { - if (matches(element, selector)) { - elements.push(element); - } - } - - return elements; - } - - var escapeFn = window.CSS && CSS.escape || function (css) { return css.replace(/([^\x7f-\uFFFF\w-])/g, function (match) { return ("\\" + match); }); }; - function escape(css) { - return isString(css) ? escapeFn.call(null, css) : ''; - } - - var voidElements = { - area: true, - base: true, - br: true, - col: true, - embed: true, - hr: true, - img: true, - input: true, - keygen: true, - link: true, - menuitem: true, - meta: true, - param: true, - source: true, - track: true, - wbr: true - }; - function isVoidElement(element) { - return toNodes(element).some(function (element) { return voidElements[element.tagName.toLowerCase()]; }); - } - - function isVisible(element) { - return toNodes(element).some(function (element) { return element.offsetWidth || element.offsetHeight || element.getClientRects().length; }); - } - - var selInput = 'input,select,textarea,button'; - function isInput(element) { - return toNodes(element).some(function (element) { return matches(element, selInput); }); - } - - function filter(element, selector) { - return toNodes(element).filter(function (element) { return matches(element, selector); }); - } - - function within(element, selector) { - return !isString(selector) - ? element === selector || (isDocument(selector) - ? selector.documentElement - : toNode(selector)).contains(toNode(element)) // IE 11 document does not implement contains - : matches(element, selector) || closest(element, selector); - } - - function on() { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - - var ref = getArgs(args); - var targets = ref[0]; - var type = ref[1]; - var selector = ref[2]; - var listener = ref[3]; - var useCapture = ref[4]; - - targets = toEventTargets(targets); - - if (listener.length > 1) { - listener = detail(listener); - } - - if (useCapture && useCapture.self) { - listener = selfFilter(listener); - } - - if (selector) { - listener = delegate(targets, selector, listener); - } - - useCapture = useCaptureFilter(useCapture); - - type.split(' ').forEach(function (type) { return targets.forEach(function (target) { return target.addEventListener(type, listener, useCapture); } - ); } - ); - return function () { return off(targets, type, listener, useCapture); }; - } - - function off(targets, type, listener, useCapture) { - if ( useCapture === void 0 ) useCapture = false; - - useCapture = useCaptureFilter(useCapture); - targets = toEventTargets(targets); - type.split(' ').forEach(function (type) { return targets.forEach(function (target) { return target.removeEventListener(type, listener, useCapture); } - ); } - ); - } - - function once() { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - - var ref = getArgs(args); - var element = ref[0]; - var type = ref[1]; - var selector = ref[2]; - var listener = ref[3]; - var useCapture = ref[4]; - var condition = ref[5]; - var off = on(element, type, selector, function (e) { - var result = !condition || condition(e); - if (result) { - off(); - listener(e, result); - } - }, useCapture); - - return off; - } - - function trigger(targets, event, detail) { - return toEventTargets(targets).reduce(function (notCanceled, target) { return notCanceled && target.dispatchEvent(createEvent(event, true, true, detail)); } - , true); - } - - function createEvent(e, bubbles, cancelable, detail) { - if ( bubbles === void 0 ) bubbles = true; - if ( cancelable === void 0 ) cancelable = false; - - if (isString(e)) { - var event = document.createEvent('CustomEvent'); // IE 11 - event.initCustomEvent(e, bubbles, cancelable, detail); - e = event; - } - - return e; - } - - function getArgs(args) { - if (isFunction(args[2])) { - args.splice(2, 0, false); - } - return args; - } - - function delegate(delegates, selector, listener) { - var this$1 = this; - - return function (e) { - - delegates.forEach(function (delegate) { - - var current = selector[0] === '>' - ? findAll(selector, delegate).reverse().filter(function (element) { return within(e.target, element); })[0] - : closest(e.target, selector); - - if (current) { - e.delegate = delegate; - e.current = current; - - listener.call(this$1, e); - } - - }); - - }; - } - - function detail(listener) { - return function (e) { return isArray(e.detail) ? listener.apply(void 0, [e].concat(e.detail)) : listener(e); }; - } - - function selfFilter(listener) { - return function (e) { - if (e.target === e.currentTarget || e.target === e.current) { - return listener.call(null, e); - } - }; - } - - function useCaptureFilter(options) { - return options && isIE && !isBoolean(options) - ? !!options.capture - : options; - } - - function isEventTarget(target) { - return target && 'addEventListener' in target; - } - - function toEventTarget(target) { - return isEventTarget(target) ? target : toNode(target); - } - - function toEventTargets(target) { - return isArray(target) - ? target.map(toEventTarget).filter(Boolean) - : isString(target) - ? findAll(target) - : isEventTarget(target) - ? [target] - : toNodes(target); - } - - function isTouch(e) { - return e.pointerType === 'touch' || !!e.touches; - } - - function getEventPos(e, prop) { - if ( prop === void 0 ) prop = 'client'; - - var touches = e.touches; - var changedTouches = e.changedTouches; - var ref = touches && touches[0] || changedTouches && changedTouches[0] || e; - var x = ref[(prop + "X")]; - var y = ref[(prop + "Y")]; - - return {x: x, y: y}; - } - - /* global setImmediate */ - - var Promise = 'Promise' in window ? window.Promise : PromiseFn; - - var Deferred = function() { - var this$1 = this; - - this.promise = new Promise(function (resolve, reject) { - this$1.reject = reject; - this$1.resolve = resolve; - }); - }; - - /** - * Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis) - */ - - var RESOLVED = 0; - var REJECTED = 1; - var PENDING = 2; - - var async = 'setImmediate' in window ? setImmediate : setTimeout; - - function PromiseFn(executor) { - - this.state = PENDING; - this.value = undefined; - this.deferred = []; - - var promise = this; - - try { - executor( - function (x) { - promise.resolve(x); - }, - function (r) { - promise.reject(r); - } - ); - } catch (e) { - promise.reject(e); - } - } - - PromiseFn.reject = function (r) { - return new PromiseFn(function (resolve, reject) { - reject(r); - }); - }; - - PromiseFn.resolve = function (x) { - return new PromiseFn(function (resolve, reject) { - resolve(x); - }); - }; - - PromiseFn.all = function all(iterable) { - return new PromiseFn(function (resolve, reject) { - var result = []; - var count = 0; - - if (iterable.length === 0) { - resolve(result); - } - - function resolver(i) { - return function (x) { - result[i] = x; - count += 1; - - if (count === iterable.length) { - resolve(result); - } - }; - } - - for (var i = 0; i < iterable.length; i += 1) { - PromiseFn.resolve(iterable[i]).then(resolver(i), reject); - } - }); - }; - - PromiseFn.race = function race(iterable) { - return new PromiseFn(function (resolve, reject) { - for (var i = 0; i < iterable.length; i += 1) { - PromiseFn.resolve(iterable[i]).then(resolve, reject); - } - }); - }; - - var p = PromiseFn.prototype; - - p.resolve = function resolve(x) { - var promise = this; - - if (promise.state === PENDING) { - if (x === promise) { - throw new TypeError('Promise settled with itself.'); - } - - var called = false; - - try { - var then = x && x.then; - - if (x !== null && isObject(x) && isFunction(then)) { - then.call( - x, - function (x) { - if (!called) { - promise.resolve(x); - } - called = true; - }, - function (r) { - if (!called) { - promise.reject(r); - } - called = true; - } - ); - return; - } - } catch (e) { - if (!called) { - promise.reject(e); - } - return; - } - - promise.state = RESOLVED; - promise.value = x; - promise.notify(); - } - }; - - p.reject = function reject(reason) { - var promise = this; - - if (promise.state === PENDING) { - if (reason === promise) { - throw new TypeError('Promise settled with itself.'); - } - - promise.state = REJECTED; - promise.value = reason; - promise.notify(); - } - }; - - p.notify = function notify() { - var this$1 = this; - - async(function () { - if (this$1.state !== PENDING) { - while (this$1.deferred.length) { - var ref = this$1.deferred.shift(); - var onResolved = ref[0]; - var onRejected = ref[1]; - var resolve = ref[2]; - var reject = ref[3]; - - try { - if (this$1.state === RESOLVED) { - if (isFunction(onResolved)) { - resolve(onResolved.call(undefined, this$1.value)); - } else { - resolve(this$1.value); - } - } else if (this$1.state === REJECTED) { - if (isFunction(onRejected)) { - resolve(onRejected.call(undefined, this$1.value)); - } else { - reject(this$1.value); - } - } - } catch (e) { - reject(e); - } - } - } - }); - }; - - p.then = function then(onResolved, onRejected) { - var this$1 = this; - - return new PromiseFn(function (resolve, reject) { - this$1.deferred.push([onResolved, onRejected, resolve, reject]); - this$1.notify(); - }); - }; - - p.catch = function (onRejected) { - return this.then(undefined, onRejected); - }; - - function ajax(url, options) { - return new Promise(function (resolve, reject) { - - var env = assign({ - data: null, - method: 'GET', - headers: {}, - xhr: new XMLHttpRequest(), - beforeSend: noop, - responseType: '' - }, options); - - env.beforeSend(env); - - var xhr = env.xhr; - - for (var prop in env) { - if (prop in xhr) { - try { - - xhr[prop] = env[prop]; - - } catch (e) {} - } - } - - xhr.open(env.method.toUpperCase(), url); - - for (var header in env.headers) { - xhr.setRequestHeader(header, env.headers[header]); - } - - on(xhr, 'load', function () { - - if (xhr.status === 0 || xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) { - resolve(xhr); - } else { - reject(assign(Error(xhr.statusText), { - xhr: xhr, - status: xhr.status - })); - } - - }); - - on(xhr, 'error', function () { return reject(assign(Error('Network Error'), {xhr: xhr})); }); - on(xhr, 'timeout', function () { return reject(assign(Error('Network Timeout'), {xhr: xhr})); }); - - xhr.send(env.data); - }); - } - - function getImage(src, srcset, sizes) { - - return new Promise(function (resolve, reject) { - var img = new Image(); - - img.onerror = reject; - img.onload = function () { return resolve(img); }; - - sizes && (img.sizes = sizes); - srcset && (img.srcset = srcset); - img.src = src; - }); - - } - - function ready(fn) { - - if (document.readyState !== 'loading') { - fn(); - return; - } - - var unbind = on(document, 'DOMContentLoaded', function () { - unbind(); - fn(); - }); - } - - function index(element, ref) { - return ref - ? toNodes(element).indexOf(toNode(ref)) - : toNodes((element = toNode(element)) && element.parentNode.children).indexOf(element); - } - - function getIndex(i, elements, current, finite) { - if ( current === void 0 ) current = 0; - if ( finite === void 0 ) finite = false; - - - elements = toNodes(elements); - - var length = elements.length; - - i = isNumeric(i) - ? toNumber(i) - : i === 'next' - ? current + 1 - : i === 'previous' - ? current - 1 - : index(elements, i); - - if (finite) { - return clamp(i, 0, length - 1); - } - - i %= length; - - return i < 0 ? i + length : i; - } - - function empty(element) { - element = $(element); - element.innerHTML = ''; - return element; - } - - function html(parent, html) { - parent = $(parent); - return isUndefined(html) - ? parent.innerHTML - : append(parent.hasChildNodes() ? empty(parent) : parent, html); - } - - function prepend(parent, element) { - - parent = $(parent); - - if (!parent.hasChildNodes()) { - return append(parent, element); - } else { - return insertNodes(element, function (element) { return parent.insertBefore(element, parent.firstChild); }); - } - } - - function append(parent, element) { - parent = $(parent); - return insertNodes(element, function (element) { return parent.appendChild(element); }); - } - - function before(ref, element) { - ref = $(ref); - return insertNodes(element, function (element) { return ref.parentNode.insertBefore(element, ref); }); - } - - function after(ref, element) { - ref = $(ref); - return insertNodes(element, function (element) { return ref.nextSibling - ? before(ref.nextSibling, element) - : append(ref.parentNode, element); } - ); - } - - function insertNodes(element, fn) { - element = isString(element) ? fragment(element) : element; - return element - ? 'length' in element - ? toNodes(element).map(fn) - : fn(element) - : null; - } - - function remove(element) { - toNodes(element).map(function (element) { return element.parentNode && element.parentNode.removeChild(element); }); - } - - function wrapAll(element, structure) { - - structure = toNode(before(element, structure)); - - while (structure.firstChild) { - structure = structure.firstChild; - } - - append(structure, element); - - return structure; - } - - function wrapInner(element, structure) { - return toNodes(toNodes(element).map(function (element) { return element.hasChildNodes ? wrapAll(toNodes(element.childNodes), structure) : append(element, structure); } - )); - } - - function unwrap(element) { - toNodes(element) - .map(function (element) { return element.parentNode; }) - .filter(function (value, index, self) { return self.indexOf(value) === index; }) - .forEach(function (parent) { - before(parent, parent.childNodes); - remove(parent); - }); - } - - var fragmentRe = /^\s*<(\w+|!)[^>]*>/; - var singleTagRe = /^<(\w+)\s*\/?>(?:<\/\1>)?$/; - - function fragment(html) { - - var matches = singleTagRe.exec(html); - if (matches) { - return document.createElement(matches[1]); - } - - var container = document.createElement('div'); - if (fragmentRe.test(html)) { - container.insertAdjacentHTML('beforeend', html.trim()); - } else { - container.textContent = html; - } - - return container.childNodes.length > 1 ? toNodes(container.childNodes) : container.firstChild; - - } - - function apply(node, fn) { - - if (!node || node.nodeType !== 1) { - return; - } - - fn(node); - node = node.firstElementChild; - while (node) { - apply(node, fn); - node = node.nextElementSibling; - } - } - - function $(selector, context) { - return !isString(selector) - ? toNode(selector) - : isHtml(selector) - ? toNode(fragment(selector)) - : find(selector, context); - } - - function $$(selector, context) { - return !isString(selector) - ? toNodes(selector) - : isHtml(selector) - ? toNodes(fragment(selector)) - : findAll(selector, context); - } - - function isHtml(str) { - return str[0] === '<' || str.match(/^\s*); - } - - function addClass(element) { - var args = [], len = arguments.length - 1; - while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; - - apply$1(element, args, 'add'); - } - - function removeClass(element) { - var args = [], len = arguments.length - 1; - while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; - - apply$1(element, args, 'remove'); - } - - function removeClasses(element, cls) { - attr(element, 'class', function (value) { return (value || '').replace(new RegExp(("\\b" + cls + "\\b"), 'g'), ''); }); - } - - function replaceClass(element) { - var args = [], len = arguments.length - 1; - while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; - - args[0] && removeClass(element, args[0]); - args[1] && addClass(element, args[1]); - } - - function hasClass(element, cls) { - return cls && toNodes(element).some(function (element) { return element.classList.contains(cls.split(' ')[0]); }); - } - - function toggleClass(element) { - var args = [], len = arguments.length - 1; - while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; - - - if (!args.length) { - return; - } - - args = getArgs$1(args); - - var force = !isString(last(args)) ? args.pop() : []; // in iOS 9.3 force === undefined evaluates to false - - args = args.filter(Boolean); - - toNodes(element).forEach(function (ref) { - var classList = ref.classList; - - for (var i = 0; i < args.length; i++) { - supports.Force - ? classList.toggle.apply(classList, [args[i]].concat(force)) - : (classList[(!isUndefined(force) ? force : !classList.contains(args[i])) ? 'add' : 'remove'](args[i])); - } - }); - - } - - function apply$1(element, args, fn) { - args = getArgs$1(args).filter(Boolean); - - args.length && toNodes(element).forEach(function (ref) { - var classList = ref.classList; - - supports.Multiple - ? classList[fn].apply(classList, args) - : args.forEach(function (cls) { return classList[fn](cls); }); - }); - } - - function getArgs$1(args) { - return args.reduce(function (args, arg) { return args.concat.call(args, isString(arg) && includes(arg, ' ') ? arg.trim().split(' ') : arg); } - , []); - } - - // IE 11 - var supports = { - - get Multiple() { - return this.get('_multiple'); - }, - - get Force() { - return this.get('_force'); - }, - - get: function(key) { - - if (!hasOwn(this, key)) { - var ref = document.createElement('_'); - var classList = ref.classList; - classList.add('a', 'b'); - classList.toggle('c', false); - this._multiple = classList.contains('b'); - this._force = !classList.contains('c'); - } - - return this[key]; - } - - }; - - var cssNumber = { - 'animation-iteration-count': true, - 'column-count': true, - 'fill-opacity': true, - 'flex-grow': true, - 'flex-shrink': true, - 'font-weight': true, - 'line-height': true, - 'opacity': true, - 'order': true, - 'orphans': true, - 'stroke-dasharray': true, - 'stroke-dashoffset': true, - 'widows': true, - 'z-index': true, - 'zoom': true - }; - - function css(element, property, value) { - - return toNodes(element).map(function (element) { - - if (isString(property)) { - - property = propName(property); - - if (isUndefined(value)) { - return getStyle(element, property); - } else if (!value && !isNumber(value)) { - element.style.removeProperty(property); - } else { - element.style[property] = isNumeric(value) && !cssNumber[property] ? (value + "px") : value; - } - - } else if (isArray(property)) { - - var styles = getStyles(element); - - return property.reduce(function (props, property) { - props[property] = styles[propName(property)]; - return props; - }, {}); - - } else if (isObject(property)) { - each(property, function (value, property) { return css(element, property, value); }); - } - - return element; - - })[0]; - - } - - function getStyles(element, pseudoElt) { - element = toNode(element); - return element.ownerDocument.defaultView.getComputedStyle(element, pseudoElt); - } - - function getStyle(element, property, pseudoElt) { - return getStyles(element, pseudoElt)[property]; - } - - var vars = {}; - - function getCssVar(name) { - - var docEl = document.documentElement; - - if (!isIE) { - return getStyles(docEl).getPropertyValue(("--uk-" + name)); - } - - if (!(name in vars)) { - - /* usage in css: .uk-name:before { content:"xyz" } */ - - var element = append(docEl, document.createElement('div')); - - addClass(element, ("uk-" + name)); - - vars[name] = getStyle(element, 'content', ':before').replace(/^["'](.*)["']$/, '$1'); - - remove(element); - - } - - return vars[name]; - - } - - var cssProps = {}; - - function propName(name) { - - var ret = cssProps[name]; - if (!ret) { - ret = cssProps[name] = vendorPropName(name) || name; - } - return ret; - } - - var cssPrefixes = ['webkit', 'moz', 'ms']; - - function vendorPropName(name) { - - name = hyphenate(name); - - var ref = document.documentElement; - var style = ref.style; - - if (name in style) { - return name; - } - - var i = cssPrefixes.length, prefixedName; - - while (i--) { - prefixedName = "-" + (cssPrefixes[i]) + "-" + name; - if (prefixedName in style) { - return prefixedName; - } - } - } - - function transition(element, props, duration, timing) { - if ( duration === void 0 ) duration = 400; - if ( timing === void 0 ) timing = 'linear'; - - - return Promise.all(toNodes(element).map(function (element) { return new Promise(function (resolve, reject) { - - for (var name in props) { - var value = css(element, name); - if (value === '') { - css(element, name, value); - } - } - - var timer = setTimeout(function () { return trigger(element, 'transitionend'); }, duration); - - once(element, 'transitionend transitioncanceled', function (ref) { - var type = ref.type; - - clearTimeout(timer); - removeClass(element, 'uk-transition'); - css(element, { - 'transition-property': '', - 'transition-duration': '', - 'transition-timing-function': '' - }); - type === 'transitioncanceled' ? reject() : resolve(); - }, {self: true}); - - addClass(element, 'uk-transition'); - css(element, assign({ - 'transition-property': Object.keys(props).map(propName).join(','), - 'transition-duration': (duration + "ms"), - 'transition-timing-function': timing - }, props)); - - }); } - )); - - } - - var Transition = { - - start: transition, - - stop: function(element) { - trigger(element, 'transitionend'); - return Promise.resolve(); - }, - - cancel: function(element) { - trigger(element, 'transitioncanceled'); - }, - - inProgress: function(element) { - return hasClass(element, 'uk-transition'); - } - - }; - - var animationPrefix = 'uk-animation-'; - var clsCancelAnimation = 'uk-cancel-animation'; - - function animate(element, animation, duration, origin, out) { - var arguments$1 = arguments; - if ( duration === void 0 ) duration = 200; - - - return Promise.all(toNodes(element).map(function (element) { return new Promise(function (resolve, reject) { - - if (hasClass(element, clsCancelAnimation)) { - requestAnimationFrame(function () { return Promise.resolve().then(function () { return animate.apply(void 0, arguments$1).then(resolve, reject); } - ); } - ); - return; - } - - var cls = animation + " " + animationPrefix + (out ? 'leave' : 'enter'); - - if (startsWith(animation, animationPrefix)) { - - if (origin) { - cls += " uk-transform-origin-" + origin; - } - - if (out) { - cls += " " + animationPrefix + "reverse"; - } - - } - - reset(); - - once(element, 'animationend animationcancel', function (ref) { - var type = ref.type; - - - var hasReset = false; - - if (type === 'animationcancel') { - reject(); - reset(); - } else { - resolve(); - Promise.resolve().then(function () { - hasReset = true; - reset(); - }); - } - - requestAnimationFrame(function () { - if (!hasReset) { - addClass(element, clsCancelAnimation); - - requestAnimationFrame(function () { return removeClass(element, clsCancelAnimation); }); - } - }); - - }, {self: true}); - - css(element, 'animationDuration', (duration + "ms")); - addClass(element, cls); - - function reset() { - css(element, 'animationDuration', ''); - removeClasses(element, (animationPrefix + "\\S*")); - } - - }); } - )); - - } - - var inProgress = new RegExp((animationPrefix + "(enter|leave)")); - var Animation = { - - in: function(element, animation, duration, origin) { - return animate(element, animation, duration, origin, false); - }, - - out: function(element, animation, duration, origin) { - return animate(element, animation, duration, origin, true); - }, - - inProgress: function(element) { - return inProgress.test(attr(element, 'class')); - }, - - cancel: function(element) { - trigger(element, 'animationcancel'); - } - - }; - - var dirs = { - width: ['x', 'left', 'right'], - height: ['y', 'top', 'bottom'] - }; - - function positionAt(element, target, elAttach, targetAttach, elOffset, targetOffset, flip, boundary) { - - elAttach = getPos(elAttach); - targetAttach = getPos(targetAttach); - - var flipped = {element: elAttach, target: targetAttach}; - - if (!element || !target) { - return flipped; - } - - var dim = getDimensions(element); - var targetDim = getDimensions(target); - var position = targetDim; - - moveTo(position, elAttach, dim, -1); - moveTo(position, targetAttach, targetDim, 1); - - elOffset = getOffsets(elOffset, dim.width, dim.height); - targetOffset = getOffsets(targetOffset, targetDim.width, targetDim.height); - - elOffset['x'] += targetOffset['x']; - elOffset['y'] += targetOffset['y']; - - position.left += elOffset['x']; - position.top += elOffset['y']; - - if (flip) { - - var boundaries = [getDimensions(getWindow(element))]; - - if (boundary) { - boundaries.unshift(getDimensions(boundary)); - } - - each(dirs, function (ref, prop) { - var dir = ref[0]; - var align = ref[1]; - var alignFlip = ref[2]; - - - if (!(flip === true || includes(flip, dir))) { - return; - } - - boundaries.some(function (boundary) { - - var elemOffset = elAttach[dir] === align - ? -dim[prop] - : elAttach[dir] === alignFlip - ? dim[prop] - : 0; - - var targetOffset = targetAttach[dir] === align - ? targetDim[prop] - : targetAttach[dir] === alignFlip - ? -targetDim[prop] - : 0; - - if (position[align] < boundary[align] || position[align] + dim[prop] > boundary[alignFlip]) { - - var centerOffset = dim[prop] / 2; - var centerTargetOffset = targetAttach[dir] === 'center' ? -targetDim[prop] / 2 : 0; - - return elAttach[dir] === 'center' && ( - apply(centerOffset, centerTargetOffset) - || apply(-centerOffset, -centerTargetOffset) - ) || apply(elemOffset, targetOffset); - - } - - function apply(elemOffset, targetOffset) { - - var newVal = position[align] + elemOffset + targetOffset - elOffset[dir] * 2; - - if (newVal >= boundary[align] && newVal + dim[prop] <= boundary[alignFlip]) { - position[align] = newVal; - - ['element', 'target'].forEach(function (el) { - flipped[el][dir] = !elemOffset - ? flipped[el][dir] - : flipped[el][dir] === dirs[prop][1] - ? dirs[prop][2] - : dirs[prop][1]; - }); - - return true; - } - - } - - }); - - }); - } - - offset(element, position); - - return flipped; - } - - function offset(element, coordinates) { - - element = toNode(element); - - if (coordinates) { - - var currentOffset = offset(element); - var pos = css(element, 'position'); - - ['left', 'top'].forEach(function (prop) { - if (prop in coordinates) { - var value = css(element, prop); - css(element, prop, coordinates[prop] - currentOffset[prop] - + toFloat(pos === 'absolute' && value === 'auto' - ? position(element)[prop] - : value) - ); - } - }); - - return; - } - - return getDimensions(element); - } - - function getDimensions(element) { - - element = toNode(element); - - if (!element) { - return {}; - } - - var ref = getWindow(element); - var top = ref.pageYOffset; - var left = ref.pageXOffset; - - if (isWindow(element)) { - - var height = element.innerHeight; - var width = element.innerWidth; - - return { - top: top, - left: left, - height: height, - width: width, - bottom: top + height, - right: left + width - }; - } - - var style, hidden; - - if (!isVisible(element) && css(element, 'display') === 'none') { - - style = attr(element, 'style'); - hidden = attr(element, 'hidden'); - - attr(element, { - style: ((style || '') + ";display:block !important;"), - hidden: null - }); - } - - var rect = element.getBoundingClientRect(); - - if (!isUndefined(style)) { - attr(element, {style: style, hidden: hidden}); - } - - return { - height: rect.height, - width: rect.width, - top: rect.top + top, - left: rect.left + left, - bottom: rect.bottom + top, - right: rect.right + left - }; - } - - function position(element) { - element = toNode(element); - - var parent = element.offsetParent || getDocEl(element); - var parentOffset = offset(parent); - var ref = ['top', 'left'].reduce(function (props, prop) { - var propName = ucfirst(prop); - props[prop] -= parentOffset[prop] - + toFloat(css(element, ("margin" + propName))) - + toFloat(css(parent, ("border" + propName + "Width"))); - return props; - }, offset(element)); - var top = ref.top; - var left = ref.left; - - return {top: top, left: left}; - } - - var height = dimension('height'); - var width = dimension('width'); - - function dimension(prop) { - var propName = ucfirst(prop); - return function (element, value) { - - element = toNode(element); - - if (isUndefined(value)) { - - if (isWindow(element)) { - return element[("inner" + propName)]; - } - - if (isDocument(element)) { - var doc = element.documentElement; - return Math.max(doc[("offset" + propName)], doc[("scroll" + propName)]); - } - - value = css(element, prop); - value = value === 'auto' ? element[("offset" + propName)] : toFloat(value) || 0; - - return value - boxModelAdjust(prop, element); - - } else { - - css(element, prop, !value && value !== 0 - ? '' - : +value + boxModelAdjust(prop, element) + 'px' - ); - - } - - }; - } - - function boxModelAdjust(prop, element, sizing) { - if ( sizing === void 0 ) sizing = 'border-box'; - - return css(element, 'boxSizing') === sizing - ? dirs[prop].slice(1).map(ucfirst).reduce(function (value, prop) { return value - + toFloat(css(element, ("padding" + prop))) - + toFloat(css(element, ("border" + prop + "Width"))); } - , 0) - : 0; - } - - function moveTo(position, attach, dim, factor) { - each(dirs, function (ref, prop) { - var dir = ref[0]; - var align = ref[1]; - var alignFlip = ref[2]; - - if (attach[dir] === alignFlip) { - position[align] += dim[prop] * factor; - } else if (attach[dir] === 'center') { - position[align] += dim[prop] * factor / 2; - } - }); - } - - function getPos(pos) { - - var x = /left|center|right/; - var y = /top|center|bottom/; - - pos = (pos || '').split(' '); - - if (pos.length === 1) { - pos = x.test(pos[0]) - ? pos.concat(['center']) - : y.test(pos[0]) - ? ['center'].concat(pos) - : ['center', 'center']; - } - - return { - x: x.test(pos[0]) ? pos[0] : 'center', - y: y.test(pos[1]) ? pos[1] : 'center' - }; - } - - function getOffsets(offsets, width, height) { - - var ref = (offsets || '').split(' '); - var x = ref[0]; - var y = ref[1]; - - return { - x: x ? toFloat(x) * (endsWith(x, '%') ? width / 100 : 1) : 0, - y: y ? toFloat(y) * (endsWith(y, '%') ? height / 100 : 1) : 0 - }; - } - - function flipPosition(pos) { - switch (pos) { - case 'left': - return 'right'; - case 'right': - return 'left'; - case 'top': - return 'bottom'; - case 'bottom': - return 'top'; - default: - return pos; - } - } - - function isInView(element, topOffset, leftOffset) { - if ( topOffset === void 0 ) topOffset = 0; - if ( leftOffset === void 0 ) leftOffset = 0; - - - if (!isVisible(element)) { - return false; - } - - element = toNode(element); - - var win = getWindow(element); - var client = element.getBoundingClientRect(); - var bounding = { - top: -topOffset, - left: -leftOffset, - bottom: topOffset + height(win), - right: leftOffset + width(win) - }; - - return intersectRect(client, bounding) || pointInRect({x: client.left, y: client.top}, bounding); - - } - - function scrolledOver(element, heightOffset) { - if ( heightOffset === void 0 ) heightOffset = 0; - - - if (!isVisible(element)) { - return 0; - } - - element = toNode(element); - - var win = getWindow(element); - var doc = getDocument(element); - var elHeight = element.offsetHeight + heightOffset; - var ref = offsetPosition(element); - var top = ref[0]; - var vp = height(win); - var vh = vp + Math.min(0, top - vp); - var diff = Math.max(0, vp - (height(doc) + heightOffset - (top + elHeight))); - - return clamp(((vh + win.pageYOffset - top) / ((vh + (elHeight - (diff < vp ? diff : 0))) / 100)) / 100); - } - - function scrollTop(element, top) { - element = toNode(element); - - if (isWindow(element) || isDocument(element)) { - var ref = getWindow(element); - var scrollTo = ref.scrollTo; - var pageXOffset = ref.pageXOffset; - scrollTo(pageXOffset, top); - } else { - element.scrollTop = top; - } - } - - function offsetPosition(element) { - var offset = [0, 0]; - - do { - - offset[0] += element.offsetTop; - offset[1] += element.offsetLeft; - - if (css(element, 'position') === 'fixed') { - var win = getWindow(element); - offset[0] += win.pageYOffset; - offset[1] += win.pageXOffset; - return offset; - } - - } while ((element = element.offsetParent)); - - return offset; - } - - function toPx(value, property, element) { - if ( property === void 0 ) property = 'width'; - if ( element === void 0 ) element = window; - - return isNumeric(value) - ? +value - : endsWith(value, 'vh') - ? percent(height(getWindow(element)), value) - : endsWith(value, 'vw') - ? percent(width(getWindow(element)), value) - : endsWith(value, '%') - ? percent(getDimensions(element)[property], value) - : toFloat(value); - } - - function percent(base, value) { - return base * toFloat(value) / 100; - } - - function getWindow(element) { - return isWindow(element) ? element : getDocument(element).defaultView; - } - - function getDocument(element) { - return toNode(element).ownerDocument; - } - - function getDocEl(element) { - return getDocument(element).documentElement; - } - - /* - Based on: - Copyright (c) 2016 Wilson Page wilsonpage@me.com - https://github.com/wilsonpage/fastdom - */ - - var fastdom = { - - reads: [], - writes: [], - - read: function(task) { - this.reads.push(task); - scheduleFlush(); - return task; - }, - - write: function(task) { - this.writes.push(task); - scheduleFlush(); - return task; - }, - - clear: function(task) { - return remove$1(this.reads, task) || remove$1(this.writes, task); - }, - - flush: flush - - }; - - function flush(recursion) { - if ( recursion === void 0 ) recursion = 1; - - runTasks(fastdom.reads); - runTasks(fastdom.writes.splice(0, fastdom.writes.length)); - - fastdom.scheduled = false; - - if (fastdom.reads.length || fastdom.writes.length) { - scheduleFlush(recursion + 1); - } - } - - var RECURSION_LIMIT = 5; - function scheduleFlush(recursion) { - if (!fastdom.scheduled) { - fastdom.scheduled = true; - if (recursion > RECURSION_LIMIT) { - throw new Error('Maximum recursion limit reached.'); - } else if (recursion) { - Promise.resolve().then(function () { return flush(recursion); }); - } else { - requestAnimationFrame(function () { return flush(); }); - } - } - } - - function runTasks(tasks) { - var task; - while ((task = tasks.shift())) { - task(); - } - } - - function remove$1(array, item) { - var index = array.indexOf(item); - return !!~index && !!array.splice(index, 1); - } - - function MouseTracker() {} - - MouseTracker.prototype = { - - positions: [], - position: null, - - init: function() { - var this$1 = this; - - - this.positions = []; - this.position = null; - - var ticking = false; - this.unbind = on(document, 'mousemove', function (e) { - - if (ticking) { - return; - } - - setTimeout(function () { - - var time = Date.now(); - var ref = this$1.positions; - var length = ref.length; - - if (length && (time - this$1.positions[length - 1].time > 100)) { - this$1.positions.splice(0, length); - } - - this$1.positions.push({time: time, x: e.pageX, y: e.pageY}); - - if (this$1.positions.length > 5) { - this$1.positions.shift(); - } - - ticking = false; - }, 5); - - ticking = true; - }); - - }, - - cancel: function() { - if (this.unbind) { - this.unbind(); - } - }, - - movesTo: function(target) { - - if (this.positions.length < 2) { - return false; - } - - var p = offset(target); - var position = last(this.positions); - var ref = this.positions; - var prevPos = ref[0]; - - if (p.left <= position.x && position.x <= p.right && p.top <= position.y && position.y <= p.bottom) { - return false; - } - - var points = [ - [{x: p.left, y: p.top}, {x: p.right, y: p.bottom}], - [{x: p.right, y: p.top}, {x: p.left, y: p.bottom}] - ]; - - if (p.right <= position.x) ; else if (p.left >= position.x) { - points[0].reverse(); - points[1].reverse(); - } else if (p.bottom <= position.y) { - points[0].reverse(); - } else if (p.top >= position.y) { - points[1].reverse(); - } - - return !!points.reduce(function (result, point) { - return result + (slope(prevPos, point[0]) < slope(position, point[0]) && slope(prevPos, point[1]) > slope(position, point[1])); - }, 0); - } - - }; - - function slope(a, b) { - return (b.y - a.y) / (b.x - a.x); - } - - var strats = {}; - - strats.events = - strats.created = - strats.beforeConnect = - strats.connected = - strats.beforeDisconnect = - strats.disconnected = - strats.destroy = concatStrat; - - // args strategy - strats.args = function (parentVal, childVal) { - return childVal !== false && concatStrat(childVal || parentVal); - }; - - // update strategy - strats.update = function (parentVal, childVal) { - return sortBy(concatStrat(parentVal, isFunction(childVal) ? {read: childVal} : childVal), 'order'); - }; - - // property strategy - strats.props = function (parentVal, childVal) { - - if (isArray(childVal)) { - childVal = childVal.reduce(function (value, key) { - value[key] = String; - return value; - }, {}); - } - - return strats.methods(parentVal, childVal); - }; - - // extend strategy - strats.computed = - strats.methods = function (parentVal, childVal) { - return childVal - ? parentVal - ? assign({}, parentVal, childVal) - : childVal - : parentVal; - }; - - // data strategy - strats.data = function (parentVal, childVal, vm) { - - if (!vm) { - - if (!childVal) { - return parentVal; - } - - if (!parentVal) { - return childVal; - } - - return function (vm) { - return mergeFnData(parentVal, childVal, vm); - }; - - } - - return mergeFnData(parentVal, childVal, vm); - }; - - function mergeFnData(parentVal, childVal, vm) { - return strats.computed( - isFunction(parentVal) - ? parentVal.call(vm, vm) - : parentVal, - isFunction(childVal) - ? childVal.call(vm, vm) - : childVal - ); - } - - // concat strategy - function concatStrat(parentVal, childVal) { - - parentVal = parentVal && !isArray(parentVal) ? [parentVal] : parentVal; - - return childVal - ? parentVal - ? parentVal.concat(childVal) - : isArray(childVal) - ? childVal - : [childVal] - : parentVal; - } - - // default strategy - function defaultStrat(parentVal, childVal) { - return isUndefined(childVal) ? parentVal : childVal; - } - - function mergeOptions(parent, child, vm) { - - var options = {}; - - if (isFunction(child)) { - child = child.options; - } - - if (child.extends) { - parent = mergeOptions(parent, child.extends, vm); - } - - if (child.mixins) { - for (var i = 0, l = child.mixins.length; i < l; i++) { - parent = mergeOptions(parent, child.mixins[i], vm); - } - } - - for (var key in parent) { - mergeKey(key); - } - - for (var key$1 in child) { - if (!hasOwn(parent, key$1)) { - mergeKey(key$1); - } - } - - function mergeKey(key) { - options[key] = (strats[key] || defaultStrat)(parent[key], child[key], vm); - } - - return options; - } - - function parseOptions(options, args) { - var obj; - - if ( args === void 0 ) args = []; - - try { - - return !options - ? {} - : startsWith(options, '{') - ? JSON.parse(options) - : args.length && !includes(options, ':') - ? (( obj = {}, obj[args[0]] = options, obj )) - : options.split(';').reduce(function (options, option) { - var ref = option.split(/:(.*)/); - var key = ref[0]; - var value = ref[1]; - if (key && !isUndefined(value)) { - options[key.trim()] = value.trim(); - } - return options; - }, {}); - - } catch (e) { - return {}; - } - - } - - var id = 0; - - var Player = function(el) { - this.id = ++id; - this.el = toNode(el); - }; - - Player.prototype.isVideo = function () { - return this.isYoutube() || this.isVimeo() || this.isHTML5(); - }; - - Player.prototype.isHTML5 = function () { - return this.el.tagName === 'VIDEO'; - }; - - Player.prototype.isIFrame = function () { - return this.el.tagName === 'IFRAME'; - }; - - Player.prototype.isYoutube = function () { - return this.isIFrame() && !!this.el.src.match(/\/\/.*?youtube(-nocookie)?\.[a-z]+\/(watch\?v=[^&\s]+|embed)|youtu\.be\/.*/); - }; - - Player.prototype.isVimeo = function () { - return this.isIFrame() && !!this.el.src.match(/vimeo\.com\/video\/.*/); - }; - - Player.prototype.enableApi = function () { - var this$1 = this; - - - if (this.ready) { - return this.ready; - } - - var youtube = this.isYoutube(); - var vimeo = this.isVimeo(); - - var poller; - - if (youtube || vimeo) { - - return this.ready = new Promise(function (resolve) { - - once(this$1.el, 'load', function () { - if (youtube) { - var listener = function () { return post(this$1.el, {event: 'listening', id: this$1.id}); }; - poller = setInterval(listener, 100); - listener(); - } - }); - - listen(function (data) { return youtube && data.id === this$1.id && data.event === 'onReady' || vimeo && Number(data.player_id) === this$1.id; }) - .then(function () { - resolve(); - poller && clearInterval(poller); - }); - - attr(this$1.el, 'src', ("" + (this$1.el.src) + (includes(this$1.el.src, '?') ? '&' : '?') + (youtube ? 'enablejsapi=1' : ("api=1&player_id=" + (this$1.id))))); - - }); - - } - - return Promise.resolve(); - - }; - - Player.prototype.play = function () { - var this$1 = this; - - - if (!this.isVideo()) { - return; - } - - if (this.isIFrame()) { - this.enableApi().then(function () { return post(this$1.el, {func: 'playVideo', method: 'play'}); }); - } else if (this.isHTML5()) { - try { - var promise = this.el.play(); - - if (promise) { - promise.catch(noop); - } - } catch (e) {} - } - }; - - Player.prototype.pause = function () { - var this$1 = this; - - - if (!this.isVideo()) { - return; - } - - if (this.isIFrame()) { - this.enableApi().then(function () { return post(this$1.el, {func: 'pauseVideo', method: 'pause'}); }); - } else if (this.isHTML5()) { - this.el.pause(); - } - }; - - Player.prototype.mute = function () { - var this$1 = this; - - - if (!this.isVideo()) { - return; - } - - if (this.isIFrame()) { - this.enableApi().then(function () { return post(this$1.el, {func: 'mute', method: 'setVolume', value: 0}); }); - } else if (this.isHTML5()) { - this.el.muted = true; - attr(this.el, 'muted', ''); - } - - }; - - function post(el, cmd) { - try { - el.contentWindow.postMessage(JSON.stringify(assign({event: 'command'}, cmd)), '*'); - } catch (e) {} - } - - function listen(cb) { - - return new Promise(function (resolve) { - - once(window, 'message', function (_, data) { return resolve(data); }, false, function (ref) { - var data = ref.data; - - - if (!data || !isString(data)) { - return; - } - - try { - data = JSON.parse(data); - } catch (e) { - return; - } - - return data && cb(data); - - }); - - }); - - } - - var IntersectionObserver = 'IntersectionObserver' in window - ? window.IntersectionObserver - : /*@__PURE__*/(function () { - function IntersectionObserverClass(callback, ref) { - var this$1 = this; - if ( ref === void 0 ) ref = {}; - var rootMargin = ref.rootMargin; if ( rootMargin === void 0 ) rootMargin = '0 0'; - - - this.targets = []; - - var ref$1 = (rootMargin || '0 0').split(' ').map(toFloat); - var offsetTop = ref$1[0]; - var offsetLeft = ref$1[1]; - - this.offsetTop = offsetTop; - this.offsetLeft = offsetLeft; - - var pending; - this.apply = function () { - - if (pending) { - return; - } - - pending = requestAnimationFrame(function () { return setTimeout(function () { - var records = this$1.takeRecords(); - - if (records.length) { - callback(records, this$1); - } - - pending = false; - }); }); - - }; - - this.off = on(window, 'scroll resize load', this.apply, {passive: true, capture: true}); - - } - - IntersectionObserverClass.prototype.takeRecords = function () { - var this$1 = this; - - return this.targets.filter(function (entry) { - - var inView = isInView(entry.target, this$1.offsetTop, this$1.offsetLeft); - - if (entry.isIntersecting === null || inView ^ entry.isIntersecting) { - entry.isIntersecting = inView; - return true; - } - - }); - }; - - IntersectionObserverClass.prototype.observe = function (target) { - this.targets.push({ - target: target, - isIntersecting: null - }); - this.apply(); - }; - - IntersectionObserverClass.prototype.disconnect = function () { - this.targets = []; - this.off(); - }; - - return IntersectionObserverClass; - }()); - - - - var util = /*#__PURE__*/Object.freeze({ - ajax: ajax, - getImage: getImage, - transition: transition, - Transition: Transition, - animate: animate, - Animation: Animation, - attr: attr, - hasAttr: hasAttr, - removeAttr: removeAttr, - data: data, - addClass: addClass, - removeClass: removeClass, - removeClasses: removeClasses, - replaceClass: replaceClass, - hasClass: hasClass, - toggleClass: toggleClass, - positionAt: positionAt, - offset: offset, - position: position, - height: height, - width: width, - boxModelAdjust: boxModelAdjust, - flipPosition: flipPosition, - isInView: isInView, - scrolledOver: scrolledOver, - scrollTop: scrollTop, - offsetPosition: offsetPosition, - toPx: toPx, - ready: ready, - index: index, - getIndex: getIndex, - empty: empty, - html: html, - prepend: prepend, - append: append, - before: before, - after: after, - remove: remove, - wrapAll: wrapAll, - wrapInner: wrapInner, - unwrap: unwrap, - fragment: fragment, - apply: apply, - $: $, - $$: $$, - isIE: isIE, - isRtl: isRtl, - hasTouch: hasTouch, - pointerDown: pointerDown, - pointerMove: pointerMove, - pointerUp: pointerUp, - pointerEnter: pointerEnter, - pointerLeave: pointerLeave, - pointerCancel: pointerCancel, - on: on, - off: off, - once: once, - trigger: trigger, - createEvent: createEvent, - toEventTargets: toEventTargets, - isTouch: isTouch, - getEventPos: getEventPos, - fastdom: fastdom, - isVoidElement: isVoidElement, - isVisible: isVisible, - selInput: selInput, - isInput: isInput, - filter: filter, - within: within, - hasOwn: hasOwn, - hyphenate: hyphenate, - camelize: camelize, - ucfirst: ucfirst, - startsWith: startsWith, - endsWith: endsWith, - includes: includes, - findIndex: findIndex, - isArray: isArray, - isFunction: isFunction, - isObject: isObject, - isPlainObject: isPlainObject, - isWindow: isWindow, - isDocument: isDocument, - isJQuery: isJQuery, - isNode: isNode, - isNodeCollection: isNodeCollection, - isBoolean: isBoolean, - isString: isString, - isNumber: isNumber, - isNumeric: isNumeric, - isEmpty: isEmpty, - isUndefined: isUndefined, - toBoolean: toBoolean, - toNumber: toNumber, - toFloat: toFloat, - toNode: toNode, - toNodes: toNodes, - toList: toList, - toMs: toMs, - isEqual: isEqual, - swap: swap, - assign: assign, - last: last, - each: each, - sortBy: sortBy, - uniqueBy: uniqueBy, - clamp: clamp, - noop: noop, - intersectRect: intersectRect, - pointInRect: pointInRect, - Dimensions: Dimensions, - MouseTracker: MouseTracker, - mergeOptions: mergeOptions, - parseOptions: parseOptions, - Player: Player, - Promise: Promise, - Deferred: Deferred, - IntersectionObserver: IntersectionObserver, - query: query, - queryAll: queryAll, - find: find, - findAll: findAll, - matches: matches, - closest: closest, - parents: parents, - escape: escape, - css: css, - getStyles: getStyles, - getStyle: getStyle, - getCssVar: getCssVar, - propName: propName - }); - - function componentAPI (UIkit) { - - var DATA = UIkit.data; - - var components = {}; - - UIkit.component = function (name, options) { - - if (!options) { - - if (isPlainObject(components[name])) { - components[name] = UIkit.extend(components[name]); - } - - return components[name]; - - } - - UIkit[name] = function (element, data) { - var i = arguments.length, argsArray = Array(i); - while ( i-- ) argsArray[i] = arguments[i]; - - - var component = UIkit.component(name); - - return component.options.functional - ? new component({data: isPlainObject(element) ? element : [].concat( argsArray )}) - : element && element.nodeType ? init(element) : $$(element).map(init)[0]; - - function init(element) { - - var instance = UIkit.getComponent(element, name); - - if (instance) { - if (!data) { - return instance; - } else { - instance.$destroy(); - } - } - - return new component({el: element, data: data}); - - } - - }; - - var opt = isPlainObject(options) ? assign({}, options) : options.options; - - opt.name = name; - - if (opt.install) { - opt.install(UIkit, opt, name); - } - - if (UIkit._initialized && !opt.functional) { - var id = hyphenate(name); - fastdom.read(function () { return UIkit[name](("[uk-" + id + "],[data-uk-" + id + "]")); }); - } - - return components[name] = isPlainObject(options) ? opt : options; - }; - - UIkit.getComponents = function (element) { return element && element[DATA] || {}; }; - UIkit.getComponent = function (element, name) { return UIkit.getComponents(element)[name]; }; - - UIkit.connect = function (node) { - - if (node[DATA]) { - for (var name in node[DATA]) { - node[DATA][name]._callConnected(); - } - } - - for (var i = 0; i < node.attributes.length; i++) { - - var name$1 = getComponentName(node.attributes[i].name); - - if (name$1 && name$1 in components) { - UIkit[name$1](node); - } - - } - - }; - - UIkit.disconnect = function (node) { - for (var name in node[DATA]) { - node[DATA][name]._callDisconnected(); - } - }; - - } - - function getComponentName(attribute) { - return startsWith(attribute, 'uk-') || startsWith(attribute, 'data-uk-') - ? camelize(attribute.replace('data-uk-', '').replace('uk-', '')) - : false; - } - - function boot (UIkit) { - - var connect = UIkit.connect; - var disconnect = UIkit.disconnect; - - if (!('MutationObserver' in window)) { - return; - } - - fastdom.read(init); - - function init() { - - if (document.body) { - apply(document.body, connect); - } - - (new MutationObserver(function (mutations) { return mutations.forEach(applyMutation); })).observe(document, { - childList: true, - subtree: true, - characterData: true, - attributes: true - }); - - UIkit._initialized = true; - } - - function applyMutation(mutation) { - - var target = mutation.target; - var type = mutation.type; - - var update = type !== 'attributes' - ? applyChildList(mutation) - : applyAttribute(mutation); - - update && UIkit.update(target); - - } - - function applyAttribute(ref) { - var target = ref.target; - var attributeName = ref.attributeName; - - - if (attributeName === 'href') { - return true; - } - - var name = getComponentName(attributeName); - - if (!name || !(name in UIkit)) { - return; - } - - if (hasAttr(target, attributeName)) { - UIkit[name](target); - return true; - } - - var component = UIkit.getComponent(target, name); - - if (component) { - component.$destroy(); - return true; - } - - } - - function applyChildList(ref) { - var addedNodes = ref.addedNodes; - var removedNodes = ref.removedNodes; - - - for (var i = 0; i < addedNodes.length; i++) { - apply(addedNodes[i], connect); - } - - for (var i$1 = 0; i$1 < removedNodes.length; i$1++) { - apply(removedNodes[i$1], disconnect); - } - - return true; - } - - function apply(node, fn) { - - if (node.nodeType !== 1 || hasAttr(node, 'uk-no-boot')) { - return; - } - - fn(node); - node = node.firstElementChild; - while (node) { - var next = node.nextElementSibling; - apply(node, fn); - node = next; - } - } - - } - - function globalAPI (UIkit) { - - var DATA = UIkit.data; - - UIkit.use = function (plugin) { - - if (plugin.installed) { - return; - } - - plugin.call(null, this); - plugin.installed = true; - - return this; - }; - - UIkit.mixin = function (mixin, component) { - component = (isString(component) ? UIkit.component(component) : component) || this; - component.options = mergeOptions(component.options, mixin); - }; - - UIkit.extend = function (options) { - - options = options || {}; - - var Super = this; - var Sub = function UIkitComponent(options) { - this._init(options); - }; - - Sub.prototype = Object.create(Super.prototype); - Sub.prototype.constructor = Sub; - Sub.options = mergeOptions(Super.options, options); - - Sub.super = Super; - Sub.extend = Super.extend; - - return Sub; - }; - - UIkit.update = function (element, e) { - - element = element ? toNode(element) : document.body; - - path(element, function (element) { return update(element[DATA], e); }); - apply(element, function (element) { return update(element[DATA], e); }); - - }; - - var container; - Object.defineProperty(UIkit, 'container', { - - get: function() { - return container || document.body; - }, - - set: function(element) { - container = $(element); - } - - }); - - function update(data, e) { - - if (!data) { - return; - } - - for (var name in data) { - if (data[name]._connected) { - data[name]._callUpdate(e); - } - } - - } - - function path(node, fn) { - if (node && node !== document.body && node.parentNode) { - path(node.parentNode, fn); - fn(node.parentNode); - } - } - - } - - function hooksAPI (UIkit) { - - UIkit.prototype._callHook = function (hook) { - var this$1 = this; - - - var handlers = this.$options[hook]; - - if (handlers) { - handlers.forEach(function (handler) { return handler.call(this$1); }); - } - }; - - UIkit.prototype._callConnected = function () { - - if (this._connected) { - return; - } - - this._data = {}; - this._computeds = {}; - this._initProps(); - - this._callHook('beforeConnect'); - this._connected = true; - - this._initEvents(); - this._initObserver(); - - this._callHook('connected'); - this._callUpdate(); - }; - - UIkit.prototype._callDisconnected = function () { - - if (!this._connected) { - return; - } - - this._callHook('beforeDisconnect'); - - if (this._observer) { - this._observer.disconnect(); - this._observer = null; - } - - this._unbindEvents(); - this._callHook('disconnected'); - - this._connected = false; - - }; - - UIkit.prototype._callUpdate = function (e) { - var this$1 = this; - if ( e === void 0 ) e = 'update'; - - - var type = e.type || e; - - if (includes(['update', 'resize'], type)) { - this._callWatches(); - } - - var updates = this.$options.update; - var ref = this._frames; - var reads = ref.reads; - var writes = ref.writes; - - if (!updates) { - return; - } - - updates.forEach(function (ref, i) { - var read = ref.read; - var write = ref.write; - var events = ref.events; - - - if (type !== 'update' && !includes(events, type)) { - return; - } - - if (read && !includes(fastdom.reads, reads[i])) { - reads[i] = fastdom.read(function () { - - var result = this$1._connected && read.call(this$1, this$1._data, type); - - if (result === false && write) { - fastdom.clear(writes[i]); - } else if (isPlainObject(result)) { - assign(this$1._data, result); - } - }); - } - - if (write && !includes(fastdom.writes, writes[i])) { - writes[i] = fastdom.write(function () { return this$1._connected && write.call(this$1, this$1._data, type); }); - } - - }); - - }; - - } - - function stateAPI (UIkit) { - - var uid = 0; - - UIkit.prototype._init = function (options) { - - options = options || {}; - options.data = normalizeData(options, this.constructor.options); - - this.$options = mergeOptions(this.constructor.options, options, this); - this.$el = null; - this.$props = {}; - - this._frames = {reads: {}, writes: {}}; - this._events = []; - - this._uid = uid++; - this._initData(); - this._initMethods(); - this._initComputeds(); - this._callHook('created'); - - if (options.el) { - this.$mount(options.el); - } - }; - - UIkit.prototype._initData = function () { - - var ref = this.$options; - var data = ref.data; if ( data === void 0 ) data = {}; - - for (var key in data) { - this.$props[key] = this[key] = data[key]; - } - }; - - UIkit.prototype._initMethods = function () { - - var ref = this.$options; - var methods = ref.methods; - - if (methods) { - for (var key in methods) { - this[key] = methods[key].bind(this); - } - } - }; - - UIkit.prototype._initComputeds = function () { - - var ref = this.$options; - var computed = ref.computed; - - this._computeds = {}; - - if (computed) { - for (var key in computed) { - registerComputed(this, key, computed[key]); - } - } - }; - - UIkit.prototype._callWatches = function () { - - var ref = this; - var computed = ref.$options.computed; - var _computeds = ref._computeds; - - for (var key in _computeds) { - - var value = _computeds[key]; - delete _computeds[key]; - - if (computed[key].watch && !isEqual(value, this[key])) { - computed[key].watch.call(this, this[key], value); - } - - } - - }; - - UIkit.prototype._initProps = function (props) { - - var key; - - props = props || getProps(this.$options, this.$name); - - for (key in props) { - if (!isUndefined(props[key])) { - this.$props[key] = props[key]; - } - } - - var exclude = [this.$options.computed, this.$options.methods]; - for (key in this.$props) { - if (key in props && notIn(exclude, key)) { - this[key] = this.$props[key]; - } - } - }; - - UIkit.prototype._initEvents = function () { - var this$1 = this; - - - var ref = this.$options; - var events = ref.events; - - if (events) { - - events.forEach(function (event) { - - if (!hasOwn(event, 'handler')) { - for (var key in event) { - registerEvent(this$1, event[key], key); - } - } else { - registerEvent(this$1, event); - } - - }); - } - }; - - UIkit.prototype._unbindEvents = function () { - this._events.forEach(function (unbind) { return unbind(); }); - this._events = []; - }; - - UIkit.prototype._initObserver = function () { - var this$1 = this; - - - var ref = this.$options; - var attrs = ref.attrs; - var props = ref.props; - var el = ref.el; - if (this._observer || !props || attrs === false) { - return; - } - - attrs = isArray(attrs) ? attrs : Object.keys(props); - - this._observer = new MutationObserver(function () { - - var data = getProps(this$1.$options, this$1.$name); - if (attrs.some(function (key) { return !isUndefined(data[key]) && data[key] !== this$1.$props[key]; })) { - this$1.$reset(); - } - - }); - - var filter = attrs.map(function (key) { return hyphenate(key); }).concat(this.$name); - - this._observer.observe(el, { - attributes: true, - attributeFilter: filter.concat(filter.map(function (key) { return ("data-" + key); })) - }); - }; - - function getProps(opts, name) { - - var data$1 = {}; - var args = opts.args; if ( args === void 0 ) args = []; - var props = opts.props; if ( props === void 0 ) props = {}; - var el = opts.el; - - if (!props) { - return data$1; - } - - for (var key in props) { - var prop = hyphenate(key); - var value = data(el, prop); - - if (!isUndefined(value)) { - - value = props[key] === Boolean && value === '' - ? true - : coerce(props[key], value); - - if (prop === 'target' && (!value || startsWith(value, '_'))) { - continue; - } - - data$1[key] = value; - } - } - - var options = parseOptions(data(el, name), args); - - for (var key$1 in options) { - var prop$1 = camelize(key$1); - if (props[prop$1] !== undefined) { - data$1[prop$1] = coerce(props[prop$1], options[key$1]); - } - } - - return data$1; - } - - function registerComputed(component, key, cb) { - Object.defineProperty(component, key, { - - enumerable: true, - - get: function() { - - var _computeds = component._computeds; - var $props = component.$props; - var $el = component.$el; - - if (!hasOwn(_computeds, key)) { - _computeds[key] = (cb.get || cb).call(component, $props, $el); - } - - return _computeds[key]; - }, - - set: function(value) { - - var _computeds = component._computeds; - - _computeds[key] = cb.set ? cb.set.call(component, value) : value; - - if (isUndefined(_computeds[key])) { - delete _computeds[key]; - } - } - - }); - } - - function registerEvent(component, event, key) { - - if (!isPlainObject(event)) { - event = ({name: key, handler: event}); - } - - var name = event.name; - var el = event.el; - var handler = event.handler; - var capture = event.capture; - var passive = event.passive; - var delegate = event.delegate; - var filter = event.filter; - var self = event.self; - el = isFunction(el) - ? el.call(component) - : el || component.$el; - - if (isArray(el)) { - el.forEach(function (el) { return registerEvent(component, assign({}, event, {el: el}), key); }); - return; - } - - if (!el || filter && !filter.call(component)) { - return; - } - - component._events.push( - on( - el, - name, - !delegate - ? null - : isString(delegate) - ? delegate - : delegate.call(component), - isString(handler) ? component[handler] : handler.bind(component), - {passive: passive, capture: capture, self: self} - ) - ); - - } - - function notIn(options, key) { - return options.every(function (arr) { return !arr || !hasOwn(arr, key); }); - } - - function coerce(type, value) { - - if (type === Boolean) { - return toBoolean(value); - } else if (type === Number) { - return toNumber(value); - } else if (type === 'list') { - return toList(value); - } - - return type ? type(value) : value; - } - - function normalizeData(ref, ref$1) { - var data = ref.data; - var el = ref.el; - var args = ref$1.args; - var props = ref$1.props; if ( props === void 0 ) props = {}; - - data = isArray(data) - ? !isEmpty(args) - ? data.slice(0, args.length).reduce(function (data, value, index) { - if (isPlainObject(value)) { - assign(data, value); - } else { - data[args[index]] = value; - } - return data; - }, {}) - : undefined - : data; - - if (data) { - for (var key in data) { - if (isUndefined(data[key])) { - delete data[key]; - } else { - data[key] = props[key] ? coerce(props[key], data[key]) : data[key]; - } - } - } - - return data; - } - } - - function instanceAPI (UIkit) { - - var DATA = UIkit.data; - - UIkit.prototype.$mount = function (el) { - - var ref = this.$options; - var name = ref.name; - - if (!el[DATA]) { - el[DATA] = {}; - } - - if (el[DATA][name]) { - return; - } - - el[DATA][name] = this; - - this.$el = this.$options.el = this.$options.el || el; - - if (within(el, document)) { - this._callConnected(); - } - }; - - UIkit.prototype.$emit = function (e) { - this._callUpdate(e); - }; - - UIkit.prototype.$reset = function () { - this._callDisconnected(); - this._callConnected(); - }; - - UIkit.prototype.$destroy = function (removeEl) { - if ( removeEl === void 0 ) removeEl = false; - - - var ref = this.$options; - var el = ref.el; - var name = ref.name; - - if (el) { - this._callDisconnected(); - } - - this._callHook('destroy'); - - if (!el || !el[DATA]) { - return; - } - - delete el[DATA][name]; - - if (!isEmpty(el[DATA])) { - delete el[DATA]; - } - - if (removeEl) { - remove(this.$el); - } - }; - - UIkit.prototype.$create = function (component, element, data) { - return UIkit[component](element, data); - }; - - UIkit.prototype.$update = UIkit.update; - UIkit.prototype.$getComponent = UIkit.getComponent; - - var names = {}; - Object.defineProperties(UIkit.prototype, { - - $container: Object.getOwnPropertyDescriptor(UIkit, 'container'), - - $name: { - - get: function() { - var ref = this.$options; - var name = ref.name; - - if (!names[name]) { - names[name] = UIkit.prefix + hyphenate(name); - } - - return names[name]; - } - - } - - }); - - } - - var UIkit = function (options) { - this._init(options); - }; - - UIkit.util = util; - UIkit.data = '__uikit__'; - UIkit.prefix = 'uk-'; - UIkit.options = {}; - - globalAPI(UIkit); - hooksAPI(UIkit); - stateAPI(UIkit); - componentAPI(UIkit); - instanceAPI(UIkit); - - var Class = { - - connected: function() { - !hasClass(this.$el, this.$name) && addClass(this.$el, this.$name); - } - - }; - - var Togglable = { - - props: { - cls: Boolean, - animation: 'list', - duration: Number, - origin: String, - transition: String, - queued: Boolean - }, - - data: { - cls: false, - animation: [false], - duration: 200, - origin: false, - transition: 'linear', - queued: false, - - initProps: { - overflow: '', - height: '', - paddingTop: '', - paddingBottom: '', - marginTop: '', - marginBottom: '' - }, - - hideProps: { - overflow: 'hidden', - height: 0, - paddingTop: 0, - paddingBottom: 0, - marginTop: 0, - marginBottom: 0 - } - - }, - - computed: { - - hasAnimation: function(ref) { - var animation = ref.animation; - - return !!animation[0]; - }, - - hasTransition: function(ref) { - var animation = ref.animation; - - return this.hasAnimation && animation[0] === true; - } - - }, - - methods: { - - toggleElement: function(targets, show, animate) { - var this$1 = this; - - return new Promise(function (resolve) { - - targets = toNodes(targets); - - var all = function (targets) { return Promise.all(targets.map(function (el) { return this$1._toggleElement(el, show, animate); })); }; - var toggled = targets.filter(function (el) { return this$1.isToggled(el); }); - var untoggled = targets.filter(function (el) { return !includes(toggled, el); }); - - var p; - - if (!this$1.queued || !isUndefined(animate) || !isUndefined(show) || !this$1.hasAnimation || targets.length < 2) { - - p = all(untoggled.concat(toggled)); - - } else { - - var body = document.body; - var scroll = body.scrollTop; - var el = toggled[0]; - var inProgress = Animation.inProgress(el) && hasClass(el, 'uk-animation-leave') - || Transition.inProgress(el) && el.style.height === '0px'; - - p = all(toggled); - - if (!inProgress) { - p = p.then(function () { - var p = all(untoggled); - body.scrollTop = scroll; - return p; - }); - } - - } - - p.then(resolve, noop); - - }); - }, - - toggleNow: function(targets, show) { - var this$1 = this; - - return new Promise(function (resolve) { return Promise.all(toNodes(targets).map(function (el) { return this$1._toggleElement(el, show, false); })).then(resolve, noop); }); - }, - - isToggled: function(el) { - var nodes = toNodes(el || this.$el); - return this.cls - ? hasClass(nodes, this.cls.split(' ')[0]) - : !hasAttr(nodes, 'hidden'); - }, - - updateAria: function(el) { - if (this.cls === false) { - attr(el, 'aria-hidden', !this.isToggled(el)); - } - }, - - _toggleElement: function(el, show, animate) { - var this$1 = this; - - - show = isBoolean(show) - ? show - : Animation.inProgress(el) - ? hasClass(el, 'uk-animation-leave') - : Transition.inProgress(el) - ? el.style.height === '0px' - : !this.isToggled(el); - - if (!trigger(el, ("before" + (show ? 'show' : 'hide')), [this])) { - return Promise.reject(); - } - - var promise = ( - isFunction(animate) - ? animate - : animate === false || !this.hasAnimation - ? this._toggle - : this.hasTransition - ? toggleHeight(this) - : toggleAnimation(this) - )(el, show); - - trigger(el, show ? 'show' : 'hide', [this]); - - var final = function () { - trigger(el, show ? 'shown' : 'hidden', [this$1]); - this$1.$update(el); - }; - - return promise ? promise.then(final) : Promise.resolve(final()); - }, - - _toggle: function(el, toggled) { - - if (!el) { - return; - } - - toggled = Boolean(toggled); - - var changed; - if (this.cls) { - changed = includes(this.cls, ' ') || toggled !== hasClass(el, this.cls); - changed && toggleClass(el, this.cls, includes(this.cls, ' ') ? undefined : toggled); - } else { - changed = toggled === hasAttr(el, 'hidden'); - changed && attr(el, 'hidden', !toggled ? '' : null); - } - - $$('[autofocus]', el).some(function (el) { return isVisible(el) ? el.focus() || true : el.blur(); }); - - this.updateAria(el); - changed && this.$update(el); - } - - } - - }; - - function toggleHeight(ref) { - var isToggled = ref.isToggled; - var duration = ref.duration; - var initProps = ref.initProps; - var hideProps = ref.hideProps; - var transition = ref.transition; - var _toggle = ref._toggle; - - return function (el, show) { - - var inProgress = Transition.inProgress(el); - var inner = el.hasChildNodes ? toFloat(css(el.firstElementChild, 'marginTop')) + toFloat(css(el.lastElementChild, 'marginBottom')) : 0; - var currentHeight = isVisible(el) ? height(el) + (inProgress ? 0 : inner) : 0; - - Transition.cancel(el); - - if (!isToggled(el)) { - _toggle(el, true); - } - - height(el, ''); - - // Update child components first - fastdom.flush(); - - var endHeight = height(el) + (inProgress ? 0 : inner); - height(el, currentHeight); - - return (show - ? Transition.start(el, assign({}, initProps, {overflow: 'hidden', height: endHeight}), Math.round(duration * (1 - currentHeight / endHeight)), transition) - : Transition.start(el, hideProps, Math.round(duration * (currentHeight / endHeight)), transition).then(function () { return _toggle(el, false); }) - ).then(function () { return css(el, initProps); }); - - }; - } - - function toggleAnimation(ref) { - var animation = ref.animation; - var duration = ref.duration; - var origin = ref.origin; - var _toggle = ref._toggle; - - return function (el, show) { - - Animation.cancel(el); - - if (show) { - _toggle(el, true); - return Animation.in(el, animation[0], duration, origin); - } - - return Animation.out(el, animation[1] || animation[0], duration, origin).then(function () { return _toggle(el, false); }); - }; - } - - var Accordion = { - - mixins: [Class, Togglable], - - props: { - targets: String, - active: null, - collapsible: Boolean, - multiple: Boolean, - toggle: String, - content: String, - transition: String - }, - - data: { - targets: '> *', - active: false, - animation: [true], - collapsible: true, - multiple: false, - clsOpen: 'uk-open', - toggle: '> .uk-accordion-title', - content: '> .uk-accordion-content', - transition: 'ease' - }, - - computed: { - - items: function(ref, $el) { - var targets = ref.targets; - - return $$(targets, $el); - } - - }, - - events: [ - - { - - name: 'click', - - delegate: function() { - return ((this.targets) + " " + (this.$props.toggle)); - }, - - handler: function(e) { - e.preventDefault(); - this.toggle(index($$(((this.targets) + " " + (this.$props.toggle)), this.$el), e.current)); - } - - } - - ], - - connected: function() { - - if (this.active === false) { - return; - } - - var active = this.items[Number(this.active)]; - if (active && !hasClass(active, this.clsOpen)) { - this.toggle(active, false); - } - }, - - update: function() { - var this$1 = this; - - - this.items.forEach(function (el) { return this$1._toggle($(this$1.content, el), hasClass(el, this$1.clsOpen)); }); - - var active = !this.collapsible && !hasClass(this.items, this.clsOpen) && this.items[0]; - if (active) { - this.toggle(active, false); - } - }, - - methods: { - - toggle: function(item, animate) { - var this$1 = this; - - - var index = getIndex(item, this.items); - var active = filter(this.items, ("." + (this.clsOpen))); - - item = this.items[index]; - - item && [item] - .concat(!this.multiple && !includes(active, item) && active || []) - .forEach(function (el) { - - var isItem = el === item; - var state = isItem && !hasClass(el, this$1.clsOpen); - - if (!state && isItem && !this$1.collapsible && active.length < 2) { - return; - } - - toggleClass(el, this$1.clsOpen, state); - - var content = el._wrapper ? el._wrapper.firstElementChild : $(this$1.content, el); - - if (!el._wrapper) { - el._wrapper = wrapAll(content, '