Component-Builder/admin/custom/uikit-v3/js/uikit.js

12369 lines
339 KiB
JavaScript
Raw Normal View History

2021-05-27 00:23:07 +00:00
/*! UIkit 3.6.22 | https://www.getuikit.com | (c) 2014 - 2021 YOOtheme | MIT License */
2017-11-11 04:33:51 +00:00
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define('uikit', factory) :
2021-05-27 00:23:07 +00:00
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.UIkit = factory());
}(this, (function () { 'use strict';
2017-11-11 04:33:51 +00:00
var objPrototype = Object.prototype;
var hasOwnProperty = objPrototype.hasOwnProperty;
2017-11-11 04:33:51 +00:00
function hasOwn(obj, key) {
return hasOwnProperty.call(obj, key);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var hyphenateRe = /\B([A-Z])/g;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var hyphenate = memoize(function (str) { return str
.replace(hyphenateRe, '-$1')
.toLowerCase(); }
);
2017-11-11 04:33:51 +00:00
var camelizeRe = /-(\w)/g;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var camelize = memoize(function (str) { return str.replace(camelizeRe, toUpper); }
);
var ucfirst = memoize(function (str) { return str.length ? toUpper(null, str.charAt(0)) + str.slice(1) : ''; }
);
2017-11-11 04:33:51 +00:00
function toUpper(_, c) {
return c ? c.toUpperCase() : '';
}
2017-11-11 04:33:51 +00:00
var strPrototype = String.prototype;
var startsWithFn = strPrototype.startsWith || function (search) { return this.lastIndexOf(search, 0) === 0; };
2017-11-11 04:33:51 +00:00
function startsWith(str, search) {
return startsWithFn.call(str, search);
}
2017-11-11 04:33:51 +00:00
var endsWithFn = strPrototype.endsWith || function (search) { return this.substr(-search.length) === search; };
2017-11-11 04:33:51 +00:00
function endsWith(str, search) {
return endsWithFn.call(str, search);
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var arrPrototype = Array.prototype;
2021-05-27 00:23:07 +00:00
var includesFn = function (search, i) { return !!~this.indexOf(search, i); };
var includesStr = strPrototype.includes || includesFn;
2019-04-22 13:31:39 +00:00
var includesArray = arrPrototype.includes || includesFn;
2017-11-11 04:33:51 +00:00
function includes(obj, search) {
return obj && (isString(obj) ? includesStr : includesArray).call(obj, search);
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
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;
2017-11-11 04:33:51 +00:00
function isFunction(obj) {
return typeof obj === 'function';
}
2017-11-11 04:33:51 +00:00
function isObject(obj) {
return obj !== null && typeof obj === 'object';
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var toString = objPrototype.toString;
function isPlainObject(obj) {
2021-05-27 00:23:07 +00:00
return toString.call(obj) === '[object Object]';
}
2017-11-11 04:33:51 +00:00
function isWindow(obj) {
return isObject(obj) && obj === obj.window;
2017-11-11 04:33:51 +00:00
}
function isDocument(obj) {
2021-05-27 00:23:07 +00:00
return nodeType(obj) === 9;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function isNode(obj) {
return nodeType(obj) >= 1;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function isElement(obj) {
return nodeType(obj) === 1;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function nodeType(obj) {
return !isWindow(obj) && isObject(obj) && obj.nodeType;
}
2017-11-11 04:33:51 +00:00
function isBoolean(value) {
return typeof value === 'boolean';
}
2017-11-11 04:33:51 +00:00
function isString(value) {
return typeof value === 'string';
}
2017-11-11 04:33:51 +00:00
function isNumber(value) {
return typeof value === 'number';
}
2017-11-11 04:33:51 +00:00
function isNumeric(value) {
return isNumber(value) || isString(value) && !isNaN(value - parseFloat(value));
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function isEmpty(obj) {
return !(isArray(obj)
? obj.length
: isObject(obj)
? Object.keys(obj).length
: false
);
}
function isUndefined(value) {
return value === void 0;
}
2017-11-11 04:33:51 +00:00
function toBoolean(value) {
return isBoolean(value)
? value
: value === 'true' || value === '1' || value === ''
? true
: value === 'false' || value === '0'
? false
: value;
}
2017-11-11 04:33:51 +00:00
function toNumber(value) {
var number = Number(value);
return !isNaN(number) ? number : false;
}
2017-11-11 04:33:51 +00:00
function toFloat(value) {
return parseFloat(value) || 0;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var toArray = Array.from || (function (value) { return arrPrototype.slice.call(value); });
function toNode(element) {
2021-05-27 00:23:07 +00:00
return toNodes(element)[0];
}
2017-11-11 04:33:51 +00:00
function toNodes(element) {
2021-05-27 00:23:07 +00:00
return element && (isNode(element) ? [element] : toArray(element).filter(isNode)) || [];
}
function toWindow(element) {
if (isWindow(element)) {
return element;
}
element = toNode(element);
return element
? (isDocument(element)
? element
: element.ownerDocument
).defaultView
: window;
}
2017-11-11 04:33:51 +00:00
function toMs(time) {
return !time
? 0
: endsWith(time, 'ms')
? toFloat(time)
: toFloat(time) * 1000;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
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) {
2021-05-27 00:23:07 +00:00
return value.replace(
new RegExp((a + "|" + b), 'g'),
function (match) { return match === a ? b : a; }
);
}
2017-11-11 04:33:51 +00:00
var assign = Object.assign || function (target) {
var args = [], len = arguments.length - 1;
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2017-11-11 04:33:51 +00:00
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;
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function last(array) {
return array[array.length - 1];
}
function each(obj, cb) {
for (var key in obj) {
2019-04-22 13:31:39 +00:00
if (false === cb(obj[key], key)) {
return false;
}
}
2019-04-22 13:31:39 +00:00
return true;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function sortBy$1(array, prop) {
return array.slice().sort(function (ref, ref$1) {
2019-04-22 13:31:39 +00:00
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
2019-04-22 13:31:39 +00:00
: propB > propA
? -1
2019-04-22 13:31:39 +00:00
: 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
);
}
2017-11-11 04:33:51 +00:00
function clamp(number, min, max) {
if ( min === void 0 ) min = 0;
if ( max === void 0 ) max = 1;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return Math.min(Math.max(toNumber(number) || 0, min), max);
}
2017-11-11 04:33:51 +00:00
function noop() {}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function intersectRect() {
var rects = [], len = arguments.length;
while ( len-- ) rects[ len ] = arguments[ len ];
return [['bottom', 'top'], ['right', 'left']].every(function (ref) {
var minProp = ref[0];
var maxProp = ref[1];
return Math.min.apply(Math, rects.map(function (ref) {
var min = ref[minProp];
return min;
})) - Math.max.apply(Math, rects.map(function (ref) {
var max = ref[maxProp];
return max;
})) > 0;
}
);
}
2017-11-11 04:33:51 +00:00
function pointInRect(point, rect) {
return point.x <= rect.right &&
point.x >= rect.left &&
point.y <= rect.bottom &&
point.y >= rect.top;
}
2017-11-11 04:33:51 +00:00
var Dimensions = {
2017-11-11 04:33:51 +00:00
ratio: function(dimensions, prop, value) {
var obj;
2017-11-11 04:33:51 +00:00
var aProp = prop === 'width' ? 'height' : 'width';
2017-11-11 04:33:51 +00:00
return ( obj = {}, obj[aProp] = dimensions[prop] ? Math.round(value * dimensions[aProp] / dimensions[prop]) : dimensions[aProp], obj[prop] = value, obj );
},
2017-11-11 04:33:51 +00:00
contain: function(dimensions, maxDimensions) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
dimensions = assign({}, dimensions);
2017-11-11 04:33:51 +00:00
each(dimensions, function (_, prop) { return dimensions = dimensions[prop] > maxDimensions[prop]
? this$1.ratio(dimensions, prop, maxDimensions[prop])
: dimensions; }
);
2017-11-11 04:33:51 +00:00
return dimensions;
},
2017-11-11 04:33:51 +00:00
cover: function(dimensions, maxDimensions) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
dimensions = this.contain(dimensions, maxDimensions);
2017-11-11 04:33:51 +00:00
each(dimensions, function (_, prop) { return dimensions = dimensions[prop] < maxDimensions[prop]
? this$1.ratio(dimensions, prop, maxDimensions[prop])
: dimensions; }
);
2017-11-11 04:33:51 +00:00
return dimensions;
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
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
: elements.indexOf(toNode(i));
if (finite) {
return clamp(i, 0, length - 1);
}
i %= length;
return i < 0 ? i + length : i;
}
function memoize(fn) {
var cache = Object.create(null);
return function (key) { return cache[key] || (cache[key] = fn(key)); };
}
function attr(element, name, value) {
2017-11-11 04:33:51 +00:00
if (isObject(name)) {
for (var key in name) {
attr(element, key, name[key]);
2017-11-11 04:33:51 +00:00
}
return;
2017-11-11 04:33:51 +00:00
}
if (isUndefined(value)) {
element = toNode(element);
return element && element.getAttribute(name);
} else {
toNodes(element).forEach(function (element) {
2017-11-11 04:33:51 +00:00
if (isFunction(value)) {
value = value.call(element, attr(element, name));
}
2017-11-11 04:33:51 +00:00
if (value === null) {
removeAttr(element, name);
} else {
element.setAttribute(name, value);
}
});
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
function hasAttr(element, name) {
return toNodes(element).some(function (element) { return element.hasAttribute(name); });
}
2017-11-11 04:33:51 +00:00
function removeAttr(element, name) {
element = toNodes(element);
2019-04-22 13:31:39 +00:00
name.split(' ').forEach(function (name) { return element.forEach(function (element) { return element.hasAttribute(name) && element.removeAttribute(name); }
); }
);
}
2017-11-11 04:33:51 +00:00
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]);
2017-11-11 04:33:51 +00:00
}
}
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
/* global DocumentTouch */
var inBrowser = typeof window !== 'undefined';
var isIE = inBrowser && /msie|trident/i.test(window.navigator.userAgent);
var isRtl = inBrowser && attr(document.documentElement, 'dir') === 'rtl';
var hasTouchEvents = inBrowser && 'ontouchstart' in window;
var hasPointerEvents = inBrowser && window.PointerEvent;
var hasTouch = inBrowser && (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';
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 isFocusable(element) {
return isInput(element) || matches(element, 'a[href],button') || hasAttr(element, 'tabindex');
}
function parent(element) {
element = toNode(element);
return element && isElement(element.parentNode) && element.parentNode;
}
function filter$1(element, selector) {
return toNodes(element).filter(function (element) { return matches(element, selector); });
}
var elProto = inBrowser ? Element.prototype : {};
var matchesFn = elProto.matches || elProto.webkitMatchesSelector || elProto.msMatchesSelector || noop;
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;
}
} while ((ancestor = parent(ancestor)));
};
function closest(element, selector) {
if (startsWith(selector, '>')) {
selector = selector.slice(1);
}
return isElement(element)
? closestFn.call(element, selector)
: toNodes(element).map(function (element) { return closest(element, selector); }).filter(Boolean);
}
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 parents(element, selector) {
var elements = [];
while ((element = parent(element))) {
if (!selector || matches(element, selector)) {
elements.push(element);
}
}
return elements;
}
function children(element, selector) {
element = toNode(element);
var children = element ? toNodes(element.children) : [];
return selector ? filter$1(children, selector) : children;
}
function index(element, ref) {
return ref
? toNodes(element).indexOf(toNode(ref))
: children(parent(element)).indexOf(element);
}
function query(selector, context) {
return toNode(selector) || find(selector, getContext(selector, context));
}
2017-11-11 04:33:51 +00:00
function queryAll(selector, context) {
var nodes = toNodes(selector);
return nodes.length && nodes || findAll(selector, getContext(selector, context));
}
2017-11-11 04:33:51 +00:00
function getContext(selector, context) {
if ( context === void 0 ) context = document;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return isString(selector) && isContextSelector(selector) || isDocument(context)
? context
: context.ownerDocument;
}
2017-11-11 04:33:51 +00:00
function find(selector, context) {
return toNode(_query(selector, context, 'querySelector'));
}
2017-11-11 04:33:51 +00:00
function findAll(selector, context) {
return toNodes(_query(selector, context, 'querySelectorAll'));
}
2017-11-11 04:33:51 +00:00
function _query(selector, context, queryFn) {
if ( context === void 0 ) context = document;
2017-11-11 04:33:51 +00:00
if (!selector || !isString(selector)) {
return null;
}
2017-11-11 04:33:51 +00:00
selector = selector.replace(contextSanitizeRe, '$1 *');
2017-11-11 04:33:51 +00:00
if (isContextSelector(selector)) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
selector = splitSelector(selector).map(function (selector, i) {
2017-11-11 04:33:51 +00:00
var ctx = context;
2017-11-11 04:33:51 +00:00
if (selector[0] === '!') {
2017-11-11 04:33:51 +00:00
var selectors = selector.substr(1).trim().split(' ');
2021-05-27 00:23:07 +00:00
ctx = closest(parent(context), selectors[0]);
selector = selectors.slice(1).join(' ').trim();
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
if (selector[0] === '-') {
2017-11-11 04:33:51 +00:00
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(' ');
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
if (!ctx) {
return null;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return ((domPath(ctx)) + " " + selector);
2017-11-11 04:33:51 +00:00
}).filter(Boolean).join(',');
2017-11-11 04:33:51 +00:00
context = document;
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
try {
2017-11-11 04:33:51 +00:00
return context[queryFn](selector);
2017-11-11 04:33:51 +00:00
} catch (e) {
2017-11-11 04:33:51 +00:00
return null;
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var contextSelectorRe = /(^|[^\\],)\s*[!>+~-]/;
var contextSanitizeRe = /([!>+~-])(?=\s+[!>+~-]|\s*$)/g;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var isContextSelector = memoize(function (selector) { return selector.match(contextSelectorRe); });
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var selectorRe = /.*?[^\\](?:,|$)/g;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var splitSelector = memoize(function (selector) { return selector.match(selectorRe).map(function (selector) { return selector.replace(/,$/, '').trim(); }
); }
);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function domPath(element) {
var names = [];
while (element.parentNode) {
if (element.id) {
names.unshift(("#" + (escape(element.id))));
break;
} else {
var tagName = element.tagName;
if (tagName !== 'HTML') {
tagName += ":nth-child(" + (index(element) + 1) + ")";
}
names.unshift(tagName);
element = element.parentNode;
}
}
2021-05-27 00:23:07 +00:00
return names.join(' > ');
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
var escapeFn = inBrowser && 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) : '';
}
2017-11-11 04:33:51 +00:00
function on() {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
2017-11-11 04:33:51 +00:00
var ref = getArgs(args);
var targets = ref[0];
var type = ref[1];
var selector = ref[2];
var listener = ref[3];
var useCapture = ref[4];
2017-11-11 04:33:51 +00:00
targets = toEventTargets(targets);
2017-11-11 04:33:51 +00:00
if (listener.length > 1) {
listener = detail(listener);
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
if (useCapture && useCapture.self) {
listener = selfFilter(listener);
}
if (selector) {
listener = delegate(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); };
}
2017-11-11 04:33:51 +00:00
function off(targets, type, listener, useCapture) {
if ( useCapture === void 0 ) useCapture = false;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
useCapture = useCaptureFilter(useCapture);
targets = toEventTargets(targets);
type.split(' ').forEach(function (type) { return targets.forEach(function (target) { return target.removeEventListener(type, listener, useCapture); }
); }
);
2017-11-11 04:33:51 +00:00
}
function once() {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
2017-11-11 04:33:51 +00:00
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);
2017-11-11 04:33:51 +00:00
return off;
2017-11-11 04:33:51 +00:00
}
function trigger(targets, event, detail) {
return toEventTargets(targets).reduce(function (notCanceled, target) { return notCanceled && target.dispatchEvent(createEvent(event, true, true, detail)); }
, true);
}
2017-11-11 04:33:51 +00:00
function createEvent(e, bubbles, cancelable, detail) {
if ( bubbles === void 0 ) bubbles = true;
if ( cancelable === void 0 ) cancelable = false;
2017-11-11 04:33:51 +00:00
if (isString(e)) {
var event = document.createEvent('CustomEvent'); // IE 11
event.initCustomEvent(e, bubbles, cancelable, detail);
e = event;
}
2017-11-11 04:33:51 +00:00
return e;
}
2017-11-11 04:33:51 +00:00
function getArgs(args) {
if (isFunction(args[2])) {
args.splice(2, 0, false);
}
return args;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function delegate(selector, listener) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
return function (e) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var current = selector[0] === '>'
? findAll(selector, e.currentTarget).reverse().filter(function (element) { return within(e.target, element); })[0]
: closest(e.target, selector);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (current) {
e.current = current;
listener.call(this$1, e);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
};
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function detail(listener) {
return function (e) { return isArray(e.detail) ? listener.apply(void 0, [ e ].concat( e.detail )) : listener(e); };
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function selfFilter(listener) {
return function (e) {
if (e.target === e.currentTarget || e.target === e.current) {
return listener.call(null, e);
}
};
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function useCaptureFilter(options) {
return options && isIE && !isBoolean(options)
? !!options.capture
: options;
}
2017-11-11 04:33:51 +00:00
function isEventTarget(target) {
return target && 'addEventListener' in target;
}
2017-11-11 04:33:51 +00:00
function toEventTarget(target) {
return isEventTarget(target) ? target : toNode(target);
}
2017-11-11 04:33:51 +00:00
function toEventTargets(target) {
return isArray(target)
? target.map(toEventTarget).filter(Boolean)
: isString(target)
? findAll(target)
: isEventTarget(target)
? [target]
: toNodes(target);
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function isTouch(e) {
2021-05-27 00:23:07 +00:00
return e.pointerType === 'touch' || !!e.touches;
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function getEventPos(e) {
2019-04-22 13:31:39 +00:00
var touches = e.touches;
var changedTouches = e.changedTouches;
var ref = touches && touches[0] || changedTouches && changedTouches[0] || e;
2021-05-27 00:23:07 +00:00
var x = ref.clientX;
var y = ref.clientY;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return {x: x, y: y};
}
2017-11-11 04:33:51 +00:00
/* global setImmediate */
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var Promise$1 = inBrowser && window.Promise || PromiseFn;
2017-11-11 04:33:51 +00:00
var Deferred = function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.promise = new Promise$1(function (resolve, reject) {
this$1.reject = reject;
this$1.resolve = resolve;
});
};
2017-11-11 04:33:51 +00:00
/**
* Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis)
*/
2017-11-11 04:33:51 +00:00
var RESOLVED = 0;
var REJECTED = 1;
var PENDING = 2;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var async = inBrowser && window.setImmediate || setTimeout;
2017-11-11 04:33:51 +00:00
function PromiseFn(executor) {
2017-11-11 04:33:51 +00:00
this.state = PENDING;
this.value = undefined;
this.deferred = [];
2017-11-11 04:33:51 +00:00
var promise = this;
2017-11-11 04:33:51 +00:00
try {
executor(
function (x) {
promise.resolve(x);
},
function (r) {
promise.reject(r);
2017-11-11 04:33:51 +00:00
}
);
} catch (e) {
promise.reject(e);
}
}
2017-11-11 04:33:51 +00:00
PromiseFn.reject = function (r) {
return new PromiseFn(function (resolve, reject) {
reject(r);
});
};
2017-11-11 04:33:51 +00:00
PromiseFn.resolve = function (x) {
return new PromiseFn(function (resolve, reject) {
resolve(x);
});
};
2017-11-11 04:33:51 +00:00
PromiseFn.all = function all(iterable) {
return new PromiseFn(function (resolve, reject) {
var result = [];
var count = 0;
2017-11-11 04:33:51 +00:00
if (iterable.length === 0) {
resolve(result);
}
2017-11-11 04:33:51 +00:00
function resolver(i) {
return function (x) {
result[i] = x;
count += 1;
2017-11-11 04:33:51 +00:00
if (count === iterable.length) {
resolve(result);
}
};
2017-11-11 04:33:51 +00:00
}
for (var i = 0; i < iterable.length; i += 1) {
PromiseFn.resolve(iterable[i]).then(resolver(i), reject);
2017-11-11 04:33:51 +00:00
}
});
};
2017-11-11 04:33:51 +00:00
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);
}
});
};
2017-11-11 04:33:51 +00:00
var p = PromiseFn.prototype;
2017-11-11 04:33:51 +00:00
p.resolve = function resolve(x) {
var promise = this;
2017-11-11 04:33:51 +00:00
if (promise.state === PENDING) {
if (x === promise) {
throw new TypeError('Promise settled with itself.');
}
2017-11-11 04:33:51 +00:00
var called = false;
2017-11-11 04:33:51 +00:00
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;
}
2017-11-11 04:33:51 +00:00
promise.state = RESOLVED;
promise.value = x;
promise.notify();
}
};
2017-11-11 04:33:51 +00:00
p.reject = function reject(reason) {
var promise = this;
2017-11-11 04:33:51 +00:00
if (promise.state === PENDING) {
if (reason === promise) {
throw new TypeError('Promise settled with itself.');
}
2017-11-11 04:33:51 +00:00
promise.state = REJECTED;
promise.value = reason;
promise.notify();
}
};
2017-11-11 04:33:51 +00:00
p.notify = function notify() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
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);
}
}
}
});
};
2017-11-11 04:33:51 +00:00
p.then = function then(onResolved, onRejected) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
return new PromiseFn(function (resolve, reject) {
this$1.deferred.push([onResolved, onRejected, resolve, reject]);
this$1.notify();
});
};
2017-11-11 04:33:51 +00:00
p.catch = function (onRejected) {
return this.then(undefined, onRejected);
};
2017-11-11 04:33:51 +00:00
function ajax(url, options) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var env = assign({
data: null,
method: 'GET',
headers: {},
xhr: new XMLHttpRequest(),
beforeSend: noop,
responseType: ''
}, options);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return Promise$1.resolve()
.then(function () { return env.beforeSend(env); })
.then(function () { return send(url, env); });
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function send(url, env) {
return new Promise$1(function (resolve, reject) {
var xhr = env.xhr;
2017-11-11 04:33:51 +00:00
for (var prop in env) {
if (prop in xhr) {
try {
2017-11-11 04:33:51 +00:00
xhr[prop] = env[prop];
2017-11-11 04:33:51 +00:00
} catch (e) {}
}
}
2017-11-11 04:33:51 +00:00
xhr.open(env.method.toUpperCase(), url);
2017-11-11 04:33:51 +00:00
for (var header in env.headers) {
xhr.setRequestHeader(header, env.headers[header]);
}
2017-11-11 04:33:51 +00:00
on(xhr, 'load', function () {
2017-11-11 04:33:51 +00:00
if (xhr.status === 0 || xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
2021-05-27 00:23:07 +00:00
// IE 11 does not support responseType 'json'
if (env.responseType === 'json' && isString(xhr.response)) {
xhr = assign(copyXhr(xhr), {response: JSON.parse(xhr.response)});
}
resolve(xhr);
2021-05-27 00:23:07 +00:00
} else {
reject(assign(Error(xhr.statusText), {
xhr: xhr,
status: xhr.status
}));
}
2017-11-11 04:33:51 +00:00
});
2017-11-11 04:33:51 +00:00
on(xhr, 'error', function () { return reject(assign(Error('Network Error'), {xhr: xhr})); });
on(xhr, 'timeout', function () { return reject(assign(Error('Network Timeout'), {xhr: xhr})); });
2017-11-11 04:33:51 +00:00
xhr.send(env.data);
});
2017-11-11 04:33:51 +00:00
}
function getImage(src, srcset, sizes) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return new Promise$1(function (resolve, reject) {
var img = new Image();
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
img.onerror = function (e) { return reject(e); };
img.onload = function () { return resolve(img); };
2017-11-11 04:33:51 +00:00
sizes && (img.sizes = sizes);
srcset && (img.srcset = srcset);
img.src = src;
});
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function copyXhr(source) {
var target = {};
for (var key in source) {
target[key] = source[key];
}
return target;
}
2017-11-11 04:33:51 +00:00
function ready(fn) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (document.readyState !== 'loading') {
fn();
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var unbind = on(document, 'DOMContentLoaded', function () {
unbind();
fn();
2019-04-22 13:31:39 +00:00
});
}
2017-11-11 04:33:51 +00:00
function empty(element) {
2019-04-22 13:31:39 +00:00
element = $(element);
element.innerHTML = '';
return element;
}
2017-11-11 04:33:51 +00:00
function html(parent, html) {
2019-04-22 13:31:39 +00:00
parent = $(parent);
return isUndefined(html)
? parent.innerHTML
: append(parent.hasChildNodes() ? empty(parent) : parent, html);
}
2017-11-11 04:33:51 +00:00
function prepend(parent, element) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
parent = $(parent);
2017-11-11 04:33:51 +00:00
if (!parent.hasChildNodes()) {
return append(parent, element);
} else {
return insertNodes(element, function (element) { return parent.insertBefore(element, parent.firstChild); });
}
}
2017-11-11 04:33:51 +00:00
function append(parent, element) {
2019-04-22 13:31:39 +00:00
parent = $(parent);
return insertNodes(element, function (element) { return parent.appendChild(element); });
}
2017-11-11 04:33:51 +00:00
function before(ref, element) {
2019-04-22 13:31:39 +00:00
ref = $(ref);
return insertNodes(element, function (element) { return ref.parentNode.insertBefore(element, ref); });
2017-11-11 04:33:51 +00:00
}
function after(ref, element) {
2019-04-22 13:31:39 +00:00
ref = $(ref);
return insertNodes(element, function (element) { return ref.nextSibling
? before(ref.nextSibling, element)
: append(ref.parentNode, element); }
);
2017-11-11 04:33:51 +00:00
}
function insertNodes(element, fn) {
element = isString(element) ? fragment(element) : element;
return element
? 'length' in element
? toNodes(element).map(fn)
: fn(element)
: null;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function remove$1(element) {
toNodes(element).forEach(function (element) { return element.parentNode && element.parentNode.removeChild(element); });
}
2017-11-11 04:33:51 +00:00
function wrapAll(element, structure) {
2017-11-11 04:33:51 +00:00
structure = toNode(before(element, structure));
2017-11-11 04:33:51 +00:00
while (structure.firstChild) {
structure = structure.firstChild;
}
2017-11-11 04:33:51 +00:00
append(structure, element);
2017-11-11 04:33:51 +00:00
return structure;
}
2017-11-11 04:33:51 +00:00
function wrapInner(element, structure) {
return toNodes(toNodes(element).map(function (element) { return element.hasChildNodes ? wrapAll(toNodes(element.childNodes), structure) : append(element, structure); }
));
}
2017-11-11 04:33:51 +00:00
function unwrap(element) {
toNodes(element)
2021-05-27 00:23:07 +00:00
.map(parent)
.filter(function (value, index, self) { return self.indexOf(value) === index; })
.forEach(function (parent) {
before(parent, parent.childNodes);
2021-05-27 00:23:07 +00:00
remove$1(parent);
});
}
2017-11-11 04:33:51 +00:00
var fragmentRe = /^\s*<(\w+|!)[^>]*>/;
var singleTagRe = /^<(\w+)\s*\/?>(?:<\/\1>)?$/;
2017-11-11 04:33:51 +00:00
function fragment(html) {
2017-11-11 04:33:51 +00:00
var matches = singleTagRe.exec(html);
if (matches) {
return document.createElement(matches[1]);
}
2017-11-11 04:33:51 +00:00
var container = document.createElement('div');
if (fragmentRe.test(html)) {
container.insertAdjacentHTML('beforeend', html.trim());
} else {
container.textContent = html;
2017-11-11 04:33:51 +00:00
}
return container.childNodes.length > 1 ? toNodes(container.childNodes) : container.firstChild;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function apply$1(node, fn) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!isElement(node)) {
return;
}
2017-11-11 04:33:51 +00:00
fn(node);
node = node.firstElementChild;
while (node) {
2021-05-27 00:23:07 +00:00
var next = node.nextElementSibling;
apply$1(node, fn);
node = next;
}
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
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 ];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
apply(element, args, 'add');
}
2017-11-11 04:33:51 +00:00
function removeClass(element) {
var args = [], len = arguments.length - 1;
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
apply(element, args, 'remove');
}
2017-11-11 04:33:51 +00:00
function removeClasses(element, cls) {
attr(element, 'class', function (value) { return (value || '').replace(new RegExp(("\\b" + cls + "\\b"), 'g'), ''); });
}
2017-11-11 04:33:51 +00:00
function replaceClass(element) {
var args = [], len = arguments.length - 1;
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2017-11-11 04:33:51 +00:00
args[0] && removeClass(element, args[0]);
args[1] && addClass(element, args[1]);
}
2017-11-11 04:33:51 +00:00
function hasClass(element, cls) {
2021-05-27 00:23:07 +00:00
var assign;
(assign = getClasses(cls), cls = assign[0]);
var nodes = toNodes(element);
for (var n = 0; n < nodes.length; n++) {
if (cls && nodes[n].classList.contains(cls)) {
return true;
}
}
return false;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function toggleClass(element, cls, force) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
cls = getClasses(cls);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var nodes = toNodes(element);
for (var n = 0; n < nodes.length; n++) {
var list = nodes[n].classList;
for (var i = 0; i < cls.length; i++) {
if (isUndefined(force)) {
list.toggle(cls[i]);
} else if (supports.Force) {
list.toggle(cls[i], !!force);
} else {
list[force ? 'add' : 'remove'](cls[i]);
}
}
}
2021-05-27 00:23:07 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function apply(element, args, fn) {
var ref;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
args = args.reduce(function (args, arg) { return args.concat(getClasses(arg)); }, []);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var nodes = toNodes(element);
var loop = function ( n ) {
if (supports.Multiple) {
(ref = nodes[n].classList)[fn].apply(ref, args);
} else {
args.forEach(function (cls) { return nodes[n].classList[fn](cls); });
}
2021-05-27 00:23:07 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
for (var n = 0; n < nodes.length; n++) loop( n );
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function getClasses(str) {
return String(str).split(/\s|,/).filter(Boolean);
2017-11-11 04:33:51 +00:00
}
// IE 11
2019-04-22 13:31:39 +00:00
var supports = {
get Multiple() {
2021-05-27 00:23:07 +00:00
return this.get('Multiple');
2019-04-22 13:31:39 +00:00
},
get Force() {
2021-05-27 00:23:07 +00:00
return this.get('Force');
2019-04-22 13:31:39 +00:00
},
get: function(key) {
2021-05-27 00:23:07 +00:00
var ref = document.createElement('_');
var classList = ref.classList;
classList.add('a', 'b');
classList.toggle('c', false);
supports = {
Multiple: classList.contains('b'),
Force: !classList.contains('c')
};
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
return supports[key];
}
2019-04-22 13:31:39 +00:00
};
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,
2019-04-22 13:31:39 +00:00
'stroke-dasharray': true,
'stroke-dashoffset': true,
'widows': true,
'z-index': true,
'zoom': true
};
2021-05-27 00:23:07 +00:00
function css(element, property, value, priority) {
if ( priority === void 0 ) priority = '';
2017-11-11 04:33:51 +00:00
return toNodes(element).map(function (element) {
2017-11-11 04:33:51 +00:00
if (isString(property)) {
2017-11-11 04:33:51 +00:00
property = propName(property);
2017-11-11 04:33:51 +00:00
if (isUndefined(value)) {
return getStyle(element, property);
2019-04-22 13:31:39 +00:00
} else if (!value && !isNumber(value)) {
element.style.removeProperty(property);
} else {
2021-05-27 00:23:07 +00:00
element.style.setProperty(property, isNumeric(value) && !cssNumber[property] ? (value + "px") : value, priority);
}
2017-11-11 04:33:51 +00:00
} else if (isArray(property)) {
2017-11-11 04:33:51 +00:00
var styles = getStyles(element);
2017-11-11 04:33:51 +00:00
return property.reduce(function (props, property) {
props[property] = styles[propName(property)];
return props;
}, {});
2017-11-11 04:33:51 +00:00
} else if (isObject(property)) {
2021-05-27 00:23:07 +00:00
priority = value;
each(property, function (value, property) { return css(element, property, value, priority); });
}
2017-11-11 04:33:51 +00:00
return element;
2017-11-11 04:33:51 +00:00
})[0];
2017-11-11 04:33:51 +00:00
}
function getStyles(element, pseudoElt) {
2021-05-27 00:23:07 +00:00
return toWindow(element).getComputedStyle(element, pseudoElt);
}
2017-11-11 04:33:51 +00:00
function getStyle(element, property, pseudoElt) {
return getStyles(element, pseudoElt)[property];
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var parseCssVar = memoize(function (name) {
/* usage in css: .uk-name:before { content:"xyz" } */
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var element = append(document.documentElement, document.createElement('div'));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
addClass(element, ("uk-" + name));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
name = getStyle(element, 'content', ':before').replace(/^["'](.*)["']$/, '$1');
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
remove$1(element);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return name;
});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function getCssVar(name) {
return !isIE
? getStyles(document.documentElement).getPropertyValue(("--uk-" + name))
: parseCssVar(name);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
var propName = memoize(function (name) { return vendorPropName(name); });
2017-11-11 04:33:51 +00:00
var cssPrefixes = ['webkit', 'moz', 'ms'];
2017-11-11 04:33:51 +00:00
function vendorPropName(name) {
2017-11-11 04:33:51 +00:00
name = hyphenate(name);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var ref = document.documentElement;
var style = ref.style;
if (name in style) {
return name;
}
2017-11-11 04:33:51 +00:00
var i = cssPrefixes.length, prefixedName;
2017-11-11 04:33:51 +00:00
while (i--) {
prefixedName = "-" + (cssPrefixes[i]) + "-" + name;
if (prefixedName in style) {
return prefixedName;
}
2017-11-11 04:33:51 +00:00
}
}
function transition(element, props, duration, timing) {
if ( duration === void 0 ) duration = 400;
if ( timing === void 0 ) timing = 'linear';
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return Promise$1.all(toNodes(element).map(function (element) { return new Promise$1(function (resolve, reject) {
2017-11-11 04:33:51 +00:00
for (var name in props) {
var value = css(element, name);
if (value === '') {
css(element, name, value);
}
}
2017-11-11 04:33:51 +00:00
var timer = setTimeout(function () { return trigger(element, 'transitionend'); }, duration);
2017-11-11 04:33:51 +00:00
once(element, 'transitionend transitioncanceled', function (ref) {
var type = ref.type;
2017-11-11 04:33:51 +00:00
clearTimeout(timer);
removeClass(element, 'uk-transition');
css(element, {
2021-05-27 00:23:07 +00:00
transitionProperty: '',
transitionDuration: '',
transitionTimingFunction: ''
});
2021-05-27 00:23:07 +00:00
type === 'transitioncanceled' ? reject() : resolve(element);
}, {self: true});
2017-11-11 04:33:51 +00:00
addClass(element, 'uk-transition');
css(element, assign({
2021-05-27 00:23:07 +00:00
transitionProperty: Object.keys(props).map(propName).join(','),
transitionDuration: (duration + "ms"),
transitionTimingFunction: timing
}, props));
2017-11-11 04:33:51 +00:00
}); }
));
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
var Transition = {
2017-11-11 04:33:51 +00:00
start: transition,
2017-11-11 04:33:51 +00:00
stop: function(element) {
trigger(element, 'transitionend');
2021-05-27 00:23:07 +00:00
return Promise$1.resolve();
},
2017-11-11 04:33:51 +00:00
cancel: function(element) {
trigger(element, 'transitioncanceled');
},
2017-11-11 04:33:51 +00:00
inProgress: function(element) {
return hasClass(element, 'uk-transition');
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
var animationPrefix = 'uk-animation-';
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function animate$1(element, animation, duration, origin, out) {
if ( duration === void 0 ) duration = 200;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return Promise$1.all(toNodes(element).map(function (element) { return new Promise$1(function (resolve, reject) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
trigger(element, 'animationcanceled');
var timer = setTimeout(function () { return trigger(element, 'animationend'); }, duration);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
once(element, 'animationend animationcanceled', function (ref) {
var type = ref.type;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
clearTimeout(timer);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
type === 'animationcanceled' ? reject() : resolve(element);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
css(element, 'animationDuration', '');
removeClasses(element, (animationPrefix + "\\S*"));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
}, {self: true});
2017-11-11 04:33:51 +00:00
css(element, 'animationDuration', (duration + "ms"));
2021-05-27 00:23:07 +00:00
addClass(element, animation, animationPrefix + (out ? 'leave' : 'enter'));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (startsWith(animation, animationPrefix)) {
origin && addClass(element, ("uk-transform-origin-" + origin));
out && addClass(element, (animationPrefix + "reverse"));
}
2017-11-11 04:33:51 +00:00
}); }
));
2017-11-11 04:33:51 +00:00
}
var inProgress = new RegExp((animationPrefix + "(enter|leave)"));
var Animation = {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
in: animate$1,
2017-11-11 04:33:51 +00:00
out: function(element, animation, duration, origin) {
2021-05-27 00:23:07 +00:00
return animate$1(element, animation, duration, origin, true);
},
2017-11-11 04:33:51 +00:00
inProgress: function(element) {
return inProgress.test(attr(element, 'class'));
},
2017-11-11 04:33:51 +00:00
cancel: function(element) {
2021-05-27 00:23:07 +00:00
trigger(element, 'animationcanceled');
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var dirs$1 = {
width: ['left', 'right'],
height: ['top', 'bottom']
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function dimensions(element) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var rect = isElement(element)
? toNode(element).getBoundingClientRect()
: {height: height(element), width: width(element), top: 0, left: 0};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return {
height: rect.height,
width: rect.width,
top: rect.top,
left: rect.left,
bottom: rect.top + rect.height,
right: rect.left + rect.width
};
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function offset(element, coordinates) {
var currentOffset = dimensions(element);
var ref = toWindow(element);
var pageYOffset = ref.pageYOffset;
var pageXOffset = ref.pageXOffset;
var offsetBy = {height: pageYOffset, width: pageXOffset};
for (var dir in dirs$1) {
for (var i in dirs$1[dir]) {
currentOffset[dirs$1[dir][i]] += offsetBy[dir];
}
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!coordinates) {
return currentOffset;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var pos = css(element, 'position');
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
each(css(element, ['left', 'top']), function (value, prop) { return css(element, prop, coordinates[prop]
- currentOffset[prop]
+ toFloat(pos === 'absolute' && value === 'auto'
? position(element)[prop]
: value)
); }
);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function position(element) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var ref = offset(element);
var top = ref.top;
var left = ref.left;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var ref$1 = toNode(element);
var ref$1_ownerDocument = ref$1.ownerDocument;
var body = ref$1_ownerDocument.body;
var documentElement = ref$1_ownerDocument.documentElement;
var offsetParent = ref$1.offsetParent;
var parent = offsetParent || documentElement;
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
while (parent && (parent === body || parent === documentElement) && css(parent, 'position') === 'static') {
parent = parent.parentNode;
}
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
if (isElement(parent)) {
var parentOffset = offset(parent);
top -= parentOffset.top + toFloat(css(parent, 'borderTopWidth'));
left -= parentOffset.left + toFloat(css(parent, 'borderLeftWidth'));
}
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
return {
top: top - toFloat(css(element, 'marginTop')),
left: left - toFloat(css(element, 'marginLeft'))
};
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function offsetPosition(element) {
var offset = [0, 0];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
element = toNode(element);
2021-05-27 00:23:07 +00:00
do {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
offset[0] += element.offsetTop;
offset[1] += element.offsetLeft;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (css(element, 'position') === 'fixed') {
var win = toWindow(element);
offset[0] += win.pageYOffset;
offset[1] += win.pageXOffset;
return offset;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
} while ((element = element.offsetParent));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return offset;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var height = dimension('height');
var width = dimension('width');
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function dimension(prop) {
var propName = ucfirst(prop);
return function (element, value) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isUndefined(value)) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isWindow(element)) {
return element[("inner" + propName)];
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isDocument(element)) {
var doc = element.documentElement;
return Math.max(doc[("offset" + propName)], doc[("scroll" + propName)]);
}
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
element = toNode(element);
2017-11-11 04:33:51 +00:00
value = css(element, prop);
2019-04-22 13:31:39 +00:00
value = value === 'auto' ? element[("offset" + propName)] : toFloat(value) || 0;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return value - boxModelAdjust(element, prop);
2017-11-11 04:33:51 +00:00
} else {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return css(element, prop, !value && value !== 0
? ''
2021-05-27 00:23:07 +00:00
: +value + boxModelAdjust(element, prop) + 'px'
);
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function boxModelAdjust(element, prop, sizing) {
2019-04-22 13:31:39 +00:00
if ( sizing === void 0 ) sizing = 'border-box';
return css(element, 'boxSizing') === sizing
2021-05-27 00:23:07 +00:00
? dirs$1[prop].map(ucfirst).reduce(function (value, prop) { return value
+ toFloat(css(element, ("padding" + prop)))
+ toFloat(css(element, ("border" + prop + "Width"))); }
, 0)
: 0;
2017-11-11 04:33:51 +00:00
}
function flipPosition(pos) {
2021-05-27 00:23:07 +00:00
for (var dir in dirs$1) {
for (var i in dirs$1[dir]) {
if (dirs$1[dir][i] === pos) {
return dirs$1[dir][1 - i];
}
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
}
return pos;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function toPx(value, property, element) {
if ( property === void 0 ) property = 'width';
if ( element === void 0 ) element = window;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return isNumeric(value)
? +value
: endsWith(value, 'vh')
2021-05-27 00:23:07 +00:00
? percent(height(toWindow(element)), value)
2019-04-22 13:31:39 +00:00
: endsWith(value, 'vw')
2021-05-27 00:23:07 +00:00
? percent(width(toWindow(element)), value)
2019-04-22 13:31:39 +00:00
: endsWith(value, '%')
2021-05-27 00:23:07 +00:00
? percent(dimensions(element)[property], value)
2019-04-22 13:31:39 +00:00
: toFloat(value);
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function percent(base, value) {
return base * toFloat(value) / 100;
}
2017-11-11 04:33:51 +00:00
/*
Based on:
Copyright (c) 2016 Wilson Page wilsonpage@me.com
https://github.com/wilsonpage/fastdom
*/
2017-11-11 04:33:51 +00:00
var fastdom = {
2017-11-11 04:33:51 +00:00
reads: [],
writes: [],
2017-11-11 04:33:51 +00:00
read: function(task) {
this.reads.push(task);
scheduleFlush();
return task;
},
2017-11-11 04:33:51 +00:00
write: function(task) {
this.writes.push(task);
scheduleFlush();
return task;
},
2017-11-11 04:33:51 +00:00
clear: function(task) {
2021-05-27 00:23:07 +00:00
remove(this.reads, task);
remove(this.writes, task);
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
flush: flush
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function flush(recursion) {
if ( recursion === void 0 ) recursion = 1;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
runTasks(fastdom.reads);
runTasks(fastdom.writes.splice(0));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
fastdom.scheduled = false;
if (fastdom.reads.length || fastdom.writes.length) {
scheduleFlush(recursion + 1);
}
2021-05-27 00:23:07 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var RECURSION_LIMIT = 4;
function scheduleFlush(recursion) {
if (fastdom.scheduled) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
fastdom.scheduled = true;
if (recursion && recursion < RECURSION_LIMIT) {
Promise$1.resolve().then(function () { return flush(recursion); });
} else {
requestAnimationFrame(function () { return flush(); });
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
2017-11-11 04:33:51 +00:00
}
function runTasks(tasks) {
var task;
while ((task = tasks.shift())) {
2021-05-27 00:23:07 +00:00
try {
task();
} catch (e) {
console.error(e);
}
}
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function remove(array, item) {
var index = array.indexOf(item);
2021-05-27 00:23:07 +00:00
return ~index && array.splice(index, 1);
2017-11-11 04:33:51 +00:00
}
function MouseTracker() {}
2017-11-11 04:33:51 +00:00
MouseTracker.prototype = {
2017-11-11 04:33:51 +00:00
positions: [],
2017-11-11 04:33:51 +00:00
init: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
this.positions = [];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var position;
this.unbind = on(document, 'mousemove', function (e) { return position = getEventPos(e); });
this.interval = setInterval(function () {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!position) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this$1.positions.push(position);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this$1.positions.length > 5) {
this$1.positions.shift();
}
}, 50);
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
cancel: function() {
2021-05-27 00:23:07 +00:00
this.unbind && this.unbind();
this.interval && clearInterval(this.interval);
},
2017-11-11 04:33:51 +00:00
movesTo: function(target) {
2017-11-11 04:33:51 +00:00
if (this.positions.length < 2) {
return false;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var p = target.getBoundingClientRect();
var left = p.left;
var right = p.right;
var top = p.top;
var bottom = p.bottom;
var ref = this.positions;
2021-05-27 00:23:07 +00:00
var prevPosition = ref[0];
var position = last(this.positions);
var path = [prevPosition, position];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (pointInRect(position, p)) {
return false;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var diagonals = [[{x: left, y: top}, {x: right, y: bottom}], [{x: left, y: bottom}, {x: right, y: top}]];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return diagonals.some(function (diagonal) {
var intersection = intersect(path, diagonal);
return intersection && pointInRect(intersection, p);
});
2017-11-11 04:33:51 +00:00
}
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
// Inspired by http://paulbourke.net/geometry/pointlineplane/
function intersect(ref, ref$1) {
var ref_0 = ref[0];
var x1 = ref_0.x;
var y1 = ref_0.y;
var ref_1 = ref[1];
var x2 = ref_1.x;
var y2 = ref_1.y;
var ref$1_0 = ref$1[0];
var x3 = ref$1_0.x;
var y3 = ref$1_0.y;
var ref$1_1 = ref$1[1];
var x4 = ref$1_1.x;
var y4 = ref$1_1.y;
var denominator = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
// Lines are parallel
if (denominator === 0) {
return false;
}
var ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denominator;
if (ua < 0) {
return false;
}
// Return an object with the x and y coordinates of the intersection
return {x: x1 + ua * (x2 - x1), y: y1 + ua * (y2 - y1)};
2017-11-11 04:33:51 +00:00
}
var strats = {};
strats.events =
strats.created =
strats.beforeConnect =
strats.connected =
strats.beforeDisconnect =
strats.disconnected =
2019-04-22 13:31:39 +00:00
strats.destroy = concatStrat;
2019-04-22 13:31:39 +00:00
// args strategy
strats.args = function (parentVal, childVal) {
2021-05-27 00:23:07 +00:00
return childVal !== false && concatStrat(childVal || parentVal);
2017-11-11 04:33:51 +00:00
};
// update strategy
strats.update = function (parentVal, childVal) {
2021-05-27 00:23:07 +00:00
return sortBy$1(concatStrat(parentVal, isFunction(childVal) ? {read: childVal} : childVal), 'order');
};
2017-11-11 04:33:51 +00:00
// property strategy
strats.props = function (parentVal, childVal) {
2017-11-11 04:33:51 +00:00
if (isArray(childVal)) {
childVal = childVal.reduce(function (value, key) {
value[key] = String;
return value;
}, {});
}
2017-11-11 04:33:51 +00:00
return strats.methods(parentVal, childVal);
};
2017-11-11 04:33:51 +00:00
// extend strategy
strats.computed =
strats.methods = function (parentVal, childVal) {
return childVal
? parentVal
? assign({}, parentVal, childVal)
: childVal
: parentVal;
};
2017-11-11 04:33:51 +00:00
// data strategy
strats.data = function (parentVal, childVal, vm) {
2017-11-11 04:33:51 +00:00
if (!vm) {
2017-11-11 04:33:51 +00:00
if (!childVal) {
return parentVal;
}
2017-11-11 04:33:51 +00:00
if (!parentVal) {
return childVal;
}
2017-11-11 04:33:51 +00:00
return function (vm) {
return mergeFnData(parentVal, childVal, vm);
};
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
return mergeFnData(parentVal, childVal, vm);
};
2017-11-11 04:33:51 +00:00
function mergeFnData(parentVal, childVal, vm) {
return strats.computed(
isFunction(parentVal)
? parentVal.call(vm, vm)
: parentVal,
isFunction(childVal)
? childVal.call(vm, vm)
: childVal
);
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
// 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
2019-04-22 13:31:39 +00:00
function defaultStrat(parentVal, childVal) {
return isUndefined(childVal) ? parentVal : childVal;
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
function mergeOptions(parent, child, vm) {
2017-11-11 04:33:51 +00:00
var options = {};
2017-11-11 04:33:51 +00:00
if (isFunction(child)) {
child = child.options;
}
2017-11-11 04:33:51 +00:00
if (child.extends) {
parent = mergeOptions(parent, child.extends, vm);
}
2017-11-11 04:33:51 +00:00
if (child.mixins) {
for (var i = 0, l = child.mixins.length; i < l; i++) {
parent = mergeOptions(parent, child.mixins[i], vm);
2017-11-11 04:33:51 +00:00
}
}
for (var key in parent) {
mergeKey(key);
}
2017-11-11 04:33:51 +00:00
for (var key$1 in child) {
if (!hasOwn(parent, key$1)) {
mergeKey(key$1);
}
}
2017-11-11 04:33:51 +00:00
function mergeKey(key) {
options[key] = (strats[key] || defaultStrat)(parent[key], child[key], vm);
}
2017-11-11 04:33:51 +00:00
return options;
}
2017-11-11 04:33:51 +00:00
function parseOptions(options, args) {
var obj;
2017-11-11 04:33:51 +00:00
if ( args === void 0 ) args = [];
2017-11-11 04:33:51 +00:00
try {
2017-11-11 04:33:51 +00:00
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;
}, {});
2017-11-11 04:33:51 +00:00
} catch (e) {
return {};
}
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function play(el) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isIFrame(el)) {
call(el, {func: 'playVideo', method: 'play'});
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isHTML5(el)) {
try {
el.play().catch(noop);
} catch (e) {}
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function pause(el) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isIFrame(el)) {
call(el, {func: 'pauseVideo', method: 'pause'});
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isHTML5(el)) {
el.pause();
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function mute(el) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isIFrame(el)) {
call(el, {func: 'mute', method: 'setVolume', value: 0});
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isHTML5(el)) {
el.muted = true;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function isHTML5(el) {
return el && el.tagName === 'VIDEO';
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function isIFrame(el) {
return el && el.tagName === 'IFRAME' && (isYoutube(el) || isVimeo(el));
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function isYoutube(el) {
return !!el.src.match(/\/\/.*?youtube(-nocookie)?\.[a-z]+\/(watch\?v=[^&\s]+|embed)|youtu\.be\/.*/);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function isVimeo(el) {
return !!el.src.match(/vimeo\.com\/video\/.*/);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function call(el, cmd) {
enableApi(el).then(function () { return post(el, cmd); });
}
2021-05-27 00:23:07 +00:00
function post(el, cmd) {
try {
el.contentWindow.postMessage(JSON.stringify(assign({event: 'command'}, cmd)), '*');
} catch (e) {}
}
var stateKey$1 = '_ukPlayer';
var counter = 0;
function enableApi(el) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (el[stateKey$1]) {
return el[stateKey$1];
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
var youtube = isYoutube(el);
var vimeo = isVimeo(el);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var id = ++counter;
var poller;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return el[stateKey$1] = new Promise$1(function (resolve) {
youtube && once(el, 'load', function () {
var listener = function () { return post(el, {event: 'listening', id: id}); };
poller = setInterval(listener, 100);
listener();
});
once(window, 'message', resolve, false, function (ref) {
var data = ref.data;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
try {
data = JSON.parse(data);
return data && (youtube && data.id === id && data.event === 'onReady' || vimeo && Number(data.player_id) === id);
} catch (e) {}
});
el.src = "" + (el.src) + (includes(el.src, '?') ? '&' : '?') + (youtube ? 'enablejsapi=1' : ("api=1&player_id=" + id));
}).then(function () { return clearInterval(poller); });
}
function isInView(element, offsetTop, offsetLeft) {
if ( offsetTop === void 0 ) offsetTop = 0;
if ( offsetLeft === void 0 ) offsetLeft = 0;
if (!isVisible(element)) {
return false;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return intersectRect.apply(void 0, scrollParents(element).map(function (parent) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var ref = offset(getViewport$1(parent));
var top = ref.top;
var left = ref.left;
var bottom = ref.bottom;
var right = ref.right;
return {
top: top - offsetTop,
left: left - offsetLeft,
bottom: bottom + offsetTop,
right: right + offsetLeft
};
}).concat(offset(element)));
}
function scrollTop(element, top) {
if (isWindow(element) || isDocument(element)) {
element = getScrollingElement(element);
} else {
element = toNode(element);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
element.scrollTop = top;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function scrollIntoView(element, ref) {
if ( ref === void 0 ) ref = {};
var offsetBy = ref.offset; if ( offsetBy === void 0 ) offsetBy = 0;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!isVisible(element)) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var parents = scrollParents(element);
var diff = 0;
return parents.reduce(function (fn, scrollElement, i) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var scrollTop = scrollElement.scrollTop;
var scrollHeight = scrollElement.scrollHeight;
var maxScroll = scrollHeight - getViewportClientHeight(scrollElement);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var top = Math.ceil(
offset(parents[i - 1] || element).top
- offset(getViewport$1(scrollElement)).top
- offsetBy
+ diff
+ scrollTop
);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (top > maxScroll) {
diff = top - maxScroll;
top = maxScroll;
} else {
diff = 0;
}
return function () { return scrollTo(scrollElement, top - scrollTop).then(fn); };
}, function () { return Promise$1.resolve(); })();
function scrollTo(element, top) {
return new Promise$1(function (resolve) {
var scroll = element.scrollTop;
var duration = getDuration(Math.abs(top));
var start = Date.now();
(function step() {
var percent = ease(clamp((Date.now() - start) / duration));
scrollTop(element, scroll + top * percent);
// scroll more if we have not reached our destination
if (percent !== 1) {
requestAnimationFrame(step);
} else {
resolve();
}
})();
});
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function getDuration(dist) {
return 40 * Math.pow(dist, .375);
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function ease(k) {
return 0.5 * (1 - Math.cos(Math.PI * k));
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function scrolledOver(element, heightOffset) {
if ( heightOffset === void 0 ) heightOffset = 0;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!isVisible(element)) {
return 0;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var ref = scrollParents(element, /auto|scroll/, true);
var scrollElement = ref[0];
var scrollHeight = scrollElement.scrollHeight;
var scrollTop = scrollElement.scrollTop;
var clientHeight = getViewportClientHeight(scrollElement);
var viewportTop = offsetPosition(element)[0] - scrollTop - offsetPosition(scrollElement)[0];
var viewportDist = Math.min(clientHeight, viewportTop + scrollTop);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var top = viewportTop - viewportDist;
var dist = Math.min(
element.offsetHeight + heightOffset + viewportDist,
scrollHeight - (viewportTop + scrollTop),
scrollHeight - clientHeight
);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return clamp(-1 * top / dist);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function scrollParents(element, overflowRe, scrollable) {
if ( overflowRe === void 0 ) overflowRe = /auto|scroll|hidden/;
if ( scrollable === void 0 ) scrollable = false;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var scrollEl = getScrollingElement(element);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var ancestors = parents(element).reverse();
ancestors = ancestors.slice(ancestors.indexOf(scrollEl) + 1);
var fixedIndex = findIndex(ancestors, function (el) { return css(el, 'position') === 'fixed'; });
if (~fixedIndex) {
ancestors = ancestors.slice(fixedIndex);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return [scrollEl].concat(ancestors.filter(function (parent) { return overflowRe.test(css(parent, 'overflow')) && (!scrollable || parent.scrollHeight > getViewportClientHeight(parent)); })
).reverse();
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function getViewport$1(scrollElement) {
return scrollElement === getScrollingElement(scrollElement) ? window : scrollElement;
}
// iOS 12 returns <body> as scrollingElement
function getViewportClientHeight(scrollElement) {
return (scrollElement === getScrollingElement(scrollElement) ? document.documentElement : scrollElement).clientHeight;
}
function getScrollingElement(element) {
var ref = toWindow(element);
var document = ref.document;
return document.scrollingElement || document.documentElement;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var dirs = {
width: ['x', 'left', 'right'],
height: ['y', 'top', 'bottom']
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function positionAt(element, target, elAttach, targetAttach, elOffset, targetOffset, flip, boundary) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
elAttach = getPos(elAttach);
targetAttach = getPos(targetAttach);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var flipped = {element: elAttach, target: targetAttach};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!element || !target) {
return flipped;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var dim = offset(element);
var targetDim = offset(target);
var position = targetDim;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
moveTo(position, elAttach, dim, -1);
moveTo(position, targetAttach, targetDim, 1);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
elOffset = getOffsets(elOffset, dim.width, dim.height);
targetOffset = getOffsets(targetOffset, targetDim.width, targetDim.height);
elOffset['x'] += targetOffset['x'];
elOffset['y'] += targetOffset['y'];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
position.left += elOffset['x'];
position.top += elOffset['y'];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (flip) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var boundaries = scrollParents(element).map(getViewport$1);
2021-05-27 00:23:07 +00:00
if (boundary && !includes(boundaries, boundary)) {
boundaries.unshift(boundary);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
boundaries = boundaries.map(function (el) { return offset(el); });
each(dirs, function (ref, prop) {
var dir = ref[0];
var align = ref[1];
var alignFlip = ref[2];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
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);
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function apply(elemOffset, targetOffset) {
var newVal = toFloat((position[align] + elemOffset + targetOffset - elOffset[dir] * 2).toFixed(4));
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;
}
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
});
}
offset(element, position);
return flipped;
}
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'];
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return {
x: x.test(pos[0]) ? pos[0] : 'center',
y: y.test(pos[1]) ? pos[1] : 'center'
};
}
function getOffsets(offsets, width, height) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var ref = (offsets || '').split(' ');
var x = ref[0];
var y = ref[1];
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return {
x: x ? toFloat(x) * (endsWith(x, '%') ? width / 100 : 1) : 0,
y: y ? toFloat(y) * (endsWith(y, '%') ? height / 100 : 1) : 0
};
}
2017-11-11 04:33:51 +00:00
var util = /*#__PURE__*/Object.freeze({
2021-05-27 00:23:07 +00:00
__proto__: null,
ajax: ajax,
getImage: getImage,
transition: transition,
Transition: Transition,
2021-05-27 00:23:07 +00:00
animate: animate$1,
Animation: Animation,
attr: attr,
hasAttr: hasAttr,
removeAttr: removeAttr,
data: data,
addClass: addClass,
removeClass: removeClass,
removeClasses: removeClasses,
replaceClass: replaceClass,
hasClass: hasClass,
toggleClass: toggleClass,
2021-05-27 00:23:07 +00:00
dimensions: dimensions,
offset: offset,
position: position,
2021-05-27 00:23:07 +00:00
offsetPosition: offsetPosition,
height: height,
width: width,
2019-04-22 13:31:39 +00:00
boxModelAdjust: boxModelAdjust,
flipPosition: flipPosition,
2019-04-22 13:31:39 +00:00
toPx: toPx,
ready: ready,
empty: empty,
html: html,
prepend: prepend,
append: append,
before: before,
after: after,
2021-05-27 00:23:07 +00:00
remove: remove$1,
wrapAll: wrapAll,
wrapInner: wrapInner,
unwrap: unwrap,
fragment: fragment,
2021-05-27 00:23:07 +00:00
apply: apply$1,
2019-04-22 13:31:39 +00:00
$: $,
$$: $$,
2021-05-27 00:23:07 +00:00
inBrowser: inBrowser,
isIE: isIE,
isRtl: isRtl,
hasTouch: hasTouch,
pointerDown: pointerDown,
pointerMove: pointerMove,
pointerUp: pointerUp,
pointerEnter: pointerEnter,
pointerLeave: pointerLeave,
2019-04-22 13:31:39 +00:00
pointerCancel: pointerCancel,
on: on,
off: off,
once: once,
trigger: trigger,
createEvent: createEvent,
toEventTargets: toEventTargets,
2019-04-22 13:31:39 +00:00
isTouch: isTouch,
getEventPos: getEventPos,
fastdom: fastdom,
isVoidElement: isVoidElement,
isVisible: isVisible,
selInput: selInput,
isInput: isInput,
2021-05-27 00:23:07 +00:00
isFocusable: isFocusable,
parent: parent,
filter: filter$1,
matches: matches,
closest: closest,
within: within,
2021-05-27 00:23:07 +00:00
parents: parents,
children: children,
index: index,
hasOwn: hasOwn,
hyphenate: hyphenate,
camelize: camelize,
ucfirst: ucfirst,
startsWith: startsWith,
endsWith: endsWith,
includes: includes,
2019-04-22 13:31:39 +00:00
findIndex: findIndex,
isArray: isArray,
isFunction: isFunction,
isObject: isObject,
isPlainObject: isPlainObject,
isWindow: isWindow,
isDocument: isDocument,
isNode: isNode,
2021-05-27 00:23:07 +00:00
isElement: isElement,
isBoolean: isBoolean,
isString: isString,
isNumber: isNumber,
isNumeric: isNumeric,
2019-04-22 13:31:39 +00:00
isEmpty: isEmpty,
isUndefined: isUndefined,
toBoolean: toBoolean,
toNumber: toNumber,
toFloat: toFloat,
2021-05-27 00:23:07 +00:00
toArray: toArray,
toNode: toNode,
toNodes: toNodes,
2021-05-27 00:23:07 +00:00
toWindow: toWindow,
toMs: toMs,
2019-04-22 13:31:39 +00:00
isEqual: isEqual,
swap: swap,
assign: assign,
2021-05-27 00:23:07 +00:00
last: last,
each: each,
2021-05-27 00:23:07 +00:00
sortBy: sortBy$1,
2019-04-22 13:31:39 +00:00
uniqueBy: uniqueBy,
clamp: clamp,
noop: noop,
intersectRect: intersectRect,
pointInRect: pointInRect,
Dimensions: Dimensions,
2021-05-27 00:23:07 +00:00
getIndex: getIndex,
memoize: memoize,
MouseTracker: MouseTracker,
mergeOptions: mergeOptions,
parseOptions: parseOptions,
2021-05-27 00:23:07 +00:00
play: play,
pause: pause,
mute: mute,
positionAt: positionAt,
Promise: Promise$1,
Deferred: Deferred,
query: query,
queryAll: queryAll,
find: find,
findAll: findAll,
escape: escape,
css: css,
getCssVar: getCssVar,
2021-05-27 00:23:07 +00:00
propName: propName,
isInView: isInView,
scrollTop: scrollTop,
scrollIntoView: scrollIntoView,
scrolledOver: scrolledOver,
scrollParents: scrollParents,
getViewport: getViewport$1,
getViewportClientHeight: getViewportClientHeight
});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function globalAPI (UIkit) {
2017-11-11 04:33:51 +00:00
var DATA = UIkit.data;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
UIkit.use = function (plugin) {
2017-11-11 04:33:51 +00:00
if (plugin.installed) {
return;
}
2017-11-11 04:33:51 +00:00
plugin.call(null, this);
plugin.installed = true;
2017-11-11 04:33:51 +00:00
return this;
};
2017-11-11 04:33:51 +00:00
UIkit.mixin = function (mixin, component) {
component = (isString(component) ? UIkit.component(component) : component) || this;
component.options = mergeOptions(component.options, mixin);
};
2017-11-11 04:33:51 +00:00
UIkit.extend = function (options) {
2017-11-11 04:33:51 +00:00
options = options || {};
2017-11-11 04:33:51 +00:00
var Super = this;
2019-04-22 13:31:39 +00:00
var Sub = function UIkitComponent(options) {
this._init(options);
};
2017-11-11 04:33:51 +00:00
Sub.prototype = Object.create(Super.prototype);
Sub.prototype.constructor = Sub;
Sub.options = mergeOptions(Super.options, options);
2017-11-11 04:33:51 +00:00
Sub.super = Super;
Sub.extend = Super.extend;
2017-11-11 04:33:51 +00:00
return Sub;
};
2017-11-11 04:33:51 +00:00
UIkit.update = function (element, e) {
2017-11-11 04:33:51 +00:00
element = element ? toNode(element) : document.body;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
parents(element).reverse().forEach(function (element) { return update(element[DATA], e); });
apply$1(element, function (element) { return update(element[DATA], e); });
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
var container;
Object.defineProperty(UIkit, 'container', {
2017-11-11 04:33:51 +00:00
get: function() {
return container || document.body;
},
2017-11-11 04:33:51 +00:00
set: function(element) {
container = $(element);
}
2017-11-11 04:33:51 +00:00
});
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function update(data, e) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (!data) {
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
for (var name in data) {
if (data[name]._connected) {
data[name]._callUpdate(e);
}
}
2017-11-11 04:33:51 +00:00
}
}
2017-11-11 04:33:51 +00:00
function hooksAPI (UIkit) {
2017-11-11 04:33:51 +00:00
UIkit.prototype._callHook = function (hook) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
var handlers = this.$options[hook];
2017-11-11 04:33:51 +00:00
if (handlers) {
handlers.forEach(function (handler) { return handler.call(this$1); });
2017-11-11 04:33:51 +00:00
}
};
2017-11-11 04:33:51 +00:00
UIkit.prototype._callConnected = function () {
2017-11-11 04:33:51 +00:00
if (this._connected) {
return;
2017-11-11 04:33:51 +00:00
}
this._data = {};
2019-04-22 13:31:39 +00:00
this._computeds = {};
2021-05-27 00:23:07 +00:00
this._initProps();
2017-11-11 04:33:51 +00:00
this._callHook('beforeConnect');
this._connected = true;
2017-11-11 04:33:51 +00:00
this._initEvents();
2021-05-27 00:23:07 +00:00
this._initObservers();
2017-11-11 04:33:51 +00:00
this._callHook('connected');
this._callUpdate();
};
UIkit.prototype._callDisconnected = function () {
2017-11-11 04:33:51 +00:00
if (!this._connected) {
return;
2017-11-11 04:33:51 +00:00
}
this._callHook('beforeDisconnect');
2021-05-27 00:23:07 +00:00
this._disconnectObservers();
this._unbindEvents();
this._callHook('disconnected');
2017-11-11 04:33:51 +00:00
this._connected = false;
2021-05-27 00:23:07 +00:00
delete this._watch;
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
UIkit.prototype._callUpdate = function (e) {
var this$1 = this;
2019-04-22 13:31:39 +00:00
if ( e === void 0 ) e = 'update';
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this._connected) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (e === 'update' || e === 'resize') {
2019-04-22 13:31:39 +00:00
this._callWatches();
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.$options.update) {
return;
}
if (!this._updates) {
this._updates = new Set();
fastdom.read(function () {
runUpdates.call(this$1, this$1._updates);
delete this$1._updates;
});
}
this._updates.add(e.type || e);
};
UIkit.prototype._callWatches = function () {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this._watch) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var initital = !hasOwn(this, '_watch');
this._watch = fastdom.read(function () {
var ref = this$1;
var computed = ref.$options.computed;
var _computeds = ref._computeds;
for (var key in computed) {
var hasPrev = hasOwn(_computeds, key);
var prev = _computeds[key];
delete _computeds[key];
var ref$1 = computed[key];
var watch = ref$1.watch;
var immediate = ref$1.immediate;
if (watch && (
initital && immediate
|| hasPrev && !isEqual(prev, this$1[key])
)) {
watch.call(this$1, this$1[key], prev);
}
}
this$1._watch = null;
});
};
function runUpdates(types) {
var this$1 = this;
var updates = this.$options.update;
var loop = function ( i ) {
var ref = updates[i];
var read = ref.read;
var write = ref.write;
var events = ref.events;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!types.has('update') && (!events || !events.some(function (type) { return types.has(type); }))) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var result = (void 0);
if (read) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
result = read.call(this$1, this$1._data, types);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (result && isPlainObject(result)) {
assign(this$1._data, result);
}
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (write && result !== false) {
fastdom.write(function () { return write.call(this$1, this$1._data, types); });
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
for (var i = 0; i < updates.length; i++) loop( i );
}
}
2017-11-11 04:33:51 +00:00
function stateAPI (UIkit) {
2017-11-11 04:33:51 +00:00
var uid = 0;
2017-11-11 04:33:51 +00:00
UIkit.prototype._init = function (options) {
2017-11-11 04:33:51 +00:00
options = options || {};
options.data = normalizeData(options, this.constructor.options);
2017-11-11 04:33:51 +00:00
this.$options = mergeOptions(this.constructor.options, options, this);
this.$el = null;
this.$props = {};
2017-11-11 04:33:51 +00:00
this._uid = uid++;
this._initData();
this._initMethods();
this._initComputeds();
this._callHook('created');
2017-11-11 04:33:51 +00:00
if (options.el) {
this.$mount(options.el);
}
};
2017-11-11 04:33:51 +00:00
UIkit.prototype._initData = function () {
2017-11-11 04:33:51 +00:00
var ref = this.$options;
2019-04-22 13:31:39 +00:00
var data = ref.data; if ( data === void 0 ) data = {};
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
for (var key in data) {
this.$props[key] = this[key] = data[key];
}
};
2017-11-11 04:33:51 +00:00
UIkit.prototype._initMethods = function () {
2017-11-11 04:33:51 +00:00
var ref = this.$options;
var methods = ref.methods;
2017-11-11 04:33:51 +00:00
if (methods) {
for (var key in methods) {
2021-05-27 00:23:07 +00:00
this[key] = methods[key].bind(this);
}
}
};
2017-11-11 04:33:51 +00:00
UIkit.prototype._initComputeds = function () {
2017-11-11 04:33:51 +00:00
var ref = this.$options;
var computed = ref.computed;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this._computeds = {};
2017-11-11 04:33:51 +00:00
if (computed) {
for (var key in computed) {
2019-04-22 13:31:39 +00:00
registerComputed(this, key, computed[key]);
2017-11-11 04:33:51 +00:00
}
}
};
2017-11-11 04:33:51 +00:00
UIkit.prototype._initProps = function (props) {
2017-11-11 04:33:51 +00:00
var key;
2017-11-11 04:33:51 +00:00
props = props || getProps(this.$options, this.$name);
2017-11-11 04:33:51 +00:00
for (key in props) {
if (!isUndefined(props[key])) {
2019-04-22 13:31:39 +00:00
this.$props[key] = props[key];
}
}
2017-11-11 04:33:51 +00:00
var exclude = [this.$options.computed, this.$options.methods];
2019-04-22 13:31:39 +00:00
for (key in this.$props) {
if (key in props && notIn(exclude, key)) {
2019-04-22 13:31:39 +00:00
this[key] = this.$props[key];
}
2017-11-11 04:33:51 +00:00
}
};
2017-11-11 04:33:51 +00:00
UIkit.prototype._initEvents = function () {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this._events = [];
var ref = this.$options;
var events = ref.events;
2017-11-11 04:33:51 +00:00
if (events) {
2017-11-11 04:33:51 +00:00
events.forEach(function (event) {
2017-11-11 04:33:51 +00:00
if (!hasOwn(event, 'handler')) {
for (var key in event) {
registerEvent(this$1, event[key], key);
}
} else {
registerEvent(this$1, event);
}
2017-11-11 04:33:51 +00:00
});
}
};
2017-11-11 04:33:51 +00:00
UIkit.prototype._unbindEvents = function () {
this._events.forEach(function (unbind) { return unbind(); });
2021-05-27 00:23:07 +00:00
delete this._events;
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
UIkit.prototype._initObservers = function () {
this._observers = [
initChildListObserver(this),
initPropsObserver(this)
];
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
UIkit.prototype._disconnectObservers = function () {
this._observers.forEach(function (observer) { return observer && observer.disconnect(); }
);
};
2017-11-11 04:33:51 +00:00
function getProps(opts, name) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
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;
2017-11-11 04:33:51 +00:00
if (!props) {
2019-04-22 13:31:39 +00:00
return data$1;
2017-11-11 04:33:51 +00:00
}
for (var key in props) {
var prop = hyphenate(key);
var value = data(el, prop);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isUndefined(value)) {
continue;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
value = props[key] === Boolean && value === ''
? true
: coerce(props[key], value);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (prop === 'target' && (!value || startsWith(value, '_'))) {
continue;
}
2021-05-27 00:23:07 +00:00
data$1[key] = value;
}
2017-11-11 04:33:51 +00:00
var options = parseOptions(data(el, name), args);
2017-11-11 04:33:51 +00:00
for (var key$1 in options) {
var prop$1 = camelize(key$1);
if (props[prop$1] !== undefined) {
2019-04-22 13:31:39 +00:00
data$1[prop$1] = coerce(props[prop$1], options[key$1]);
}
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return data$1;
}
2017-11-11 04:33:51 +00:00
function registerComputed(component, key, cb) {
Object.defineProperty(component, key, {
2017-11-11 04:33:51 +00:00
enumerable: true,
2017-11-11 04:33:51 +00:00
get: function() {
2017-11-11 04:33:51 +00:00
var _computeds = component._computeds;
var $props = component.$props;
var $el = component.$el;
2017-11-11 04:33:51 +00:00
if (!hasOwn(_computeds, key)) {
2019-04-22 13:31:39 +00:00
_computeds[key] = (cb.get || cb).call(component, $props, $el);
}
2017-11-11 04:33:51 +00:00
return _computeds[key];
},
2017-11-11 04:33:51 +00:00
set: function(value) {
2019-04-22 13:31:39 +00:00
var _computeds = component._computeds;
_computeds[key] = cb.set ? cb.set.call(component, value) : value;
if (isUndefined(_computeds[key])) {
delete _computeds[key];
}
}
2017-11-11 04:33:51 +00:00
});
}
2017-11-11 04:33:51 +00:00
function registerEvent(component, event, key) {
2017-11-11 04:33:51 +00:00
if (!isPlainObject(event)) {
event = ({name: key, handler: event});
}
2017-11-11 04:33:51 +00:00
var name = event.name;
var el = event.el;
var handler = event.handler;
var capture = event.capture;
var passive = event.passive;
var delegate = event.delegate;
2019-04-22 13:31:39 +00:00
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;
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
if (!el || filter && !filter.call(component)) {
return;
}
2017-11-11 04:33:51 +00:00
component._events.push(
on(
el,
name,
!delegate
? null
: isString(delegate)
? delegate
: delegate.call(component),
2021-05-27 00:23:07 +00:00
isString(handler) ? component[handler] : handler.bind(component),
{passive: passive, capture: capture, self: self}
)
);
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
function notIn(options, key) {
return options.every(function (arr) { return !arr || !hasOwn(arr, key); });
}
2017-11-11 04:33:51 +00:00
function coerce(type, value) {
2017-11-11 04:33:51 +00:00
if (type === Boolean) {
return toBoolean(value);
} else if (type === Number) {
return toNumber(value);
} else if (type === 'list') {
return toList(value);
}
2017-11-11 04:33:51 +00:00
return type ? type(value) : value;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function toList(value) {
return isArray(value)
? value
: isString(value)
? value.split(/,(?![^(]*\))/).map(function (value) { return isNumeric(value)
? toNumber(value)
: toBoolean(value.trim()); })
: [value];
}
function normalizeData(ref, ref$1) {
2019-04-22 13:31:39 +00:00
var data = ref.data;
var args = ref$1.args;
var props = ref$1.props; if ( props === void 0 ) props = {};
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
data = isArray(data)
? !isEmpty(args)
? data.slice(0, args.length).reduce(function (data, value, index) {
if (isPlainObject(value)) {
2019-04-22 13:31:39 +00:00
assign(data, value);
} else {
2019-04-22 13:31:39 +00:00
data[args[index]] = value;
}
2019-04-22 13:31:39 +00:00
return data;
}, {})
: undefined
2019-04-22 13:31:39 +00:00
: data;
2019-04-22 13:31:39 +00:00
if (data) {
for (var key in data) {
if (isUndefined(data[key])) {
delete data[key];
} else {
2021-05-27 00:23:07 +00:00
data[key] = props[key] ? coerce(props[key], data[key]) : data[key];
}
}
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return data;
}
2021-05-27 00:23:07 +00:00
function initChildListObserver(component) {
var ref = component.$options;
var el = ref.el;
var observer = new MutationObserver(function () { return component.$emit(); });
observer.observe(el, {
childList: true,
subtree: true
});
return observer;
}
function initPropsObserver(component) {
var $name = component.$name;
var $options = component.$options;
var $props = component.$props;
var attrs = $options.attrs;
var props = $options.props;
var el = $options.el;
if (!props || attrs === false) {
return;
}
var attributes = isArray(attrs) ? attrs : Object.keys(props);
var filter = attributes.map(function (key) { return hyphenate(key); }).concat($name);
var observer = new MutationObserver(function (records) {
var data = getProps($options, $name);
if (records.some(function (ref) {
var attributeName = ref.attributeName;
var prop = attributeName.replace('data-', '');
return (prop === $name ? attributes : [camelize(prop), camelize(attributeName)]).some(function (prop) { return !isUndefined(data[prop]) && data[prop] !== $props[prop]; }
);
})) {
component.$reset();
}
});
observer.observe(el, {
attributes: true,
attributeFilter: filter.concat(filter.map(function (key) { return ("data-" + key); }))
});
return observer;
}
}
2017-11-11 04:33:51 +00:00
function instanceAPI (UIkit) {
2017-11-11 04:33:51 +00:00
var DATA = UIkit.data;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
UIkit.prototype.$create = function (component, element, data) {
return UIkit[component](element, data);
};
UIkit.prototype.$mount = function (el) {
2017-11-11 04:33:51 +00:00
var ref = this.$options;
var name = ref.name;
2017-11-11 04:33:51 +00:00
if (!el[DATA]) {
el[DATA] = {};
}
2017-11-11 04:33:51 +00:00
if (el[DATA][name]) {
return;
}
2017-11-11 04:33:51 +00:00
el[DATA][name] = this;
2017-11-11 04:33:51 +00:00
this.$el = this.$options.el = this.$options.el || el;
2017-11-11 04:33:51 +00:00
if (within(el, document)) {
this._callConnected();
2017-11-11 04:33:51 +00:00
}
};
2017-11-11 04:33:51 +00:00
UIkit.prototype.$reset = function () {
this._callDisconnected();
this._callConnected();
};
2017-11-11 04:33:51 +00:00
UIkit.prototype.$destroy = function (removeEl) {
if ( removeEl === void 0 ) removeEl = false;
2017-11-11 04:33:51 +00:00
var ref = this.$options;
var el = ref.el;
var name = ref.name;
2017-11-11 04:33:51 +00:00
if (el) {
this._callDisconnected();
2017-11-11 04:33:51 +00:00
}
this._callHook('destroy');
if (!el || !el[DATA]) {
return;
2017-11-11 04:33:51 +00:00
}
delete el[DATA][name];
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (!isEmpty(el[DATA])) {
delete el[DATA];
}
2017-11-11 04:33:51 +00:00
if (removeEl) {
2021-05-27 00:23:07 +00:00
remove$1(this.$el);
2017-11-11 04:33:51 +00:00
}
};
2021-05-27 00:23:07 +00:00
UIkit.prototype.$emit = function (e) {
this._callUpdate(e);
};
UIkit.prototype.$update = function (element, e) {
if ( element === void 0 ) element = this.$el;
UIkit.update(element, e);
};
2017-11-11 04:33:51 +00:00
UIkit.prototype.$getComponent = UIkit.getComponent;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var componentName = memoize(function (name) { return UIkit.prefix + hyphenate(name); });
Object.defineProperties(UIkit.prototype, {
2017-11-11 04:33:51 +00:00
$container: Object.getOwnPropertyDescriptor(UIkit, 'container'),
2017-11-11 04:33:51 +00:00
$name: {
2017-11-11 04:33:51 +00:00
get: function() {
2021-05-27 00:23:07 +00:00
return componentName(this.$options.name);
}
2021-05-27 00:23:07 +00:00
}
});
}
function componentAPI (UIkit) {
var DATA = UIkit.data;
var components = {};
UIkit.component = function (name, options) {
var id = hyphenate(name);
name = camelize(id);
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 ? init(element) : $$(element).map(init)[0];
function init(element) {
var instance = UIkit.getComponent(element, name);
if (instance) {
if (!data) {
return instance;
} else {
instance.$destroy();
}
}
2021-05-27 00:23:07 +00:00
return new component({el: element, data: data});
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
};
var opt = isPlainObject(options) ? assign({}, options) : options.options;
opt.name = name;
if (opt.install) {
opt.install(UIkit, opt, name);
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
if (UIkit._initialized && !opt.functional) {
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();
}
};
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var getComponentName = memoize(function (attribute) {
return startsWith(attribute, 'uk-') || startsWith(attribute, 'data-uk-')
? camelize(attribute.replace('data-uk-', '').replace('uk-', ''))
: false;
});
var UIkit = function (options) {
this._init(options);
};
2017-11-11 04:33:51 +00:00
UIkit.util = util;
UIkit.data = '__uikit__';
UIkit.prefix = 'uk-';
UIkit.options = {};
2021-05-27 00:23:07 +00:00
UIkit.version = '3.6.22';
2017-11-11 04:33:51 +00:00
globalAPI(UIkit);
hooksAPI(UIkit);
stateAPI(UIkit);
componentAPI(UIkit);
instanceAPI(UIkit);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function Core (UIkit) {
if (!inBrowser) {
return;
}
// throttle 'resize'
var pendingResize;
var handleResize = function () {
if (pendingResize) {
return;
}
pendingResize = true;
fastdom.write(function () { return pendingResize = false; });
UIkit.update(null, 'resize');
};
on(window, 'load resize', handleResize);
on(document, 'loadedmetadata load', handleResize, true);
if ('ResizeObserver' in window) {
(new ResizeObserver(handleResize)).observe(document.documentElement);
}
// throttle `scroll` event (Safari triggers multiple `scroll` events per frame)
var pending;
on(window, 'scroll', function (e) {
if (pending) {
return;
}
pending = true;
fastdom.write(function () { return pending = false; });
UIkit.update(null, e.type);
}, {passive: true, capture: true});
var started = 0;
on(document, 'animationstart', function (ref) {
var target = ref.target;
if ((css(target, 'animationName') || '').match(/^uk-.*(left|right)/)) {
started++;
css(document.documentElement, 'overflowX', 'hidden');
setTimeout(function () {
if (!--started) {
css(document.documentElement, 'overflowX', '');
}
}, toMs(css(target, 'animationDuration')) + 100);
}
}, true);
on(document, pointerDown, function (e) {
if (!isTouch(e)) {
return;
}
// Handle Swipe Gesture
var pos = getEventPos(e);
var target = 'tagName' in e.target ? e.target : parent(e.target);
once(document, (pointerUp + " " + pointerCancel + " scroll"), function (e) {
var ref = getEventPos(e);
var x = ref.x;
var y = ref.y;
// swipe
if (e.type !== 'scroll' && target && x && Math.abs(pos.x - x) > 100 || y && Math.abs(pos.y - y) > 100) {
setTimeout(function () {
trigger(target, 'swipe');
trigger(target, ("swipe" + (swipeDirection(pos.x, pos.y, x, y))));
});
}
});
}, {passive: true});
}
function swipeDirection(x1, y1, x2, y2) {
return Math.abs(x1 - x2) >= Math.abs(y1 - y2)
? x1 - x2 > 0
? 'Left'
: 'Right'
: y1 - y2 > 0
? 'Up'
: 'Down';
}
function boot (UIkit) {
var connect = UIkit.connect;
var disconnect = UIkit.disconnect;
if (!inBrowser || !window.MutationObserver) {
return;
}
fastdom.read(function () {
if (document.body) {
apply$1(document.body, connect);
}
new MutationObserver(function (records) { return records.forEach(applyChildListMutation); }
).observe(document, {
childList: true,
subtree: true
});
new MutationObserver(function (records) { return records.forEach(applyAttributeMutation); }
).observe(document, {
attributes: true,
subtree: true
});
UIkit._initialized = true;
});
function applyChildListMutation(ref) {
var addedNodes = ref.addedNodes;
var removedNodes = ref.removedNodes;
for (var i = 0; i < addedNodes.length; i++) {
apply$1(addedNodes[i], connect);
}
for (var i$1 = 0; i$1 < removedNodes.length; i$1++) {
apply$1(removedNodes[i$1], disconnect);
}
}
function applyAttributeMutation(ref) {
var target = ref.target;
var attributeName = ref.attributeName;
var name = getComponentName(attributeName);
if (!name || !(name in UIkit)) {
return;
}
if (hasAttr(target, attributeName)) {
UIkit[name](target);
return;
}
var component = UIkit.getComponent(target, name);
if (component) {
component.$destroy();
}
}
}
var Class = {
2017-11-11 04:33:51 +00:00
connected: function() {
2019-04-22 13:31:39 +00:00
!hasClass(this.$el, this.$name) && addClass(this.$el, this.$name);
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
var Togglable = {
2017-11-11 04:33:51 +00:00
props: {
cls: Boolean,
animation: 'list',
duration: Number,
origin: String,
2021-05-27 00:23:07 +00:00
transition: String
},
2017-11-11 04:33:51 +00:00
data: {
cls: false,
animation: [false],
duration: 200,
origin: false,
transition: 'linear',
2021-05-27 00:23:07 +00:00
clsEnter: 'uk-togglabe-enter',
clsLeave: 'uk-togglabe-leave',
2017-11-11 04:33:51 +00:00
initProps: {
overflow: '',
height: '',
paddingTop: '',
paddingBottom: '',
marginTop: '',
marginBottom: ''
},
hideProps: {
overflow: 'hidden',
height: 0,
paddingTop: 0,
paddingBottom: 0,
marginTop: 0,
marginBottom: 0
2017-11-11 04:33:51 +00:00
}
},
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
hasAnimation: function(ref) {
var animation = ref.animation;
2017-11-11 04:33:51 +00:00
return !!animation[0];
},
2017-11-11 04:33:51 +00:00
hasTransition: function(ref) {
var animation = ref.animation;
2017-11-11 04:33:51 +00:00
return this.hasAnimation && animation[0] === true;
}
2017-11-11 04:33:51 +00:00
},
2021-05-27 00:23:07 +00:00
methods: {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
toggleElement: function(targets, toggle, animate) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return new Promise$1(function (resolve) { return Promise$1.all(toNodes(targets).map(function (el) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var show = isBoolean(toggle) ? toggle : !this$1.isToggled(el);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!trigger(el, ("before" + (show ? 'show' : 'hide')), [this$1])) {
return Promise$1.reject();
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var promise = (
isFunction(animate)
? animate
: animate === false || !this$1.hasAnimation
? this$1._toggle
: this$1.hasTransition
? toggleHeight(this$1)
: toggleAnimation(this$1)
)(el, show);
2021-05-27 00:23:07 +00:00
var cls = show ? this$1.clsEnter : this$1.clsLeave;
2021-05-27 00:23:07 +00:00
addClass(el, cls);
2021-05-27 00:23:07 +00:00
trigger(el, show ? 'show' : 'hide', [this$1]);
2021-05-27 00:23:07 +00:00
var done = function () {
removeClass(el, cls);
trigger(el, show ? 'shown' : 'hidden', [this$1]);
this$1.$update(el);
};
2021-05-27 00:23:07 +00:00
return promise ? promise.then(done, function () {
removeClass(el, cls);
return Promise$1.reject();
}) : done();
2021-05-27 00:23:07 +00:00
})).then(resolve, noop); }
);
},
isToggled: function(el) {
if ( el === void 0 ) el = this.$el;
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
return hasClass(el, this.clsEnter)
? true
: hasClass(el, this.clsLeave)
? false
: this.cls
? hasClass(el, this.cls.split(' ')[0])
: !hasAttr(el, 'hidden');
},
_toggle: function(el, toggled) {
if (!el) {
return;
}
2019-04-22 13:31:39 +00:00
toggled = Boolean(toggled);
var changed;
if (this.cls) {
2019-04-22 13:31:39 +00:00
changed = includes(this.cls, ' ') || toggled !== hasClass(el, this.cls);
changed && toggleClass(el, this.cls, includes(this.cls, ' ') ? undefined : toggled);
} else {
2021-05-27 00:23:07 +00:00
changed = toggled === el.hidden;
changed && (el.hidden = !toggled);
}
2019-04-22 13:31:39 +00:00
$$('[autofocus]', el).some(function (el) { return isVisible(el) ? el.focus() || true : el.blur(); });
2021-05-27 00:23:07 +00:00
if (changed) {
trigger(el, 'toggled', [toggled, this]);
this.$update(el);
}
2019-04-22 13:31:39 +00:00
}
2019-04-22 13:31:39 +00:00
}
2019-04-22 13:31:39 +00:00
};
2019-04-22 13:31:39 +00:00
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;
2019-04-22 13:31:39 +00:00
return function (el, show) {
2019-04-22 13:31:39 +00:00
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;
2019-04-22 13:31:39 +00:00
Transition.cancel(el);
2019-04-22 13:31:39 +00:00
if (!isToggled(el)) {
_toggle(el, true);
}
2019-04-22 13:31:39 +00:00
height(el, '');
2019-04-22 13:31:39 +00:00
// Update child components first
fastdom.flush();
2019-04-22 13:31:39 +00:00
var endHeight = height(el) + (inProgress ? 0 : inner);
height(el, currentHeight);
2019-04-22 13:31:39 +00:00
return (show
2021-05-27 00:23:07 +00:00
? 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); })
2019-04-22 13:31:39 +00:00
).then(function () { return css(el, initProps); });
2019-04-22 13:31:39 +00:00
};
}
2021-05-27 00:23:07 +00:00
function toggleAnimation(cmp) {
2019-04-22 13:31:39 +00:00
return function (el, show) {
2019-04-22 13:31:39 +00:00
Animation.cancel(el);
2021-05-27 00:23:07 +00:00
var animation = cmp.animation;
var duration = cmp.duration;
var _toggle = cmp._toggle;
2019-04-22 13:31:39 +00:00
if (show) {
_toggle(el, true);
2021-05-27 00:23:07 +00:00
return Animation.in(el, animation[0], duration, cmp.origin);
}
2021-05-27 00:23:07 +00:00
return Animation.out(el, animation[1] || animation[0], duration, cmp.origin).then(function () { return _toggle(el, false); });
2019-04-22 13:31:39 +00:00
};
}
var Accordion = {
mixins: [Class, Togglable],
props: {
targets: String,
active: null,
collapsible: Boolean,
multiple: Boolean,
toggle: String,
content: String,
2021-05-27 00:23:07 +00:00
transition: String,
offset: Number
2017-11-11 04:33:51 +00:00
},
data: {
2017-11-11 04:33:51 +00:00
targets: '> *',
active: false,
animation: [true],
collapsible: true,
multiple: false,
clsOpen: 'uk-open',
toggle: '> .uk-accordion-title',
content: '> .uk-accordion-content',
2021-05-27 00:23:07 +00:00
transition: 'ease',
offset: 0
2017-11-11 04:33:51 +00:00
},
computed: {
2021-05-27 00:23:07 +00:00
items: {
get: function(ref, $el) {
var targets = ref.targets;
return $$(targets, $el);
},
watch: function(items, prev) {
var this$1 = this;
items.forEach(function (el) { return hide($(this$1.content, el), !hasClass(el, this$1.clsOpen)); });
if (prev || hasClass(items, this.clsOpen)) {
return;
}
var active = this.active !== false && items[Number(this.active)]
|| !this.collapsible && items[0];
if (active) {
this.toggle(active, false);
}
},
immediate: true
},
toggles: function(ref) {
var toggle = ref.toggle;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return this.items.map(function (item) { return $(toggle, item); });
2017-11-11 04:33:51 +00:00
}
},
events: [
{
name: 'click',
delegate: function() {
2017-11-11 04:33:51 +00:00
return ((this.targets) + " " + (this.$props.toggle));
},
handler: function(e) {
2017-11-11 04:33:51 +00:00
e.preventDefault();
2021-05-27 00:23:07 +00:00
this.toggle(index(this.toggles, e.current));
2017-11-11 04:33:51 +00:00
}
}
],
methods: {
2019-04-22 13:31:39 +00:00
toggle: function(item, animate) {
2017-11-11 04:33:51 +00:00
var this$1 = this;
2021-05-27 00:23:07 +00:00
var items = [this.items[getIndex(item, this.items)]];
var activeItems = filter$1(this.items, ("." + (this.clsOpen)));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.multiple && !includes(activeItems, items[0])) {
items = items.concat(activeItems);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.collapsible && activeItems.length < 2 && !filter$1(items, (":not(." + (this.clsOpen) + ")")).length) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
items.forEach(function (el) { return this$1.toggleElement(el, !hasClass(el, this$1.clsOpen), function (el, show) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
toggleClass(el, this$1.clsOpen, show);
attr($(this$1.$props.toggle, el), 'aria-expanded', show);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var content = $(("" + (el._wrapper ? '> * ' : '') + (this$1.content)), el);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (animate === false || !this$1.hasTransition) {
hide(content, !show);
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!el._wrapper) {
el._wrapper = wrapAll(content, ("<div" + (show ? ' hidden' : '') + ">"));
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
hide(content, false);
return toggleHeight(this$1)(el._wrapper, show).then(function () {
hide(content, !show);
delete el._wrapper;
unwrap(content);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (show) {
var toggle = $(this$1.$props.toggle, el);
if (!isInView(toggle)) {
scrollIntoView(toggle, {offset: this$1.offset});
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
}
2017-11-11 04:33:51 +00:00
});
2021-05-27 00:23:07 +00:00
}); });
2017-11-11 04:33:51 +00:00
}
}
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function hide(el, hide) {
el && (el.hidden = hide);
}
var alert = {
2017-11-11 04:33:51 +00:00
mixins: [Class, Togglable],
args: 'animation',
props: {
close: String
},
data: {
2017-11-11 04:33:51 +00:00
animation: [true],
selClose: '.uk-alert-close',
duration: 150,
hideProps: assign({opacity: 0}, Togglable.data.hideProps)
2017-11-11 04:33:51 +00:00
},
events: [
{
name: 'click',
delegate: function() {
2017-11-11 04:33:51 +00:00
return this.selClose;
},
handler: function(e) {
2017-11-11 04:33:51 +00:00
e.preventDefault();
this.close();
}
}
],
methods: {
close: function() {
2017-11-11 04:33:51 +00:00
var this$1 = this;
this.toggleElement(this.$el).then(function () { return this$1.$destroy(true); });
}
}
};
var Video = {
args: 'autoplay',
props: {
automute: Boolean,
2019-04-22 13:31:39 +00:00
autoplay: Boolean
},
data: {
automute: false,
autoplay: true
},
computed: {
inView: function(ref) {
var autoplay = ref.autoplay;
return autoplay === 'inview';
}
},
connected: function() {
if (this.inView && !hasAttr(this.$el, 'preload')) {
this.$el.preload = 'none';
}
if (this.automute) {
2021-05-27 00:23:07 +00:00
mute(this.$el);
}
},
2019-04-22 13:31:39 +00:00
update: {
2019-04-22 13:31:39 +00:00
read: function() {
2021-05-27 00:23:07 +00:00
return {
visible: isVisible(this.$el) && css(this.$el, 'visibility') !== 'hidden',
inView: this.inView && isInView(this.$el)
};
2019-04-22 13:31:39 +00:00
},
2019-04-22 13:31:39 +00:00
write: function(ref) {
var visible = ref.visible;
var inView = ref.inView;
2019-04-22 13:31:39 +00:00
if (!visible || this.inView && !inView) {
2021-05-27 00:23:07 +00:00
pause(this.$el);
2019-04-22 13:31:39 +00:00
} else if (this.autoplay === true || this.inView && inView) {
2021-05-27 00:23:07 +00:00
play(this.$el);
2019-04-22 13:31:39 +00:00
}
2019-04-22 13:31:39 +00:00
},
2019-04-22 13:31:39 +00:00
events: ['resize', 'scroll']
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var cover = {
2017-11-11 04:33:51 +00:00
mixins: [Class, Video],
2017-11-11 04:33:51 +00:00
props: {
width: Number,
height: Number
},
data: {
2017-11-11 04:33:51 +00:00
automute: true
},
update: {
read: function() {
2017-11-11 04:33:51 +00:00
var el = this.$el;
2021-05-27 00:23:07 +00:00
var ref = getPositionedParent(el) || parent(el);
var height = ref.offsetHeight;
var width = ref.offsetWidth;
var dim = Dimensions.cover(
{
width: this.width || el.naturalWidth || el.videoWidth || el.clientWidth,
height: this.height || el.naturalHeight || el.videoHeight || el.clientHeight
},
{
width: width + (width % 2 ? 1 : 0),
height: height + (height % 2 ? 1 : 0)
}
);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!dim.width || !dim.height) {
return false;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
return dim;
},
write: function(ref) {
2019-04-22 13:31:39 +00:00
var height = ref.height;
var width = ref.width;
2021-05-27 00:23:07 +00:00
css(this.$el, {height: height, width: width});
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
}
};
2021-05-27 00:23:07 +00:00
function getPositionedParent(el) {
while ((el = parent(el))) {
if (css(el, 'position') !== 'static') {
return el;
}
}
}
var Position = {
props: {
pos: String,
offset: null,
flip: Boolean,
clsPos: String
2017-11-11 04:33:51 +00:00
},
data: {
pos: ("bottom-" + (!isRtl ? 'left' : 'right')),
flip: true,
offset: false,
clsPos: ''
},
2017-11-11 04:33:51 +00:00
computed: {
pos: function(ref) {
var pos = ref.pos;
return (pos + (!includes(pos, '-') ? '-center' : '')).split('-');
},
dir: function() {
return this.pos[0];
},
align: function() {
return this.pos[1];
2017-11-11 04:33:51 +00:00
}
},
2017-11-11 04:33:51 +00:00
methods: {
positionAt: function(element, target, boundary) {
removeClasses(element, ((this.clsPos) + "-(top|bottom|left|right)(-[a-z]+)?"));
var ref = this;
2019-04-22 13:31:39 +00:00
var offset$1 = ref.offset;
var axis = this.getAxis();
2019-04-22 13:31:39 +00:00
if (!isNumeric(offset$1)) {
2021-05-27 00:23:07 +00:00
var node = $(offset$1);
2019-04-22 13:31:39 +00:00
offset$1 = node
? offset(node)[axis === 'x' ? 'left' : 'top'] - offset(target)[axis === 'x' ? 'right' : 'bottom']
: 0;
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
var ref$1 = positionAt(
element,
target,
axis === 'x' ? ((flipPosition(this.dir)) + " " + (this.align)) : ((this.align) + " " + (flipPosition(this.dir))),
axis === 'x' ? ((this.dir) + " " + (this.align)) : ((this.align) + " " + (this.dir)),
2019-04-22 13:31:39 +00:00
axis === 'x' ? ("" + (this.dir === 'left' ? -offset$1 : offset$1)) : (" " + (this.dir === 'top' ? -offset$1 : offset$1)),
null,
this.flip,
boundary
).target;
var x = ref$1.x;
var y = ref$1.y;
this.dir = axis === 'x' ? x : y;
this.align = axis === 'x' ? y : x;
toggleClass(element, ((this.clsPos) + "-" + (this.dir) + "-" + (this.align)), this.offset === false);
},
getAxis: function() {
return this.dir === 'top' || this.dir === 'bottom' ? 'y' : 'x';
}
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var active$1;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var drop = {
2017-11-11 04:33:51 +00:00
mixins: [Position, Togglable],
args: 'pos',
props: {
mode: 'list',
toggle: Boolean,
boundary: Boolean,
2017-11-11 04:33:51 +00:00
boundaryAlign: Boolean,
delayShow: Number,
delayHide: Number,
clsDrop: String
},
data: {
2017-11-11 04:33:51 +00:00
mode: ['click', 'hover'],
toggle: '- *',
2021-05-27 00:23:07 +00:00
boundary: true,
2017-11-11 04:33:51 +00:00
boundaryAlign: false,
delayShow: 0,
delayHide: 800,
clsDrop: false,
animation: ['uk-animation-fade'],
cls: 'uk-open'
},
computed: {
boundary: function(ref, $el) {
var boundary = ref.boundary;
2021-05-27 00:23:07 +00:00
return boundary === true ? window : query(boundary, $el);
},
clsDrop: function(ref) {
var clsDrop = ref.clsDrop;
return clsDrop || ("uk-" + (this.$options.name));
},
clsPos: function() {
return this.clsDrop;
}
},
2019-04-22 13:31:39 +00:00
created: function() {
2017-11-11 04:33:51 +00:00
this.tracker = new MouseTracker();
},
connected: function() {
2017-11-11 04:33:51 +00:00
addClass(this.$el, this.clsDrop);
var ref = this.$props;
var toggle = ref.toggle;
this.toggle = toggle && this.$create('toggle', query(toggle, this.$el), {
target: this.$el,
mode: this.mode
});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
disconnected: function() {
if (this.isActive()) {
active$1 = null;
}
2017-11-11 04:33:51 +00:00
},
events: [
{
name: 'click',
delegate: function() {
2017-11-11 04:33:51 +00:00
return ("." + (this.clsDrop) + "-close");
},
handler: function(e) {
2017-11-11 04:33:51 +00:00
e.preventDefault();
this.hide(false);
}
},
{
name: 'click',
delegate: function() {
2017-11-11 04:33:51 +00:00
return 'a[href^="#"]';
},
2021-05-27 00:23:07 +00:00
handler: function(ref) {
var defaultPrevented = ref.defaultPrevented;
var hash = ref.current.hash;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!defaultPrevented && hash && !within(hash, this.$el)) {
2017-11-11 04:33:51 +00:00
this.hide(false);
}
}
},
{
name: 'beforescroll',
handler: function() {
2017-11-11 04:33:51 +00:00
this.hide(false);
}
},
{
name: 'toggle',
self: true,
handler: function(e, toggle) {
2017-11-11 04:33:51 +00:00
e.preventDefault();
if (this.isToggled()) {
this.hide(false);
} else {
this.show(toggle, false);
}
}
},
{
2021-05-27 00:23:07 +00:00
name: 'toggleshow',
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
self: true,
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
handler: function(e, toggle) {
2017-11-11 04:33:51 +00:00
e.preventDefault();
2021-05-27 00:23:07 +00:00
this.show(toggle);
2017-11-11 04:33:51 +00:00
}
},
{
2021-05-27 00:23:07 +00:00
name: 'togglehide',
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
self: true,
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
handler: function(e) {
2017-11-11 04:33:51 +00:00
e.preventDefault();
2021-05-27 00:23:07 +00:00
this.hide();
2017-11-11 04:33:51 +00:00
}
},
{
2021-05-27 00:23:07 +00:00
name: (pointerEnter + " focusin"),
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
filter: function() {
return includes(this.mode, 'hover');
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
handler: function(e) {
if (!isTouch(e)) {
this.clearTimers();
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
},
{
name: (pointerLeave + " focusout"),
filter: function() {
return includes(this.mode, 'hover');
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
handler: function(e) {
if (!isTouch(e) && e.relatedTarget) {
2017-11-11 04:33:51 +00:00
this.hide();
}
}
},
{
2021-05-27 00:23:07 +00:00
name: 'toggled',
2017-11-11 04:33:51 +00:00
self: true,
2021-05-27 00:23:07 +00:00
handler: function(e, toggled) {
if (!toggled) {
return;
}
2017-11-11 04:33:51 +00:00
this.clearTimers();
this.position();
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
},
{
name: 'show',
self: true,
handler: function() {
var this$1 = this;
active$1 = this;
this.tracker.init();
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
once(this.$el, 'hide', on(document, pointerDown, function (ref) {
var target = ref.target;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return !within(target, this$1.$el) && once(document, (pointerUp + " " + pointerCancel + " scroll"), function (ref) {
var defaultPrevented = ref.defaultPrevented;
var type = ref.type;
var newTarget = ref.target;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!defaultPrevented && type === pointerUp && target === newTarget && !(this$1.toggle && within(target, this$1.toggle.$el))) {
this$1.hide(false);
}
}, true);
}
), {self: true});
once(this.$el, 'hide', on(document, 'keydown', function (e) {
if (e.keyCode === 27) {
this$1.hide(false);
}
}), {self: true});
2017-11-11 04:33:51 +00:00
}
},
{
name: 'beforehide',
self: true,
handler: function() {
2017-11-11 04:33:51 +00:00
this.clearTimers();
}
},
{
name: 'hide',
handler: function(ref) {
2017-11-11 04:33:51 +00:00
var target = ref.target;
if (this.$el !== target) {
2021-05-27 00:23:07 +00:00
active$1 = active$1 === null && within(target, this.$el) && this.isToggled() ? this : active$1;
2017-11-11 04:33:51 +00:00
return;
}
2021-05-27 00:23:07 +00:00
active$1 = this.isActive() ? null : active$1;
2017-11-11 04:33:51 +00:00
this.tracker.cancel();
}
}
],
update: {
write: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this.isToggled() && !hasClass(this.$el, this.clsEnter)) {
2017-11-11 04:33:51 +00:00
this.position();
}
},
events: ['resize']
},
methods: {
show: function(toggle, delay) {
2017-11-11 04:33:51 +00:00
var this$1 = this;
2021-05-27 00:23:07 +00:00
if ( toggle === void 0 ) toggle = this.toggle;
2017-11-11 04:33:51 +00:00
if ( delay === void 0 ) delay = true;
2021-05-27 00:23:07 +00:00
if (this.isToggled() && toggle && this.toggle && toggle.$el !== this.toggle.$el) {
this.hide(false);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.toggle = toggle;
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
this.clearTimers();
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
if (this.isActive()) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (active$1) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (delay && active$1.isDelaying) {
this.showTimer = setTimeout(this.show, 10);
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var prev;
while (active$1 && prev !== active$1 && !within(this.$el, active$1.$el)) {
prev = active$1;
active$1.hide(false);
}
2021-05-27 00:23:07 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.showTimer = setTimeout(function () { return !this$1.isToggled() && this$1.toggleElement(this$1.$el, true); }, delay && this.delayShow || 0);
2017-11-11 04:33:51 +00:00
},
hide: function(delay) {
2017-11-11 04:33:51 +00:00
var this$1 = this;
if ( delay === void 0 ) delay = true;
2021-05-27 00:23:07 +00:00
var hide = function () { return this$1.toggleElement(this$1.$el, false, false); };
2017-11-11 04:33:51 +00:00
this.clearTimers();
2021-05-27 00:23:07 +00:00
this.isDelaying = getPositionedElements(this.$el).some(function (el) { return this$1.tracker.movesTo(el); });
2017-11-11 04:33:51 +00:00
if (delay && this.isDelaying) {
2021-05-27 00:23:07 +00:00
this.hideTimer = setTimeout(this.hide, 50);
2017-11-11 04:33:51 +00:00
} else if (delay && this.delayHide) {
this.hideTimer = setTimeout(hide, this.delayHide);
} else {
hide();
}
},
clearTimers: function() {
2017-11-11 04:33:51 +00:00
clearTimeout(this.showTimer);
clearTimeout(this.hideTimer);
this.showTimer = null;
this.hideTimer = null;
this.isDelaying = false;
},
isActive: function() {
2021-05-27 00:23:07 +00:00
return active$1 === this;
2017-11-11 04:33:51 +00:00
},
position: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
removeClass(this.$el, ((this.clsDrop) + "-stack"));
2017-11-11 04:33:51 +00:00
toggleClass(this.$el, ((this.clsDrop) + "-boundary"), this.boundaryAlign);
var boundary = offset(this.boundary);
var alignTo = this.boundaryAlign ? boundary : offset(this.toggle.$el);
2017-11-11 04:33:51 +00:00
if (this.align === 'justify') {
var prop = this.getAxis() === 'y' ? 'width' : 'height';
css(this.$el, prop, alignTo[prop]);
2021-05-27 00:23:07 +00:00
} else if (this.boundary && this.$el.offsetWidth > Math.max(boundary.right - alignTo.left, alignTo.right - boundary.left)) {
2017-11-11 04:33:51 +00:00
addClass(this.$el, ((this.clsDrop) + "-stack"));
}
this.positionAt(this.$el, this.boundaryAlign ? this.boundary : this.toggle.$el, this.boundary);
}
}
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function getPositionedElements(el) {
var result = [];
apply$1(el, function (el) { return css(el, 'position') !== 'static' && result.push(el); });
return result;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
var formCustom = {
2017-11-11 04:33:51 +00:00
mixins: [Class],
args: 'target',
props: {
target: Boolean
},
data: {
2017-11-11 04:33:51 +00:00
target: false
},
computed: {
input: function(_, $el) {
return $(selInput, $el);
2017-11-11 04:33:51 +00:00
},
state: function() {
2017-11-11 04:33:51 +00:00
return this.input.nextElementSibling;
},
target: function(ref, $el) {
2017-11-11 04:33:51 +00:00
var target = ref.target;
return target && (target === true
2021-05-27 00:23:07 +00:00
&& parent(this.input) === $el
2017-11-11 04:33:51 +00:00
&& this.input.nextElementSibling
|| query(target, $el));
}
},
update: function() {
var ref = this;
var target = ref.target;
var input = ref.input;
if (!target) {
return;
}
var option;
var prop = isInput(target) ? 'value' : 'textContent';
var prev = target[prop];
var value = input.files && input.files[0]
? input.files[0].name
2021-05-27 00:23:07 +00:00
: matches(input, 'select') && (option = $$('option', input).filter(function (el) { return el.selected; })[0]) // eslint-disable-line prefer-destructuring
? option.textContent
: input.value;
if (prev !== value) {
target[prop] = value;
}
2017-11-11 04:33:51 +00:00
},
2021-05-27 00:23:07 +00:00
events: [
{
name: 'change',
handler: function() {
this.$update();
}
},
{
name: 'reset',
el: function() {
return closest(this.$el, 'form');
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
handler: function() {
this.$update();
}
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
]
};
2017-11-11 04:33:51 +00:00
// Deprecated
2021-05-27 00:23:07 +00:00
var gif = {
update: {
2019-04-22 13:31:39 +00:00
read: function(data) {
var inview = isInView(this.$el);
2019-04-22 13:31:39 +00:00
if (!inview || data.isInView === inview) {
return false;
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
data.isInView = inview;
},
2017-11-11 04:33:51 +00:00
write: function() {
2021-05-27 00:23:07 +00:00
this.$el.src = '' + this.$el.src; // force self-assign
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
events: ['scroll', 'resize']
}
};
2017-11-11 04:33:51 +00:00
var Margin = {
2017-11-11 04:33:51 +00:00
props: {
margin: String,
firstColumn: Boolean
},
2017-11-11 04:33:51 +00:00
data: {
margin: 'uk-margin-small-top',
firstColumn: 'uk-first-column'
},
2017-11-11 04:33:51 +00:00
update: {
2021-05-27 00:23:07 +00:00
read: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var rows = getRows(this.$el.children);
2021-05-27 00:23:07 +00:00
return {
rows: rows,
columns: getColumns(rows)
};
2017-11-11 04:33:51 +00:00
},
write: function(ref) {
2021-05-27 00:23:07 +00:00
var columns = ref.columns;
var rows = ref.rows;
2021-05-27 00:23:07 +00:00
for (var i = 0; i < rows.length; i++) {
for (var j = 0; j < rows[i].length; j++) {
toggleClass(rows[i][j], this.margin, i !== 0);
toggleClass(rows[i][j], this.firstColumn, !!~columns[0].indexOf(rows[i][j]));
}
}
},
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
}
};
function getRows(items) {
2021-05-27 00:23:07 +00:00
return sortBy(items, 'top', 'bottom');
}
function getColumns(rows) {
var columns = [];
for (var i = 0; i < rows.length; i++) {
var sorted = sortBy(rows[i], 'left', 'right');
for (var j = 0; j < sorted.length; j++) {
columns[j] = !columns[j] ? sorted[j] : columns[j].concat(sorted[j]);
}
}
return isRtl
? columns.reverse()
: columns;
}
function sortBy(items, startProp, endProp) {
var sorted = [[]];
for (var i = 0; i < items.length; i++) {
var el = items[i];
2021-05-27 00:23:07 +00:00
if (!isVisible(el)) {
continue;
}
2021-05-27 00:23:07 +00:00
var dim = getOffset(el);
for (var j = sorted.length - 1; j >= 0; j--) {
2021-05-27 00:23:07 +00:00
var current = sorted[j];
2021-05-27 00:23:07 +00:00
if (!current[0]) {
current.push(el);
break;
}
2021-05-27 00:23:07 +00:00
var startDim = (void 0);
if (current[0].offsetParent === el.offsetParent) {
startDim = getOffset(current[0]);
2019-04-22 13:31:39 +00:00
} else {
dim = getOffset(el, true);
2021-05-27 00:23:07 +00:00
startDim = getOffset(current[0], true);
2019-04-22 13:31:39 +00:00
}
2021-05-27 00:23:07 +00:00
if (dim[startProp] >= startDim[endProp] - 1 && dim[startProp] !== startDim[startProp]) {
sorted.push([el]);
break;
}
2021-05-27 00:23:07 +00:00
if (dim[endProp] - 1 > startDim[startProp] || dim[startProp] === startDim[startProp]) {
current.push(el);
break;
}
if (j === 0) {
2021-05-27 00:23:07 +00:00
sorted.unshift([el]);
break;
}
}
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
return sorted;
}
2019-04-22 13:31:39 +00:00
function getOffset(element, offset) {
var assign;
if ( offset === void 0 ) offset = false;
var offsetTop = element.offsetTop;
var offsetLeft = element.offsetLeft;
var offsetHeight = element.offsetHeight;
2021-05-27 00:23:07 +00:00
var offsetWidth = element.offsetWidth;
2019-04-22 13:31:39 +00:00
if (offset) {
(assign = offsetPosition(element), offsetTop = assign[0], offsetLeft = assign[1]);
}
return {
top: offsetTop,
left: offsetLeft,
2021-05-27 00:23:07 +00:00
bottom: offsetTop + offsetHeight,
right: offsetLeft + offsetWidth
};
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var grid = {
2017-11-11 04:33:51 +00:00
extends: Margin,
2017-11-11 04:33:51 +00:00
mixins: [Class],
name: 'grid',
props: {
masonry: Boolean,
parallax: Number
},
data: {
2017-11-11 04:33:51 +00:00
margin: 'uk-grid-margin',
clsStack: 'uk-grid-stack',
masonry: false,
parallax: 0
2017-11-11 04:33:51 +00:00
},
connected: function() {
this.masonry && addClass(this.$el, 'uk-flex-top uk-flex-wrap-top');
},
2017-11-11 04:33:51 +00:00
update: [
{
2021-05-27 00:23:07 +00:00
write: function(ref) {
var columns = ref.columns;
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
toggleClass(this.$el, this.clsStack, columns.length < 2);
},
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
events: ['resize']
2021-05-27 00:23:07 +00:00
},
2021-05-27 00:23:07 +00:00
{
2021-05-27 00:23:07 +00:00
read: function(data) {
2021-05-27 00:23:07 +00:00
var columns = data.columns;
var rows = data.rows;
2021-05-27 00:23:07 +00:00
// Filter component makes elements positioned absolute
if (!columns.length || !this.masonry && !this.parallax || positionedAbsolute(this.$el)) {
data.translates = false;
return false;
}
2021-05-27 00:23:07 +00:00
var translates = false;
2021-05-27 00:23:07 +00:00
var nodes = children(this.$el);
var columnHeights = getColumnHeights(columns);
var margin = getMarginTop(nodes, this.margin) * (rows.length - 1);
var elHeight = Math.max.apply(Math, columnHeights) + margin;
2021-05-27 00:23:07 +00:00
if (this.masonry) {
columns = columns.map(function (column) { return sortBy$1(column, 'offsetTop'); });
translates = getTranslates(rows, columns);
}
2021-05-27 00:23:07 +00:00
var padding = Math.abs(this.parallax);
if (padding) {
padding = columnHeights.reduce(function (newPadding, hgt, i) { return Math.max(newPadding, hgt + margin + (i % 2 ? padding : padding / 8) - elHeight); }
, 0);
}
2021-05-27 00:23:07 +00:00
return {padding: padding, columns: columns, translates: translates, height: translates ? elHeight : ''};
},
write: function(ref) {
2019-04-22 13:31:39 +00:00
var height = ref.height;
2021-05-27 00:23:07 +00:00
var padding = ref.padding;
2021-05-27 00:23:07 +00:00
css(this.$el, 'paddingBottom', padding || '');
2019-04-22 13:31:39 +00:00
height !== false && css(this.$el, 'height', height);
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
},
{
2017-11-11 04:33:51 +00:00
read: function(ref) {
2019-04-22 13:31:39 +00:00
var height$1 = ref.height;
2021-05-27 00:23:07 +00:00
if (positionedAbsolute(this.$el)) {
return false;
}
return {
scrolled: this.parallax
2021-05-27 00:23:07 +00:00
? scrolledOver(this.$el, height$1 ? height$1 - height(this.$el) : 0) * Math.abs(this.parallax)
: false
};
},
write: function(ref) {
2021-05-27 00:23:07 +00:00
var columns = ref.columns;
var scrolled = ref.scrolled;
var translates = ref.translates;
if (scrolled === false && !translates) {
return;
}
2021-05-27 00:23:07 +00:00
columns.forEach(function (column, i) { return column.forEach(function (el, j) { return css(el, 'transform', !scrolled && !translates ? '' : ("translateY(" + ((translates && -translates[i][j]) + (scrolled ? i % 2 ? scrolled : scrolled / 8 : 0)) + "px)")); }
); }
);
},
2019-04-22 13:31:39 +00:00
events: ['scroll', 'resize']
}
]
};
2021-05-27 00:23:07 +00:00
function positionedAbsolute(el) {
return children(el).some(function (el) { return css(el, 'position') === 'absolute'; });
}
function getTranslates(rows, columns) {
var rowHeights = rows.map(function (row) { return Math.max.apply(Math, row.map(function (el) { return el.offsetHeight; })); }
);
return columns.map(function (elements) {
var prev = 0;
return elements.map(function (element, row) { return prev += row
? rowHeights[row - 1] - elements[row - 1].offsetHeight
: 0; }
);
});
}
function getMarginTop(nodes, cls) {
2017-11-11 04:33:51 +00:00
var ref = nodes.filter(function (el) { return hasClass(el, cls); });
var node = ref[0];
2017-11-11 04:33:51 +00:00
return toFloat(node
? css(node, 'marginTop')
: css(nodes[0], 'paddingLeft'));
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function getColumnHeights(columns) {
return columns.map(function (column) { return column.reduce(function (sum, el) { return sum + el.offsetHeight; }, 0); }
);
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
// IE 11 fix (min-height on a flex container won't apply to its flex items)
var FlexBug = isIE ? {
2021-05-27 00:23:07 +00:00
props: {
selMinHeight: String
},
2019-04-22 13:31:39 +00:00
data: {
selMinHeight: false,
forceHeight: false
},
computed: {
elements: function(ref, $el) {
var selMinHeight = ref.selMinHeight;
return selMinHeight ? $$(selMinHeight, $el) : [$el];
}
},
update: [
{
read: function() {
css(this.elements, 'height', '');
},
order: -5,
events: ['resize']
},
{
write: function() {
var this$1 = this;
this.elements.forEach(function (el) {
var height = toFloat(css(el, 'minHeight'));
2021-05-27 00:23:07 +00:00
if (height && (this$1.forceHeight || Math.round(height + boxModelAdjust(el, 'height', 'content-box')) >= el.offsetHeight)) {
2019-04-22 13:31:39 +00:00
css(el, 'height', height);
}
});
},
order: 5,
events: ['resize']
}
]
} : {};
2021-05-27 00:23:07 +00:00
var heightMatch = {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
mixins: [FlexBug],
2017-11-11 04:33:51 +00:00
args: 'target',
props: {
target: String,
row: Boolean
},
data: {
2017-11-11 04:33:51 +00:00
target: '> *',
2019-04-22 13:31:39 +00:00
row: true,
forceHeight: true
2017-11-11 04:33:51 +00:00
},
computed: {
elements: function(ref, $el) {
2017-11-11 04:33:51 +00:00
var target = ref.target;
return $$(target, $el);
}
},
update: {
read: function() {
return {
2021-05-27 00:23:07 +00:00
rows: (this.row ? getRows(this.elements) : [this.elements]).map(match$1)
};
2017-11-11 04:33:51 +00:00
},
write: function(ref) {
var rows = ref.rows;
rows.forEach(function (ref) {
2019-04-22 13:31:39 +00:00
var heights = ref.heights;
var elements = ref.elements;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return elements.forEach(function (el, i) { return css(el, 'minHeight', heights[i]); }
);
}
);
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function match$1(elements) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (elements.length < 2) {
return {heights: [''], elements: elements};
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var heights = elements.map(getHeight);
var max = Math.max.apply(Math, heights);
2019-04-22 13:31:39 +00:00
var hasMinHeight = elements.some(function (el) { return el.style.minHeight; });
var hasShrunk = elements.some(function (el, i) { return !el.style.minHeight && heights[i] < max; });
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (hasMinHeight && hasShrunk) {
css(elements, 'minHeight', '');
2021-05-27 00:23:07 +00:00
heights = elements.map(getHeight);
max = Math.max.apply(Math, heights);
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
heights = elements.map(function (el, i) { return heights[i] === max && toFloat(el.style.minHeight).toFixed(2) !== max.toFixed(2) ? '' : max; }
);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return {heights: heights, elements: elements};
}
2021-05-27 00:23:07 +00:00
function getHeight(element) {
var style = false;
if (!isVisible(element)) {
style = element.style.display;
css(element, 'display', 'block', 'important');
}
var height = dimensions(element).height - boxModelAdjust(element, 'height', 'content-box');
if (style !== false) {
css(element, 'display', style);
}
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
return height;
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var heightViewport = {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
mixins: [FlexBug],
2017-11-11 04:33:51 +00:00
props: {
expand: Boolean,
offsetTop: Boolean,
offsetBottom: Boolean,
minHeight: Number
},
data: {
2017-11-11 04:33:51 +00:00
expand: false,
offsetTop: false,
offsetBottom: false,
minHeight: 0
},
update: {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
read: function(ref) {
var prev = ref.minHeight;
if (!isVisible(this.$el)) {
return false;
}
2017-11-11 04:33:51 +00:00
var minHeight = '';
2021-05-27 00:23:07 +00:00
var box = boxModelAdjust(this.$el, 'height', 'content-box');
2017-11-11 04:33:51 +00:00
if (this.expand) {
2021-05-27 00:23:07 +00:00
minHeight = height(window) - (dimensions(document.documentElement).height - dimensions(this.$el).height) - box || '';
2017-11-11 04:33:51 +00:00
} else {
// on mobile devices (iOS and Android) window.innerHeight !== 100vh
minHeight = 'calc(100vh';
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (this.offsetTop) {
2021-05-27 00:23:07 +00:00
var ref$1 = offset(this.$el);
var top = ref$1.top;
minHeight += top > 0 && top < height(window) / 2 ? (" - " + top + "px") : '';
2019-04-22 13:31:39 +00:00
2017-11-11 04:33:51 +00:00
}
if (this.offsetBottom === true) {
2021-05-27 00:23:07 +00:00
minHeight += " - " + (dimensions(this.$el.nextElementSibling).height) + "px";
2017-11-11 04:33:51 +00:00
} else if (isNumeric(this.offsetBottom)) {
minHeight += " - " + (this.offsetBottom) + "vh";
2017-11-11 04:33:51 +00:00
} else if (this.offsetBottom && endsWith(this.offsetBottom, 'px')) {
minHeight += " - " + (toFloat(this.offsetBottom)) + "px";
2017-11-11 04:33:51 +00:00
} else if (isString(this.offsetBottom)) {
2021-05-27 00:23:07 +00:00
minHeight += " - " + (dimensions(query(this.offsetBottom, this.$el)).height) + "px";
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
minHeight += (box ? (" - " + box + "px") : '') + ")";
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
return {minHeight: minHeight, prev: prev};
},
write: function(ref) {
var minHeight = ref.minHeight;
2021-05-27 00:23:07 +00:00
var prev = ref.prev;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
css(this.$el, {minHeight: minHeight});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (minHeight !== prev) {
this.$update(this.$el, 'resize');
}
if (this.minHeight && toFloat(css(this.$el, 'minHeight')) < this.minHeight) {
2017-11-11 04:33:51 +00:00
css(this.$el, 'minHeight', this.minHeight);
}
},
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
}
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var SVG = {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
args: 'src',
2017-11-11 04:33:51 +00:00
props: {
2019-04-22 13:31:39 +00:00
id: Boolean,
icon: String,
src: String,
style: String,
width: Number,
height: Number,
ratio: Number,
2021-05-27 00:23:07 +00:00
class: String,
2019-04-22 13:31:39 +00:00
strokeAnimation: Boolean,
2021-05-27 00:23:07 +00:00
focusable: Boolean, // IE 11
2019-04-22 13:31:39 +00:00
attributes: 'list'
},
2017-11-11 04:33:51 +00:00
data: {
ratio: 1,
2021-05-27 00:23:07 +00:00
include: ['style', 'class', 'focusable'],
class: '',
2019-04-22 13:31:39 +00:00
strokeAnimation: false
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
beforeConnect: function() {
this.class += ' uk-svg';
},
connected: function() {
var this$1 = this;
2019-04-22 13:31:39 +00:00
var assign;
2017-11-11 04:33:51 +00:00
if (!this.icon && includes(this.src, '#')) {
2021-05-27 00:23:07 +00:00
(assign = this.src.split('#'), this.src = assign[0], this.icon = assign[1]);
}
this.svg = this.getSvg().then(function (el) {
if (this$1._connected) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var svg = insertSVG(el, this$1.$el);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this$1.svgEl && svg !== this$1.svgEl) {
remove$1(this$1.svgEl);
}
this$1.applyAttributes(svg, el);
this$1.$emit();
return this$1.svgEl = svg;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}, noop);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
disconnected: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.svg.then(function (svg) {
if (!this$1._connected) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (isVoidElement(this$1.$el)) {
this$1.$el.hidden = false;
}
remove$1(svg);
this$1.svgEl = null;
}
});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.svg = null;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
update: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
read: function() {
return !!(this.strokeAnimation && this.svgEl && isVisible(this.svgEl));
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
write: function() {
applyAnimation(this.svgEl);
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
type: ['resize']
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
methods: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
getSvg: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return loadSVG(this.src).then(function (svg) { return parseSVG(svg, this$1.icon) || Promise$1.reject('SVG not found.'); }
2019-04-22 13:31:39 +00:00
);
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
applyAttributes: function(el, ref) {
2019-04-22 13:31:39 +00:00
var this$1 = this;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
for (var prop in this.$options.props) {
2021-05-27 00:23:07 +00:00
if (includes(this.include, prop) && (prop in this)) {
2019-04-22 13:31:39 +00:00
attr(el, prop, this[prop]);
}
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
for (var attribute in this.attributes) {
2021-05-27 00:23:07 +00:00
var ref$1 = this.attributes[attribute].split(':', 2);
var prop$1 = ref$1[0];
var value = ref$1[1];
2019-04-22 13:31:39 +00:00
attr(el, prop$1, value);
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (!this.id) {
removeAttr(el, 'id');
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var props = ['width', 'height'];
2021-05-27 00:23:07 +00:00
var dimensions = props.map(function (prop) { return this$1[prop]; });
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (!dimensions.some(function (val) { return val; })) {
2021-05-27 00:23:07 +00:00
dimensions = props.map(function (prop) { return attr(ref, prop); });
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var viewBox = attr(ref, 'viewBox');
2019-04-22 13:31:39 +00:00
if (viewBox && !dimensions.some(function (val) { return val; })) {
dimensions = viewBox.split(' ').slice(2);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
dimensions.forEach(function (val, i) { return attr(el, props[i], toFloat(val) * this$1.ratio || null); }
);
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var loadSVG = memoize(function (src) { return new Promise$1(function (resolve, reject) {
2019-04-22 13:31:39 +00:00
if (!src) {
reject();
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (startsWith(src, 'data:')) {
resolve(decodeURIComponent(src.split(',')[1]));
} else {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
ajax(src).then(
function (xhr) { return resolve(xhr.response); },
function () { return reject('SVG not found.'); }
);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}
2021-05-27 00:23:07 +00:00
}); }
);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function parseSVG(svg, icon) {
2019-04-22 13:31:39 +00:00
if (icon && includes(svg, '<symbol')) {
svg = parseSymbols(svg, icon) || svg;
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
svg = $(svg.substr(svg.indexOf('<svg')));
return svg && svg.hasChildNodes() && svg;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var symbolRe = /<symbol([^]*?id=(['"])(.+?)\2[^]*?<\/)symbol>/g;
var symbols = {};
2017-11-11 04:33:51 +00:00
function parseSymbols(svg, icon) {
2017-11-11 04:33:51 +00:00
if (!symbols[svg]) {
2017-11-11 04:33:51 +00:00
symbols[svg] = {};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
symbolRe.lastIndex = 0;
var match;
while ((match = symbolRe.exec(svg))) {
symbols[svg][match[3]] = "<svg xmlns=\"http://www.w3.org/2000/svg\"" + (match[1]) + "svg>";
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
return symbols[svg][icon];
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function applyAnimation(el) {
var length = getMaxPathLength(el);
if (length) {
el.style.setProperty('--uk-animation-stroke', length);
}
}
function getMaxPathLength(el) {
2021-05-27 00:23:07 +00:00
return Math.ceil(Math.max.apply(Math, [ 0 ].concat( $$('[stroke]', el).map(function (stroke) {
try {
return stroke.getTotalLength();
} catch (e) {
return 0;
}
}) )));
2019-04-22 13:31:39 +00:00
}
function insertSVG(el, root) {
2021-05-27 00:23:07 +00:00
2019-04-22 13:31:39 +00:00
if (isVoidElement(root) || root.tagName === 'CANVAS') {
2021-05-27 00:23:07 +00:00
root.hidden = true;
2019-04-22 13:31:39 +00:00
var next = root.nextElementSibling;
return equals(el, next)
? next
: after(root, el);
}
2021-05-27 00:23:07 +00:00
var last = root.lastElementChild;
return equals(el, last)
? last
: append(root, el);
2019-04-22 13:31:39 +00:00
}
function equals(el, other) {
2021-05-27 00:23:07 +00:00
return isSVG(el) && isSVG(other) && innerHTML(el) === innerHTML(other);
}
function isSVG(el) {
return el && el.tagName === 'svg';
}
function innerHTML(el) {
return (el.innerHTML || (new XMLSerializer()).serializeToString(el).replace(/<svg.*?>(.*?)<\/svg>/g, '$1')).replace(/\s/g, '');
2019-04-22 13:31:39 +00:00
}
var closeIcon = "<svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" xmlns=\"http://www.w3.org/2000/svg\"><line fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" x1=\"1\" y1=\"1\" x2=\"13\" y2=\"13\"/><line fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" x1=\"13\" y1=\"1\" x2=\"1\" y2=\"13\"/></svg>";
2017-11-11 04:33:51 +00:00
var closeLarge = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><line fill=\"none\" stroke=\"#000\" stroke-width=\"1.4\" x1=\"1\" y1=\"1\" x2=\"19\" y2=\"19\"/><line fill=\"none\" stroke=\"#000\" stroke-width=\"1.4\" x1=\"19\" y1=\"1\" x2=\"1\" y2=\"19\"/></svg>";
2017-11-11 04:33:51 +00:00
var marker = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"9\" y=\"4\" width=\"1\" height=\"11\"/><rect x=\"4\" y=\"9\" width=\"11\" height=\"1\"/></svg>";
2017-11-11 04:33:51 +00:00
var navbarToggleIcon = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><rect y=\"9\" width=\"20\" height=\"2\"/><rect y=\"3\" width=\"20\" height=\"2\"/><rect y=\"15\" width=\"20\" height=\"2\"/></svg>";
2017-11-11 04:33:51 +00:00
var overlayIcon = "<svg width=\"40\" height=\"40\" viewBox=\"0 0 40 40\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"19\" y=\"0\" width=\"1\" height=\"40\"/><rect x=\"0\" y=\"19\" width=\"40\" height=\"1\"/></svg>";
2017-11-11 04:33:51 +00:00
var paginationNext = "<svg width=\"7\" height=\"12\" viewBox=\"0 0 7 12\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" points=\"1 1 6 6 1 11\"/></svg>";
2017-11-11 04:33:51 +00:00
var paginationPrevious = "<svg width=\"7\" height=\"12\" viewBox=\"0 0 7 12\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" points=\"6 1 1 6 6 11\"/></svg>";
2017-11-11 04:33:51 +00:00
var searchIcon = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"9\" cy=\"9\" r=\"7\"/><path fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" d=\"M14,14 L18,18 L14,14 Z\"/></svg>";
2017-11-11 04:33:51 +00:00
var searchLarge = "<svg width=\"40\" height=\"40\" viewBox=\"0 0 40 40\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.8\" cx=\"17.5\" cy=\"17.5\" r=\"16.5\"/><line fill=\"none\" stroke=\"#000\" stroke-width=\"1.8\" x1=\"38\" y1=\"39\" x2=\"29\" y2=\"30\"/></svg>";
2017-11-11 04:33:51 +00:00
var searchNavbar = "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" cx=\"10.5\" cy=\"10.5\" r=\"9.5\"/><line fill=\"none\" stroke=\"#000\" stroke-width=\"1.1\" x1=\"23\" y1=\"23\" x2=\"17\" y2=\"17\"/></svg>";
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var slidenavNext = "<svg width=\"14\" height=\"24\" viewBox=\"0 0 14 24\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.4\" points=\"1.225,23 12.775,12 1.225,1 \"/></svg>";
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var slidenavNextLarge = "<svg width=\"25\" height=\"40\" viewBox=\"0 0 25 40\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"2\" points=\"4.002,38.547 22.527,20.024 4,1.5 \"/></svg>";
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var slidenavPrevious = "<svg width=\"14\" height=\"24\" viewBox=\"0 0 14 24\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.4\" points=\"12.775,1 1.225,12 12.775,23 \"/></svg>";
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var slidenavPreviousLarge = "<svg width=\"25\" height=\"40\" viewBox=\"0 0 25 40\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"2\" points=\"20.527,1.5 2,20.024 20.525,38.547 \"/></svg>";
2017-11-11 04:33:51 +00:00
var spinner = "<svg width=\"30\" height=\"30\" viewBox=\"0 0 30 30\" xmlns=\"http://www.w3.org/2000/svg\"><circle fill=\"none\" stroke=\"#000\" cx=\"15\" cy=\"15\" r=\"14\"/></svg>";
2017-11-11 04:33:51 +00:00
var totop = "<svg width=\"18\" height=\"10\" viewBox=\"0 0 18 10\" xmlns=\"http://www.w3.org/2000/svg\"><polyline fill=\"none\" stroke=\"#000\" stroke-width=\"1.2\" points=\"1 9 9 1 17 9 \"/></svg>";
2017-11-11 04:33:51 +00:00
var icons = {
spinner: spinner,
totop: totop,
marker: marker,
'close-icon': closeIcon,
'close-large': closeLarge,
'navbar-toggle-icon': navbarToggleIcon,
'overlay-icon': overlayIcon,
'pagination-next': paginationNext,
'pagination-previous': paginationPrevious,
'search-icon': searchIcon,
'search-large': searchLarge,
'search-navbar': searchNavbar,
'slidenav-next': slidenavNext,
'slidenav-next-large': slidenavNextLarge,
'slidenav-previous': slidenavPrevious,
'slidenav-previous-large': slidenavPreviousLarge
};
2017-11-11 04:33:51 +00:00
var Icon = {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
install: install$3,
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
extends: SVG,
2017-11-11 04:33:51 +00:00
args: 'icon',
2017-11-11 04:33:51 +00:00
props: ['icon'],
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
data: {
include: ['focusable']
},
2017-11-11 04:33:51 +00:00
isIcon: true,
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
beforeConnect: function() {
addClass(this.$el, 'uk-icon');
2017-11-11 04:33:51 +00:00
},
methods: {
2017-11-11 04:33:51 +00:00
getSvg: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var icon = getIcon(this.icon);
2017-11-11 04:33:51 +00:00
if (!icon) {
2021-05-27 00:23:07 +00:00
return Promise$1.reject('Icon not found.');
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return Promise$1.resolve(icon);
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
var IconComponent = {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
args: false,
extends: Icon,
2017-11-11 04:33:51 +00:00
data: function (vm) { return ({
icon: hyphenate(vm.constructor.options.name)
2021-05-27 00:23:07 +00:00
}); },
beforeConnect: function() {
addClass(this.$el, this.$name);
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
var Slidenav = {
2017-11-11 04:33:51 +00:00
extends: IconComponent,
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
beforeConnect: function() {
addClass(this.$el, 'uk-slidenav');
2017-11-11 04:33:51 +00:00
},
computed: {
2017-11-11 04:33:51 +00:00
icon: function(ref, $el) {
var icon = ref.icon;
2017-11-11 04:33:51 +00:00
return hasClass($el, 'uk-slidenav-large')
? (icon + "-large")
: icon;
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
var Search = {
2017-11-11 04:33:51 +00:00
extends: IconComponent,
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
icon: function(ref, $el) {
var icon = ref.icon;
2017-11-11 04:33:51 +00:00
return hasClass($el, 'uk-search-icon') && parents($el, '.uk-search-large').length
? 'search-large'
: parents($el, '.uk-search-navbar').length
? 'search-navbar'
: icon;
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
var Close = {
2017-11-11 04:33:51 +00:00
extends: IconComponent,
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
icon: function() {
return ("close-" + (hasClass(this.$el, 'uk-close-large') ? 'large' : 'icon'));
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
var Spinner = {
2017-11-11 04:33:51 +00:00
extends: IconComponent,
2017-11-11 04:33:51 +00:00
connected: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.svg.then(function (svg) { return svg && this$1.ratio !== 1 && css($('circle', svg), 'strokeWidth', 1 / this$1.ratio); });
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var parsed = {};
function install$3(UIkit) {
UIkit.icon.add = function (name, svg) {
var obj;
2017-11-11 04:33:51 +00:00
var added = isString(name) ? (( obj = {}, obj[name] = svg, obj )) : name;
each(added, function (svg, name) {
icons[name] = svg;
delete parsed[name];
});
2017-11-11 04:33:51 +00:00
if (UIkit._initialized) {
2021-05-27 00:23:07 +00:00
apply$1(document.body, function (el) { return each(UIkit.getComponents(el), function (cmp) {
2019-04-22 13:31:39 +00:00
cmp.$options.isIcon && cmp.icon in added && cmp.$reset();
}); }
2017-11-11 04:33:51 +00:00
);
}
};
}
2017-11-11 04:33:51 +00:00
function getIcon(icon) {
2017-11-11 04:33:51 +00:00
if (!icons[icon]) {
return null;
}
2017-11-11 04:33:51 +00:00
if (!parsed[icon]) {
2021-05-27 00:23:07 +00:00
parsed[icon] = $((icons[applyRtl(icon)] || icons[icon]).trim());
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
return parsed[icon].cloneNode(true);
}
2017-11-11 04:33:51 +00:00
function applyRtl(icon) {
return isRtl ? swap(swap(icon, 'left', 'right'), 'previous', 'next') : icon;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var img = {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
args: 'dataSrc',
props: {
dataSrc: String,
dataSrcset: Boolean,
sizes: String,
width: Number,
height: Number,
offsetTop: String,
offsetLeft: String,
target: String
},
data: {
dataSrc: '',
dataSrcset: false,
sizes: false,
width: false,
height: false,
offsetTop: '50vh',
2021-05-27 00:23:07 +00:00
offsetLeft: '50vw',
target: false
},
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
cacheKey: function(ref) {
var dataSrc = ref.dataSrc;
2017-11-11 04:33:51 +00:00
return ((this.$name) + "." + dataSrc);
},
2017-11-11 04:33:51 +00:00
width: function(ref) {
2019-04-22 13:31:39 +00:00
var width = ref.width;
var dataWidth = ref.dataWidth;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return width || dataWidth;
},
2017-11-11 04:33:51 +00:00
height: function(ref) {
2019-04-22 13:31:39 +00:00
var height = ref.height;
var dataHeight = ref.dataHeight;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return height || dataHeight;
2017-11-11 04:33:51 +00:00
},
sizes: function(ref) {
var sizes = ref.sizes;
var dataSizes = ref.dataSizes;
2017-11-11 04:33:51 +00:00
return sizes || dataSizes;
},
2017-11-11 04:33:51 +00:00
isImg: function(_, $el) {
return isImg($el);
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
target: {
get: function(ref) {
var target = ref.target;
2021-05-27 00:23:07 +00:00
return [this.$el ].concat( queryAll(target, this.$el));
2019-04-22 13:31:39 +00:00
},
watch: function() {
this.observe();
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
offsetTop: function(ref) {
var offsetTop = ref.offsetTop;
2017-11-11 04:33:51 +00:00
return toPx(offsetTop, 'height');
},
2017-11-11 04:33:51 +00:00
offsetLeft: function(ref) {
var offsetLeft = ref.offsetLeft;
2017-11-11 04:33:51 +00:00
return toPx(offsetLeft, 'width');
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
connected: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!window.IntersectionObserver) {
setSrcAttrs(this.$el, this.dataSrc, this.dataSrcset, this.sizes);
return;
}
if (storage[this.cacheKey]) {
2021-05-27 00:23:07 +00:00
setSrcAttrs(this.$el, storage[this.cacheKey], this.dataSrcset, this.sizes);
} else if (this.isImg && this.width && this.height) {
setSrcAttrs(this.$el, getPlaceholderImage(this.width, this.height, this.sizes));
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
this.observer = new IntersectionObserver(this.load, {
rootMargin: ((this.offsetTop) + "px " + (this.offsetLeft) + "px")
});
requestAnimationFrame(this.observe);
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
disconnected: function() {
2021-05-27 00:23:07 +00:00
this.observer && this.observer.disconnect();
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
update: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
read: function(ref) {
var this$1 = this;
var image = ref.image;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.observer) {
return false;
}
2019-04-22 13:31:39 +00:00
if (!image && document.readyState === 'complete') {
this.load(this.observer.takeRecords());
}
if (this.isImg) {
return false;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
image && image.then(function (img) { return img && img.currentSrc !== '' && setSrcAttrs(this$1.$el, currentSrc(img)); });
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
write: function(data) {
if (this.dataSrcset && window.devicePixelRatio !== 1) {
var bgSize = css(this.$el, 'backgroundSize');
if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === data.bgSize) {
data.bgSize = getSourceSize(this.dataSrcset, this.sizes);
css(this.$el, 'backgroundSize', ((data.bgSize) + "px"));
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
methods: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
load: function(entries) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
// Old chromium based browsers (UC Browser) did not implement `isIntersecting`
if (!entries.some(function (entry) { return isUndefined(entry.isIntersecting) || entry.isIntersecting; })) {
2019-04-22 13:31:39 +00:00
return;
}
this._data.image = getImage(this.dataSrc, this.dataSrcset, this.sizes).then(function (img) {
setSrcAttrs(this$1.$el, currentSrc(img), img.srcset, img.sizes);
storage[this$1.cacheKey] = currentSrc(img);
return img;
2021-05-27 00:23:07 +00:00
}, function (e) { return trigger(this$1.$el, new e.constructor(e.type, e)); });
2019-04-22 13:31:39 +00:00
this.observer.disconnect();
},
observe: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this._connected && !this._data.image) {
2019-04-22 13:31:39 +00:00
this.target.forEach(function (el) { return this$1.observer.observe(el); });
}
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
function setSrcAttrs(el, src, srcset, sizes) {
2017-11-11 04:33:51 +00:00
if (isImg(el)) {
sizes && (el.sizes = sizes);
srcset && (el.srcset = srcset);
src && (el.src = src);
} else if (src) {
2017-11-11 04:33:51 +00:00
var change = !includes(el.style.backgroundImage, src);
if (change) {
2019-04-22 13:31:39 +00:00
css(el, 'backgroundImage', ("url(" + (escape(src)) + ")"));
trigger(el, createEvent('load', false));
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function getPlaceholderImage(width, height, sizes) {
var assign;
2017-11-11 04:33:51 +00:00
if (sizes) {
2019-04-22 13:31:39 +00:00
((assign = Dimensions.ratio({width: width, height: height}, 'width', toPx(sizesToPixel(sizes))), width = assign.width, height = assign.height));
}
2019-04-22 13:31:39 +00:00
return ("data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"" + width + "\" height=\"" + height + "\"></svg>");
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var sizesRe = /\s*(.*?)\s*(\w+|calc\(.*?\))\s*(?:,|$)/g;
function sizesToPixel(sizes) {
var matches;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
sizesRe.lastIndex = 0;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
while ((matches = sizesRe.exec(sizes))) {
if (!matches[1] || window.matchMedia(matches[1]).matches) {
matches = evaluateSize(matches[2]);
break;
}
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return matches || '100vw';
}
2017-11-11 04:33:51 +00:00
var sizeRe = /\d+(?:\w+|%)/g;
var additionRe = /[+-]?(\d+)/g;
function evaluateSize(size) {
return startsWith(size, 'calc')
? size
2021-05-27 00:23:07 +00:00
.slice(5, -1)
.replace(sizeRe, function (size) { return toPx(size); })
.replace(/ /g, '')
.match(additionRe)
.reduce(function (a, b) { return a + +b; }, 0)
: size;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var srcSetRe = /\s+\d+w\s*(?:,|$)/g;
function getSourceSize(srcset, sizes) {
var srcSize = toPx(sizesToPixel(sizes));
var descriptors = (srcset.match(srcSetRe) || []).map(toFloat).sort(function (a, b) { return a - b; });
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return descriptors.filter(function (size) { return size >= srcSize; })[0] || descriptors.pop() || '';
}
2017-11-11 04:33:51 +00:00
function isImg(el) {
return el.tagName === 'IMG';
}
function currentSrc(el) {
return el.currentSrc || el.src;
}
2017-11-11 04:33:51 +00:00
var key = '__test__';
var storage;
2017-11-11 04:33:51 +00:00
// workaround for Safari's private browsing mode and accessing sessionStorage in Blink
try {
storage = window.sessionStorage || {};
storage[key] = 1;
delete storage[key];
} catch (e) {
storage = {};
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var Media = {
props: {
media: Boolean
},
data: {
media: false
},
computed: {
matchMedia: function() {
var media = toMedia(this.media);
return !media || window.matchMedia(media).matches;
}
}
};
function toMedia(value) {
if (isString(value)) {
if (value[0] === '@') {
var name = "breakpoint-" + (value.substr(1));
value = toFloat(getCssVar(name));
} else if (isNaN(value)) {
return value;
}
}
return value && !isNaN(value) ? ("(min-width: " + value + "px)") : false;
}
2021-05-27 00:23:07 +00:00
var leader = {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
mixins: [Class, Media],
2017-11-11 04:33:51 +00:00
props: {
2019-04-22 13:31:39 +00:00
fill: String
2017-11-11 04:33:51 +00:00
},
data: {
fill: '',
clsWrapper: 'uk-leader-fill',
clsHide: 'uk-leader-hide',
attrFill: 'data-fill'
2017-11-11 04:33:51 +00:00
},
computed: {
fill: function(ref) {
var fill = ref.fill;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return fill || getCssVar('leader-fill-content');
2017-11-11 04:33:51 +00:00
}
},
connected: function() {
2019-04-22 13:31:39 +00:00
var assign;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
(assign = wrapInner(this.$el, ("<span class=\"" + (this.clsWrapper) + "\">")), this.wrapper = assign[0]);
},
2017-11-11 04:33:51 +00:00
disconnected: function() {
unwrap(this.wrapper.childNodes);
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
update: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
read: function(ref) {
var changed = ref.changed;
var width = ref.width;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var prev = width;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
width = Math.floor(this.$el.offsetWidth / 2);
2019-04-22 13:31:39 +00:00
return {
width: width,
fill: this.fill,
changed: changed || prev !== width,
hide: !this.matchMedia
};
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
write: function(data) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
toggleClass(this.wrapper, this.clsHide, data.hide);
2019-04-22 13:31:39 +00:00
if (data.changed) {
data.changed = false;
attr(this.wrapper, this.attrFill, new Array(data.width).join(data.fill));
}
2019-04-22 13:31:39 +00:00
},
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
var Container = {
2017-11-11 04:33:51 +00:00
props: {
container: Boolean
},
data: {
container: true
},
computed: {
container: function(ref) {
var container = ref.container;
return container === true && this.$container || container && $(container);
2017-11-11 04:33:51 +00:00
}
}
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var active = [];
2017-11-11 04:33:51 +00:00
var Modal = {
2017-11-11 04:33:51 +00:00
mixins: [Class, Container, Togglable],
props: {
selPanel: String,
selClose: String,
escClose: Boolean,
bgClose: Boolean,
stack: Boolean
2017-11-11 04:33:51 +00:00
},
data: {
cls: 'uk-open',
escClose: true,
bgClose: true,
overlay: true,
stack: false
},
computed: {
panel: function(ref, $el) {
var selPanel = ref.selPanel;
return $(selPanel, $el);
},
transitionElement: function() {
return this.panel;
},
bgClose: function(ref) {
var bgClose = ref.bgClose;
2017-11-11 04:33:51 +00:00
return bgClose && this.panel;
2017-11-11 04:33:51 +00:00
}
},
2019-04-22 13:31:39 +00:00
beforeDisconnect: function() {
if (this.isToggled()) {
2021-05-27 00:23:07 +00:00
this.toggleElement(this.$el, false, false);
2019-04-22 13:31:39 +00:00
}
},
2017-11-11 04:33:51 +00:00
events: [
{
name: 'click',
delegate: function() {
return this.selClose;
2017-11-11 04:33:51 +00:00
},
handler: function(e) {
e.preventDefault();
this.hide();
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
},
{
name: 'toggle',
2017-11-11 04:33:51 +00:00
self: true,
handler: function(e) {
if (e.defaultPrevented) {
return;
2017-11-11 04:33:51 +00:00
}
e.preventDefault();
2021-05-27 00:23:07 +00:00
if (this.isToggled() === includes(active, this)) {
this.toggle();
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
},
{
name: 'beforeshow',
2017-11-11 04:33:51 +00:00
self: true,
handler: function(e) {
2021-05-27 00:23:07 +00:00
if (includes(active, this)) {
return false;
}
2021-05-27 00:23:07 +00:00
if (!this.stack && active.length) {
Promise$1.all(active.map(function (modal) { return modal.hide(); })).then(this.show);
e.preventDefault();
} else {
active.push(this);
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
},
{
2019-04-22 13:31:39 +00:00
name: 'show',
2017-11-11 04:33:51 +00:00
self: true,
2017-11-11 04:33:51 +00:00
handler: function() {
2021-05-27 00:23:07 +00:00
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var docEl = document.documentElement;
if (width(window) > docEl.clientWidth && this.overlay) {
css(document.body, 'overflowY', 'scroll');
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
if (this.stack) {
css(this.$el, 'zIndex', toFloat(css(this.$el, 'zIndex')) + active.length);
}
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
addClass(docEl, this.clsPage);
2021-05-27 00:23:07 +00:00
if (this.bgClose) {
once(this.$el, 'hide', on(document, pointerDown, function (ref) {
var target = ref.target;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (last(active) !== this$1 || this$1.overlay && !within(target, this$1.$el) || within(target, this$1.panel)) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
once(document, (pointerUp + " " + pointerCancel + " scroll"), function (ref) {
var defaultPrevented = ref.defaultPrevented;
var type = ref.type;
var newTarget = ref.target;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!defaultPrevented && type === pointerUp && target === newTarget) {
this$1.hide();
}
}, true);
}), {self: true});
}
if (this.escClose) {
once(this.$el, 'hide', on(document, 'keydown', function (e) {
if (e.keyCode === 27 && last(active) === this$1) {
this$1.hide();
}
}), {self: true});
2017-11-11 04:33:51 +00:00
}
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
{
2017-11-11 04:33:51 +00:00
name: 'hidden',
2017-11-11 04:33:51 +00:00
self: true,
2017-11-11 04:33:51 +00:00
handler: function() {
2021-05-27 00:23:07 +00:00
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (includes(active, this)) {
active.splice(active.indexOf(this), 1);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!active.length) {
2019-04-22 13:31:39 +00:00
css(document.body, 'overflowY', '');
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
css(this.$el, 'zIndex', '');
if (!active.some(function (modal) { return modal.clsPage === this$1.clsPage; })) {
removeClass(document.documentElement, this.clsPage);
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
],
2017-11-11 04:33:51 +00:00
methods: {
2017-11-11 04:33:51 +00:00
toggle: function() {
return this.isToggled() ? this.hide() : this.show();
2017-11-11 04:33:51 +00:00
},
show: function() {
2019-04-22 13:31:39 +00:00
var this$1 = this;
2021-05-27 00:23:07 +00:00
if (this.container && parent(this.$el) !== this.container) {
append(this.container, this.$el);
2021-05-27 00:23:07 +00:00
return new Promise$1(function (resolve) { return requestAnimationFrame(function () { return this$1.show().then(resolve); }
2019-04-22 13:31:39 +00:00
); }
);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return this.toggleElement(this.$el, true, animate(this));
2017-11-11 04:33:51 +00:00
},
hide: function() {
2021-05-27 00:23:07 +00:00
return this.toggleElement(this.$el, false, animate(this));
2017-11-11 04:33:51 +00:00
}
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function animate(ref) {
2019-04-22 13:31:39 +00:00
var transitionElement = ref.transitionElement;
var _toggle = ref._toggle;
2021-05-27 00:23:07 +00:00
return function (el, show) { return new Promise$1(function (resolve, reject) { return once(el, 'show hide', function () {
2019-04-22 13:31:39 +00:00
el._reject && el._reject();
el._reject = reject;
_toggle(el, show);
2021-05-27 00:23:07 +00:00
var off = once(transitionElement, 'transitionstart', function () {
once(transitionElement, 'transitionend transitioncancel', resolve, {self: true});
clearTimeout(timer);
}, {self: true});
var timer = setTimeout(function () {
off();
2019-04-22 13:31:39 +00:00
resolve();
2021-05-27 00:23:07 +00:00
}, toMs(css(transitionElement, 'transitionDuration')));
2019-04-22 13:31:39 +00:00
}); }
2021-05-27 00:23:07 +00:00
).then(function () { return delete el._reject; }); };
2019-04-22 13:31:39 +00:00
}
2021-05-27 00:23:07 +00:00
var modal = {
2021-05-27 00:23:07 +00:00
install: install$2,
2017-11-11 04:33:51 +00:00
mixins: [Modal],
data: {
clsPage: 'uk-modal-page',
selPanel: '.uk-modal-dialog',
selClose: '.uk-modal-close, .uk-modal-close-default, .uk-modal-close-outside, .uk-modal-close-full'
2017-11-11 04:33:51 +00:00
},
events: [
{
name: 'show',
2017-11-11 04:33:51 +00:00
self: true,
2017-11-11 04:33:51 +00:00
handler: function() {
2017-11-11 04:33:51 +00:00
if (hasClass(this.panel, 'uk-margin-auto-vertical')) {
addClass(this.$el, 'uk-flex');
} else {
css(this.$el, 'display', 'block');
2017-11-11 04:33:51 +00:00
}
height(this.$el); // force reflow
}
2017-11-11 04:33:51 +00:00
},
{
name: 'hidden',
2017-11-11 04:33:51 +00:00
self: true,
2017-11-11 04:33:51 +00:00
handler: function() {
css(this.$el, 'display', '');
removeClass(this.$el, 'uk-flex');
2017-11-11 04:33:51 +00:00
}
}
2017-11-11 04:33:51 +00:00
]
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function install$2(ref) {
var modal = ref.modal;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
modal.dialog = function (content, options) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var dialog = modal(
("<div class=\"uk-modal\"> <div class=\"uk-modal-dialog\">" + content + "</div> </div>"),
options
);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
dialog.show();
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
on(dialog.$el, 'hidden', function () { return Promise$1.resolve().then(function () { return dialog.$destroy(true); }
); }, {self: true}
);
2017-11-11 04:33:51 +00:00
return dialog;
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
modal.alert = function (message, options) {
return openDialog(
function (ref) {
var labels = ref.labels;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return ("<div class=\"uk-modal-body\">" + (isString(message) ? message : html(message)) + "</div> <div class=\"uk-modal-footer uk-text-right\"> <button class=\"uk-button uk-button-primary uk-modal-close\" autofocus>" + (labels.ok) + "</button> </div>");
},
options,
function (deferred) { return deferred.resolve(); }
);
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
modal.confirm = function (message, options) {
return openDialog(
function (ref) {
var labels = ref.labels;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return ("<form> <div class=\"uk-modal-body\">" + (isString(message) ? message : html(message)) + "</div> <div class=\"uk-modal-footer uk-text-right\"> <button class=\"uk-button uk-button-default uk-modal-close\" type=\"button\">" + (labels.cancel) + "</button> <button class=\"uk-button uk-button-primary\" autofocus>" + (labels.ok) + "</button> </div> </form>");
},
options,
function (deferred) { return deferred.reject(); }
);
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
modal.prompt = function (message, value, options) {
return openDialog(
function (ref) {
var labels = ref.labels;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return ("<form class=\"uk-form-stacked\"> <div class=\"uk-modal-body\"> <label>" + (isString(message) ? message : html(message)) + "</label> <input class=\"uk-input\" value=\"" + (value || '') + "\" autofocus> </div> <div class=\"uk-modal-footer uk-text-right\"> <button class=\"uk-button uk-button-default uk-modal-close\" type=\"button\">" + (labels.cancel) + "</button> <button class=\"uk-button uk-button-primary\">" + (labels.ok) + "</button> </div> </form>");
},
options,
function (deferred) { return deferred.resolve(null); },
function (dialog) { return $('input', dialog.$el).value; }
);
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
modal.labels = {
ok: 'Ok',
cancel: 'Cancel'
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function openDialog(tmpl, options, hideFn, submitFn) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
options = assign({bgClose: false, escClose: true, labels: modal.labels}, options);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var dialog = modal.dialog(tmpl(options), options);
var deferred = new Deferred();
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var resolved = false;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
on(dialog.$el, 'submit', 'form', function (e) {
e.preventDefault();
deferred.resolve(submitFn && submitFn(dialog));
resolved = true;
dialog.hide();
});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
on(dialog.$el, 'hide', function () { return !resolved && hideFn(deferred); });
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
deferred.promise.dialog = dialog;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return deferred.promise;
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var nav = {
extends: Accordion,
data: {
targets: '> .uk-parent',
toggle: '> a',
content: '> ul'
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var navbar = {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
mixins: [Class, FlexBug],
2017-11-11 04:33:51 +00:00
props: {
dropdown: String,
mode: 'list',
align: String,
offset: Number,
boundary: Boolean,
boundaryAlign: Boolean,
clsDrop: String,
delayShow: Number,
delayHide: Number,
dropbar: Boolean,
dropbarMode: String,
dropbarAnchor: Boolean,
duration: Number
2017-11-11 04:33:51 +00:00
},
data: {
dropdown: '.uk-navbar-nav > li',
align: !isRtl ? 'left' : 'right',
clsDrop: 'uk-navbar-dropdown',
mode: undefined,
offset: undefined,
delayShow: undefined,
delayHide: undefined,
boundaryAlign: undefined,
flip: 'x',
boundary: true,
dropbar: false,
dropbarMode: 'slide',
dropbarAnchor: false,
duration: 200,
2019-04-22 13:31:39 +00:00
forceHeight: true,
selMinHeight: '.uk-navbar-nav > li > a, .uk-navbar-item, .uk-navbar-toggle'
},
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
boundary: function(ref, $el) {
var boundary = ref.boundary;
var boundaryAlign = ref.boundaryAlign;
2017-11-11 04:33:51 +00:00
return (boundary === true || boundaryAlign) ? $el : boundary;
2017-11-11 04:33:51 +00:00
},
dropbarAnchor: function(ref, $el) {
var dropbarAnchor = ref.dropbarAnchor;
2017-11-11 04:33:51 +00:00
return query(dropbarAnchor, $el);
},
pos: function(ref) {
var align = ref.align;
2017-11-11 04:33:51 +00:00
return ("bottom-" + align);
2017-11-11 04:33:51 +00:00
},
2021-05-27 00:23:07 +00:00
dropbar: {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
get: function(ref) {
var dropbar = ref.dropbar;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!dropbar) {
return null;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
dropbar = this._dropbar || query(dropbar, this.$el) || $('+ .uk-navbar-dropbar', this.$el);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return dropbar ? dropbar : (this._dropbar = $('<div></div>'));
2021-05-27 00:23:07 +00:00
},
2021-05-27 00:23:07 +00:00
watch: function(dropbar) {
addClass(dropbar, 'uk-navbar-dropbar');
},
2021-05-27 00:23:07 +00:00
immediate: true
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
dropdowns: {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
get: function(ref, $el) {
var dropdown = ref.dropdown;
var clsDrop = ref.clsDrop;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return $$((dropdown + " ." + clsDrop), $el);
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
watch: function(dropdowns) {
var this$1 = this;
this.$create(
'drop',
dropdowns.filter(function (el) { return !this$1.getDropdown(el); }),
assign({}, this.$props, {boundary: this.boundary, pos: this.pos, offset: this.dropbar || this.offset})
);
},
immediate: true
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
}
},
disconnected: function() {
this.dropbar && remove$1(this.dropbar);
delete this._dropbar;
},
2017-11-11 04:33:51 +00:00
events: [
2017-11-11 04:33:51 +00:00
{
name: 'mouseover',
2017-11-11 04:33:51 +00:00
delegate: function() {
return this.dropdown;
},
2017-11-11 04:33:51 +00:00
handler: function(ref) {
var current = ref.current;
2017-11-11 04:33:51 +00:00
var active = this.getActive();
if (active && active.toggle && !within(active.toggle.$el, current) && !active.tracker.movesTo(active.$el)) {
active.hide(false);
}
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
{
name: 'mouseleave',
2017-11-11 04:33:51 +00:00
el: function() {
return this.dropbar;
},
2017-11-11 04:33:51 +00:00
handler: function() {
var active = this.getActive();
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (active && !this.dropdowns.some(function (el) { return matches(el, ':hover'); })) {
active.hide();
}
}
},
2017-11-11 04:33:51 +00:00
{
name: 'beforeshow',
2017-11-11 04:33:51 +00:00
capture: true,
2017-11-11 04:33:51 +00:00
filter: function() {
return this.dropbar;
},
2017-11-11 04:33:51 +00:00
handler: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!parent(this.dropbar)) {
after(this.dropbarAnchor || this.$el, this.dropbar);
}
2017-11-11 04:33:51 +00:00
}
},
2017-11-11 04:33:51 +00:00
{
name: 'show',
2017-11-11 04:33:51 +00:00
filter: function() {
return this.dropbar;
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
handler: function(_, ref) {
var $el = ref.$el;
var dir = ref.dir;
if (!hasClass($el, this.clsDrop)) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this.dropbarMode === 'slide') {
addClass(this.dropbar, 'uk-navbar-dropbar-slide');
}
2017-11-11 04:33:51 +00:00
this.clsDrop && addClass($el, ((this.clsDrop) + "-dropbar"));
2017-11-11 04:33:51 +00:00
if (dir === 'bottom') {
this.transitionTo($el.offsetHeight + toFloat(css($el, 'marginTop')) + toFloat(css($el, 'marginBottom')), $el);
}
}
},
2017-11-11 04:33:51 +00:00
{
name: 'beforehide',
2017-11-11 04:33:51 +00:00
filter: function() {
return this.dropbar;
},
2017-11-11 04:33:51 +00:00
handler: function(e, ref) {
var $el = ref.$el;
2017-11-11 04:33:51 +00:00
var active = this.getActive();
2017-11-11 04:33:51 +00:00
if (matches(this.dropbar, ':hover') && active && active.$el === $el) {
e.preventDefault();
2017-11-11 04:33:51 +00:00
}
}
},
{
name: 'hide',
2017-11-11 04:33:51 +00:00
filter: function() {
return this.dropbar;
2017-11-11 04:33:51 +00:00
},
handler: function(_, ref) {
var $el = ref.$el;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!hasClass($el, this.clsDrop)) {
return;
}
2017-11-11 04:33:51 +00:00
var active = this.getActive();
2017-11-11 04:33:51 +00:00
if (!active || active && active.$el === $el) {
this.transitionTo(0);
}
}
}
2017-11-11 04:33:51 +00:00
],
2017-11-11 04:33:51 +00:00
methods: {
2017-11-11 04:33:51 +00:00
getActive: function() {
2019-04-22 13:31:39 +00:00
var ref = this.dropdowns.map(this.getDropdown).filter(function (drop) { return drop && drop.isActive(); });
var active = ref[0];
return active && includes(active.mode, 'hover') && within(active.toggle.$el, this.$el) && active;
},
2017-11-11 04:33:51 +00:00
transitionTo: function(newHeight, el) {
2019-04-22 13:31:39 +00:00
var this$1 = this;
2017-11-11 04:33:51 +00:00
var ref = this;
var dropbar = ref.dropbar;
var oldHeight = isVisible(dropbar) ? height(dropbar) : 0;
2017-11-11 04:33:51 +00:00
el = oldHeight < newHeight && el;
2017-11-11 04:33:51 +00:00
css(el, 'clip', ("rect(0," + (el.offsetWidth) + "px," + oldHeight + "px,0)"));
2017-11-11 04:33:51 +00:00
height(dropbar, oldHeight);
2017-11-11 04:33:51 +00:00
Transition.cancel([el, dropbar]);
2021-05-27 00:23:07 +00:00
return Promise$1.all([
Transition.start(dropbar, {height: newHeight}, this.duration),
Transition.start(el, {clip: ("rect(0," + (el.offsetWidth) + "px," + newHeight + "px,0)")}, this.duration)
])
.catch(noop)
2019-04-22 13:31:39 +00:00
.then(function () {
css(el, {clip: ''});
this$1.$update(dropbar);
});
},
2017-11-11 04:33:51 +00:00
getDropdown: function(el) {
return this.$getComponent(el, 'drop') || this.$getComponent(el, 'dropdown');
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var offcanvas = {
2017-11-11 04:33:51 +00:00
mixins: [Modal],
2017-11-11 04:33:51 +00:00
args: 'mode',
2017-11-11 04:33:51 +00:00
props: {
mode: String,
flip: Boolean,
overlay: Boolean
},
2017-11-11 04:33:51 +00:00
data: {
mode: 'slide',
flip: false,
overlay: false,
clsPage: 'uk-offcanvas-page',
clsContainer: 'uk-offcanvas-container',
selPanel: '.uk-offcanvas-bar',
clsFlip: 'uk-offcanvas-flip',
2019-04-22 13:31:39 +00:00
clsContainerAnimation: 'uk-offcanvas-container-animation',
clsSidebarAnimation: 'uk-offcanvas-bar-animation',
clsMode: 'uk-offcanvas',
clsOverlay: 'uk-offcanvas-overlay',
2021-05-27 00:23:07 +00:00
selClose: '.uk-offcanvas-close',
container: false
},
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
clsFlip: function(ref) {
var flip = ref.flip;
var clsFlip = ref.clsFlip;
2017-11-11 04:33:51 +00:00
return flip ? clsFlip : '';
},
2017-11-11 04:33:51 +00:00
clsOverlay: function(ref) {
var overlay = ref.overlay;
var clsOverlay = ref.clsOverlay;
2017-11-11 04:33:51 +00:00
return overlay ? clsOverlay : '';
},
2017-11-11 04:33:51 +00:00
clsMode: function(ref) {
var mode = ref.mode;
var clsMode = ref.clsMode;
2017-11-11 04:33:51 +00:00
return (clsMode + "-" + mode);
},
2017-11-11 04:33:51 +00:00
clsSidebarAnimation: function(ref) {
var mode = ref.mode;
var clsSidebarAnimation = ref.clsSidebarAnimation;
2017-11-11 04:33:51 +00:00
return mode === 'none' || mode === 'reveal' ? '' : clsSidebarAnimation;
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
clsContainerAnimation: function(ref) {
var mode = ref.mode;
2019-04-22 13:31:39 +00:00
var clsContainerAnimation = ref.clsContainerAnimation;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return mode !== 'push' && mode !== 'reveal' ? '' : clsContainerAnimation;
2017-11-11 04:33:51 +00:00
},
transitionElement: function(ref) {
var mode = ref.mode;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return mode === 'reveal' ? parent(this.panel) : this.panel;
2017-11-11 04:33:51 +00:00
}
},
2021-05-27 00:23:07 +00:00
update: {
read: function() {
if (this.isToggled() && !isVisible(this.$el)) {
this.hide();
}
},
events: ['resize']
},
2019-04-22 13:31:39 +00:00
events: [
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
{
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
name: 'click',
2019-04-22 13:31:39 +00:00
delegate: function() {
return 'a[href^="#"]';
},
2019-04-22 13:31:39 +00:00
handler: function(ref) {
2021-05-27 00:23:07 +00:00
var hash = ref.current.hash;
var defaultPrevented = ref.defaultPrevented;
2021-05-27 00:23:07 +00:00
if (!defaultPrevented && hash && $(hash, document.body)) {
2019-04-22 13:31:39 +00:00
this.hide();
}
2017-11-11 04:33:51 +00:00
}
},
{
2019-04-22 13:31:39 +00:00
name: 'touchstart',
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
passive: true,
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
el: function() {
return this.panel;
},
2017-11-11 04:33:51 +00:00
handler: function(ref) {
2019-04-22 13:31:39 +00:00
var targetTouches = ref.targetTouches;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (targetTouches.length === 1) {
this.clientY = targetTouches[0].clientY;
}
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
{
2019-04-22 13:31:39 +00:00
name: 'touchmove',
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
self: true,
passive: false,
2017-11-11 04:33:51 +00:00
filter: function() {
return this.overlay;
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
handler: function(e) {
2021-05-27 00:23:07 +00:00
e.cancelable && e.preventDefault();
2019-04-22 13:31:39 +00:00
}
},
{
name: 'touchmove',
passive: false,
el: function() {
return this.panel;
},
handler: function(e) {
if (e.targetTouches.length !== 1) {
return;
}
var clientY = event.targetTouches[0].clientY - this.clientY;
var ref = this.panel;
var scrollTop = ref.scrollTop;
var scrollHeight = ref.scrollHeight;
var clientHeight = ref.clientHeight;
if (clientHeight >= scrollHeight
|| scrollTop === 0 && clientY > 0
|| scrollHeight - scrollTop <= clientHeight && clientY < 0
) {
2021-05-27 00:23:07 +00:00
e.cancelable && e.preventDefault();
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
{
name: 'show',
2017-11-11 04:33:51 +00:00
self: true,
2017-11-11 04:33:51 +00:00
handler: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this.mode === 'reveal' && !hasClass(parent(this.panel), this.clsMode)) {
wrapAll(this.panel, '<div>');
2021-05-27 00:23:07 +00:00
addClass(parent(this.panel), this.clsMode);
}
2019-04-22 13:31:39 +00:00
css(document.documentElement, 'overflowY', this.overlay ? 'hidden' : '');
addClass(document.body, this.clsContainer, this.clsFlip);
2021-05-27 00:23:07 +00:00
css(document.body, 'touch-action', 'pan-y pinch-zoom');
css(this.$el, 'display', 'block');
2019-04-22 13:31:39 +00:00
addClass(this.$el, this.clsOverlay);
addClass(this.panel, this.clsSidebarAnimation, this.mode !== 'reveal' ? this.clsMode : '');
height(document.body); // force reflow
addClass(document.body, this.clsContainerAnimation);
this.clsContainerAnimation && suppressUserScale();
2021-05-27 00:23:07 +00:00
}
},
{
name: 'hide',
self: true,
handler: function() {
2019-04-22 13:31:39 +00:00
removeClass(document.body, this.clsContainerAnimation);
2021-05-27 00:23:07 +00:00
css(document.body, 'touch-action', '');
}
},
{
name: 'hidden',
self: true,
handler: function() {
2019-04-22 13:31:39 +00:00
this.clsContainerAnimation && resumeUserScale();
if (this.mode === 'reveal') {
unwrap(this.panel);
}
removeClass(this.panel, this.clsSidebarAnimation, this.clsMode);
removeClass(this.$el, this.clsOverlay);
css(this.$el, 'display', '');
2019-04-22 13:31:39 +00:00
removeClass(document.body, this.clsContainer, this.clsFlip);
css(document.documentElement, 'overflowY', '');
}
},
{
name: 'swipeLeft swipeRight',
handler: function(e) {
2019-04-22 13:31:39 +00:00
if (this.isToggled() && endsWith(e.type, 'Left') ^ this.flip) {
this.hide();
}
}
}
]
};
2019-04-22 13:31:39 +00:00
// Chrome in responsive mode zooms page upon opening offcanvas
function suppressUserScale() {
getViewport().content += ',user-scalable=0';
}
function resumeUserScale() {
var viewport = getViewport();
viewport.content = viewport.content.replace(/,user-scalable=0$/, '');
}
function getViewport() {
return $('meta[name="viewport"]', document.head) || append(document.head, '<meta name="viewport">');
}
2021-05-27 00:23:07 +00:00
var overflowAuto = {
mixins: [Class],
props: {
selContainer: String,
2019-04-22 13:31:39 +00:00
selContent: String
},
data: {
selContainer: '.uk-modal',
2019-04-22 13:31:39 +00:00
selContent: '.uk-modal-dialog'
},
computed: {
container: function(ref, $el) {
var selContainer = ref.selContainer;
return closest($el, selContainer);
},
content: function(ref, $el) {
var selContent = ref.selContent;
return closest($el, selContent);
}
},
connected: function() {
css(this.$el, 'minHeight', 150);
},
update: {
read: function() {
2021-05-27 00:23:07 +00:00
if (!this.content || !this.container || !isVisible(this.$el)) {
return false;
}
return {
current: toFloat(css(this.$el, 'maxHeight')),
2021-05-27 00:23:07 +00:00
max: Math.max(150, height(this.container) - (dimensions(this.content).height - height(this.$el)))
};
},
write: function(ref) {
var current = ref.current;
var max = ref.max;
css(this.$el, 'maxHeight', max);
if (Math.round(current) !== Math.round(max)) {
trigger(this.$el, 'resize');
}
},
2019-04-22 13:31:39 +00:00
events: ['resize']
}
};
2021-05-27 00:23:07 +00:00
var responsive = {
props: ['width', 'height'],
connected: function() {
addClass(this.$el, 'uk-responsive-width');
},
update: {
read: function() {
return isVisible(this.$el) && this.width && this.height
2021-05-27 00:23:07 +00:00
? {width: width(parent(this.$el)), height: this.height}
: false;
},
write: function(dim) {
2019-04-22 13:31:39 +00:00
height(this.$el, Dimensions.contain({
height: this.height,
width: this.width
}, dim).height);
},
2019-04-22 13:31:39 +00:00
events: ['resize']
}
};
2021-05-27 00:23:07 +00:00
var scroll = {
props: {
offset: Number
},
data: {
offset: 0
},
methods: {
scrollTo: function(el) {
var this$1 = this;
el = el && $(el) || document.body;
2021-05-27 00:23:07 +00:00
if (trigger(this.$el, 'beforescroll', [this, el])) {
scrollIntoView(el, {offset: this.offset}).then(function () { return trigger(this$1.$el, 'scrolled', [this$1, el]); }
);
}
}
},
events: {
click: function(e) {
if (e.defaultPrevented) {
return;
}
e.preventDefault();
2021-05-27 00:23:07 +00:00
this.scrollTo(("#" + (escape(decodeURIComponent((this.$el.hash || '').substr(1))))));
}
}
};
2021-05-27 00:23:07 +00:00
var stateKey = '_ukScrollspy';
var scrollspy = {
args: 'cls',
props: {
2019-04-22 13:31:39 +00:00
cls: String,
target: String,
hidden: Boolean,
offsetTop: Number,
offsetLeft: Number,
repeat: Boolean,
delay: Number
},
data: function () { return ({
2019-04-22 13:31:39 +00:00
cls: false,
target: false,
hidden: true,
offsetTop: 0,
offsetLeft: 0,
repeat: false,
delay: 0,
inViewClass: 'uk-scrollspy-inview'
}); },
computed: {
2021-05-27 00:23:07 +00:00
elements: {
get: function(ref, $el) {
var target = ref.target;
return target ? $$(target, $el) : [$el];
},
watch: function(elements) {
if (this.hidden) {
css(filter$1(elements, (":not(." + (this.inViewClass) + ")")), 'visibility', 'hidden');
}
},
immediate: true
}
},
2021-05-27 00:23:07 +00:00
disconnected: function() {
var this$1 = this;
2021-05-27 00:23:07 +00:00
this.elements.forEach(function (el) {
removeClass(el, this$1.inViewClass, el[stateKey] ? el[stateKey].cls : '');
delete el[stateKey];
});
},
2021-05-27 00:23:07 +00:00
update: [
{
2021-05-27 00:23:07 +00:00
read: function(data$1) {
var this$1 = this;
2021-05-27 00:23:07 +00:00
// Let child components be applied at least once first
if (!data$1.update) {
Promise$1.resolve().then(function () {
this$1.$emit();
data$1.update = true;
});
return false;
}
2019-04-22 13:31:39 +00:00
this.elements.forEach(function (el) {
2021-05-27 00:23:07 +00:00
if (!el[stateKey]) {
el[stateKey] = {cls: data(el, 'uk-scrollspy-class') || this$1.cls};
}
2021-05-27 00:23:07 +00:00
el[stateKey].show = isInView(el, this$1.offsetTop, this$1.offsetLeft);
});
},
2019-04-22 13:31:39 +00:00
write: function(data) {
var this$1 = this;
2019-04-22 13:31:39 +00:00
this.elements.forEach(function (el) {
2021-05-27 00:23:07 +00:00
var state = el[stateKey];
2019-04-22 13:31:39 +00:00
if (state.show && !state.inview && !state.queued) {
2021-05-27 00:23:07 +00:00
state.queued = true;
2021-05-27 00:23:07 +00:00
data.promise = (data.promise || Promise$1.resolve()).then(function () { return new Promise$1(function (resolve) { return setTimeout(resolve, this$1.delay); }
); }
).then(function () {
this$1.toggle(el, true);
setTimeout(function () {
state.queued = false;
this$1.$emit();
}, 300);
});
2021-05-27 00:23:07 +00:00
} else if (!state.show && state.inview && !state.queued && this$1.repeat) {
2021-05-27 00:23:07 +00:00
this$1.toggle(el, false);
2021-05-27 00:23:07 +00:00
}
2021-05-27 00:23:07 +00:00
});
2021-05-27 00:23:07 +00:00
},
2021-05-27 00:23:07 +00:00
events: ['scroll', 'resize']
2021-05-27 00:23:07 +00:00
}
2021-05-27 00:23:07 +00:00
],
2021-05-27 00:23:07 +00:00
methods: {
2021-05-27 00:23:07 +00:00
toggle: function(el, inview) {
2021-05-27 00:23:07 +00:00
var state = el[stateKey];
2021-05-27 00:23:07 +00:00
state.off && state.off();
2021-05-27 00:23:07 +00:00
css(el, 'visibility', !inview && this.hidden ? 'hidden' : '');
2021-05-27 00:23:07 +00:00
toggleClass(el, this.inViewClass, inview);
toggleClass(el, state.cls);
2021-05-27 00:23:07 +00:00
if (/\buk-animation-/.test(state.cls)) {
state.off = once(el, 'animationcancel animationend', function () { return removeClasses(el, 'uk-animation-\\w*'); }
);
}
2021-05-27 00:23:07 +00:00
trigger(el, inview ? 'inview' : 'outview');
2021-05-27 00:23:07 +00:00
state.inview = inview;
2021-05-27 00:23:07 +00:00
this.$update(el);
}
2021-05-27 00:23:07 +00:00
}
};
2021-05-27 00:23:07 +00:00
var scrollspyNav = {
props: {
cls: String,
closest: String,
scroll: Boolean,
overflow: Boolean,
offset: Number
},
data: {
cls: 'uk-active',
closest: false,
scroll: false,
overflow: true,
offset: 0
},
2021-05-27 00:23:07 +00:00
computed: {
links: {
get: function(_, $el) {
return $$('a[href^="#"]', $el).filter(function (el) { return el.hash; });
},
watch: function(links) {
if (this.scroll) {
this.$create('scroll', links, {offset: this.offset || 0});
}
},
2021-05-27 00:23:07 +00:00
immediate: true
},
targets: function() {
return $$(this.links.map(function (el) { return escape(el.hash).substr(1); }).join(','));
},
2019-04-22 13:31:39 +00:00
elements: function(ref) {
var selector = ref.closest;
return closest(this.links, selector || '*');
}
},
update: [
{
read: function() {
var this$1 = this;
2021-05-27 00:23:07 +00:00
var ref = this.targets;
var length = ref.length;
2021-05-27 00:23:07 +00:00
if (!length || !isVisible(this.$el)) {
return false;
}
2021-05-27 00:23:07 +00:00
var ref$1 = scrollParents(this.targets, /auto|scroll/, true);
var scrollElement = ref$1[0];
var scrollTop = scrollElement.scrollTop;
var scrollHeight = scrollElement.scrollHeight;
var max = scrollHeight - getViewportClientHeight(scrollElement);
var active = false;
2021-05-27 00:23:07 +00:00
if (scrollTop === max) {
active = length - 1;
} else {
2021-05-27 00:23:07 +00:00
this.targets.every(function (el, i) {
if (offset(el).top - offset(getViewport$1(scrollElement)).top - this$1.offset <= 0) {
active = i;
return true;
}
2021-05-27 00:23:07 +00:00
});
2021-05-27 00:23:07 +00:00
if (active === false && this.overflow) {
active = 0;
}
}
2021-05-27 00:23:07 +00:00
return {active: active};
},
write: function(ref) {
var active = ref.active;
this.links.forEach(function (el) { return el.blur(); });
removeClass(this.elements, this.cls);
2021-05-27 00:23:07 +00:00
if (active !== false) {
trigger(this.$el, 'active', [active, addClass(this.elements[active], this.cls)]);
}
},
2019-04-22 13:31:39 +00:00
events: ['scroll', 'resize']
}
]
};
2021-05-27 00:23:07 +00:00
var sticky = {
2019-04-22 13:31:39 +00:00
mixins: [Class, Media],
props: {
top: null,
bottom: Boolean,
2021-05-27 00:23:07 +00:00
offset: String,
animation: String,
clsActive: String,
clsInactive: String,
clsFixed: String,
clsBelow: String,
selTarget: String,
widthElement: Boolean,
showOnUp: Boolean,
targetOffset: Number
},
data: {
top: 0,
bottom: false,
offset: 0,
animation: '',
clsActive: 'uk-active',
clsInactive: '',
clsFixed: 'uk-sticky-fixed',
clsBelow: 'uk-sticky-below',
selTarget: '',
widthElement: false,
showOnUp: false,
targetOffset: false
},
computed: {
2021-05-27 00:23:07 +00:00
offset: function(ref) {
var offset = ref.offset;
return toPx(offset);
},
selTarget: function(ref, $el) {
var selTarget = ref.selTarget;
return selTarget && $(selTarget, $el) || $el;
},
widthElement: function(ref, $el) {
var widthElement = ref.widthElement;
return query(widthElement, $el) || this.placeholder;
2019-04-22 13:31:39 +00:00
},
isActive: {
get: function() {
return hasClass(this.selTarget, this.clsActive);
},
set: function(value) {
if (value && !this.isActive) {
replaceClass(this.selTarget, this.clsInactive, this.clsActive);
trigger(this.$el, 'active');
} else if (!value && !hasClass(this.selTarget, this.clsInactive)) {
replaceClass(this.selTarget, this.clsActive, this.clsInactive);
trigger(this.$el, 'inactive');
}
}
}
},
connected: function() {
this.placeholder = $('+ .uk-sticky-placeholder', this.$el) || $('<div class="uk-sticky-placeholder"></div>');
2019-04-22 13:31:39 +00:00
this.isFixed = false;
this.isActive = false;
},
disconnected: function() {
2019-04-22 13:31:39 +00:00
if (this.isFixed) {
this.hide();
removeClass(this.selTarget, this.clsInactive);
}
2021-05-27 00:23:07 +00:00
remove$1(this.placeholder);
this.placeholder = null;
this.widthElement = null;
},
events: [
{
name: 'load hashchange popstate',
2021-05-27 00:23:07 +00:00
el: function() {
return window;
},
handler: function() {
var this$1 = this;
if (!(this.targetOffset !== false && location.hash && window.pageYOffset > 0)) {
return;
}
var target = $(location.hash);
if (target) {
fastdom.read(function () {
var ref = offset(target);
var top = ref.top;
var elTop = offset(this$1.$el).top;
var elHeight = this$1.$el.offsetHeight;
2019-04-22 13:31:39 +00:00
if (this$1.isFixed && elTop + elHeight >= top && elTop <= top + target.offsetHeight) {
scrollTop(window, top - elHeight - (isNumeric(this$1.targetOffset) ? this$1.targetOffset : 0) - this$1.offset);
}
});
}
}
}
],
update: [
{
2021-05-27 00:23:07 +00:00
read: function(ref, types) {
2019-04-22 13:31:39 +00:00
var height = ref.height;
2021-05-27 00:23:07 +00:00
this.inactive = !this.matchMedia || !isVisible(this.$el);
if (this.inactive) {
return false;
}
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
if (this.isActive && types.has('resize')) {
2019-04-22 13:31:39 +00:00
this.hide();
height = this.$el.offsetHeight;
this.show();
}
height = !this.isActive ? this.$el.offsetHeight : height;
this.topOffset = offset(this.isFixed ? this.placeholder : this.$el).top;
this.bottomOffset = this.topOffset + height;
var bottom = parseProp('bottom', this);
this.top = Math.max(toFloat(parseProp('top', this)), this.topOffset) - this.offset;
2021-05-27 00:23:07 +00:00
this.bottom = bottom && bottom - this.$el.offsetHeight;
this.width = dimensions(isVisible(this.widthElement) ? this.widthElement : this.$el).width;
2019-04-22 13:31:39 +00:00
return {
2019-04-22 13:31:39 +00:00
height: height,
2021-05-27 00:23:07 +00:00
top: offsetPosition(this.placeholder)[0],
2019-04-22 13:31:39 +00:00
margins: css(this.$el, ['marginTop', 'marginBottom', 'marginLeft', 'marginRight'])
};
},
write: function(ref) {
2019-04-22 13:31:39 +00:00
var height = ref.height;
var margins = ref.margins;
var ref$1 = this;
var placeholder = ref$1.placeholder;
2019-04-22 13:31:39 +00:00
css(placeholder, assign({height: height}, margins));
if (!within(placeholder, document)) {
after(this.$el, placeholder);
2021-05-27 00:23:07 +00:00
placeholder.hidden = true;
}
2021-05-27 00:23:07 +00:00
this.isActive = !!this.isActive; // force self-assign
},
2019-04-22 13:31:39 +00:00
events: ['resize']
},
{
2019-04-22 13:31:39 +00:00
read: function(ref) {
var scroll = ref.scroll; if ( scroll === void 0 ) scroll = 0;
2019-04-22 13:31:39 +00:00
this.scroll = window.pageYOffset;
return {
2019-04-22 13:31:39 +00:00
dir: scroll <= this.scroll ? 'down' : 'up',
2021-05-27 00:23:07 +00:00
scroll: this.scroll
};
},
2021-05-27 00:23:07 +00:00
write: function(data, types) {
var this$1 = this;
2021-05-27 00:23:07 +00:00
var now = Date.now();
var isScrollUpdate = types.has('scroll');
2019-04-22 13:31:39 +00:00
var initTimestamp = data.initTimestamp; if ( initTimestamp === void 0 ) initTimestamp = 0;
var dir = data.dir;
var lastDir = data.lastDir;
var lastScroll = data.lastScroll;
var scroll = data.scroll;
var top = data.top;
data.lastScroll = scroll;
2021-05-27 00:23:07 +00:00
if (scroll < 0 || scroll === lastScroll && isScrollUpdate || this.showOnUp && !isScrollUpdate && !this.isFixed) {
2019-04-22 13:31:39 +00:00
return;
}
if (now - initTimestamp > 300 || dir !== lastDir) {
data.initScroll = scroll;
data.initTimestamp = now;
}
data.lastDir = dir;
2021-05-27 00:23:07 +00:00
if (this.showOnUp && !this.isFixed && Math.abs(data.initScroll - scroll) <= 30 && Math.abs(lastScroll - scroll) <= 10) {
return;
}
if (this.inactive
|| scroll < this.top
2021-05-27 00:23:07 +00:00
|| this.showOnUp && (scroll <= this.top || dir === 'down' && isScrollUpdate || dir === 'up' && !this.isFixed && scroll <= this.bottomOffset)
) {
2019-04-22 13:31:39 +00:00
if (!this.isFixed) {
if (Animation.inProgress(this.$el) && top > scroll) {
Animation.cancel(this.$el);
this.hide();
}
return;
}
2019-04-22 13:31:39 +00:00
this.isFixed = false;
if (this.animation && scroll > this.topOffset) {
Animation.cancel(this.$el);
Animation.out(this.$el, this.animation).then(function () { return this$1.hide(); }, noop);
} else {
this.hide();
}
2019-04-22 13:31:39 +00:00
} else if (this.isFixed) {
this.update();
} else if (this.animation) {
Animation.cancel(this.$el);
this.show();
Animation.in(this.$el, this.animation).catch(noop);
} else {
this.show();
}
},
2019-04-22 13:31:39 +00:00
events: ['resize', 'scroll']
}
2019-04-22 13:31:39 +00:00
],
methods: {
show: function() {
2019-04-22 13:31:39 +00:00
this.isFixed = true;
this.update();
2021-05-27 00:23:07 +00:00
this.placeholder.hidden = false;
},
hide: function() {
2019-04-22 13:31:39 +00:00
this.isActive = false;
removeClass(this.$el, this.clsFixed, this.clsBelow);
css(this.$el, {position: '', top: '', width: ''});
2021-05-27 00:23:07 +00:00
this.placeholder.hidden = true;
},
update: function() {
var active = this.top !== 0 || this.scroll > this.top;
var top = Math.max(0, this.offset);
2021-05-27 00:23:07 +00:00
if (isNumeric(this.bottom) && this.scroll > this.bottom - this.offset) {
top = this.bottom - this.scroll;
}
css(this.$el, {
position: 'fixed',
top: (top + "px"),
width: this.width
});
2019-04-22 13:31:39 +00:00
this.isActive = active;
toggleClass(this.$el, this.clsBelow, this.scroll > this.bottomOffset);
addClass(this.$el, this.clsFixed);
}
}
};
function parseProp(prop, ref) {
var $props = ref.$props;
var $el = ref.$el;
var propOffset = ref[(prop + "Offset")];
var value = $props[prop];
if (!value) {
return;
}
2021-05-27 00:23:07 +00:00
if (isString(value) && value.match(/^-?\d/)) {
2021-05-27 00:23:07 +00:00
return propOffset + toPx(value);
} else {
2021-05-27 00:23:07 +00:00
return offset(value === true ? parent($el) : query(value, $el)).bottom;
}
}
var Switcher = {
mixins: [Togglable],
args: 'connect',
props: {
connect: String,
toggle: String,
active: Number,
swiping: Boolean
},
data: {
connect: '~.uk-switcher',
2019-04-22 13:31:39 +00:00
toggle: '> * > :first-child',
active: 0,
swiping: true,
cls: 'uk-active',
2021-05-27 00:23:07 +00:00
attrItem: 'uk-switcher-item'
},
computed: {
2021-05-27 00:23:07 +00:00
connects: {
get: function(ref, $el) {
var connect = ref.connect;
return queryAll(connect, $el);
},
watch: function(connects) {
var this$1 = this;
if (this.swiping) {
css(connects, 'touch-action', 'pan-y pinch-zoom');
}
var index = this.index();
this.connects.forEach(function (el) { return children(el).forEach(function (child, i) { return toggleClass(child, this$1.cls, i === index); }
); }
);
},
immediate: true
},
2021-05-27 00:23:07 +00:00
toggles: {
get: function(ref, $el) {
var toggle = ref.toggle;
return $$(toggle, $el).filter(function (el) { return !matches(el, '.uk-disabled *, .uk-disabled, [disabled]'); });
},
watch: function(toggles) {
var active = this.index();
this.show(~active ? active : toggles[this.active] || toggles[0]);
},
immediate: true
},
children: function() {
var this$1 = this;
2021-05-27 00:23:07 +00:00
return children(this.$el).filter(function (child) { return this$1.toggles.some(function (toggle) { return within(toggle, child); }); });
}
},
events: [
{
name: 'click',
delegate: function() {
2021-05-27 00:23:07 +00:00
return this.toggle;
},
handler: function(e) {
e.preventDefault();
2021-05-27 00:23:07 +00:00
this.show(e.current);
}
},
{
name: 'click',
el: function() {
return this.connects;
},
delegate: function() {
return ("[" + (this.attrItem) + "],[data-" + (this.attrItem) + "]");
},
handler: function(e) {
e.preventDefault();
this.show(data(e.current, this.attrItem));
}
},
{
name: 'swipeRight swipeLeft',
filter: function() {
return this.swiping;
},
el: function() {
return this.connects;
},
2019-04-22 13:31:39 +00:00
handler: function(ref) {
var type = ref.type;
2019-04-22 13:31:39 +00:00
this.show(endsWith(type, 'Left') ? 'next' : 'previous');
}
}
],
methods: {
index: function() {
2021-05-27 00:23:07 +00:00
var this$1 = this;
return findIndex(this.children, function (el) { return hasClass(el, this$1.cls); });
},
show: function(item) {
var this$1 = this;
var prev = this.index();
2021-05-27 00:23:07 +00:00
var next = getIndex(
this.children[getIndex(item, this.toggles, prev)],
children(this.$el)
);
2021-05-27 00:23:07 +00:00
if (prev === next) {
return;
}
2021-05-27 00:23:07 +00:00
this.children.forEach(function (child, i) {
toggleClass(child, this$1.cls, next === i);
attr(this$1.toggles[i], 'aria-expanded', next === i);
});
2021-05-27 00:23:07 +00:00
this.connects.forEach(function (ref) {
var children = ref.children;
return this$1.toggleElement(toNodes(children).filter(function (child) { return hasClass(child, this$1.cls); }
), false, prev >= 0).then(function () { return this$1.toggleElement(children[next], true, prev >= 0); }
);
}
);
}
}
};
2021-05-27 00:23:07 +00:00
var tab = {
2017-11-11 04:33:51 +00:00
mixins: [Class],
extends: Switcher,
props: {
2019-04-22 13:31:39 +00:00
media: Boolean
},
data: {
media: 960,
attrItem: 'uk-tab-item'
},
connected: function() {
var cls = hasClass(this.$el, 'uk-tab-left')
? 'uk-tab-left'
: hasClass(this.$el, 'uk-tab-right')
? 'uk-tab-right'
: false;
if (cls) {
this.$create('toggle', this.$el, {cls: cls, mode: 'media', media: this.media});
}
}
};
2021-05-27 00:23:07 +00:00
var toggle = {
2019-04-22 13:31:39 +00:00
mixins: [Media, Togglable],
args: 'target',
props: {
href: String,
target: null,
2021-05-27 00:23:07 +00:00
mode: 'list',
queued: Boolean
},
data: {
href: false,
target: false,
mode: 'click',
2019-04-22 13:31:39 +00:00
queued: true
},
2021-05-27 00:23:07 +00:00
connected: function() {
if (!isFocusable(this.$el)) {
attr(this.$el, 'tabindex', '0');
}
},
computed: {
2021-05-27 00:23:07 +00:00
target: {
2021-05-27 00:23:07 +00:00
get: function(ref, $el) {
var href = ref.href;
var target = ref.target;
2021-05-27 00:23:07 +00:00
target = queryAll(target || href, $el);
return target.length && target || [$el];
},
watch: function() {
this.updateAria();
},
immediate: true
}
2019-04-22 13:31:39 +00:00
},
events: [
{
2021-05-27 00:23:07 +00:00
name: (pointerEnter + " " + pointerLeave + " focus blur"),
filter: function() {
return includes(this.mode, 'hover');
},
handler: function(e) {
if (!isTouch(e)) {
2021-05-27 00:23:07 +00:00
this.toggle(("toggle" + (includes([pointerEnter, 'focus'], e.type) ? 'show' : 'hide')));
}
}
},
{
name: 'click',
filter: function() {
return includes(this.mode, 'click') || hasTouch && includes(this.mode, 'hover');
},
handler: function(e) {
var link;
2021-05-27 00:23:07 +00:00
if (closest(e.target, 'a[href="#"], a[href=""]')
|| (link = closest(e.target, 'a[href]')) && (
2021-05-27 00:23:07 +00:00
!isToggled(this.target, this.cls)
|| link.hash && matches(this.target, link.hash)
)
) {
2019-04-22 13:31:39 +00:00
e.preventDefault();
}
this.toggle();
}
2021-05-27 00:23:07 +00:00
},
{
name: 'toggled',
self: true,
el: function() {
return this.target;
},
handler: function(e, toggled) {
this.updateAria(toggled);
}
}
2019-04-22 13:31:39 +00:00
],
update: {
2019-04-22 13:31:39 +00:00
read: function() {
return includes(this.mode, 'media') && this.media
? {match: this.matchMedia}
: false;
},
write: function(ref) {
var match = ref.match;
var toggled = this.isToggled(this.target);
2019-04-22 13:31:39 +00:00
if (match ? !toggled : toggled) {
this.toggle();
}
},
2019-04-22 13:31:39 +00:00
events: ['resize']
},
methods: {
toggle: function(type) {
2021-05-27 00:23:07 +00:00
var this$1 = this;
if (!trigger(this.target, type || 'toggle', [this])) {
return;
}
if (!this.queued) {
return this.toggleElement(this.target);
}
var leaving = this.target.filter(function (el) { return hasClass(el, this$1.clsLeave); });
if (leaving.length) {
this.target.forEach(function (el) {
var isLeaving = includes(leaving, el);
this$1.toggleElement(el, isLeaving, isLeaving);
});
return;
}
2021-05-27 00:23:07 +00:00
var toggled = this.target.filter(this.isToggled);
this.toggleElement(toggled, false).then(function () { return this$1.toggleElement(this$1.target.filter(function (el) { return !includes(toggled, el); }
), true); }
);
},
updateAria: function(toggled) {
attr(this.$el, 'aria-expanded', isBoolean(toggled)
? toggled
: isToggled(this.target, this.cls)
);
}
}
};
2021-05-27 00:23:07 +00:00
// TODO improve isToggled handling
function isToggled(target, cls) {
return cls
? hasClass(target, cls.split(' ')[0])
: isVisible(target);
}
var components$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
Accordion: Accordion,
Alert: alert,
Cover: cover,
Drop: drop,
Dropdown: drop,
FormCustom: formCustom,
Gif: gif,
Grid: grid,
HeightMatch: heightMatch,
HeightViewport: heightViewport,
Icon: Icon,
Img: img,
Leader: leader,
Margin: Margin,
Modal: modal,
Nav: nav,
Navbar: navbar,
Offcanvas: offcanvas,
OverflowAuto: overflowAuto,
Responsive: responsive,
Scroll: scroll,
Scrollspy: scrollspy,
ScrollspyNav: scrollspyNav,
Sticky: sticky,
Svg: SVG,
Switcher: Switcher,
Tab: tab,
Toggle: toggle,
Video: Video,
Close: Close,
Spinner: Spinner,
SlidenavNext: Slidenav,
SlidenavPrevious: Slidenav,
SearchIcon: Search,
Marker: IconComponent,
NavbarToggleIcon: IconComponent,
OverlayIcon: IconComponent,
PaginationNext: IconComponent,
PaginationPrevious: IconComponent,
Totop: IconComponent
});
// register components
each(components$1, function (component, name) { return UIkit.component(name, component); }
);
// core functionality
UIkit.use(Core);
boot(UIkit);
var countdown = {
mixins: [Class],
2017-11-11 04:33:51 +00:00
props: {
date: String,
clsWrapper: String
2017-11-11 04:33:51 +00:00
},
data: {
date: '',
clsWrapper: '.uk-countdown-%unit%'
2017-11-11 04:33:51 +00:00
},
computed: {
date: function(ref) {
var date = ref.date;
2017-11-11 04:33:51 +00:00
return Date.parse(date);
},
2017-11-11 04:33:51 +00:00
days: function(ref, $el) {
var clsWrapper = ref.clsWrapper;
2017-11-11 04:33:51 +00:00
return $(clsWrapper.replace('%unit%', 'days'), $el);
},
2017-11-11 04:33:51 +00:00
hours: function(ref, $el) {
var clsWrapper = ref.clsWrapper;
2017-11-11 04:33:51 +00:00
return $(clsWrapper.replace('%unit%', 'hours'), $el);
},
2017-11-11 04:33:51 +00:00
minutes: function(ref, $el) {
var clsWrapper = ref.clsWrapper;
2017-11-11 04:33:51 +00:00
return $(clsWrapper.replace('%unit%', 'minutes'), $el);
},
seconds: function(ref, $el) {
var clsWrapper = ref.clsWrapper;
return $(clsWrapper.replace('%unit%', 'seconds'), $el);
},
units: function() {
var this$1 = this;
return ['days', 'hours', 'minutes', 'seconds'].filter(function (unit) { return this$1[unit]; });
2017-11-11 04:33:51 +00:00
}
},
connected: function() {
this.start();
},
disconnected: function() {
2017-11-11 04:33:51 +00:00
var this$1 = this;
this.stop();
this.units.forEach(function (unit) { return empty(this$1[unit]); });
},
events: [
{
name: 'visibilitychange',
2021-05-27 00:23:07 +00:00
el: function() {
return document;
},
handler: function() {
if (document.hidden) {
this.stop();
} else {
this.start();
}
}
2017-11-11 04:33:51 +00:00
}
],
update: {
write: function() {
var this$1 = this;
var timespan = getTimeSpan(this.date);
if (timespan.total <= 0) {
this.stop();
timespan.days
= timespan.hours
= timespan.minutes
= timespan.seconds
= 0;
}
this.units.forEach(function (unit) {
var digits = String(Math.floor(timespan[unit]));
digits = digits.length < 2 ? ("0" + digits) : digits;
2017-11-11 04:33:51 +00:00
var el = this$1[unit];
if (el.textContent !== digits) {
digits = digits.split('');
2017-11-11 04:33:51 +00:00
if (digits.length !== el.children.length) {
html(el, digits.map(function () { return '<span></span>'; }).join(''));
}
2017-11-11 04:33:51 +00:00
digits.forEach(function (digit, i) { return el.children[i].textContent = digit; });
2017-11-11 04:33:51 +00:00
}
});
2017-11-11 04:33:51 +00:00
}
},
methods: {
2017-11-11 04:33:51 +00:00
start: function() {
2017-11-11 04:33:51 +00:00
this.stop();
if (this.date && this.units.length) {
2021-05-27 00:23:07 +00:00
this.$update();
this.timer = setInterval(this.$update, 1000);
2017-11-11 04:33:51 +00:00
}
},
stop: function() {
2017-11-11 04:33:51 +00:00
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
2017-11-11 04:33:51 +00:00
}
}
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
function getTimeSpan(date) {
2017-11-11 04:33:51 +00:00
var total = date - Date.now();
return {
total: total,
seconds: total / 1000 % 60,
minutes: total / 1000 / 60 % 60,
hours: total / 1000 / 60 / 60 % 24,
days: total / 1000 / 60 / 60 / 24
};
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var clsLeave = 'uk-transition-leave';
var clsEnter = 'uk-transition-enter';
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function fade(action, target, duration, stagger) {
if ( stagger === void 0 ) stagger = 0;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var index = transitionIndex(target, true);
var propsIn = {opacity: 1};
var propsOut = {opacity: 0};
2021-05-27 00:23:07 +00:00
var wrapIndexFn = function (fn) { return function () { return index === transitionIndex(target) ? fn() : Promise$1.reject(); }; };
2021-05-27 00:23:07 +00:00
var leaveFn = wrapIndexFn(function () {
2021-05-27 00:23:07 +00:00
addClass(target, clsLeave);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return Promise$1.all(getTransitionNodes(target).map(function (child, i) { return new Promise$1(function (resolve) { return setTimeout(function () { return Transition.start(child, propsOut, duration / 2, 'ease').then(resolve); }, i * stagger); }
); }
)).then(function () { return removeClass(target, clsLeave); });
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var enterFn = wrapIndexFn(function () {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var oldHeight = height(target);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
addClass(target, clsEnter);
action();
2021-05-27 00:23:07 +00:00
css(children(target), {opacity: 0});
2021-05-27 00:23:07 +00:00
// Ensure UIkit updates have propagated
return new Promise$1(function (resolve) { return requestAnimationFrame(function () {
2021-05-27 00:23:07 +00:00
var nodes = children(target);
var newHeight = height(target);
2021-05-27 00:23:07 +00:00
// Ensure Grid cells do not stretch when height is applied
css(target, 'alignContent', 'flex-start');
height(target, oldHeight);
2021-05-27 00:23:07 +00:00
var transitionNodes = getTransitionNodes(target);
css(nodes, propsOut);
2021-05-27 00:23:07 +00:00
var transitions = transitionNodes.map(function (child, i) { return new Promise$1(function (resolve) { return setTimeout(function () { return Transition.start(child, propsIn, duration / 2, 'ease').then(resolve); }, i * stagger); }
); }
);
2021-05-27 00:23:07 +00:00
if (oldHeight !== newHeight) {
transitions.push(Transition.start(target, {height: newHeight}, duration / 2 + transitionNodes.length * stagger, 'ease'));
}
2021-05-27 00:23:07 +00:00
Promise$1.all(transitions).then(function () {
removeClass(target, clsEnter);
if (index === transitionIndex(target)) {
css(target, {height: '', alignContent: ''});
css(nodes, {opacity: ''});
delete target.dataset.transition;
}
resolve();
});
}); }
);
});
2021-05-27 00:23:07 +00:00
return hasClass(target, clsLeave)
? waitTransitionend(target).then(enterFn)
: hasClass(target, clsEnter)
? waitTransitionend(target).then(leaveFn).then(enterFn)
: leaveFn().then(enterFn);
}
2021-05-27 00:23:07 +00:00
function transitionIndex(target, next) {
if (next) {
target.dataset.transition = 1 + transitionIndex(target);
}
2021-05-27 00:23:07 +00:00
return toNumber(target.dataset.transition) || 0;
}
2021-05-27 00:23:07 +00:00
function waitTransitionend(target) {
return Promise$1.all(children(target).filter(Transition.inProgress).map(function (el) { return new Promise$1(function (resolve) { return once(el, 'transitionend transitioncanceled', resolve); }); }
));
}
2021-05-27 00:23:07 +00:00
function getTransitionNodes(target) {
return getRows(children(target)).reduce(function (nodes, row) { return nodes.concat(sortBy$1(row.filter(function (el) { return isInView(el); }), 'offsetLeft')); }, []);
}
function slide (action, target, duration) {
return new Promise$1(function (resolve) { return requestAnimationFrame(function () {
var nodes = children(target);
// Get current state
var currentProps = nodes.map(function (el) { return getProps(el, true); });
var targetProps = css(target, ['height', 'padding']);
// Cancel previous animations
Transition.cancel(target);
nodes.forEach(Transition.cancel);
reset(target);
// Adding, sorting, removing nodes
action();
// Find new nodes
nodes = nodes.concat(children(target).filter(function (el) { return !includes(nodes, el); }));
// Wait for update to propagate
Promise$1.resolve().then(function () {
// Force update
fastdom.flush();
// Get new state
var targetPropsTo = css(target, ['height', 'padding']);
var ref = getTransitionProps(target, nodes, currentProps);
var propsTo = ref[0];
var propsFrom = ref[1];
// Reset to previous state
nodes.forEach(function (el, i) { return propsFrom[i] && css(el, propsFrom[i]); });
css(target, assign({display: 'block'}, targetProps));
// Start transitions on next frame
requestAnimationFrame(function () {
var transitions = nodes.map(function (el, i) { return parent(el) === target && Transition.start(el, propsTo[i], duration, 'ease'); }
).concat(Transition.start(target, targetPropsTo, duration, 'ease'));
Promise$1.all(transitions).then(function () {
nodes.forEach(function (el, i) { return parent(el) === target && css(el, 'display', propsTo[i].opacity === 0 ? 'none' : ''); });
reset(target);
}, noop).then(resolve);
});
});
}); });
}
function getProps(el, opacity) {
var zIndex = css(el, 'zIndex');
return isVisible(el)
? assign({
display: '',
opacity: opacity ? css(el, 'opacity') : '0',
pointerEvents: 'none',
position: 'absolute',
zIndex: zIndex === 'auto' ? index(el) : zIndex
}, getPositionWithMargin(el))
: false;
}
2021-05-27 00:23:07 +00:00
function getTransitionProps(target, nodes, currentProps) {
var propsTo = nodes.map(function (el, i) { return parent(el) && i in currentProps
? currentProps[i]
? isVisible(el)
? getPositionWithMargin(el)
: {opacity: 0}
: {opacity: isVisible(el) ? 1 : 0}
: false; });
var propsFrom = propsTo.map(function (props, i) {
var from = parent(nodes[i]) === target && (currentProps[i] || getProps(nodes[i]));
if (!from) {
return false;
}
if (!props) {
delete from.opacity;
} else if (!('opacity' in props)) {
var opacity = from.opacity;
if (opacity % 1) {
props.opacity = 1;
} else {
delete from.opacity;
}
}
return from;
});
return [propsTo, propsFrom];
}
function reset(el) {
css(el.children, {
height: '',
left: '',
opacity: '',
pointerEvents: '',
position: '',
top: '',
2021-05-27 00:23:07 +00:00
marginTop: '',
marginLeft: '',
transform: '',
width: '',
zIndex: ''
});
2021-05-27 00:23:07 +00:00
css(el, {height: '', display: '', padding: ''});
}
function getPositionWithMargin(el) {
2021-05-27 00:23:07 +00:00
var ref = offset(el);
2019-04-22 13:31:39 +00:00
var height = ref.height;
var width = ref.width;
var ref$1 = position(el);
var top = ref$1.top;
var left = ref$1.left;
2021-05-27 00:23:07 +00:00
var ref$2 = css(el, ['marginTop', 'marginLeft']);
var marginLeft = ref$2.marginLeft;
var marginTop = ref$2.marginTop;
2021-05-27 00:23:07 +00:00
return {top: top, left: left, height: height, width: width, marginLeft: marginLeft, marginTop: marginTop, transform: ''};
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var Animate = {
props: {
duration: Number,
animation: Boolean
},
data: {
duration: 150,
animation: 'slide'
},
methods: {
animate: function(action, target) {
var this$1 = this;
if ( target === void 0 ) target = this.$el;
var name = this.animation;
var animationFn = name === 'fade'
? fade
: name === 'delayed-fade'
? function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
return fade.apply(void 0, args.concat( [40] ));
}
: !name
? function () {
action();
return Promise$1.resolve();
}
: slide;
return animationFn(action, target, this.duration)
.then(function () { return this$1.$update(target, 'resize'); }, noop);
}
}
2021-05-27 00:23:07 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var filter = {
2017-11-11 04:33:51 +00:00
mixins: [Animate],
2017-11-11 04:33:51 +00:00
args: 'target',
2017-11-11 04:33:51 +00:00
props: {
target: Boolean,
selActive: Boolean
},
2017-11-11 04:33:51 +00:00
data: {
target: null,
selActive: false,
attrItem: 'uk-filter-control',
cls: 'uk-active',
2021-05-27 00:23:07 +00:00
duration: 250
},
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
toggles: {
get: function(ref, $el) {
var attrItem = ref.attrItem;
2021-05-27 00:23:07 +00:00
return $$(("[" + attrItem + "],[data-" + attrItem + "]"), $el);
2019-04-22 13:31:39 +00:00
},
watch: function() {
2021-05-27 00:23:07 +00:00
var this$1 = this;
2019-04-22 13:31:39 +00:00
this.updateState();
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this.selActive !== false) {
var actives = $$(this.selActive, this.$el);
this.toggles.forEach(function (el) { return toggleClass(el, this$1.cls, includes(actives, el)); });
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
},
immediate: true
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
children: {
2021-05-27 00:23:07 +00:00
get: function(ref, $el) {
var target = ref.target;
return $$((target + " > *"), $el);
2019-04-22 13:31:39 +00:00
},
watch: function(list, old) {
2021-05-27 00:23:07 +00:00
if (old && !isEqualList(list, old)) {
2019-04-22 13:31:39 +00:00
this.updateState();
}
2021-05-27 00:23:07 +00:00
},
immediate: true
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
events: [
2017-11-11 04:33:51 +00:00
{
name: 'click',
2017-11-11 04:33:51 +00:00
delegate: function() {
return ("[" + (this.attrItem) + "],[data-" + (this.attrItem) + "]");
},
2017-11-11 04:33:51 +00:00
handler: function(e) {
2017-11-11 04:33:51 +00:00
e.preventDefault();
this.apply(e.current);
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
],
2017-11-11 04:33:51 +00:00
methods: {
apply: function(el) {
2021-05-27 00:23:07 +00:00
var prevState = this.getState();
var newState = mergeState(el, this.attrItem, this.getState());
if (!isEqualState(prevState, newState)) {
this.setState(newState);
}
},
2017-11-11 04:33:51 +00:00
getState: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
return this.toggles
.filter(function (item) { return hasClass(item, this$1.cls); })
.reduce(function (state, el) { return mergeState(el, this$1.attrItem, state); }, {filter: {'': ''}, sort: []});
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
setState: function(state, animate) {
var this$1 = this;
2019-04-22 13:31:39 +00:00
if ( animate === void 0 ) animate = true;
2017-11-11 04:33:51 +00:00
state = assign({filter: {'': ''}, sort: []}, state);
2017-11-11 04:33:51 +00:00
trigger(this.$el, 'beforeFilter', [this, state]);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this.toggles.forEach(function (el) { return toggleClass(el, this$1.cls, !!matchFilter(el, this$1.attrItem, state)); });
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
Promise$1.all($$(this.target, this.$el).map(function (target) {
var filterFn = function () {
applyState(state, target, children(target));
this$1.$update(this$1.$el);
};
return animate ? this$1.animate(filterFn, target) : filterFn();
})).then(function () { return trigger(this$1.$el, 'afterFilter', [this$1]); });
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
updateState: function() {
var this$1 = this;
fastdom.write(function () { return this$1.setState(this$1.getState(), false); });
2017-11-11 04:33:51 +00:00
}
}
};
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function getFilter(el, attr) {
return parseOptions(data(el, attr), ['filter']);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function isEqualState(stateA, stateB) {
return ['filter', 'sort'].every(function (prop) { return isEqual(stateA[prop], stateB[prop]); });
}
function applyState(state, target, children) {
var selector = getSelector(state);
children.forEach(function (el) { return css(el, 'display', selector && !matches(el, selector) ? 'none' : ''); });
var ref = state.sort;
var sort = ref[0];
var order = ref[1];
if (sort) {
var sorted = sortItems(children, sort, order);
if (!isEqual(sorted, children)) {
append(target, sorted);
}
}
}
2019-04-22 13:31:39 +00:00
function mergeState(el, attr, state) {
var filterBy = getFilter(el, attr);
var filter = filterBy.filter;
var group = filterBy.group;
var sort = filterBy.sort;
var order = filterBy.order; if ( order === void 0 ) order = 'asc';
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (filter || isUndefined(sort)) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (group) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (filter) {
delete state.filter[''];
2019-04-22 13:31:39 +00:00
state.filter[group] = filter;
} else {
2019-04-22 13:31:39 +00:00
delete state.filter[group];
if (isEmpty(state.filter) || '' in state.filter) {
state.filter = {'': filter || ''};
}
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
} else {
state.filter = {'': filter || ''};
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}
if (!isUndefined(sort)) {
state.sort = [sort, order];
}
2017-11-11 04:33:51 +00:00
return state;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function matchFilter(el, attr, ref) {
var stateFilter = ref.filter; if ( stateFilter === void 0 ) stateFilter = {'': ''};
var ref_sort = ref.sort;
var stateSort = ref_sort[0];
var stateOrder = ref_sort[1];
2019-04-22 13:31:39 +00:00
var ref$1 = getFilter(el, attr);
var filter = ref$1.filter; if ( filter === void 0 ) filter = '';
var group = ref$1.group; if ( group === void 0 ) group = '';
var sort = ref$1.sort;
var order = ref$1.order; if ( order === void 0 ) order = 'asc';
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return isUndefined(sort)
? group in stateFilter && filter === stateFilter[group]
|| !filter && group && !(group in stateFilter) && !stateFilter['']
: stateSort === sort && stateOrder === order;
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function isEqualList(listA, listB) {
return listA.length === listB.length
2019-04-22 13:31:39 +00:00
&& listA.every(function (el) { return ~listB.indexOf(el); });
}
2017-11-11 04:33:51 +00:00
function getSelector(ref) {
2019-04-22 13:31:39 +00:00
var filter = ref.filter;
2017-11-11 04:33:51 +00:00
var selector = '';
2019-04-22 13:31:39 +00:00
each(filter, function (value) { return selector += value || ''; });
return selector;
}
2017-11-11 04:33:51 +00:00
function sortItems(nodes, sort, order) {
2019-04-22 13:31:39 +00:00
return assign([], nodes).sort(function (a, b) { return data(a, sort).localeCompare(data(b, sort), undefined, {numeric: true}) * (order === 'asc' || -1); });
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var Animations$2 = {
2017-11-11 04:33:51 +00:00
slide: {
2017-11-11 04:33:51 +00:00
show: function(dir) {
return [
{transform: translate(dir * -100)},
{transform: translate()}
];
},
2017-11-11 04:33:51 +00:00
percent: function(current) {
return translated(current);
},
2017-11-11 04:33:51 +00:00
translate: function(percent, dir) {
return [
{transform: translate(dir * -100 * percent)},
{transform: translate(dir * 100 * (1 - percent))}
];
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
function translated(el) {
return Math.abs(css(el, 'transform').split(',')[4] / el.offsetWidth) || 0;
}
2017-11-11 04:33:51 +00:00
function translate(value, unit) {
if ( value === void 0 ) value = 0;
if ( unit === void 0 ) unit = '%';
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
value += value ? unit : '';
return isIE ? ("translateX(" + value + ")") : ("translate3d(" + value + ", 0, 0)"); // currently not translate3d in IE, translate3d within translate3d does not work while transitioning
}
2017-11-11 04:33:51 +00:00
function scale3d(value) {
return ("scale3d(" + value + ", " + value + ", 1)");
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var Animations$1 = assign({}, Animations$2, {
2017-11-11 04:33:51 +00:00
fade: {
2017-11-11 04:33:51 +00:00
show: function() {
return [
{opacity: 0},
{opacity: 1}
];
},
2017-11-11 04:33:51 +00:00
percent: function(current) {
return 1 - css(current, 'opacity');
},
2017-11-11 04:33:51 +00:00
translate: function(percent) {
return [
{opacity: 1 - percent},
{opacity: percent}
];
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
scale: {
2017-11-11 04:33:51 +00:00
show: function() {
return [
{opacity: 0, transform: scale3d(1 - .2)},
{opacity: 1, transform: scale3d(1)}
];
},
2017-11-11 04:33:51 +00:00
percent: function(current) {
return 1 - css(current, 'opacity');
},
2017-11-11 04:33:51 +00:00
translate: function(percent) {
return [
{opacity: 1 - percent, transform: scale3d(1 - .2 * percent)},
{opacity: percent, transform: scale3d(1 - .2 + .2 * percent)}
];
}
2017-11-11 04:33:51 +00:00
}
});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function Transitioner$1(prev, next, dir, ref) {
var animation = ref.animation;
var easing = ref.easing;
2017-11-11 04:33:51 +00:00
var percent = animation.percent;
var translate = animation.translate;
var show = animation.show; if ( show === void 0 ) show = noop;
var props = show(dir);
var deferred = new Deferred();
2017-11-11 04:33:51 +00:00
return {
2017-11-11 04:33:51 +00:00
dir: dir,
2017-11-11 04:33:51 +00:00
show: function(duration, percent, linear) {
var this$1 = this;
if ( percent === void 0 ) percent = 0;
2017-11-11 04:33:51 +00:00
var timing = linear ? 'linear' : easing;
duration -= Math.round(duration * clamp(percent, -1, 1));
2017-11-11 04:33:51 +00:00
this.translate(percent);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
triggerUpdate$1(next, 'itemin', {percent: percent, duration: duration, timing: timing, dir: dir});
triggerUpdate$1(prev, 'itemout', {percent: 1 - percent, duration: duration, timing: timing, dir: dir});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
Promise$1.all([
Transition.start(next, props[1], duration, timing),
Transition.start(prev, props[0], duration, timing)
]).then(function () {
this$1.reset();
deferred.resolve();
}, noop);
2017-11-11 04:33:51 +00:00
return deferred.promise;
},
2017-11-11 04:33:51 +00:00
cancel: function() {
Transition.cancel([next, prev]);
},
2017-11-11 04:33:51 +00:00
reset: function() {
for (var prop in props[0]) {
css([next, prev], prop, '');
}
},
2017-11-11 04:33:51 +00:00
forward: function(duration, percent) {
if ( percent === void 0 ) percent = this.percent();
2017-11-11 04:33:51 +00:00
Transition.cancel([next, prev]);
return this.show(duration, percent, true);
},
2017-11-11 04:33:51 +00:00
translate: function(percent) {
2017-11-11 04:33:51 +00:00
this.reset();
2017-11-11 04:33:51 +00:00
var props = translate(percent, dir);
css(next, props[1]);
css(prev, props[0]);
2021-05-27 00:23:07 +00:00
triggerUpdate$1(next, 'itemtranslatein', {percent: percent, dir: dir});
triggerUpdate$1(prev, 'itemtranslateout', {percent: 1 - percent, dir: dir});
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
percent: function() {
return percent(prev || next, next, dir);
},
2017-11-11 04:33:51 +00:00
getDistance: function() {
2019-04-22 13:31:39 +00:00
return prev && prev.offsetWidth;
2017-11-11 04:33:51 +00:00
}
};
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function triggerUpdate$1(el, type, data) {
2019-04-22 13:31:39 +00:00
trigger(el, createEvent(type, false, false, data));
}
2017-11-11 04:33:51 +00:00
var SliderAutoplay = {
2017-11-11 04:33:51 +00:00
props: {
autoplay: Boolean,
autoplayInterval: Number,
pauseOnHover: Boolean
2017-11-11 04:33:51 +00:00
},
data: {
autoplay: false,
autoplayInterval: 7000,
pauseOnHover: true
2017-11-11 04:33:51 +00:00
},
connected: function() {
2019-04-22 13:31:39 +00:00
this.autoplay && this.startAutoplay();
},
2017-11-11 04:33:51 +00:00
disconnected: function() {
this.stopAutoplay();
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
update: function() {
attr(this.slides, 'tabindex', '-1');
},
2017-11-11 04:33:51 +00:00
events: [
{
name: 'visibilitychange',
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
el: function() {
return document;
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
filter: function() {
return this.autoplay;
},
handler: function() {
if (document.hidden) {
this.stopAutoplay();
} else {
this.startAutoplay();
}
2017-11-11 04:33:51 +00:00
}
}
],
methods: {
startAutoplay: function() {
2017-11-11 04:33:51 +00:00
var this$1 = this;
this.stopAutoplay();
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this.interval = setInterval(
2021-05-27 00:23:07 +00:00
function () { return (!this$1.draggable || !$(':focus', this$1.$el))
&& (!this$1.pauseOnHover || !matches(this$1.$el, ':hover'))
2019-04-22 13:31:39 +00:00
&& !this$1.stack.length
&& this$1.show('next'); },
this.autoplayInterval
);
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
stopAutoplay: function() {
2019-04-22 13:31:39 +00:00
this.interval && clearInterval(this.interval);
2017-11-11 04:33:51 +00:00
}
}
};
2017-11-11 04:33:51 +00:00
var SliderDrag = {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
props: {
draggable: Boolean
},
data: {
2019-04-22 13:31:39 +00:00
draggable: true,
threshold: 10
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
created: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
['start', 'move', 'end'].forEach(function (key) {
2017-11-11 04:33:51 +00:00
var fn = this$1[key];
this$1[key] = function (e) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var pos = getEventPos(e).x * (isRtl ? -1 : 1);
2017-11-11 04:33:51 +00:00
this$1.prevPos = pos !== this$1.pos ? this$1.pos : this$1.prevPos;
this$1.pos = pos;
2017-11-11 04:33:51 +00:00
fn(e);
};
2017-11-11 04:33:51 +00:00
});
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
events: [
2017-11-11 04:33:51 +00:00
{
2017-11-11 04:33:51 +00:00
name: pointerDown,
2017-11-11 04:33:51 +00:00
delegate: function() {
2019-04-22 13:31:39 +00:00
return this.selSlides;
},
2017-11-11 04:33:51 +00:00
handler: function(e) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (!this.draggable
|| !isTouch(e) && hasTextNodesOnly(e.target)
2021-05-27 00:23:07 +00:00
|| closest(e.target, selInput)
|| e.button > 0
|| this.length < 2
) {
return;
}
2017-11-11 04:33:51 +00:00
this.start(e);
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
{
name: 'dragstart',
2017-11-11 04:33:51 +00:00
handler: function(e) {
e.preventDefault();
}
}
2017-11-11 04:33:51 +00:00
],
2017-11-11 04:33:51 +00:00
methods: {
2017-11-11 04:33:51 +00:00
start: function() {
2017-11-11 04:33:51 +00:00
this.drag = this.pos;
2017-11-11 04:33:51 +00:00
if (this._transitioner) {
this.percent = this._transitioner.percent();
this.drag += this._transitioner.getDistance() * this.percent * this.dir;
this._transitioner.cancel();
this._transitioner.translate(this.percent);
2017-11-11 04:33:51 +00:00
this.dragging = true;
2017-11-11 04:33:51 +00:00
this.stack = [];
2017-11-11 04:33:51 +00:00
} else {
this.prevIndex = this.index;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
on(document, pointerMove, this.move, {passive: false});
// 'input' event is triggered by video controls
on(document, (pointerUp + " " + pointerCancel + " input"), this.end, true);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
css(this.list, 'userSelect', 'none');
2017-11-11 04:33:51 +00:00
},
move: function(e) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
var distance = this.pos - this.drag;
if (distance === 0 || this.prevPos === this.pos || !this.dragging && Math.abs(distance) < this.threshold) {
return;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
// prevent click event
2019-04-22 13:31:39 +00:00
css(this.list, 'pointerEvents', 'none');
e.cancelable && e.preventDefault();
2017-11-11 04:33:51 +00:00
this.dragging = true;
this.dir = (distance < 0 ? 1 : -1);
2017-11-11 04:33:51 +00:00
var ref = this;
var slides = ref.slides;
var ref$1 = this;
var prevIndex = ref$1.prevIndex;
var dis = Math.abs(distance);
var nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);
2019-04-22 13:31:39 +00:00
var width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
while (nextIndex !== prevIndex && dis > width) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this.drag -= width * this.dir;
2017-11-11 04:33:51 +00:00
prevIndex = nextIndex;
2019-04-22 13:31:39 +00:00
dis -= width;
nextIndex = this.getIndex(prevIndex + this.dir, prevIndex);
width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth;
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this.percent = dis / width;
2017-11-11 04:33:51 +00:00
var prev = slides[prevIndex];
var next = slides[nextIndex];
var changed = this.index !== nextIndex;
var edge = prevIndex === nextIndex;
2017-11-11 04:33:51 +00:00
var itemShown;
2017-11-11 04:33:51 +00:00
[this.index, this.prevIndex].filter(function (i) { return !includes([nextIndex, prevIndex], i); }).forEach(function (i) {
trigger(slides[i], 'itemhidden', [this$1]);
2017-11-11 04:33:51 +00:00
if (edge) {
itemShown = true;
this$1.prevIndex = prevIndex;
}
2017-11-11 04:33:51 +00:00
});
2017-11-11 04:33:51 +00:00
if (this.index === prevIndex && this.prevIndex !== prevIndex || itemShown) {
trigger(slides[this.index], 'itemshown', [this]);
}
if (changed) {
this.prevIndex = prevIndex;
this.index = nextIndex;
!edge && trigger(prev, 'beforeitemhide', [this]);
trigger(next, 'beforeitemshow', [this]);
2017-11-11 04:33:51 +00:00
}
this._transitioner = this._translate(Math.abs(this.percent), prev, !edge && next);
if (changed) {
!edge && trigger(prev, 'itemhide', [this]);
trigger(next, 'itemshow', [this]);
2017-11-11 04:33:51 +00:00
}
},
end: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
off(document, pointerMove, this.move, {passive: false});
off(document, (pointerUp + " " + pointerCancel + " input"), this.end, true);
2017-11-11 04:33:51 +00:00
if (this.dragging) {
2017-11-11 04:33:51 +00:00
this.dragging = null;
2017-11-11 04:33:51 +00:00
if (this.index === this.prevIndex) {
this.percent = 1 - this.percent;
this.dir *= -1;
this._show(false, this.index, true);
this._transitioner = null;
} else {
2017-11-11 04:33:51 +00:00
var dirChange = (isRtl ? this.dir * (isRtl ? 1 : -1) : this.dir) < 0 === this.prevPos > this.pos;
this.index = dirChange ? this.index : this.prevIndex;
2017-11-11 04:33:51 +00:00
if (dirChange) {
this.percent = 1 - this.percent;
}
2017-11-11 04:33:51 +00:00
this.show(this.dir > 0 && !dirChange || this.dir < 0 && dirChange ? 'next' : 'previous', true);
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
css(this.list, {userSelect: '', pointerEvents: ''});
this.drag
= this.percent
= null;
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
function hasTextNodesOnly(el) {
return !el.children.length && el.childNodes.length;
}
2017-11-11 04:33:51 +00:00
var SliderNav = {
2017-11-11 04:33:51 +00:00
data: {
selNav: false
},
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
nav: function(ref, $el) {
var selNav = ref.selNav;
return $(selNav, $el);
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
selNavItem: function(ref) {
var attrItem = ref.attrItem;
2017-11-11 04:33:51 +00:00
return ("[" + attrItem + "],[data-" + attrItem + "]");
2017-11-11 04:33:51 +00:00
},
navItems: function(_, $el) {
2019-04-22 13:31:39 +00:00
return $$(this.selNavItem, $el);
2017-11-11 04:33:51 +00:00
}
},
2019-04-22 13:31:39 +00:00
update: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
write: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (this.nav && this.length !== this.nav.children.length) {
2021-05-27 00:23:07 +00:00
html(this.nav, this.slides.map(function (_, i) { return ("<li " + (this$1.attrItem) + "=\"" + i + "\"><a href></a></li>"); }).join(''));
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.navItems.concat(this.nav).forEach(function (el) { return el && (el.hidden = !this$1.maxIndex); });
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this.updateNav();
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
events: [
2017-11-11 04:33:51 +00:00
{
2017-11-11 04:33:51 +00:00
name: 'click',
2017-11-11 04:33:51 +00:00
delegate: function() {
2019-04-22 13:31:39 +00:00
return this.selNavItem;
},
2017-11-11 04:33:51 +00:00
handler: function(e) {
e.preventDefault();
this.show(data(e.current, this.attrItem));
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
{
2017-11-11 04:33:51 +00:00
name: 'itemshow',
handler: 'updateNav'
2017-11-11 04:33:51 +00:00
}
],
2017-11-11 04:33:51 +00:00
methods: {
updateNav: function() {
2017-11-11 04:33:51 +00:00
var this$1 = this;
var i = this.getValidIndex();
this.navItems.forEach(function (el) {
2017-11-11 04:33:51 +00:00
var cmd = data(el, this$1.attrItem);
2017-11-11 04:33:51 +00:00
toggleClass(el, this$1.clsActive, toNumber(cmd) === i);
toggleClass(el, 'uk-invisible', this$1.finite && (cmd === 'previous' && i === 0 || cmd === 'next' && i >= this$1.maxIndex));
});
2017-11-11 04:33:51 +00:00
}
}
};
2017-11-11 04:33:51 +00:00
var Slider = {
2017-11-11 04:33:51 +00:00
mixins: [SliderAutoplay, SliderDrag, SliderNav],
2017-11-11 04:33:51 +00:00
props: {
clsActivated: Boolean,
easing: String,
index: Number,
finite: Boolean,
2021-05-27 00:23:07 +00:00
velocity: Number,
selSlides: String
},
2017-11-11 04:33:51 +00:00
data: function () { return ({
easing: 'ease',
finite: false,
velocity: 1,
index: 0,
2021-05-27 00:23:07 +00:00
prevIndex: -1,
stack: [],
percent: 0,
clsActive: 'uk-active',
clsActivated: false,
Transitioner: false,
transitionOptions: {}
}); },
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
connected: function() {
this.prevIndex = -1;
this.index = this.getValidIndex(this.$props.index);
this.stack = [];
},
disconnected: function() {
removeClass(this.slides, this.clsActive);
},
computed: {
2017-11-11 04:33:51 +00:00
duration: function(ref, $el) {
var velocity = ref.velocity;
2017-11-11 04:33:51 +00:00
return speedUp($el.offsetWidth / velocity);
},
2017-11-11 04:33:51 +00:00
list: function(ref, $el) {
var selList = ref.selList;
2017-11-11 04:33:51 +00:00
return $(selList, $el);
},
2017-11-11 04:33:51 +00:00
maxIndex: function() {
return this.length - 1;
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
selSlides: function(ref) {
var selList = ref.selList;
2021-05-27 00:23:07 +00:00
var selSlides = ref.selSlides;
return (selList + " " + (selSlides || '> *'));
},
slides: {
get: function() {
return $$(this.selSlides, this.$el);
},
watch: function() {
this.$reset();
}
2017-11-11 04:33:51 +00:00
},
2021-05-27 00:23:07 +00:00
length: function() {
return this.slides.length;
2017-11-11 04:33:51 +00:00
}
},
events: {
itemshown: function() {
this.$update(this.list);
}
2017-11-11 04:33:51 +00:00
},
methods: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
show: function(index, force) {
var this$1 = this;
if ( force === void 0 ) force = false;
2017-11-11 04:33:51 +00:00
if (this.dragging || !this.length) {
return;
}
2017-11-11 04:33:51 +00:00
var ref = this;
var stack = ref.stack;
var queueIndex = force ? 0 : stack.length;
var reset = function () {
stack.splice(queueIndex, 1);
2017-11-11 04:33:51 +00:00
if (stack.length) {
this$1.show(stack.shift(), true);
}
};
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
stack[force ? 'unshift' : 'push'](index);
2017-11-11 04:33:51 +00:00
if (!force && stack.length > 1) {
2017-11-11 04:33:51 +00:00
if (stack.length === 2) {
this._transitioner.forward(Math.min(this.duration, 200));
}
2017-11-11 04:33:51 +00:00
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var prevIndex = this.getIndex(this.index);
var prev = hasClass(this.slides, this.clsActive) && this.slides[prevIndex];
2019-04-22 13:31:39 +00:00
var nextIndex = this.getIndex(index, this.index);
var next = this.slides[nextIndex];
2017-11-11 04:33:51 +00:00
if (prev === next) {
reset();
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this.dir = getDirection(index, prevIndex);
this.prevIndex = prevIndex;
this.index = nextIndex;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (prev && !trigger(prev, 'beforeitemhide', [this])
|| !trigger(next, 'beforeitemshow', [this, prev])
) {
this.index = this.prevIndex;
reset();
return;
}
2017-11-11 04:33:51 +00:00
var promise = this._show(prev, next, force).then(function () {
2017-11-11 04:33:51 +00:00
prev && trigger(prev, 'itemhidden', [this$1]);
trigger(next, 'itemshown', [this$1]);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return new Promise$1(function (resolve) {
fastdom.write(function () {
stack.shift();
if (stack.length) {
this$1.show(stack.shift(), true);
} else {
this$1._transitioner = null;
}
resolve();
});
});
2017-11-11 04:33:51 +00:00
});
2017-11-11 04:33:51 +00:00
prev && trigger(prev, 'itemhide', [this]);
trigger(next, 'itemshow', [this]);
2017-11-11 04:33:51 +00:00
return promise;
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
getIndex: function(index, prev) {
if ( index === void 0 ) index = this.index;
if ( prev === void 0 ) prev = this.index;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return clamp(getIndex(index, this.slides, prev, this.finite), 0, this.maxIndex);
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
getValidIndex: function(index, prevIndex) {
if ( index === void 0 ) index = this.index;
if ( prevIndex === void 0 ) prevIndex = this.prevIndex;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return this.getIndex(index, prevIndex);
},
2017-11-11 04:33:51 +00:00
_show: function(prev, next, force) {
2017-11-11 04:33:51 +00:00
this._transitioner = this._getTransitioner(
prev,
next,
this.dir,
assign({
easing: force
? next.offsetWidth < 600
? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
: 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
: this.easing
}, this.transitionOptions)
);
2017-11-11 04:33:51 +00:00
if (!force && !prev) {
2021-05-27 00:23:07 +00:00
this._translate(1);
return Promise$1.resolve();
}
2017-11-11 04:33:51 +00:00
var ref = this.stack;
var length = ref.length;
return this._transitioner[length > 1 ? 'forward' : 'show'](length > 1 ? Math.min(this.duration, 75 + 75 / (length - 1)) : this.duration, this.percent);
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
_getDistance: function(prev, next) {
2021-05-27 00:23:07 +00:00
return this._getTransitioner(prev, prev !== next && next).getDistance();
2017-11-11 04:33:51 +00:00
},
_translate: function(percent, prev, next) {
if ( prev === void 0 ) prev = this.prevIndex;
if ( next === void 0 ) next = this.index;
var transitioner = this._getTransitioner(prev !== next ? prev : false, next);
transitioner.translate(percent);
return transitioner;
2017-11-11 04:33:51 +00:00
},
_getTransitioner: function(prev, next, dir, options) {
if ( prev === void 0 ) prev = this.prevIndex;
if ( next === void 0 ) next = this.index;
if ( dir === void 0 ) dir = this.dir || 1;
if ( options === void 0 ) options = this.transitionOptions;
2017-11-11 04:33:51 +00:00
return new this.Transitioner(
isNumber(prev) ? this.slides[prev] : prev,
isNumber(next) ? this.slides[next] : next,
dir * (isRtl ? -1 : 1),
options
);
}
2017-11-11 04:33:51 +00:00
}
};
2019-04-22 13:31:39 +00:00
function getDirection(index, prevIndex) {
return index === 'next'
? 1
2019-04-22 13:31:39 +00:00
: index === 'previous'
? -1
2019-04-22 13:31:39 +00:00
: index < prevIndex
? -1
: 1;
}
function speedUp(x) {
return .5 * x + 300; // parabola through (400,500; 600,600; 1800,1200)
}
var Slideshow = {
mixins: [Slider],
2017-11-11 04:33:51 +00:00
props: {
animation: String
2017-11-11 04:33:51 +00:00
},
data: {
2017-11-11 04:33:51 +00:00
animation: 'slide',
clsActivated: 'uk-transition-active',
2021-05-27 00:23:07 +00:00
Animations: Animations$2,
Transitioner: Transitioner$1
2017-11-11 04:33:51 +00:00
},
computed: {
animation: function(ref) {
var animation = ref.animation;
2019-04-22 13:31:39 +00:00
var Animations = ref.Animations;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return assign(Animations[animation] || Animations.slide, {name: animation});
2017-11-11 04:33:51 +00:00
},
transitionOptions: function() {
return {animation: this.animation};
}
},
events: {
'itemshow itemhide itemshown itemhidden': function(ref) {
var target = ref.target;
this.$update(target);
2017-11-11 04:33:51 +00:00
},
beforeitemshow: function(ref) {
var target = ref.target;
addClass(target, this.clsActive);
2017-11-11 04:33:51 +00:00
},
itemshown: function(ref) {
var target = ref.target;
2017-11-11 04:33:51 +00:00
addClass(target, this.clsActivated);
},
2017-11-11 04:33:51 +00:00
itemhidden: function(ref) {
var target = ref.target;
2017-11-11 04:33:51 +00:00
removeClass(target, this.clsActive, this.clsActivated);
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var LightboxPanel = {
2017-11-11 04:33:51 +00:00
mixins: [Container, Modal, Togglable, Slideshow],
2017-11-11 04:33:51 +00:00
functional: true,
2017-11-11 04:33:51 +00:00
props: {
delayControls: Number,
preload: Number,
videoAutoplay: Boolean,
template: String
2017-11-11 04:33:51 +00:00
},
data: function () { return ({
preload: 1,
videoAutoplay: false,
delayControls: 3000,
items: [],
cls: 'uk-open',
clsPage: 'uk-lightbox-page',
selList: '.uk-lightbox-items',
attrItem: 'uk-lightbox-item',
selClose: '.uk-close-large',
2021-05-27 00:23:07 +00:00
selCaption: '.uk-lightbox-caption',
pauseOnHover: false,
velocity: 2,
Animations: Animations$1,
2021-05-27 00:23:07 +00:00
template: "<div class=\"uk-lightbox uk-overflow-hidden\"> <ul class=\"uk-lightbox-items\"></ul> <div class=\"uk-lightbox-toolbar uk-position-top uk-text-right uk-transition-slide-top uk-transition-opaque\"> <button class=\"uk-lightbox-toolbar-icon uk-close-large\" type=\"button\" uk-close></button> </div> <a class=\"uk-lightbox-button uk-position-center-left uk-position-medium uk-transition-fade\" href uk-slidenav-previous uk-lightbox-item=\"previous\"></a> <a class=\"uk-lightbox-button uk-position-center-right uk-position-medium uk-transition-fade\" href uk-slidenav-next uk-lightbox-item=\"next\"></a> <div class=\"uk-lightbox-toolbar uk-lightbox-caption uk-position-bottom uk-text-center uk-transition-slide-bottom uk-transition-opaque\"></div> </div>"
}); },
2017-11-11 04:33:51 +00:00
created: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var $el = $(this.template);
var list = $(this.selList, $el);
this.items.forEach(function () { return append(list, '<li>'); });
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.$mount(append(this.container, $el));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
},
computed: {
caption: function(ref, $el) {
var selCaption = ref.selCaption;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return $(selCaption, $el);
}
},
2017-11-11 04:33:51 +00:00
events: [
{
name: (pointerMove + " " + pointerDown + " keydown"),
2017-11-11 04:33:51 +00:00
handler: 'showControls'
2017-11-11 04:33:51 +00:00
},
{
2021-05-27 00:23:07 +00:00
name: 'click',
self: true,
2017-11-11 04:33:51 +00:00
delegate: function() {
2019-04-22 13:31:39 +00:00
return this.selSlides;
2017-11-11 04:33:51 +00:00
},
handler: function(e) {
2019-04-22 13:31:39 +00:00
if (e.defaultPrevented) {
return;
}
this.hide();
2017-11-11 04:33:51 +00:00
}
},
{
name: 'shown',
2017-11-11 04:33:51 +00:00
self: true,
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
handler: function() {
this.showControls();
}
2017-11-11 04:33:51 +00:00
},
{
name: 'hide',
2017-11-11 04:33:51 +00:00
self: true,
2017-11-11 04:33:51 +00:00
handler: function() {
2017-11-11 04:33:51 +00:00
this.hideControls();
2017-11-11 04:33:51 +00:00
removeClass(this.slides, this.clsActive);
Transition.stop(this.slides);
2017-11-11 04:33:51 +00:00
}
},
2019-04-22 13:31:39 +00:00
{
name: 'hidden',
self: true,
handler: function() {
this.$destroy(true);
}
},
2017-11-11 04:33:51 +00:00
{
name: 'keyup',
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
el: function() {
return document;
},
2017-11-11 04:33:51 +00:00
handler: function(e) {
2021-05-27 00:23:07 +00:00
if (!this.isToggled(this.$el) || !this.draggable) {
return;
}
2017-11-11 04:33:51 +00:00
switch (e.keyCode) {
case 37:
this.show('previous');
break;
case 39:
this.show('next');
break;
}
}
2017-11-11 04:33:51 +00:00
},
{
name: 'beforeitemshow',
handler: function(e) {
2017-11-11 04:33:51 +00:00
if (this.isToggled()) {
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this.draggable = false;
e.preventDefault();
2021-05-27 00:23:07 +00:00
this.toggleElement(this.$el, true, false);
this.animation = Animations$1['scale'];
removeClass(e.target, this.clsActive);
this.stack.splice(1, 0, this.index);
2017-11-11 04:33:51 +00:00
}
},
{
name: 'itemshow',
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
handler: function() {
2021-05-27 00:23:07 +00:00
html(this.caption, this.getItem().caption || '');
2021-05-27 00:23:07 +00:00
for (var j = -this.preload; j <= this.preload; j++) {
this.loadItem(this.index + j);
}
2017-11-11 04:33:51 +00:00
}
},
{
name: 'itemshown',
2017-11-11 04:33:51 +00:00
handler: function() {
2019-04-22 13:31:39 +00:00
this.draggable = this.$props.draggable;
2017-11-11 04:33:51 +00:00
}
},
{
name: 'itemload',
2017-11-11 04:33:51 +00:00
handler: function(_, item) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var src = item.source;
var type = item.type;
2021-05-27 00:23:07 +00:00
var alt = item.alt; if ( alt === void 0 ) alt = '';
var poster = item.poster;
var attrs = item.attrs; if ( attrs === void 0 ) attrs = {};
2017-11-11 04:33:51 +00:00
this.setItem(item, '<span uk-spinner></span>');
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!src) {
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var matches;
2021-05-27 00:23:07 +00:00
var iframeAttrs = {
frameborder: '0',
allow: 'autoplay',
allowfullscreen: '',
style: 'max-width: 100%; box-sizing: border-box;',
'uk-responsive': '',
'uk-video': ("" + (this.videoAutoplay))
};
2017-11-11 04:33:51 +00:00
// Image
2021-05-27 00:23:07 +00:00
if (type === 'image' || src.match(/\.(avif|jpe?g|a?png|gif|svg|webp)($|\?)/i)) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
getImage(src, attrs.srcset, attrs.size).then(
function (ref) {
2019-04-22 13:31:39 +00:00
var width = ref.width;
var height = ref.height;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return this$1.setItem(item, createEl('img', assign({src: src, width: width, height: height, alt: alt}, attrs)));
},
function () { return this$1.setError(item); }
);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
// Video
} else if (type === 'video' || src.match(/\.(mp4|webm|ogv)($|\?)/i)) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var video = createEl('video', assign({
src: src,
poster: poster,
controls: '',
playsinline: '',
'uk-video': ("" + (this.videoAutoplay))
}, attrs));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
on(video, 'loadedmetadata', function () {
attr(video, {width: video.videoWidth, height: video.videoHeight});
this$1.setItem(item, video);
});
on(video, 'error', function () { return this$1.setError(item); });
// Iframe
} else if (type === 'iframe' || src.match(/\.(html|php)($|\?)/i)) {
this.setItem(item, createEl('iframe', assign({
src: src,
frameborder: '0',
allowfullscreen: '',
class: 'uk-lightbox-iframe'
}, attrs)));
// YouTube
} else if ((matches = src.match(/\/\/(?:.*?youtube(-nocookie)?\..*?[?&]v=|youtu\.be\/)([\w-]{11})[&?]?(.*)?/))) {
this.setItem(item, createEl('iframe', assign({
src: ("https://www.youtube" + (matches[1] || '') + ".com/embed/" + (matches[2]) + (matches[3] ? ("?" + (matches[3])) : '')),
width: 1920,
height: 1080
}, iframeAttrs, attrs)));
// Vimeo
} else if ((matches = src.match(/\/\/.*?vimeo\.[a-z]+\/(\d+)[&?]?(.*)?/))) {
ajax(("https://vimeo.com/api/oembed.json?maxwidth=1920&url=" + (encodeURI(src))), {
responseType: 'json',
withCredentials: false
}).then(
function (ref) {
var ref_response = ref.response;
var height = ref_response.height;
var width = ref_response.width;
return this$1.setItem(item, createEl('iframe', assign({
src: ("https://player.vimeo.com/video/" + (matches[1]) + (matches[2] ? ("?" + (matches[2])) : '')),
width: width,
height: height
}, iframeAttrs, attrs)));
},
2021-05-27 00:23:07 +00:00
function () { return this$1.setError(item); }
);
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
}
}
2017-11-11 04:33:51 +00:00
],
2017-11-11 04:33:51 +00:00
methods: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
loadItem: function(index) {
if ( index === void 0 ) index = this.index;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var item = this.getItem(index);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.getSlide(item).childElementCount) {
trigger(this.$el, 'itemload', [item]);
2017-11-11 04:33:51 +00:00
}
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
getItem: function(index) {
if ( index === void 0 ) index = this.index;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return this.items[getIndex(index, this.slides)];
},
2017-11-11 04:33:51 +00:00
setItem: function(item, content) {
2021-05-27 00:23:07 +00:00
trigger(this.$el, 'itemloaded', [this, html(this.getSlide(item), content) ]);
},
getSlide: function(item) {
return this.slides[this.items.indexOf(item)];
},
2017-11-11 04:33:51 +00:00
setError: function(item) {
this.setItem(item, '<span uk-icon="icon: bolt; ratio: 2"></span>');
},
2017-11-11 04:33:51 +00:00
showControls: function() {
2017-11-11 04:33:51 +00:00
clearTimeout(this.controlsTimer);
this.controlsTimer = setTimeout(this.hideControls, this.delayControls);
2017-11-11 04:33:51 +00:00
addClass(this.$el, 'uk-active', 'uk-transition-active');
2017-11-11 04:33:51 +00:00
},
hideControls: function() {
removeClass(this.$el, 'uk-active', 'uk-transition-active');
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function createEl(tag, attrs) {
var el = fragment(("<" + tag + ">"));
attr(el, attrs);
return el;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var lightbox = {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
install: install$1,
2017-11-11 04:33:51 +00:00
props: {toggle: String},
2017-11-11 04:33:51 +00:00
data: {toggle: 'a'},
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
toggles: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
get: function(ref, $el) {
var toggle = ref.toggle;
return $$(toggle, $el);
},
watch: function() {
this.hide();
}
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
disconnected: function() {
2019-04-22 13:31:39 +00:00
this.hide();
},
2017-11-11 04:33:51 +00:00
events: [
2017-11-11 04:33:51 +00:00
{
2017-11-11 04:33:51 +00:00
name: 'click',
2017-11-11 04:33:51 +00:00
delegate: function() {
return ((this.toggle) + ":not(.uk-disabled)");
},
2017-11-11 04:33:51 +00:00
handler: function(e) {
e.preventDefault();
2021-05-27 00:23:07 +00:00
this.show(e.current);
2017-11-11 04:33:51 +00:00
}
}
2017-11-11 04:33:51 +00:00
],
2017-11-11 04:33:51 +00:00
methods: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
show: function(index) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var items = uniqueBy(this.toggles.map(toItem), 'source');
if (isElement(index)) {
var ref = toItem(index);
var source = ref.source;
index = findIndex(items, function (ref) {
var src = ref.source;
return source === src;
});
}
this.panel = this.panel || this.$create('lightboxPanel', assign({}, this.$props, {items: items}));
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
on(this.panel.$el, 'hidden', function () { return this$1.panel = false; });
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return this.panel.show(index);
2017-11-11 04:33:51 +00:00
},
hide: function() {
2017-11-11 04:33:51 +00:00
return this.panel && this.panel.hide();
2017-11-11 04:33:51 +00:00
}
}
};
2021-05-27 00:23:07 +00:00
function install$1(UIkit, Lightbox) {
2017-11-11 04:33:51 +00:00
if (!UIkit.lightboxPanel) {
2021-05-27 00:23:07 +00:00
UIkit.component('lightboxPanel', LightboxPanel);
}
2017-11-11 04:33:51 +00:00
assign(
Lightbox.props,
UIkit.component('lightboxPanel').options.props
);
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function toItem(el) {
2021-05-27 00:23:07 +00:00
var item = {};
['href', 'caption', 'type', 'poster', 'alt', 'attrs'].forEach(function (attr) {
item[attr === 'href' ? 'source' : attr] = data(el, attr);
});
item.attrs = parseOptions(item.attrs);
return item;
2019-04-22 13:31:39 +00:00
}
2021-05-27 00:23:07 +00:00
var obj$1;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var notification = {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
mixins: [Container],
2017-11-11 04:33:51 +00:00
functional: true,
2017-11-11 04:33:51 +00:00
args: ['message', 'status'],
2017-11-11 04:33:51 +00:00
data: {
message: '',
status: '',
timeout: 5000,
group: null,
pos: 'top-center',
2021-05-27 00:23:07 +00:00
clsContainer: 'uk-notification',
clsClose: 'uk-notification-close',
clsMsg: 'uk-notification-message'
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
install: install,
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
computed: {
marginProp: function(ref) {
var pos = ref.pos;
return ("margin" + (startsWith(pos, 'top') ? 'Top' : 'Bottom'));
},
startProps: function() {
var obj;
return ( obj = {opacity: 0}, obj[this.marginProp] = -this.$el.offsetHeight, obj );
}
},
created: function() {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var container = $(("." + (this.clsContainer) + "-" + (this.pos)), this.container)
|| append(this.container, ("<div class=\"" + (this.clsContainer) + " " + (this.clsContainer) + "-" + (this.pos) + "\" style=\"display: block\"></div>"));
2017-11-11 04:33:51 +00:00
this.$mount(append(container,
2021-05-27 00:23:07 +00:00
("<div class=\"" + (this.clsMsg) + (this.status ? (" " + (this.clsMsg) + "-" + (this.status)) : '') + "\"> <a href class=\"" + (this.clsClose) + "\" data-uk-close></a> <div>" + (this.message) + "</div> </div>")
));
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
connected: function() {
var this$1 = this;
2019-04-22 13:31:39 +00:00
var obj;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var margin = toFloat(css(this.$el, this.marginProp));
Transition.start(
2019-04-22 13:31:39 +00:00
css(this.$el, this.startProps),
( obj = {opacity: 1}, obj[this.marginProp] = margin, obj )
).then(function () {
if (this$1.timeout) {
this$1.timer = setTimeout(this$1.close, this$1.timeout);
}
});
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
events: ( obj$1 = {
2017-11-11 04:33:51 +00:00
click: function(e) {
2019-04-22 13:31:39 +00:00
if (closest(e.target, 'a[href="#"],a[href=""]')) {
e.preventDefault();
}
this.close();
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
}, obj$1[pointerEnter] = function () {
if (this.timer) {
clearTimeout(this.timer);
}
2021-05-27 00:23:07 +00:00
}, obj$1[pointerLeave] = function () {
if (this.timeout) {
this.timer = setTimeout(this.close, this.timeout);
}
2021-05-27 00:23:07 +00:00
}, obj$1 ),
2017-11-11 04:33:51 +00:00
methods: {
2017-11-11 04:33:51 +00:00
close: function(immediate) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var removeFn = function (el) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var container = parent(el);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
trigger(el, 'close', [this$1]);
remove$1(el);
if (container && !container.hasChildNodes()) {
remove$1(container);
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
if (this.timer) {
clearTimeout(this.timer);
}
2017-11-11 04:33:51 +00:00
if (immediate) {
2021-05-27 00:23:07 +00:00
removeFn(this.$el);
} else {
2019-04-22 13:31:39 +00:00
Transition.start(this.$el, this.startProps).then(removeFn);
}
2017-11-11 04:33:51 +00:00
}
}
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function install(UIkit) {
UIkit.notification.closeAll = function (group, immediate) {
2021-05-27 00:23:07 +00:00
apply$1(document.body, function (el) {
var notification = UIkit.getComponent(el, 'notification');
if (notification && (!group || group === notification.group)) {
notification.close(immediate);
}
});
};
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
var props = ['x', 'y', 'bgx', 'bgy', 'rotate', 'scale', 'color', 'backgroundColor', 'borderColor', 'opacity', 'blur', 'hue', 'grayscale', 'invert', 'saturate', 'sepia', 'fopacity', 'stroke'];
2017-11-11 04:33:51 +00:00
var Parallax = {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
mixins: [Media],
props: props.reduce(function (props, prop) {
props[prop] = 'list';
return props;
2019-04-22 13:31:39 +00:00
}, {}),
data: props.reduce(function (data, prop) {
data[prop] = undefined;
return data;
}, {}),
2017-11-11 04:33:51 +00:00
computed: {
props: function(properties, $el) {
2017-11-11 04:33:51 +00:00
var this$1 = this;
return props.reduce(function (props, prop) {
2017-11-11 04:33:51 +00:00
if (isUndefined(properties[prop])) {
return props;
}
2017-11-11 04:33:51 +00:00
var isColor = prop.match(/color/i);
var isCssProp = isColor || prop === 'opacity';
2017-11-11 04:33:51 +00:00
var pos, bgPos, diff;
2021-05-27 00:23:07 +00:00
var steps = properties[prop].slice();
2017-11-11 04:33:51 +00:00
if (isCssProp) {
css($el, prop, '');
}
2017-11-11 04:33:51 +00:00
if (steps.length < 2) {
steps.unshift((prop === 'scale'
? 1
: isCssProp
? css($el, prop)
: 0) || 0);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var unit = getUnit(steps);
2017-11-11 04:33:51 +00:00
if (isColor) {
2017-11-11 04:33:51 +00:00
var ref = $el.style;
var color = ref.color;
steps = steps.map(function (step) { return parseColor($el, step); });
$el.style.color = color;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
} else if (startsWith(prop, 'bg')) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var attr = prop === 'bgy' ? 'height' : 'width';
steps = steps.map(function (step) { return toPx(step, attr, this$1.$el); });
2017-11-11 04:33:51 +00:00
css($el, ("background-position-" + (prop[2])), '');
bgPos = css($el, 'backgroundPosition').split(' ')[prop[2] === 'x' ? 0 : 1]; // IE 11 can't read background-position-[x|y]
2017-11-11 04:33:51 +00:00
if (this$1.covers) {
2017-11-11 04:33:51 +00:00
var min = Math.min.apply(Math, steps);
var max = Math.max.apply(Math, steps);
var down = steps.indexOf(min) < steps.indexOf(max);
2017-11-11 04:33:51 +00:00
diff = max - min;
2017-11-11 04:33:51 +00:00
steps = steps.map(function (step) { return step - (down ? min : max); });
pos = (down ? -diff : 0) + "px";
2017-11-11 04:33:51 +00:00
} else {
2017-11-11 04:33:51 +00:00
pos = bgPos;
}
2019-04-22 13:31:39 +00:00
} else {
steps = steps.map(toFloat);
}
if (prop === 'stroke') {
if (!steps.some(function (step) { return step; })) {
return props;
}
var length = getMaxPathLength(this$1.$el);
css($el, 'strokeDasharray', length);
if (unit === '%') {
steps = steps.map(function (step) { return step * length / 100; });
}
steps = steps.reverse();
prop = 'strokeDashoffset';
}
2017-11-11 04:33:51 +00:00
props[prop] = {steps: steps, unit: unit, pos: pos, bgPos: bgPos, diff: diff};
2017-11-11 04:33:51 +00:00
return props;
2017-11-11 04:33:51 +00:00
}, {});
2017-11-11 04:33:51 +00:00
},
bgProps: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
return ['bgx', 'bgy'].filter(function (bg) { return bg in this$1.props; });
},
2017-11-11 04:33:51 +00:00
covers: function(_, $el) {
return covers($el);
2017-11-11 04:33:51 +00:00
}
},
2017-11-11 04:33:51 +00:00
disconnected: function() {
delete this._image;
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
update: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
read: function(data) {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.matchMedia) {
2019-04-22 13:31:39 +00:00
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (!data.image && this.covers && this.bgProps.length) {
var src = css(this.$el, 'backgroundImage').replace(/^none|url\(["']?(.+?)["']?\)$/, '$1');
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (src) {
var img = new Image();
img.src = src;
data.image = img;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (!img.naturalWidth) {
2021-05-27 00:23:07 +00:00
img.onload = function () { return this$1.$update(); };
2019-04-22 13:31:39 +00:00
}
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var image = data.image;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (!image || !image.naturalWidth) {
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var dimEl = {
width: this.$el.offsetWidth,
height: this.$el.offsetHeight
};
var dimImage = {
width: image.naturalWidth,
height: image.naturalHeight
};
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var dim = Dimensions.cover(dimImage, dimEl);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this.bgProps.forEach(function (prop) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var ref = this$1.props[prop];
var diff = ref.diff;
var bgPos = ref.bgPos;
var steps = ref.steps;
var attr = prop === 'bgy' ? 'height' : 'width';
var span = dim[attr] - dimEl[attr];
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (span < diff) {
dimEl[attr] = dim[attr] + diff - span;
} else if (span > diff) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var posPercentage = dimEl[attr] / toPx(bgPos, attr, this$1.$el);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (posPercentage) {
this$1.props[prop].steps = steps.map(function (step) { return step - (span - diff) / posPercentage; });
}
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
dim = Dimensions.cover(dimImage, dimEl);
});
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
data.dim = dim;
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
write: function(ref) {
var dim = ref.dim;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.matchMedia) {
2019-04-22 13:31:39 +00:00
css(this.$el, {backgroundSize: '', backgroundRepeat: ''});
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
dim && css(this.$el, {
backgroundSize: ((dim.width) + "px " + (dim.height) + "px"),
backgroundRepeat: 'no-repeat'
});
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
methods: {
2017-11-11 04:33:51 +00:00
reset: function() {
var this$1 = this;
each(this.getCss(0), function (_, prop) { return css(this$1.$el, prop, ''); });
2017-11-11 04:33:51 +00:00
},
getCss: function(percent) {
2017-11-11 04:33:51 +00:00
var ref = this;
var props = ref.props;
2019-04-22 13:31:39 +00:00
return Object.keys(props).reduce(function (css, prop) {
2017-11-11 04:33:51 +00:00
var ref = props[prop];
var steps = ref.steps;
var unit = ref.unit;
var pos = ref.pos;
var value = getValue(steps, percent);
2017-11-11 04:33:51 +00:00
switch (prop) {
2017-11-11 04:33:51 +00:00
// transforms
case 'x':
2019-04-22 13:31:39 +00:00
case 'y': {
unit = unit || 'px';
css.transform += " translate" + (ucfirst(prop)) + "(" + (toFloat(value).toFixed(unit === 'px' ? 0 : 2)) + unit + ")";
break;
2019-04-22 13:31:39 +00:00
}
case 'rotate':
2019-04-22 13:31:39 +00:00
unit = unit || 'deg';
css.transform += " rotate(" + (value + unit) + ")";
break;
case 'scale':
2019-04-22 13:31:39 +00:00
css.transform += " scale(" + value + ")";
break;
// bg image
case 'bgy':
case 'bgx':
2019-04-22 13:31:39 +00:00
css[("background-position-" + (prop[2]))] = "calc(" + pos + " + " + value + "px)";
break;
// color
case 'color':
case 'backgroundColor':
2019-04-22 13:31:39 +00:00
case 'borderColor': {
2019-04-22 13:31:39 +00:00
var ref$1 = getStep(steps, percent);
var start = ref$1[0];
var end = ref$1[1];
var p = ref$1[2];
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
css[prop] = "rgba(" + (start.map(function (value, i) {
value = value + p * (end[i] - value);
return i === 3 ? toFloat(value) : parseInt(value, 10);
}).join(',')) + ")";
2017-11-11 04:33:51 +00:00
break;
2019-04-22 13:31:39 +00:00
}
// CSS Filter
case 'blur':
2019-04-22 13:31:39 +00:00
unit = unit || 'px';
css.filter += " blur(" + (value + unit) + ")";
2017-11-11 04:33:51 +00:00
break;
case 'hue':
2019-04-22 13:31:39 +00:00
unit = unit || 'deg';
css.filter += " hue-rotate(" + (value + unit) + ")";
break;
case 'fopacity':
2019-04-22 13:31:39 +00:00
unit = unit || '%';
css.filter += " opacity(" + (value + unit) + ")";
break;
case 'grayscale':
case 'invert':
case 'saturate':
case 'sepia':
2019-04-22 13:31:39 +00:00
unit = unit || '%';
css.filter += " " + prop + "(" + (value + unit) + ")";
2017-11-11 04:33:51 +00:00
break;
default:
2019-04-22 13:31:39 +00:00
css[prop] = value;
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
return css;
2017-11-11 04:33:51 +00:00
}, {transform: '', filter: ''});
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
function parseColor(el, color) {
2019-04-22 13:31:39 +00:00
return css(css(el, 'color', color), 'color')
.split(/[(),]/g)
.slice(1, -1)
.concat(1)
.slice(0, 4)
.map(toFloat);
}
2017-11-11 04:33:51 +00:00
function getStep(steps, percent) {
var count = steps.length - 1;
2019-04-22 13:31:39 +00:00
var index = Math.min(Math.floor(count * percent), count - 1);
var step = steps.slice(index, index + 2);
2017-11-11 04:33:51 +00:00
step.push(percent === 1 ? 1 : percent % (1 / count) * count);
2017-11-11 04:33:51 +00:00
return step;
}
2017-11-11 04:33:51 +00:00
function getValue(steps, percent, digits) {
if ( digits === void 0 ) digits = 2;
2017-11-11 04:33:51 +00:00
var ref = getStep(steps, percent);
var start = ref[0];
var end = ref[1];
var p = ref[2];
return (isNumber(start)
2019-04-22 13:31:39 +00:00
? start + Math.abs(start - end) * p * (start < end ? 1 : -1)
: +end
).toFixed(digits);
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
function getUnit(steps) {
return steps.reduce(function (unit, step) { return isString(step) && step.replace(/-|\d/g, '').trim() || unit; }, '');
}
function covers(el) {
var ref = el.style;
var backgroundSize = ref.backgroundSize;
var covers = css(css(el, 'backgroundSize', ''), 'backgroundSize') === 'cover';
el.style.backgroundSize = backgroundSize;
return covers;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var parallax = {
2017-11-11 04:33:51 +00:00
mixins: [Parallax],
2017-11-11 04:33:51 +00:00
props: {
target: String,
viewport: Number,
2019-04-22 13:31:39 +00:00
easing: Number
},
2017-11-11 04:33:51 +00:00
data: {
target: false,
viewport: 1,
2019-04-22 13:31:39 +00:00
easing: 1
},
2017-11-11 04:33:51 +00:00
computed: {
2017-11-11 04:33:51 +00:00
target: function(ref, $el) {
var target = ref.target;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return getOffsetElement(target && query(target, $el) || $el);
}
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
update: {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
read: function(ref, types) {
2019-04-22 13:31:39 +00:00
var percent = ref.percent;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!types.has('scroll')) {
2019-04-22 13:31:39 +00:00
percent = false;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.matchMedia) {
2019-04-22 13:31:39 +00:00
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var prev = percent;
2021-05-27 00:23:07 +00:00
percent = ease(scrolledOver(this.target) / (this.viewport || 1), this.easing);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return {
percent: percent,
style: prev !== percent ? this.getCss(percent) : false
};
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
write: function(ref) {
var style = ref.style;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.matchMedia) {
2019-04-22 13:31:39 +00:00
this.reset();
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
style && css(this.$el, style);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
events: ['scroll', 'resize']
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function ease(percent, easing) {
return clamp(percent * (1 - (easing - easing * percent)));
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
// SVG elements do not inherit from HTMLElement
function getOffsetElement(el) {
return el
? 'offsetTop' in el
? el
2021-05-27 00:23:07 +00:00
: getOffsetElement(parent(el))
2019-04-22 13:31:39 +00:00
: document.body;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var SliderReactive = {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
update: {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
write: function() {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (this.stack.length || this.dragging) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var index = this.getValidIndex(this.index);
if (!~this.prevIndex || this.index !== index) {
this.show(index);
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
}
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function Transitioner (prev, next, dir, ref) {
var center = ref.center;
var easing = ref.easing;
var list = ref.list;
2017-11-11 04:33:51 +00:00
var deferred = new Deferred();
2017-11-11 04:33:51 +00:00
var from = prev
? getLeft(prev, list, center)
2021-05-27 00:23:07 +00:00
: getLeft(next, list, center) + dimensions(next).width * dir;
var to = next
? getLeft(next, list, center)
2021-05-27 00:23:07 +00:00
: from + dimensions(prev).width * dir * (isRtl ? -1 : 1);
2017-11-11 04:33:51 +00:00
return {
2017-11-11 04:33:51 +00:00
dir: dir,
2017-11-11 04:33:51 +00:00
show: function(duration, percent, linear) {
if ( percent === void 0 ) percent = 0;
2017-11-11 04:33:51 +00:00
var timing = linear ? 'linear' : easing;
duration -= Math.round(duration * clamp(percent, -1, 1));
2017-11-11 04:33:51 +00:00
this.translate(percent);
2017-11-11 04:33:51 +00:00
percent = prev ? percent : clamp(percent, 0, 1);
2021-05-27 00:23:07 +00:00
triggerUpdate(this.getItemIn(), 'itemin', {percent: percent, duration: duration, timing: timing, dir: dir});
prev && triggerUpdate(this.getItemIn(true), 'itemout', {percent: 1 - percent, duration: duration, timing: timing, dir: dir});
2017-11-11 04:33:51 +00:00
Transition
.start(list, {transform: translate(-to * (isRtl ? -1 : 1), 'px')}, duration, timing)
.then(deferred.resolve, noop);
2017-11-11 04:33:51 +00:00
return deferred.promise;
2017-11-11 04:33:51 +00:00
},
cancel: function() {
Transition.cancel(list);
2017-11-11 04:33:51 +00:00
},
reset: function() {
css(list, 'transform', '');
2017-11-11 04:33:51 +00:00
},
forward: function(duration, percent) {
if ( percent === void 0 ) percent = this.percent();
2017-11-11 04:33:51 +00:00
Transition.cancel(list);
return this.show(duration, percent, true);
2017-11-11 04:33:51 +00:00
},
translate: function(percent) {
2017-11-11 04:33:51 +00:00
var distance = this.getDistance() * dir * (isRtl ? -1 : 1);
2017-11-11 04:33:51 +00:00
css(list, 'transform', translate(clamp(
-to + (distance - distance * percent),
-getWidth(list),
2021-05-27 00:23:07 +00:00
dimensions(list).width
) * (isRtl ? -1 : 1), 'px'));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var actives = this.getActives();
var itemIn = this.getItemIn();
var itemOut = this.getItemIn(true);
percent = prev ? clamp(percent, -1, 1) : 0;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
children(list).forEach(function (slide, i) {
var isActive = includes(actives, slide);
var isIn = slide === itemIn;
var isOut = slide === itemOut;
var translateIn = isIn || !isOut && (isActive || dir * (isRtl ? -1 : 1) === -1 ^ getElLeft(slide, list) > getElLeft(prev || next));
triggerUpdate(slide, ("itemtranslate" + (translateIn ? 'in' : 'out')), {
dir: dir,
percent: isOut
? 1 - percent
: isIn
? percent
: isActive
? 1
: 0
});
});
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
percent: function() {
return Math.abs((css(list, 'transform').split(',')[4] * (isRtl ? -1 : 1) + from) / (to - from));
},
2017-11-11 04:33:51 +00:00
getDistance: function() {
return Math.abs(to - from);
},
2017-11-11 04:33:51 +00:00
getItemIn: function(out) {
if ( out === void 0 ) out = false;
2017-11-11 04:33:51 +00:00
var actives = this.getActives();
2021-05-27 00:23:07 +00:00
var nextActives = inView(list, getLeft(next || prev, list, center));
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (out) {
var temp = actives;
actives = nextActives;
nextActives = temp;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return nextActives[findIndex(nextActives, function (el) { return !includes(actives, el); })];
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
getActives: function() {
return inView(list, getLeft(prev || next, list, center));
2017-11-11 04:33:51 +00:00
}
};
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
function getLeft(el, list, center) {
2017-11-11 04:33:51 +00:00
var left = getElLeft(el, list);
2017-11-11 04:33:51 +00:00
return center
? left - centerEl(el, list)
: Math.min(left, getMax(list));
2017-11-11 04:33:51 +00:00
}
2017-11-11 04:33:51 +00:00
function getMax(list) {
2021-05-27 00:23:07 +00:00
return Math.max(0, getWidth(list) - dimensions(list).width);
}
2017-11-11 04:33:51 +00:00
function getWidth(list) {
2021-05-27 00:23:07 +00:00
return children(list).reduce(function (right, el) { return dimensions(el).width + right; }, 0);
}
2017-11-11 04:33:51 +00:00
function centerEl(el, list) {
2021-05-27 00:23:07 +00:00
return dimensions(list).width / 2 - dimensions(el).width / 2;
}
2017-11-11 04:33:51 +00:00
function getElLeft(el, list) {
2021-05-27 00:23:07 +00:00
return el && (position(el).left + (isRtl ? dimensions(el).width - dimensions(list).width : 0)) * (isRtl ? -1 : 1) || 0;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function inView(list, listLeft) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
listLeft -= 1;
var listRight = listLeft + dimensions(list).width + 2;
return children(list).filter(function (slide) {
var slideLeft = getElLeft(slide, list);
var slideRight = slideLeft + dimensions(slide).width;
return slideLeft >= listLeft && slideRight <= listRight;
});
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function triggerUpdate(el, type, data) {
trigger(el, createEvent(type, false, false, data));
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var slider = {
2017-11-11 04:33:51 +00:00
mixins: [Class, Slider, SliderReactive],
2017-11-11 04:33:51 +00:00
props: {
center: Boolean,
2019-04-22 13:31:39 +00:00
sets: Boolean
},
2017-11-11 04:33:51 +00:00
data: {
center: false,
sets: false,
attrItem: 'uk-slider-item',
selList: '.uk-slider-items',
selNav: '.uk-slider-nav',
clsContainer: 'uk-slider-container',
2021-05-27 00:23:07 +00:00
Transitioner: Transitioner
},
2017-11-11 04:33:51 +00:00
computed: {
avgWidth: function() {
return getWidth(this.list) / this.length;
},
2017-11-11 04:33:51 +00:00
finite: function(ref) {
var finite = ref.finite;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return finite || Math.ceil(getWidth(this.list)) < dimensions(this.list).width + getMaxElWidth(this.list) + this.center;
},
2017-11-11 04:33:51 +00:00
maxIndex: function() {
2017-11-11 04:33:51 +00:00
if (!this.finite || this.center && !this.sets) {
return this.length - 1;
}
2017-11-11 04:33:51 +00:00
if (this.center) {
2021-05-27 00:23:07 +00:00
return last(this.sets);
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var lft = 0;
var max = getMax(this.list);
2021-05-27 00:23:07 +00:00
var index = findIndex(this.slides, function (el) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (lft >= max) {
return true;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
lft += dimensions(el).width;
});
return ~index ? index : this.length - 1;
},
2017-11-11 04:33:51 +00:00
sets: function(ref) {
var this$1 = this;
var sets = ref.sets;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!sets) {
return;
}
var width = dimensions(this.list).width / (this.center ? 2 : 1);
2017-11-11 04:33:51 +00:00
var left = 0;
2019-04-22 13:31:39 +00:00
var leftCenter = width;
var slideLeft = 0;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
sets = sortBy$1(this.slides, 'offsetLeft').reduce(function (sets, slide, i) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var slideWidth = dimensions(slide).width;
var slideRight = slideLeft + slideWidth;
2017-11-11 04:33:51 +00:00
if (slideRight > left) {
2017-11-11 04:33:51 +00:00
if (!this$1.center && i > this$1.maxIndex) {
i = this$1.maxIndex;
}
2017-11-11 04:33:51 +00:00
if (!includes(sets, i)) {
2017-11-11 04:33:51 +00:00
var cmp = this$1.slides[i + 1];
2021-05-27 00:23:07 +00:00
if (this$1.center && cmp && slideWidth < leftCenter - dimensions(cmp).width / 2) {
leftCenter -= slideWidth;
} else {
2019-04-22 13:31:39 +00:00
leftCenter = width;
sets.push(i);
2019-04-22 13:31:39 +00:00
left = slideLeft + width + (this$1.center ? slideWidth / 2 : 0);
}
2017-11-11 04:33:51 +00:00
}
}
slideLeft += slideWidth;
2017-11-11 04:33:51 +00:00
return sets;
2017-11-11 04:33:51 +00:00
}, []);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return !isEmpty(sets) && sets;
2017-11-11 04:33:51 +00:00
},
transitionOptions: function() {
return {
center: this.center,
list: this.list
};
2017-11-11 04:33:51 +00:00
}
},
connected: function() {
toggleClass(this.$el, this.clsContainer, !$(("." + (this.clsContainer)), this.$el));
2017-11-11 04:33:51 +00:00
},
update: {
2017-11-11 04:33:51 +00:00
write: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.navItems.forEach(function (el) {
var index = toNumber(data(el, this$1.attrItem));
if (index !== false) {
el.hidden = !this$1.maxIndex || index > this$1.maxIndex || this$1.sets && !includes(this$1.sets, index);
}
});
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this.length && !this.dragging && !this.stack.length) {
this.reorder();
this._translate(1);
}
var actives = this._getTransitioner(this.index).getActives();
this.slides.forEach(function (slide) { return toggleClass(slide, this$1.clsActive, includes(actives, slide)); });
if (this.clsActivated && (!this.sets || includes(this.sets, toFloat(this.index)))) {
this.slides.forEach(function (slide) { return toggleClass(slide, this$1.clsActivated || '', includes(actives, slide)); });
}
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
events: {
2017-11-11 04:33:51 +00:00
beforeitemshow: function(e) {
2017-11-11 04:33:51 +00:00
if (!this.dragging && this.sets && this.stack.length < 2 && !includes(this.sets, this.index)) {
this.index = this.getValidIndex();
}
2017-11-11 04:33:51 +00:00
var diff = Math.abs(
this.index
- this.prevIndex
+ (this.dir > 0 && this.index < this.prevIndex || this.dir < 0 && this.index > this.prevIndex ? (this.maxIndex + 1) * this.dir : 0)
);
2017-11-11 04:33:51 +00:00
if (!this.dragging && diff > 1) {
2017-11-11 04:33:51 +00:00
for (var i = 0; i < diff; i++) {
2019-04-22 13:31:39 +00:00
this.stack.splice(1, 0, this.dir > 0 ? 'next' : 'previous');
2017-11-11 04:33:51 +00:00
}
e.preventDefault();
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var index = this.dir < 0 || !this.slides[this.prevIndex] ? this.index : this.prevIndex;
this.duration = speedUp(this.avgWidth / this.velocity) * (dimensions(this.slides[index]).width / this.avgWidth);
2017-11-11 04:33:51 +00:00
this.reorder();
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
itemshow: function() {
2021-05-27 00:23:07 +00:00
~this.prevIndex && addClass(this._getTransitioner().getItemIn(), this.clsActive);
2017-11-11 04:33:51 +00:00
}
},
2017-11-11 04:33:51 +00:00
methods: {
reorder: function() {
2017-11-11 04:33:51 +00:00
var this$1 = this;
if (this.finite) {
2021-05-27 00:23:07 +00:00
css(this.slides, 'order', '');
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var index = this.dir > 0 && this.slides[this.prevIndex] ? this.prevIndex : this.index;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
this.slides.forEach(function (slide, i) { return css(slide, 'order', this$1.dir > 0 && i < index
? 1
: this$1.dir < 0 && i >= this$1.index
? -1
: ''
); }
);
2017-11-11 04:33:51 +00:00
if (!this.center) {
return;
}
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var next = this.slides[index];
2021-05-27 00:23:07 +00:00
var width = dimensions(this.list).width / 2 - dimensions(next).width / 2;
var j = 0;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
while (width > 0) {
var slideIndex = this.getIndex(--j + index, index);
var slide = this.slides[slideIndex];
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
css(slide, 'order', slideIndex > index ? -2 : -1);
2021-05-27 00:23:07 +00:00
width -= dimensions(slide).width;
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
getValidIndex: function(index, prevIndex) {
if ( index === void 0 ) index = this.index;
if ( prevIndex === void 0 ) prevIndex = this.prevIndex;
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
index = this.getIndex(index, prevIndex);
2017-11-11 04:33:51 +00:00
if (!this.sets) {
2019-04-22 13:31:39 +00:00
return index;
}
2017-11-11 04:33:51 +00:00
var prev;
2017-11-11 04:33:51 +00:00
do {
2019-04-22 13:31:39 +00:00
if (includes(this.sets, index)) {
return index;
2017-11-11 04:33:51 +00:00
}
2019-04-22 13:31:39 +00:00
prev = index;
index = this.getIndex(index + this.dir, prevIndex);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
} while (index !== prev);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
return index;
2017-11-11 04:33:51 +00:00
}
}
};
2021-05-27 00:23:07 +00:00
function getMaxElWidth(list) {
return Math.max.apply(Math, [ 0 ].concat( children(list).map(function (el) { return dimensions(el).width; }) ));
}
var sliderParallax = {
2017-11-11 04:33:51 +00:00
mixins: [Parallax],
2017-11-11 04:33:51 +00:00
data: {
selItem: '!li'
2017-11-11 04:33:51 +00:00
},
computed: {
item: function(ref, $el) {
var selItem = ref.selItem;
2017-11-11 04:33:51 +00:00
return query(selItem, $el);
2017-11-11 04:33:51 +00:00
}
},
events: [
{
name: 'itemin itemout',
self: true,
el: function() {
return this.item;
},
handler: function(ref) {
2021-05-27 00:23:07 +00:00
var this$1 = this;
var type = ref.type;
var ref_detail = ref.detail;
var percent = ref_detail.percent;
var duration = ref_detail.duration;
var timing = ref_detail.timing;
var dir = ref_detail.dir;
2021-05-27 00:23:07 +00:00
fastdom.read(function () {
var propsFrom = this$1.getCss(getCurrentPercent(type, dir, percent));
var propsTo = this$1.getCss(isIn(type) ? .5 : dir > 0 ? 1 : 0);
fastdom.write(function () {
css(this$1.$el, propsFrom);
Transition.start(this$1.$el, propsTo, duration, timing).catch(noop);
});
});
2017-11-11 04:33:51 +00:00
}
},
2017-11-11 04:33:51 +00:00
{
name: 'transitioncanceled transitionend',
2017-11-11 04:33:51 +00:00
self: true,
2017-11-11 04:33:51 +00:00
el: function() {
return this.item;
2017-11-11 04:33:51 +00:00
},
handler: function() {
Transition.cancel(this.$el);
}
2017-11-11 04:33:51 +00:00
},
2017-11-11 04:33:51 +00:00
{
name: 'itemtranslatein itemtranslateout',
2017-11-11 04:33:51 +00:00
self: true,
2017-11-11 04:33:51 +00:00
el: function() {
return this.item;
2017-11-11 04:33:51 +00:00
},
handler: function(ref) {
2021-05-27 00:23:07 +00:00
var this$1 = this;
var type = ref.type;
var ref_detail = ref.detail;
var percent = ref_detail.percent;
var dir = ref_detail.dir;
2021-05-27 00:23:07 +00:00
fastdom.read(function () {
var props = this$1.getCss(getCurrentPercent(type, dir, percent));
fastdom.write(function () { return css(this$1.$el, props); });
});
}
2017-11-11 04:33:51 +00:00
}
]
};
2017-11-11 04:33:51 +00:00
function isIn(type) {
return endsWith(type, 'in');
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function getCurrentPercent(type, dir, percent) {
2017-11-11 04:33:51 +00:00
percent /= 2;
2017-11-11 04:33:51 +00:00
return !isIn(type)
? dir < 0
? percent
: 1 - percent
: dir < 0
? 1 - percent
: percent;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
var Animations = assign({}, Animations$2, {
2017-11-11 04:33:51 +00:00
fade: {
show: function() {
2017-11-11 04:33:51 +00:00
return [
{opacity: 0, zIndex: 0},
{zIndex: -1}
];
},
percent: function(current) {
2017-11-11 04:33:51 +00:00
return 1 - css(current, 'opacity');
},
translate: function(percent) {
2017-11-11 04:33:51 +00:00
return [
{opacity: 1 - percent, zIndex: 0},
{zIndex: -1}
];
}
},
scale: {
show: function() {
2017-11-11 04:33:51 +00:00
return [
{opacity: 0, transform: scale3d(1 + .5), zIndex: 0},
{zIndex: -1}
];
},
percent: function(current) {
2017-11-11 04:33:51 +00:00
return 1 - css(current, 'opacity');
},
translate: function(percent) {
2017-11-11 04:33:51 +00:00
return [
{opacity: 1 - percent, transform: scale3d(1 + .5 * percent), zIndex: 0},
{zIndex: -1}
];
}
},
pull: {
show: function(dir) {
2017-11-11 04:33:51 +00:00
return dir < 0
? [
{transform: translate(30), zIndex: -1},
2019-04-22 13:31:39 +00:00
{transform: translate(), zIndex: 0}
]
2017-11-11 04:33:51 +00:00
: [
{transform: translate(-100), zIndex: 0},
{transform: translate(), zIndex: -1}
];
},
percent: function(current, next, dir) {
2017-11-11 04:33:51 +00:00
return dir < 0
? 1 - translated(next)
: translated(current);
2017-11-11 04:33:51 +00:00
},
translate: function(percent, dir) {
2017-11-11 04:33:51 +00:00
return dir < 0
? [
{transform: translate(30 * percent), zIndex: -1},
2019-04-22 13:31:39 +00:00
{transform: translate(-100 * (1 - percent)), zIndex: 0}
]
2017-11-11 04:33:51 +00:00
: [
{transform: translate(-percent * 100), zIndex: 0},
{transform: translate(30 * (1 - percent)), zIndex: -1}
];
}
},
push: {
show: function(dir) {
2017-11-11 04:33:51 +00:00
return dir < 0
? [
{transform: translate(100), zIndex: 0},
2019-04-22 13:31:39 +00:00
{transform: translate(), zIndex: -1}
]
2017-11-11 04:33:51 +00:00
: [
{transform: translate(-30), zIndex: -1},
{transform: translate(), zIndex: 0}
];
},
percent: function(current, next, dir) {
2017-11-11 04:33:51 +00:00
return dir > 0
? 1 - translated(next)
: translated(current);
2017-11-11 04:33:51 +00:00
},
translate: function(percent, dir) {
2017-11-11 04:33:51 +00:00
return dir < 0
? [
{transform: translate(percent * 100), zIndex: 0},
2019-04-22 13:31:39 +00:00
{transform: translate(-30 * (1 - percent)), zIndex: -1}
]
2017-11-11 04:33:51 +00:00
: [
{transform: translate(-30 * percent), zIndex: -1},
{transform: translate(100 * (1 - percent)), zIndex: 0}
];
}
}
});
2021-05-27 00:23:07 +00:00
var slideshow = {
2017-11-11 04:33:51 +00:00
mixins: [Class, Slideshow, SliderReactive],
2017-11-11 04:33:51 +00:00
props: {
ratio: String,
2019-04-22 13:31:39 +00:00
minHeight: Number,
maxHeight: Number
2017-11-11 04:33:51 +00:00
},
data: {
2017-11-11 04:33:51 +00:00
ratio: '16:9',
minHeight: false,
maxHeight: false,
selList: '.uk-slideshow-items',
attrItem: 'uk-slideshow-item',
selNav: '.uk-slideshow-nav',
2021-05-27 00:23:07 +00:00
Animations: Animations
2017-11-11 04:33:51 +00:00
},
update: {
read: function() {
2017-11-11 04:33:51 +00:00
var ref = this.ratio.split(':').map(Number);
2019-04-22 13:31:39 +00:00
var width = ref[0];
var height = ref[1];
2019-04-22 13:31:39 +00:00
height = height * this.list.offsetWidth / width || 0;
2017-11-11 04:33:51 +00:00
if (this.minHeight) {
2019-04-22 13:31:39 +00:00
height = Math.max(this.minHeight, height);
2017-11-11 04:33:51 +00:00
}
if (this.maxHeight) {
2019-04-22 13:31:39 +00:00
height = Math.min(this.maxHeight, height);
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
return {height: height - boxModelAdjust(this.list, 'height', 'content-box')};
2017-11-11 04:33:51 +00:00
},
write: function(ref) {
2019-04-22 13:31:39 +00:00
var height = ref.height;
2021-05-27 00:23:07 +00:00
height > 0 && css(this.list, 'minHeight', height);
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
events: ['resize']
2017-11-11 04:33:51 +00:00
}
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var sortable = {
2017-11-11 04:33:51 +00:00
mixins: [Class, Animate],
2017-11-11 04:33:51 +00:00
props: {
group: String,
threshold: Number,
clsItem: String,
clsPlaceholder: String,
clsDrag: String,
clsDragState: String,
clsBase: String,
clsNoDrag: String,
clsEmpty: String,
clsCustom: String,
handle: String
},
data: {
2017-11-11 04:33:51 +00:00
group: false,
threshold: 5,
clsItem: 'uk-sortable-item',
clsPlaceholder: 'uk-sortable-placeholder',
clsDrag: 'uk-sortable-drag',
clsDragState: 'uk-drag',
clsBase: 'uk-sortable',
clsNoDrag: 'uk-sortable-nodrag',
clsEmpty: 'uk-sortable-empty',
clsCustom: '',
2021-05-27 00:23:07 +00:00
handle: false,
pos: {}
2017-11-11 04:33:51 +00:00
},
2019-04-22 13:31:39 +00:00
created: function() {
2017-11-11 04:33:51 +00:00
var this$1 = this;
['init', 'start', 'move', 'end'].forEach(function (key) {
var fn = this$1[key];
this$1[key] = function (e) {
2021-05-27 00:23:07 +00:00
assign(this$1.pos, getEventPos(e));
2017-11-11 04:33:51 +00:00
fn(e);
};
});
},
2019-04-22 13:31:39 +00:00
events: {
name: pointerDown,
passive: false,
handler: 'init'
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
computed: {
target: function() {
return (this.$el.tBodies || [this.$el])[0];
},
items: function() {
return children(this.target);
},
isEmpty: {
get: function() {
return isEmpty(this.items);
},
watch: function(empty) {
toggleClass(this.target, this.clsEmpty, empty);
},
immediate: true
},
handles: {
get: function(ref, el) {
var handle = ref.handle;
return handle ? $$(handle, el) : this.items;
},
watch: function(handles, prev) {
css(prev, {touchAction: '', userSelect: ''});
css(handles, {touchAction: hasTouch ? 'none' : '', userSelect: 'none'}); // touchAction set to 'none' causes a performance drop in Chrome 80
},
immediate: true
}
},
2017-11-11 04:33:51 +00:00
update: {
2021-05-27 00:23:07 +00:00
write: function(data) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!this.drag || !parent(this.placeholder)) {
return;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
var ref = this;
var ref_pos = ref.pos;
var x = ref_pos.x;
var y = ref_pos.y;
var ref_origin = ref.origin;
var offsetTop = ref_origin.offsetTop;
var offsetLeft = ref_origin.offsetLeft;
var placeholder = ref.placeholder;
css(this.drag, {
top: y - offsetTop,
left: x - offsetLeft
});
2021-05-27 00:23:07 +00:00
var sortable = this.getSortable(document.elementFromPoint(x, y));
if (!sortable) {
2017-11-11 04:33:51 +00:00
return;
}
2021-05-27 00:23:07 +00:00
var items = sortable.items;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (items.some(Transition.inProgress)) {
return;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var target = findTarget(items, {x: x, y: y});
if (items.length && (!target || target === placeholder)) {
return;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
var previous = this.getSortable(placeholder);
var insertTarget = findInsertTarget(sortable.target, target, placeholder, x, y, sortable === previous && data.moved !== target);
if (insertTarget === false) {
return;
}
if (insertTarget && placeholder === insertTarget) {
return;
}
if (sortable !== previous) {
previous.remove(placeholder);
data.moved = target;
} else {
delete data.moved;
}
sortable.insert(placeholder, insertTarget);
this.touched.add(sortable);
},
events: ['move']
2017-11-11 04:33:51 +00:00
},
methods: {
init: function(e) {
2017-11-11 04:33:51 +00:00
var target = e.target;
var button = e.button;
var defaultPrevented = e.defaultPrevented;
2021-05-27 00:23:07 +00:00
var ref = this.items.filter(function (el) { return within(target, el); });
var placeholder = ref[0];
2017-11-11 04:33:51 +00:00
if (!placeholder
2019-04-22 13:31:39 +00:00
|| defaultPrevented
|| button > 0
2019-04-22 13:31:39 +00:00
|| isInput(target)
2017-11-11 04:33:51 +00:00
|| within(target, ("." + (this.clsNoDrag)))
2019-04-22 13:31:39 +00:00
|| this.handle && !within(target, this.handle)
2017-11-11 04:33:51 +00:00
) {
return;
}
e.preventDefault();
2021-05-27 00:23:07 +00:00
this.touched = new Set([this]);
2017-11-11 04:33:51 +00:00
this.placeholder = placeholder;
this.origin = assign({target: target, index: index(placeholder)}, this.pos);
on(document, pointerMove, this.move);
on(document, pointerUp, this.end);
2017-11-11 04:33:51 +00:00
if (!this.threshold) {
this.start(e);
}
},
start: function(e) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.drag = appendDrag(this.$container, this.placeholder);
var ref = this.placeholder.getBoundingClientRect();
2017-11-11 04:33:51 +00:00
var left = ref.left;
var top = ref.top;
2021-05-27 00:23:07 +00:00
assign(this.origin, {offsetLeft: this.pos.x - left, offsetTop: this.pos.y - top});
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
addClass(this.drag, this.clsDrag, this.clsCustom);
2017-11-11 04:33:51 +00:00
addClass(this.placeholder, this.clsPlaceholder);
2021-05-27 00:23:07 +00:00
addClass(this.items, this.clsItem);
addClass(document.documentElement, this.clsDragState);
2017-11-11 04:33:51 +00:00
trigger(this.$el, 'start', [this, this.placeholder]);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
trackScroll(this.pos);
2017-11-11 04:33:51 +00:00
this.move(e);
},
move: function(e) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (this.drag) {
this.$emit('move');
} else if (Math.abs(this.pos.x - this.origin.x) > this.threshold || Math.abs(this.pos.y - this.origin.y) > this.threshold) {
this.start(e);
2017-11-11 04:33:51 +00:00
}
},
2021-05-27 00:23:07 +00:00
end: function() {
var this$1 = this;
2017-11-11 04:33:51 +00:00
off(document, pointerMove, this.move);
off(document, pointerUp, this.end);
off(window, 'scroll', this.scroll);
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
if (!this.drag) {
2017-11-11 04:33:51 +00:00
return;
}
2021-05-27 00:23:07 +00:00
untrackScroll();
var sortable = this.getSortable(this.placeholder);
2017-11-11 04:33:51 +00:00
if (this === sortable) {
if (this.origin.index !== index(this.placeholder)) {
trigger(this.$el, 'moved', [this, this.placeholder]);
}
} else {
trigger(sortable.$el, 'added', [sortable, this.placeholder]);
trigger(this.$el, 'removed', [this, this.placeholder]);
}
trigger(this.$el, 'stop', [this, this.placeholder]);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
remove$1(this.drag);
2017-11-11 04:33:51 +00:00
this.drag = null;
2021-05-27 00:23:07 +00:00
this.touched.forEach(function (ref) {
var clsPlaceholder = ref.clsPlaceholder;
var clsItem = ref.clsItem;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return this$1.touched.forEach(function (sortable) { return removeClass(sortable.items, clsPlaceholder, clsItem); }
);
}
);
this.touched = null;
removeClass(document.documentElement, this.clsDragState);
2017-11-11 04:33:51 +00:00
},
insert: function(element, target) {
2017-11-11 04:33:51 +00:00
var this$1 = this;
2021-05-27 00:23:07 +00:00
addClass(this.items, this.clsItem);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var insert = function () { return target
? before(target, element)
: append(this$1.target, element); };
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
this.animate(insert);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
},
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
remove: function(element) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (!within(element, this.target)) {
return;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
this.animate(function () { return remove$1(element); });
2017-11-11 04:33:51 +00:00
},
2021-05-27 00:23:07 +00:00
getSortable: function(element) {
do {
var sortable = this.$getComponent(element, 'sortable');
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (sortable && (sortable === this || this.group !== false && sortable.group === this.group)) {
return sortable;
}
} while ((element = parent(element)));
}
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
};
var trackTimer;
function trackScroll(pos) {
var last = Date.now();
trackTimer = setInterval(function () {
var x = pos.x;
var y = pos.y;
y += window.pageYOffset;
var dist = (Date.now() - last) * .3;
last = Date.now();
scrollParents(document.elementFromPoint(x, pos.y)).reverse().some(function (scrollEl) {
var scroll = scrollEl.scrollTop;
var scrollHeight = scrollEl.scrollHeight;
var ref = offset(getViewport$1(scrollEl));
var top = ref.top;
var bottom = ref.bottom;
var height = ref.height;
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
if (top < y && top + 35 > y) {
scroll -= dist;
} else if (bottom > y && bottom - 35 < y) {
scroll += dist;
2017-11-11 04:33:51 +00:00
} else {
2021-05-27 00:23:07 +00:00
return;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
if (scroll > 0 && scroll < scrollHeight - height) {
scrollTop(scrollEl, scroll);
return true;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
});
}, 15);
}
function untrackScroll() {
clearInterval(trackTimer);
}
function appendDrag(container, element) {
var clone = append(container, element.outerHTML.replace(/(^<)(?:li|tr)|(?:li|tr)(\/>$)/g, '$1div$2'));
css(clone, 'margin', '0', 'important');
css(clone, assign({
boxSizing: 'border-box',
width: element.offsetWidth,
height: element.offsetHeight
}, css(element, ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom'])));
height(clone.firstElementChild, height(element.firstElementChild));
return clone;
}
function findTarget(items, point) {
return items[findIndex(items, function (item) { return pointInRect(point, item.getBoundingClientRect()); })];
}
function findInsertTarget(list, target, placeholder, x, y, sameList) {
if (!children(list).length) {
return;
}
var rect = target.getBoundingClientRect();
if (!sameList) {
if (!isHorizontal(list, placeholder)) {
return y < rect.top + rect.height / 2
? target
: target.nextElementSibling;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
return target;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
var placeholderRect = placeholder.getBoundingClientRect();
var sameRow = linesIntersect(
[rect.top, rect.bottom],
[placeholderRect.top, placeholderRect.bottom]
);
var pointerPos = sameRow ? x : y;
var lengthProp = sameRow ? 'width' : 'height';
var startProp = sameRow ? 'left' : 'top';
var endProp = sameRow ? 'right' : 'bottom';
var diff = placeholderRect[lengthProp] < rect[lengthProp] ? rect[lengthProp] - placeholderRect[lengthProp] : 0;
if (placeholderRect[startProp] < rect[startProp]) {
if (diff && pointerPos < rect[startProp] + diff) {
return false;
}
return target.nextElementSibling;
}
if (diff && pointerPos > rect[endProp] - diff) {
return false;
}
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return target;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
function isHorizontal(list, placeholder) {
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
var single = children(list).length === 1;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (single) {
append(list, placeholder);
}
var items = children(list);
var isHorizontal = items.some(function (el, i) {
var rectA = el.getBoundingClientRect();
return items.slice(i + 1).some(function (el) {
var rectB = el.getBoundingClientRect();
return !linesIntersect([rectA.left, rectA.right], [rectB.left, rectB.right]);
});
});
if (single) {
remove$1(placeholder);
}
return isHorizontal;
}
function linesIntersect(lineA, lineB) {
return lineA[1] > lineB[0] && lineB[1] > lineA[0];
}
var obj;
var tooltip = {
2017-11-11 04:33:51 +00:00
mixins: [Container, Togglable, Position],
2017-11-11 04:33:51 +00:00
args: 'title',
2017-11-11 04:33:51 +00:00
props: {
delay: Number,
title: String
},
data: {
2017-11-11 04:33:51 +00:00
pos: 'top',
title: '',
delay: 0,
animation: ['uk-animation-scale-up'],
duration: 100,
cls: 'uk-active',
clsPos: 'uk-tooltip'
},
beforeConnect: function() {
this._hasTitle = hasAttr(this.$el, 'title');
2021-05-27 00:23:07 +00:00
attr(this.$el, 'title', '');
this.updateAria(false);
makeFocusable(this.$el);
2017-11-11 04:33:51 +00:00
},
disconnected: function() {
2017-11-11 04:33:51 +00:00
this.hide();
2021-05-27 00:23:07 +00:00
attr(this.$el, 'title', this._hasTitle ? this.title : null);
2017-11-11 04:33:51 +00:00
},
methods: {
show: function() {
2017-11-11 04:33:51 +00:00
var this$1 = this;
2021-05-27 00:23:07 +00:00
if (this.isToggled(this.tooltip || null) || !this.title) {
2017-11-11 04:33:51 +00:00
return;
}
2021-05-27 00:23:07 +00:00
this._unbind = once(document, ("show keydown " + pointerDown), this.hide, false, function (e) { return e.type === pointerDown && !within(e.target, this$1.$el)
|| e.type === 'keydown' && e.keyCode === 27
|| e.type === 'show' && e.detail[0] !== this$1 && e.detail[0].$name === this$1.$name; }
);
2017-11-11 04:33:51 +00:00
clearTimeout(this.showTimer);
2021-05-27 00:23:07 +00:00
this.showTimer = setTimeout(this._show, this.delay);
2017-11-11 04:33:51 +00:00
},
hide: function() {
2021-05-27 00:23:07 +00:00
var this$1 = this;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
if (matches(this.$el, 'input:focus')) {
2017-11-11 04:33:51 +00:00
return;
}
clearTimeout(this.showTimer);
2021-05-27 00:23:07 +00:00
if (!this.isToggled(this.tooltip || null)) {
return;
}
this.toggleElement(this.tooltip, false, false).then(function () {
this$1.tooltip = remove$1(this$1.tooltip);
this$1._unbind();
});
2019-04-22 13:31:39 +00:00
},
_show: function() {
2021-05-27 00:23:07 +00:00
var this$1 = this;
2019-04-22 13:31:39 +00:00
this.tooltip = append(this.container,
2021-05-27 00:23:07 +00:00
("<div class=\"" + (this.clsPos) + "\"> <div class=\"" + (this.clsPos) + "-inner\">" + (this.title) + "</div> </div>")
2019-04-22 13:31:39 +00:00
);
2021-05-27 00:23:07 +00:00
on(this.tooltip, 'toggled', function (e, toggled) {
this$1.updateAria(toggled);
if (!toggled) {
return;
}
this$1.positionAt(this$1.tooltip, this$1.$el);
2019-04-22 13:31:39 +00:00
2021-05-27 00:23:07 +00:00
this$1.origin = this$1.getAxis() === 'y'
? ((flipPosition(this$1.dir)) + "-" + (this$1.align))
: ((this$1.align) + "-" + (flipPosition(this$1.dir)));
});
2019-04-22 13:31:39 +00:00
this.toggleElement(this.tooltip, true);
},
2021-05-27 00:23:07 +00:00
updateAria: function(toggled) {
attr(this.$el, 'aria-expanded', toggled);
2017-11-11 04:33:51 +00:00
}
},
2021-05-27 00:23:07 +00:00
events: ( obj = {
2019-04-22 13:31:39 +00:00
focus: 'show',
blur: 'hide'
2021-05-27 00:23:07 +00:00
}, obj[(pointerEnter + " " + pointerLeave)] = function (e) {
2017-11-11 04:33:51 +00:00
if (!isTouch(e)) {
2021-05-27 00:23:07 +00:00
this[e.type === pointerEnter ? 'show' : 'hide']();
}
}, obj[pointerDown] = function (e) {
if (isTouch(e)) {
this.show();
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
}, obj )
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function makeFocusable(el) {
if (!isFocusable(el)) {
attr(el, 'tabindex', '0');
}
}
var upload = {
2017-11-11 04:33:51 +00:00
props: {
allow: String,
clsDragover: String,
concurrent: Number,
maxSize: Number,
method: String,
2017-11-11 04:33:51 +00:00
mime: String,
msgInvalidMime: String,
msgInvalidName: String,
msgInvalidSize: String,
2017-11-11 04:33:51 +00:00
multiple: Boolean,
name: String,
params: Object,
type: String,
2019-04-22 13:31:39 +00:00
url: String
2017-11-11 04:33:51 +00:00
},
data: {
2017-11-11 04:33:51 +00:00
allow: false,
clsDragover: 'uk-dragover',
concurrent: 1,
maxSize: 0,
method: 'POST',
2017-11-11 04:33:51 +00:00
mime: false,
msgInvalidMime: 'Invalid File Type: %s',
msgInvalidName: 'Invalid File Name: %s',
msgInvalidSize: 'Invalid File Size: %s Kilobytes Max',
2017-11-11 04:33:51 +00:00
multiple: false,
name: 'files[]',
params: {},
type: '',
2017-11-11 04:33:51 +00:00
url: '',
abort: noop,
beforeAll: noop,
beforeSend: noop,
complete: noop,
completeAll: noop,
error: noop,
fail: noop,
load: noop,
loadEnd: noop,
loadStart: noop,
progress: noop
},
events: {
change: function(e) {
2017-11-11 04:33:51 +00:00
if (!matches(e.target, 'input[type="file"]')) {
return;
}
e.preventDefault();
if (e.target.files) {
this.upload(e.target.files);
}
e.target.value = '';
},
drop: function(e) {
2017-11-11 04:33:51 +00:00
stop(e);
var transfer = e.dataTransfer;
if (!transfer || !transfer.files) {
return;
}
removeClass(this.$el, this.clsDragover);
this.upload(transfer.files);
},
dragenter: function(e) {
2017-11-11 04:33:51 +00:00
stop(e);
},
dragover: function(e) {
2017-11-11 04:33:51 +00:00
stop(e);
addClass(this.$el, this.clsDragover);
},
dragleave: function(e) {
2017-11-11 04:33:51 +00:00
stop(e);
removeClass(this.$el, this.clsDragover);
}
},
methods: {
upload: function(files) {
2017-11-11 04:33:51 +00:00
var this$1 = this;
if (!files.length) {
return;
}
trigger(this.$el, 'upload', [files]);
for (var i = 0; i < files.length; i++) {
2019-04-22 13:31:39 +00:00
if (this.maxSize && this.maxSize * 1000 < files[i].size) {
this.fail(this.msgInvalidSize.replace('%s', this.maxSize));
return;
2017-11-11 04:33:51 +00:00
}
2021-05-27 00:23:07 +00:00
if (this.allow && !match(this.allow, files[i].name)) {
2019-04-22 13:31:39 +00:00
this.fail(this.msgInvalidName.replace('%s', this.allow));
return;
}
2021-05-27 00:23:07 +00:00
if (this.mime && !match(this.mime, files[i].type)) {
2019-04-22 13:31:39 +00:00
this.fail(this.msgInvalidMime.replace('%s', this.mime));
return;
2017-11-11 04:33:51 +00:00
}
}
if (!this.multiple) {
files = [files[0]];
}
this.beforeAll(this, files);
var chunks = chunk(files, this.concurrent);
var upload = function (files) {
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
var data = new FormData();
2017-11-11 04:33:51 +00:00
2019-04-22 13:31:39 +00:00
files.forEach(function (file) { return data.append(this$1.name, file); });
2017-11-11 04:33:51 +00:00
for (var key in this$1.params) {
2019-04-22 13:31:39 +00:00
data.append(key, this$1.params[key]);
}
2017-11-11 04:33:51 +00:00
ajax(this$1.url, {
2019-04-22 13:31:39 +00:00
data: data,
method: this$1.method,
responseType: this$1.type,
beforeSend: function (env) {
2017-11-11 04:33:51 +00:00
var xhr = env.xhr;
xhr.upload && on(xhr.upload, 'progress', this$1.progress);
['loadStart', 'load', 'loadEnd', 'abort'].forEach(function (type) { return on(xhr, type.toLowerCase(), this$1[type]); }
);
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
return this$1.beforeSend(env);
2017-11-11 04:33:51 +00:00
}
}).then(
function (xhr) {
2017-11-11 04:33:51 +00:00
this$1.complete(xhr);
2017-11-11 04:33:51 +00:00
if (chunks.length) {
upload(chunks.shift());
} else {
this$1.completeAll(xhr);
}
2017-11-11 04:33:51 +00:00
},
function (e) { return this$1.error(e); }
);
2017-11-11 04:33:51 +00:00
};
2017-11-11 04:33:51 +00:00
upload(chunks.shift());
}
}
};
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
function match(pattern, path) {
2017-11-11 04:33:51 +00:00
return path.match(new RegExp(("^" + (pattern.replace(/\//g, '\\/').replace(/\*\*/g, '(\\/[^\\/]+)*').replace(/\*/g, '[^\\/]+').replace(/((?!\\))\?/g, '$1.')) + "$"), 'i'));
}
function chunk(files, size) {
var chunks = [];
for (var i = 0; i < files.length; i += size) {
var chunk = [];
for (var j = 0; j < size; j++) {
chunk.push(files[i + j]);
}
chunks.push(chunk);
}
return chunks;
}
function stop(e) {
e.preventDefault();
e.stopPropagation();
}
2021-05-27 00:23:07 +00:00
var components = /*#__PURE__*/Object.freeze({
__proto__: null,
Countdown: countdown,
Filter: filter,
Lightbox: lightbox,
LightboxPanel: LightboxPanel,
Notification: notification,
Parallax: parallax,
Slider: slider,
SliderParallax: sliderParallax,
Slideshow: slideshow,
SlideshowParallax: sliderParallax,
Sortable: sortable,
Tooltip: tooltip,
Upload: upload
});
2021-05-27 00:23:07 +00:00
each(components, function (component, name) { return UIkit.component(name, component); }
);
2017-11-11 04:33:51 +00:00
return UIkit;
2017-11-11 04:33:51 +00:00
2021-05-27 00:23:07 +00:00
})));