Component-Builder/media/uikit/js/uikit.js

3917 lines
116 KiB
JavaScript
Raw Normal View History

2017-11-12 00:33:10 +00:00
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2016-01-30 20:28:43 +00:00
(function(core) {
2017-11-12 00:33:10 +00:00
var uikit;
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (!window.jQuery) {
throw new Error('UIkit 2.x requires jQuery');
} else {
uikit = core(window.jQuery);
}
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (typeof define == 'function' && define.amd) { // AMD
define('uikit', function(){
2016-01-30 20:28:43 +00:00
uikit.load = function(res, req, onload, config) {
2017-11-12 00:33:10 +00:00
var resources = res.split(','), load = [], i, base = (config.config && config.config.uikit && config.config.uikit.base ? config.config.uikit.base : '').replace(/\/+$/g, '');
2016-01-30 20:28:43 +00:00
if (!base) {
2017-11-12 00:33:10 +00:00
throw new Error('Please define base path to UIkit in the requirejs config.');
2016-01-30 20:28:43 +00:00
}
for (i = 0; i < resources.length; i += 1) {
var resource = resources[i].replace(/\./g, '/');
load.push(base+'/components/'+resource);
}
req(load, function() {
onload(uikit);
});
};
return uikit;
});
}
2017-11-12 00:33:10 +00:00
})(function($) {
2016-01-30 20:28:43 +00:00
"use strict";
2017-11-12 00:33:10 +00:00
if (window.UIkit2) {
return window.UIkit2;
}
var UI = {}, _UI = window.UIkit || undefined;
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
UI.version = '2.27.4';
2016-01-30 20:28:43 +00:00
UI.noConflict = function() {
// restore UIkit version
if (_UI) {
2017-11-12 00:33:10 +00:00
window.UIkit = _UI;
2016-01-30 20:28:43 +00:00
$.UIkit = _UI;
$.fn.uk = _UI.fn;
}
return UI;
};
2017-11-12 00:33:10 +00:00
window.UIkit2 = UI;
if (!_UI) {
window.UIkit = UI;
}
2016-01-30 20:28:43 +00:00
// cache jQuery
UI.$ = $;
UI.$doc = UI.$(document);
UI.$win = UI.$(window);
UI.$html = UI.$('html');
UI.support = {};
UI.support.transition = (function() {
var transitionEnd = (function() {
2017-11-12 00:33:10 +00:00
var element = document.body || document.documentElement,
2016-01-30 20:28:43 +00:00
transEndEventNames = {
WebkitTransition : 'webkitTransitionEnd',
MozTransition : 'transitionend',
OTransition : 'oTransitionEnd otransitionend',
transition : 'transitionend'
}, name;
for (name in transEndEventNames) {
if (element.style[name] !== undefined) return transEndEventNames[name];
}
}());
return transitionEnd && { end: transitionEnd };
})();
UI.support.animation = (function() {
var animationEnd = (function() {
2017-11-12 00:33:10 +00:00
var element = document.body || document.documentElement,
2016-01-30 20:28:43 +00:00
animEndEventNames = {
WebkitAnimation : 'webkitAnimationEnd',
MozAnimation : 'animationend',
OAnimation : 'oAnimationEnd oanimationend',
animation : 'animationend'
}, name;
for (name in animEndEventNames) {
if (element.style[name] !== undefined) return animEndEventNames[name];
}
}());
return animationEnd && { end: animationEnd };
})();
// requestAnimationFrame polyfill
2016-03-19 01:51:35 +00:00
//https://github.com/darius/requestAnimationFrame
(function() {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
Date.now = Date.now || function() { return new Date().getTime(); };
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var vendors = ['webkit', 'moz'];
for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
var vp = vendors[i];
window.requestAnimationFrame = window[vp+'RequestAnimationFrame'];
window.cancelAnimationFrame = (window[vp+'CancelAnimationFrame']
|| window[vp+'CancelRequestAnimationFrame']);
}
if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) // iOS6 is buggy
|| !window.requestAnimationFrame || !window.cancelAnimationFrame) {
var lastTime = 0;
window.requestAnimationFrame = function(callback) {
var now = Date.now();
var nextTime = Math.max(lastTime + 16, now);
return setTimeout(function() { callback(lastTime = nextTime); },
nextTime - now);
2016-01-30 20:28:43 +00:00
};
2016-03-19 01:51:35 +00:00
window.cancelAnimationFrame = clearTimeout;
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
}());
2016-01-30 20:28:43 +00:00
UI.support.touch = (
('ontouchstart' in document) ||
2017-11-12 00:33:10 +00:00
(window.DocumentTouch && document instanceof window.DocumentTouch) ||
(window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 0) || //IE 10
(window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 0) || //IE >=11
2016-01-30 20:28:43 +00:00
false
);
2017-11-12 00:33:10 +00:00
UI.support.mutationobserver = (window.MutationObserver || window.WebKitMutationObserver || null);
2016-01-30 20:28:43 +00:00
UI.Utils = {};
UI.Utils.isFullscreen = function() {
2016-03-19 01:51:35 +00:00
return document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || document.fullscreenElement || false;
2016-01-30 20:28:43 +00:00
};
UI.Utils.str2json = function(str, notevil) {
try {
if (notevil) {
return JSON.parse(str
// wrap keys without quote with valid double quote
.replace(/([\$\w]+)\s*:/g, function(_, $1){return '"'+$1+'":';})
// replacing single quote wrapped ones to double quote
.replace(/'([^']+)'/g, function(_, $1){return '"'+$1+'"';})
);
} else {
2017-11-12 00:33:10 +00:00
return (new Function('', 'var json = ' + str + '; return JSON.parse(JSON.stringify(json));'))();
2016-01-30 20:28:43 +00:00
}
} catch(e) { return false; }
};
UI.Utils.debounce = function(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
2017-11-12 00:33:10 +00:00
UI.Utils.throttle = function (func, limit) {
var wait = false;
return function () {
if (!wait) {
func.call();
wait = true;
setTimeout(function () {
wait = false;
}, limit);
}
}
};
2016-01-30 20:28:43 +00:00
UI.Utils.removeCssRules = function(selectorRegEx) {
var idx, idxs, stylesheet, _i, _j, _k, _len, _len1, _len2, _ref;
if(!selectorRegEx) return;
setTimeout(function(){
try {
_ref = document.styleSheets;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
stylesheet = _ref[_i];
idxs = [];
stylesheet.cssRules = stylesheet.cssRules;
for (idx = _j = 0, _len1 = stylesheet.cssRules.length; _j < _len1; idx = ++_j) {
if (stylesheet.cssRules[idx].type === CSSRule.STYLE_RULE && selectorRegEx.test(stylesheet.cssRules[idx].selectorText)) {
idxs.unshift(idx);
}
}
for (_k = 0, _len2 = idxs.length; _k < _len2; _k++) {
stylesheet.deleteRule(idxs[_k]);
}
}
} catch (_error) {}
}, 0);
};
UI.Utils.isInView = function(element, options) {
var $element = $(element);
if (!$element.is(':visible')) {
return false;
}
var window_left = UI.$win.scrollLeft(), window_top = UI.$win.scrollTop(), offset = $element.offset(), left = offset.left, top = offset.top;
options = $.extend({topoffset:0, leftoffset:0}, options);
if (top + $element.height() >= window_top && top - options.topoffset <= window_top + UI.$win.height() &&
left + $element.width() >= window_left && left - options.leftoffset <= window_left + UI.$win.width()) {
return true;
} else {
return false;
}
};
UI.Utils.checkDisplay = function(context, initanimation) {
var elements = UI.$('[data-uk-margin], [data-uk-grid-match], [data-uk-grid-margin], [data-uk-check-display]', context || document), animated;
if (context && !elements.length) {
elements = $(context);
}
elements.trigger('display.uk.check');
// fix firefox / IE animations
if (initanimation) {
if (typeof(initanimation)!='string') {
initanimation = '[class*="uk-animation-"]';
}
elements.find(initanimation).each(function(){
var ele = UI.$(this),
cls = ele.attr('class'),
2017-11-12 00:33:10 +00:00
anim = cls.match(/uk-animation-(.+)/);
2016-01-30 20:28:43 +00:00
ele.removeClass(anim[0]).width();
ele.addClass(anim[0]);
});
}
return elements;
};
UI.Utils.options = function(string) {
2016-03-19 01:51:35 +00:00
if ($.type(string)!='string') return string;
if (string.indexOf(':') != -1 && string.trim().substr(-1) != '}') {
string = '{'+string+'}';
}
2016-01-30 20:28:43 +00:00
var start = (string ? string.indexOf("{") : -1), options = {};
if (start != -1) {
try {
options = UI.Utils.str2json(string.substr(start));
} catch (e) {}
}
return options;
};
UI.Utils.animate = function(element, cls) {
var d = $.Deferred();
element = UI.$(element);
element.css('display', 'none').addClass(cls).one(UI.support.animation.end, function() {
element.removeClass(cls);
d.resolve();
2016-03-19 01:51:35 +00:00
});
2016-01-30 20:28:43 +00:00
element.css('display', '');
return d.promise();
};
UI.Utils.uid = function(prefix) {
return (prefix || 'id') + (new Date().getTime())+"RAND"+(Math.ceil(Math.random() * 100000));
};
UI.Utils.template = function(str, data) {
var tokens = str.replace(/\n/g, '\\n').replace(/\{\{\{\s*(.+?)\s*\}\}\}/g, "{{!$1}}").split(/(\{\{\s*(.+?)\s*\}\})/g),
i=0, toc, cmd, prop, val, fn, output = [], openblocks = 0;
while(i < tokens.length) {
toc = tokens[i];
if(toc.match(/\{\{\s*(.+?)\s*\}\}/)) {
i = i + 1;
toc = tokens[i];
cmd = toc[0];
prop = toc.substring(toc.match(/^(\^|\#|\!|\~|\:)/) ? 1:0);
switch(cmd) {
case '~':
2017-11-12 00:33:10 +00:00
output.push('for(var $i=0;$i<'+prop+'.length;$i++) { var $item = '+prop+'[$i];');
2016-01-30 20:28:43 +00:00
openblocks++;
break;
case ':':
2017-11-12 00:33:10 +00:00
output.push('for(var $key in '+prop+') { var $val = '+prop+'[$key];');
2016-01-30 20:28:43 +00:00
openblocks++;
break;
case '#':
2017-11-12 00:33:10 +00:00
output.push('if('+prop+') {');
2016-01-30 20:28:43 +00:00
openblocks++;
break;
case '^':
2017-11-12 00:33:10 +00:00
output.push('if(!'+prop+') {');
2016-01-30 20:28:43 +00:00
openblocks++;
break;
case '/':
2017-11-12 00:33:10 +00:00
output.push('}');
2016-01-30 20:28:43 +00:00
openblocks--;
break;
case '!':
2017-11-12 00:33:10 +00:00
output.push('__ret.push('+prop+');');
2016-01-30 20:28:43 +00:00
break;
default:
2017-11-12 00:33:10 +00:00
output.push('__ret.push(escape('+prop+'));');
2016-01-30 20:28:43 +00:00
break;
}
} else {
output.push("__ret.push('"+toc.replace(/\'/g, "\\'")+"');");
}
i = i + 1;
}
fn = new Function('$data', [
'var __ret = [];',
'try {',
'with($data){', (!openblocks ? output.join('') : '__ret = ["Not all blocks are closed correctly."]'), '};',
'}catch(e){__ret = [e.message];}',
'return __ret.join("").replace(/\\n\\n/g, "\\n");',
"function escape(html) { return String(html).replace(/&/g, '&amp;').replace(/\"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');}"
].join("\n"));
return data ? fn(data) : fn;
};
2017-11-12 00:33:10 +00:00
UI.Utils.focus = function(element, extra) {
element = $(element);
if (!element.length) {
return element;
}
var autofocus = element.find('[autofocus]:first'), tabidx;
if (autofocus.length) {
return autofocus.focus();
}
autofocus = element.find(':input'+(extra && (','+extra) || '')).first();
if (autofocus.length) {
return autofocus.focus();
}
if (!element.attr('tabindex')) {
tabidx = 1000;
element.attr('tabindex', tabidx);
}
element[0].focus();
if (tabidx) {
element.attr('tabindex', '');
}
return element;
}
2016-01-30 20:28:43 +00:00
UI.Utils.events = {};
UI.Utils.events.click = UI.support.touch ? 'tap' : 'click';
// deprecated
UI.fn = function(command, options) {
var args = arguments, cmd = command.match(/^([a-z\-]+)(?:\.([a-z]+))?/i), component = cmd[1], method = cmd[2];
if (!UI[component]) {
2017-11-12 00:33:10 +00:00
$.error('UIkit component [' + component + '] does not exist.');
2016-01-30 20:28:43 +00:00
return this;
}
return this.each(function() {
var $this = $(this), data = $this.data(component);
if (!data) $this.data(component, (data = UI[component](this, method ? undefined : options)));
if (method) data[method].apply(data, Array.prototype.slice.call(args, 1));
});
};
$.UIkit = UI;
$.fn.uk = UI.fn;
UI.langdirection = UI.$html.attr("dir") == "rtl" ? "right" : "left";
UI.components = {};
2017-11-12 00:33:10 +00:00
UI.component = function(name, def, override) {
if (UI.components[name] && !override) {
return UI.components[name];
}
2016-01-30 20:28:43 +00:00
var fn = function(element, options) {
var $this = this;
this.UIkit = UI;
this.element = element ? UI.$(element) : null;
this.options = $.extend(true, {}, this.defaults, options);
this.plugins = {};
if (this.element) {
this.element.data(name, this);
}
this.init();
(this.options.plugins.length ? this.options.plugins : Object.keys(fn.plugins)).forEach(function(plugin) {
if (fn.plugins[plugin].init) {
fn.plugins[plugin].init($this);
$this.plugins[plugin] = true;
}
});
this.trigger('init.uk.component', [name, this]);
return this;
};
fn.plugins = {};
$.extend(true, fn.prototype, {
defaults : {plugins: []},
boot: function(){},
init: function(){},
on: function(a1,a2,a3){
return UI.$(this.element || this).on(a1,a2,a3);
},
one: function(a1,a2,a3){
return UI.$(this.element || this).one(a1,a2,a3);
},
off: function(evt){
return UI.$(this.element || this).off(evt);
},
trigger: function(evt, params) {
return UI.$(this.element || this).trigger(evt, params);
},
find: function(selector) {
return UI.$(this.element ? this.element: []).find(selector);
},
proxy: function(obj, methods) {
var $this = this;
methods.split(' ').forEach(function(method) {
if (!$this[method]) $this[method] = function() { return obj[method].apply(obj, arguments); };
});
},
mixin: function(obj, methods) {
var $this = this;
methods.split(' ').forEach(function(method) {
if (!$this[method]) $this[method] = obj[method].bind($this);
});
},
option: function() {
if (arguments.length == 1) {
return this.options[arguments[0]] || undefined;
} else if (arguments.length == 2) {
this.options[arguments[0]] = arguments[1];
}
}
}, def);
this.components[name] = fn;
this[name] = function() {
var element, options;
if (arguments.length) {
switch(arguments.length) {
case 1:
2017-11-12 00:33:10 +00:00
if (typeof arguments[0] === 'string' || arguments[0].nodeType || arguments[0] instanceof jQuery) {
2016-01-30 20:28:43 +00:00
element = $(arguments[0]);
} else {
options = arguments[0];
}
break;
case 2:
element = $(arguments[0]);
options = arguments[1];
break;
}
}
if (element && element.data(name)) {
return element.data(name);
}
return (new UI.components[name](element, options));
};
if (UI.domready) {
UI.component.boot(name);
}
return fn;
};
UI.plugin = function(component, name, def) {
this.components[component].plugins[name] = def;
};
UI.component.boot = function(name) {
if (UI.components[name].prototype && UI.components[name].prototype.boot && !UI.components[name].booted) {
UI.components[name].prototype.boot.apply(UI, []);
UI.components[name].booted = true;
}
};
UI.component.bootComponents = function() {
for (var component in UI.components) {
UI.component.boot(component);
}
};
// DOM mutation save ready helper function
UI.domObservers = [];
UI.domready = false;
UI.ready = function(fn) {
UI.domObservers.push(fn);
if (UI.domready) {
fn(document);
}
};
UI.on = function(a1,a2,a3){
if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) {
a2.apply(UI.$doc);
}
return UI.$doc.on(a1,a2,a3);
};
UI.one = function(a1,a2,a3){
if (a1 && a1.indexOf('ready.uk.dom') > -1 && UI.domready) {
a2.apply(UI.$doc);
return UI.$doc;
}
return UI.$doc.one(a1,a2,a3);
};
UI.trigger = function(evt, params) {
return UI.$doc.trigger(evt, params);
};
UI.domObserve = function(selector, fn) {
if(!UI.support.mutationobserver) return;
fn = fn || function() {};
UI.$(selector).each(function() {
var element = this,
$element = UI.$(element);
if ($element.data('observer')) {
return;
}
try {
var observer = new UI.support.mutationobserver(UI.Utils.debounce(function(mutations) {
2017-11-12 00:33:10 +00:00
fn.apply(element, [$element]);
2016-01-30 20:28:43 +00:00
$element.trigger('changed.uk.dom');
2017-11-12 00:33:10 +00:00
}, 50), {childList: true, subtree: true});
2016-01-30 20:28:43 +00:00
// pass in the target node, as well as the observer options
observer.observe(element, { childList: true, subtree: true });
$element.data('observer', observer);
} catch(e) {}
});
};
UI.init = function(root) {
root = root || document;
UI.domObservers.forEach(function(fn){
fn(root);
});
};
UI.on('domready.uk.dom', function(){
UI.init();
if (UI.domready) UI.Utils.checkDisplay();
});
2016-03-19 01:51:35 +00:00
document.addEventListener('DOMContentLoaded', function(){
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var domReady = function() {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
UI.$body = UI.$('body');
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
UI.trigger('beforeready.uk.dom');
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
UI.component.bootComponents();
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
// custom scroll observer
2017-11-12 00:33:10 +00:00
var rafToken = requestAnimationFrame((function(){
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var memory = {dir: {x:0, y:0}, x: window.pageXOffset, y:window.pageYOffset};
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var fn = function(){
// reading this (window.page[X|Y]Offset) causes a full page recalc of the layout in Chrome,
// so we only want to do this once
var wpxo = window.pageXOffset;
var wpyo = window.pageYOffset;
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
// Did the scroll position change since the last time we were here?
if (memory.x != wpxo || memory.y != wpyo) {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
// Set the direction of the scroll and store the new position
if (wpxo != memory.x) {memory.dir.x = wpxo > memory.x ? 1:-1; } else { memory.dir.x = 0; }
if (wpyo != memory.y) {memory.dir.y = wpyo > memory.y ? 1:-1; } else { memory.dir.y = 0; }
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
memory.x = wpxo;
memory.y = wpyo;
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
// Trigger the scroll event, this could probably be sent using memory.clone() but this is
// more explicit and easier to see exactly what is being sent in the event.
UI.$doc.trigger('scrolling.uk.document', [{
2017-11-12 00:33:10 +00:00
dir: {x: memory.dir.x, y: memory.dir.y}, x: wpxo, y: wpyo
2016-03-19 01:51:35 +00:00
}]);
}
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
cancelAnimationFrame(rafToken);
rafToken = requestAnimationFrame(fn);
2016-03-19 01:51:35 +00:00
};
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
if (UI.support.touch) {
UI.$html.on('touchmove touchend MSPointerMove MSPointerUp pointermove pointerup', fn);
}
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
if (memory.x || memory.y) fn();
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
return fn;
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
})());
// run component init functions on dom
UI.trigger('domready.uk.dom');
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
if (UI.support.touch) {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
// remove css hover rules for touch devices
// UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/);
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
// viewport unit fix for uk-height-viewport - should be fixed in iOS 8
if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
UI.$win.on('load orientationchange resize', UI.Utils.debounce((function(){
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var fn = function() {
$('.uk-height-viewport').css('height', window.innerHeight);
return fn;
};
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
return fn();
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
})(), 100));
}
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
UI.trigger('afterready.uk.dom');
// mark that domready is left behind
UI.domready = true;
2017-11-12 00:33:10 +00:00
// auto init js components
if (UI.support.mutationobserver) {
var initFn = UI.Utils.debounce(function(){
requestAnimationFrame(function(){ UI.init(document.body);});
}, 10);
(new UI.support.mutationobserver(function(mutations) {
var init = false;
mutations.every(function(mutation){
if (mutation.type != 'childList') return true;
for (var i = 0, node; i < mutation.addedNodes.length; ++i) {
node = mutation.addedNodes[i];
if (node.outerHTML && node.outerHTML.indexOf('data-uk-') !== -1) {
return (init = true) && false;
}
}
return true;
});
if (init) initFn();
})).observe(document.body, {childList: true, subtree: true});
}
2016-03-19 01:51:35 +00:00
};
if (document.readyState == 'complete' || document.readyState == 'interactive') {
setTimeout(domReady);
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
return domReady;
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
}());
2016-01-30 20:28:43 +00:00
// add touch identifier class
2017-11-12 00:33:10 +00:00
UI.$html.addClass(UI.support.touch ? 'uk-touch' : 'uk-notouch');
2016-01-30 20:28:43 +00:00
// add uk-hover class on tap to support overlays on touch devices
if (UI.support.touch) {
2016-03-19 01:51:35 +00:00
var hoverset = false,
exclude,
hovercls = 'uk-hover',
selector = '.uk-overlay, .uk-overlay-hover, .uk-overlay-toggle, .uk-animation-hover, .uk-has-hover';
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
UI.$html.on('mouseenter touchstart MSPointerDown pointerdown', selector, function() {
2016-01-30 20:28:43 +00:00
if (hoverset) $('.'+hovercls).removeClass(hovercls);
hoverset = $(this).addClass(hovercls);
2016-03-19 01:51:35 +00:00
}).on('mouseleave touchend MSPointerUp pointerup', function(e) {
2016-01-30 20:28:43 +00:00
exclude = $(e.target).parents(selector);
if (hoverset) {
hoverset.not(exclude).removeClass(hovercls);
}
});
}
return UI;
});
// Based on Zeptos touch.js
// https://raw.github.com/madrobby/zepto/master/src/touch.js
// Zepto.js may be freely distributed under the MIT license.
;(function($){
if ($.fn.swipeLeft) {
return;
}
var touch = {}, touchTimeout, tapTimeout, swipeTimeout, longTapTimeout, longTapDelay = 750, gesture;
2017-11-12 00:33:10 +00:00
var hasTouchEvents = 'ontouchstart' in window,
hasPointerEvents = window.PointerEvent,
hasTouch = hasTouchEvents
|| window.DocumentTouch && document instanceof DocumentTouch
|| navigator.msPointerEnabled && navigator.msMaxTouchPoints > 0 // IE 10
|| navigator.pointerEnabled && navigator.maxTouchPoints > 0; // IE >=11
2016-01-30 20:28:43 +00:00
function swipeDirection(x1, x2, y1, y2) {
return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down');
}
function longTap() {
longTapTimeout = null;
if (touch.last) {
2016-03-19 01:51:35 +00:00
if ( touch.el !== undefined ) touch.el.trigger('longTap');
2016-01-30 20:28:43 +00:00
touch = {};
}
}
function cancelLongTap() {
if (longTapTimeout) clearTimeout(longTapTimeout);
longTapTimeout = null;
}
function cancelAll() {
if (touchTimeout) clearTimeout(touchTimeout);
if (tapTimeout) clearTimeout(tapTimeout);
if (swipeTimeout) clearTimeout(swipeTimeout);
if (longTapTimeout) clearTimeout(longTapTimeout);
touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null;
touch = {};
}
function isPrimaryTouch(event){
return event.pointerType == event.MSPOINTER_TYPE_TOUCH && event.isPrimary;
}
$(function(){
var now, delta, deltaX = 0, deltaY = 0, firstTouch;
if ('MSGesture' in window) {
gesture = new MSGesture();
gesture.target = document.body;
}
$(document)
.on('MSGestureEnd gestureend', function(e){
var swipeDirectionFromVelocity = e.originalEvent.velocityX > 1 ? 'Right' : e.originalEvent.velocityX < -1 ? 'Left' : e.originalEvent.velocityY > 1 ? 'Down' : e.originalEvent.velocityY < -1 ? 'Up' : null;
2016-03-19 01:51:35 +00:00
if (swipeDirectionFromVelocity && touch.el !== undefined) {
2016-01-30 20:28:43 +00:00
touch.el.trigger('swipe');
touch.el.trigger('swipe'+ swipeDirectionFromVelocity);
}
})
// MSPointerDown: for IE10
// pointerdown: for IE11
.on('touchstart MSPointerDown pointerdown', function(e){
if(e.type == 'MSPointerDown' && !isPrimaryTouch(e.originalEvent)) return;
firstTouch = (e.type == 'MSPointerDown' || e.type == 'pointerdown') ? e : e.originalEvent.touches[0];
now = Date.now();
delta = now - (touch.last || now);
touch.el = $('tagName' in firstTouch.target ? firstTouch.target : firstTouch.target.parentNode);
if(touchTimeout) clearTimeout(touchTimeout);
touch.x1 = firstTouch.pageX;
touch.y1 = firstTouch.pageY;
if (delta > 0 && delta <= 250) touch.isDoubleTap = true;
touch.last = now;
longTapTimeout = setTimeout(longTap, longTapDelay);
// adds the current touch contact for IE gesture recognition
2017-11-12 00:33:10 +00:00
if (e.originalEvent && e.originalEvent.pointerId && gesture && ( e.type == 'MSPointerDown' || e.type == 'pointerdown' || e.type == 'touchstart' ) ) {
2016-01-30 20:28:43 +00:00
gesture.addPointer(e.originalEvent.pointerId);
}
})
// MSPointerMove: for IE10
// pointermove: for IE11
.on('touchmove MSPointerMove pointermove', function(e){
if (e.type == 'MSPointerMove' && !isPrimaryTouch(e.originalEvent)) return;
firstTouch = (e.type == 'MSPointerMove' || e.type == 'pointermove') ? e : e.originalEvent.touches[0];
cancelLongTap();
touch.x2 = firstTouch.pageX;
touch.y2 = firstTouch.pageY;
deltaX += Math.abs(touch.x1 - touch.x2);
deltaY += Math.abs(touch.y1 - touch.y2);
})
// MSPointerUp: for IE10
// pointerup: for IE11
.on('touchend MSPointerUp pointerup', function(e){
if (e.type == 'MSPointerUp' && !isPrimaryTouch(e.originalEvent)) return;
cancelLongTap();
// swipe
if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)){
swipeTimeout = setTimeout(function() {
2016-03-19 01:51:35 +00:00
if ( touch.el !== undefined ) {
touch.el.trigger('swipe');
touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)));
}
2016-01-30 20:28:43 +00:00
touch = {};
}, 0);
// normal tap
} else if ('last' in touch) {
// don't fire tap when delta position changed by more than 30 pixels,
// for instance when moving to a point and back to origin
if (isNaN(deltaX) || (deltaX < 30 && deltaY < 30)) {
// delay by one tick so we can cancel the 'tap' event if 'scroll' fires
// ('tap' fires before 'scroll')
tapTimeout = setTimeout(function() {
// trigger universal 'tap' with the option to cancelTouch()
// (cancelTouch cancels processing of single vs double taps for faster 'tap' response)
var event = $.Event('tap');
event.cancelTouch = cancelAll;
2016-03-19 01:51:35 +00:00
if ( touch.el !== undefined ) touch.el.trigger(event);
2016-01-30 20:28:43 +00:00
// trigger double tap immediately
if (touch.isDoubleTap) {
2016-03-19 01:51:35 +00:00
if ( touch.el !== undefined ) touch.el.trigger('doubleTap');
2016-01-30 20:28:43 +00:00
touch = {};
}
// trigger single tap after 250ms of inactivity
else {
touchTimeout = setTimeout(function(){
touchTimeout = null;
2016-03-19 01:51:35 +00:00
if ( touch.el !== undefined ) touch.el.trigger('singleTap');
2016-01-30 20:28:43 +00:00
touch = {};
}, 250);
}
}, 0);
} else {
touch = {};
}
deltaX = deltaY = 0;
}
})
// when the browser window loses focus,
// for example when a modal dialog is shown,
// cancel all ongoing events
2017-11-12 00:33:10 +00:00
.on('touchcancel MSPointerCancel pointercancel', function(e){
// Ignore pointercancel if the event supports touch events, to prevent pointercancel in swipe gesture
if ((e.type == 'touchcancel' && hasTouchEvents && hasTouch) || (!hasTouchEvents && e.type == 'pointercancel' && hasPointerEvents)) {
cancelAll();
}
});
2016-01-30 20:28:43 +00:00
// scrolling the window indicates intention of the user
// to scroll, not tap or swipe, so cancel all ongoing events
$(window).on('scroll', cancelAll);
});
['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){
$.fn[eventName] = function(callback){ return $(this).on(eventName, callback); };
});
})(jQuery);
(function(UI) {
"use strict";
var stacks = [];
UI.component('stackMargin', {
defaults: {
2016-03-19 01:51:35 +00:00
cls: 'uk-margin-small-top',
2017-11-12 00:33:10 +00:00
rowfirst: false,
observe: false
2016-01-30 20:28:43 +00:00
},
boot: function() {
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-margin]', context).each(function() {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var ele = UI.$(this);
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (!ele.data('stackMargin')) {
UI.stackMargin(ele, UI.Utils.options(ele.attr('data-uk-margin')));
2016-01-30 20:28:43 +00:00
}
});
});
},
init: function() {
var $this = this;
UI.$win.on('resize orientationchange', (function() {
var fn = function() {
$this.process();
};
UI.$(function() {
fn();
2017-11-12 00:33:10 +00:00
UI.$win.on('load', fn);
2016-01-30 20:28:43 +00:00
});
return UI.Utils.debounce(fn, 20);
})());
2017-11-12 00:33:10 +00:00
this.on('display.uk.check', function(e) {
if (this.element.is(':visible')) this.process();
2016-01-30 20:28:43 +00:00
}.bind(this));
2017-11-12 00:33:10 +00:00
if (this.options.observe) {
UI.domObserve(this.element, function(e) {
if ($this.element.is(':visible')) $this.process();
});
}
2016-01-30 20:28:43 +00:00
stacks.push(this);
},
process: function() {
2016-03-19 01:51:35 +00:00
var $this = this, columns = this.element.children();
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
UI.Utils.stackMargin(columns, this.options);
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (!this.options.rowfirst || !columns.length) {
2016-03-19 01:51:35 +00:00
return this;
}
// Mark first column elements
2017-11-12 00:33:10 +00:00
var group = {}, minleft = false;
2016-03-19 01:51:35 +00:00
2017-11-12 00:33:10 +00:00
columns.removeClass(this.options.rowfirst).each(function(offset, $ele){
$ele = UI.$(this);
if (this.style.display != 'none') {
offset = $ele.offset().left;
((group[offset] = group[offset] || []) && group[offset]).push(this);
minleft = minleft === false ? offset : Math.min(minleft, offset);
}
});
UI.$(group[minleft]).addClass(this.options.rowfirst);
2016-01-30 20:28:43 +00:00
return this;
}
2016-03-19 01:51:35 +00:00
2016-01-30 20:28:43 +00:00
});
// responsive element e.g. iframes
(function(){
var elements = [], check = function(ele) {
if (!ele.is(':visible')) return;
var width = ele.parent().width(),
iwidth = ele.data('width'),
ratio = (width / iwidth),
height = Math.floor(ratio * ele.data('height'));
2017-11-12 00:33:10 +00:00
ele.css({height: (width < iwidth) ? height : ele.data('height')});
2016-01-30 20:28:43 +00:00
};
UI.component('responsiveElement', {
defaults: {},
boot: function() {
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('iframe.uk-responsive-width, [data-uk-responsive]', context).each(function() {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this), obj;
2017-11-12 00:33:10 +00:00
if (!ele.data('responsiveElement')) {
2016-01-30 20:28:43 +00:00
obj = UI.responsiveElement(ele, {});
}
});
});
},
init: function() {
var ele = this.element;
if (ele.attr('width') && ele.attr('height')) {
ele.data({
2017-11-12 00:33:10 +00:00
width : ele.attr('width'),
height: ele.attr('height')
2016-01-30 20:28:43 +00:00
}).on('display.uk.check', function(){
check(ele);
});
check(ele);
elements.push(ele);
}
}
});
UI.$win.on('resize load', UI.Utils.debounce(function(){
elements.forEach(function(ele){
check(ele);
});
}, 15));
})();
// helper
UI.Utils.stackMargin = function(elements, options) {
options = UI.$.extend({
2017-11-12 00:33:10 +00:00
cls: 'uk-margin-small-top'
2016-01-30 20:28:43 +00:00
}, options);
elements = UI.$(elements).removeClass(options.cls);
2017-11-12 00:33:10 +00:00
var min = false;
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
elements.each(function(offset, height, pos, $ele){
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
$ele = UI.$(this);
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if ($ele.css('display') != 'none') {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
offset = $ele.offset();
height = $ele.outerHeight();
pos = offset.top + height;
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
$ele.data({
ukMarginPos: pos,
ukMarginTop: offset.top
});
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (min === false || (offset.top < min.top) ) {
min = {
top : offset.top,
left : offset.left,
pos : pos
};
2016-01-30 20:28:43 +00:00
}
}
2017-11-12 00:33:10 +00:00
}).each(function($ele) {
$ele = UI.$(this);
if ($ele.css('display') != 'none' && $ele.data('ukMarginTop') > min.top && $ele.data('ukMarginPos') > min.pos) {
$ele.addClass(options.cls);
}
2016-01-30 20:28:43 +00:00
});
};
UI.Utils.matchHeights = function(elements, options) {
elements = UI.$(elements).css('min-height', '');
options = UI.$.extend({ row : true }, options);
var matchHeights = function(group){
if (group.length < 2) return;
var max = 0;
group.each(function() {
max = Math.max(max, UI.$(this).outerHeight());
}).each(function() {
var element = UI.$(this),
height = max - (element.css('box-sizing') == 'border-box' ? 0 : (element.outerHeight() - element.height()));
element.css('min-height', height + 'px');
});
};
if (options.row) {
elements.first().width(); // force redraw
setTimeout(function(){
var lastoffset = false, group = [];
elements.each(function() {
var ele = UI.$(this), offset = ele.offset().top;
if (offset != lastoffset && group.length) {
matchHeights(UI.$(group));
group = [];
offset = ele.offset().top;
}
group.push(ele);
lastoffset = offset;
});
if (group.length) {
matchHeights(UI.$(group));
}
}, 0);
} else {
matchHeights(elements);
}
};
2016-03-19 01:51:35 +00:00
(function(cacheSvgs){
UI.Utils.inlineSvg = function(selector, root) {
var images = UI.$(selector || 'img[src$=".svg"]', root || document).each(function(){
var img = UI.$(this),
src = img.attr('src');
if (!cacheSvgs[src]) {
var d = UI.$.Deferred();
UI.$.get(src, {nc: Math.random()}, function(data){
d.resolve(UI.$(data).find('svg'));
});
cacheSvgs[src] = d.promise();
}
cacheSvgs[src].then(function(svg) {
var $svg = UI.$(svg).clone();
if (img.attr('id')) $svg.attr('id', img.attr('id'));
if (img.attr('class')) $svg.attr('class', img.attr('class'));
if (img.attr('style')) $svg.attr('style', img.attr('style'));
if (img.attr('width')) {
$svg.attr('width', img.attr('width'));
if (!img.attr('height')) $svg.removeAttr('height');
}
if (img.attr('height')){
$svg.attr('height', img.attr('height'));
if (!img.attr('width')) $svg.removeAttr('width');
}
img.replaceWith($svg);
});
});
};
// init code
UI.ready(function(context) {
UI.Utils.inlineSvg('[data-uk-svg]', context);
});
})({});
2017-11-12 00:33:10 +00:00
UI.Utils.getCssVar = function(name) {
/* usage in css: .var-name:before { content:"xyz" } */
var val, doc = document.documentElement, element = doc.appendChild(document.createElement('div'));
element.classList.add('var-'+name);
try {
val = JSON.parse(val = getComputedStyle(element, ':before').content.replace(/^["'](.*)["']$/, '$1'));
} catch (e) {
val = undefined;
}
doc.removeChild(element);
return val;
}
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
UI.component('smoothScroll', {
boot: function() {
// init code
2017-11-12 00:33:10 +00:00
UI.$html.on('click.smooth-scroll.uikit', '[data-uk-smooth-scroll]', function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('smoothScroll')) {
var obj = UI.smoothScroll(ele, UI.Utils.options(ele.attr('data-uk-smooth-scroll')));
ele.trigger('click');
2016-01-30 20:28:43 +00:00
}
return false;
});
},
init: function() {
var $this = this;
2017-11-12 00:33:10 +00:00
this.on('click', function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
2017-11-12 00:33:10 +00:00
scrollToElement(UI.$(this.hash).length ? UI.$(this.hash) : UI.$('body'), $this.options);
2016-01-30 20:28:43 +00:00
});
}
});
function scrollToElement(ele, options) {
options = UI.$.extend({
duration: 1000,
transition: 'easeOutExpo',
offset: 0,
complete: function(){}
}, options);
// get / set parameters
var target = ele.offset().top - options.offset,
docheight = UI.$doc.height(),
winheight = window.innerHeight;
if ((target + winheight) > docheight) {
target = docheight - winheight;
}
// animate to target, fire callback when done
2017-11-12 00:33:10 +00:00
UI.$('html,body').stop().animate({scrollTop: target}, options.duration, options.transition).promise().done(options.complete);
2016-01-30 20:28:43 +00:00
}
UI.Utils.scrollToElement = scrollToElement;
if (!UI.$.easing.easeOutExpo) {
UI.$.easing.easeOutExpo = function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; };
}
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
var $win = UI.$win,
$doc = UI.$doc,
scrollspies = [],
checkScrollSpy = function() {
for(var i=0; i < scrollspies.length; i++) {
window.requestAnimationFrame.apply(window, [scrollspies[i].check]);
}
};
UI.component('scrollspy', {
defaults: {
2017-11-12 00:33:10 +00:00
target : false,
cls : 'uk-scrollspy-inview',
initcls : 'uk-scrollspy-init-inview',
topoffset : 0,
leftoffset : 0,
repeat : false,
delay : 0
2016-01-30 20:28:43 +00:00
},
boot: function() {
// listen to scroll and resize
2017-11-12 00:33:10 +00:00
$doc.on('scrolling.uk.document', checkScrollSpy);
$win.on('load resize orientationchange', UI.Utils.debounce(checkScrollSpy, 50));
2016-01-30 20:28:43 +00:00
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-scrollspy]', context).each(function() {
2016-01-30 20:28:43 +00:00
var element = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!element.data('scrollspy')) {
var obj = UI.scrollspy(element, UI.Utils.options(element.attr('data-uk-scrollspy')));
2016-01-30 20:28:43 +00:00
}
});
});
},
init: function() {
var $this = this, inviewstate, initinview, togglecls = this.options.cls.split(/,/), fn = function(){
var elements = $this.options.target ? $this.element.find($this.options.target) : $this.element,
delayIdx = elements.length === 1 ? 1 : 0,
toggleclsIdx = 0;
elements.each(function(idx){
var element = UI.$(this),
inviewstate = element.data('inviewstate'),
inview = UI.Utils.isInView(element, $this.options),
2017-11-12 00:33:10 +00:00
toggle = element.attr('data-uk-scrollspy-cls') || togglecls[toggleclsIdx].trim();
2016-01-30 20:28:43 +00:00
if (inview && !inviewstate && !element.data('scrollspy-idle')) {
if (!initinview) {
element.addClass($this.options.initcls);
$this.offset = element.offset();
initinview = true;
2017-11-12 00:33:10 +00:00
element.trigger('init.uk.scrollspy');
2016-01-30 20:28:43 +00:00
}
element.data('scrollspy-idle', setTimeout(function(){
2017-11-12 00:33:10 +00:00
element.addClass('uk-scrollspy-inview').toggleClass(toggle).width();
element.trigger('inview.uk.scrollspy');
2016-01-30 20:28:43 +00:00
element.data('scrollspy-idle', false);
element.data('inviewstate', true);
}, $this.options.delay * delayIdx));
delayIdx++;
}
if (!inview && inviewstate && $this.options.repeat) {
if (element.data('scrollspy-idle')) {
clearTimeout(element.data('scrollspy-idle'));
2016-03-19 01:51:35 +00:00
element.data('scrollspy-idle', false);
2016-01-30 20:28:43 +00:00
}
2017-11-12 00:33:10 +00:00
element.removeClass('uk-scrollspy-inview').toggleClass(toggle);
2016-01-30 20:28:43 +00:00
element.data('inviewstate', false);
2017-11-12 00:33:10 +00:00
element.trigger('outview.uk.scrollspy');
2016-01-30 20:28:43 +00:00
}
toggleclsIdx = togglecls[toggleclsIdx + 1] ? (toggleclsIdx + 1) : 0;
});
};
fn();
this.check = fn;
scrollspies.push(this);
}
});
var scrollspynavs = [],
checkScrollSpyNavs = function() {
for(var i=0; i < scrollspynavs.length; i++) {
window.requestAnimationFrame.apply(window, [scrollspynavs[i].check]);
}
};
UI.component('scrollspynav', {
defaults: {
2017-11-12 00:33:10 +00:00
cls : 'uk-active',
closest : false,
topoffset : 0,
leftoffset : 0,
smoothscroll : false
2016-01-30 20:28:43 +00:00
},
boot: function() {
// listen to scroll and resize
2017-11-12 00:33:10 +00:00
$doc.on('scrolling.uk.document', checkScrollSpyNavs);
$win.on('resize orientationchange', UI.Utils.debounce(checkScrollSpyNavs, 50));
2016-01-30 20:28:43 +00:00
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-scrollspy-nav]', context).each(function() {
2016-01-30 20:28:43 +00:00
var element = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!element.data('scrollspynav')) {
var obj = UI.scrollspynav(element, UI.Utils.options(element.attr('data-uk-scrollspy-nav')));
2016-01-30 20:28:43 +00:00
}
});
});
},
init: function() {
var ids = [],
2017-11-12 00:33:10 +00:00
links = this.find("a[href^='#']").each(function(){ if(this.getAttribute('href').trim()!=='#') ids.push(this.getAttribute('href')); }),
2016-01-30 20:28:43 +00:00
targets = UI.$(ids.join(",")),
clsActive = this.options.cls,
clsClosest = this.options.closest || this.options.closest;
var $this = this, inviews, fn = function(){
inviews = [];
for (var i=0 ; i < targets.length ; i++) {
if (UI.Utils.isInView(targets.eq(i), $this.options)) {
inviews.push(targets.eq(i));
}
}
if (inviews.length) {
var navitems,
scrollTop = $win.scrollTop(),
target = (function(){
for(var i=0; i< inviews.length;i++){
2017-11-12 00:33:10 +00:00
if (inviews[i].offset().top - $this.options.topoffset >= scrollTop){
2016-01-30 20:28:43 +00:00
return inviews[i];
}
}
})();
if (!target) return;
if ($this.options.closest) {
2016-03-19 01:51:35 +00:00
links.blur().closest(clsClosest).removeClass(clsActive);
2017-11-12 00:33:10 +00:00
navitems = links.filter("a[href='#"+target.attr('id')+"']").closest(clsClosest).addClass(clsActive);
2016-01-30 20:28:43 +00:00
} else {
navitems = links.removeClass(clsActive).filter("a[href='#"+target.attr("id")+"']").addClass(clsActive);
}
2017-11-12 00:33:10 +00:00
$this.element.trigger('inview.uk.scrollspynav', [target, navitems]);
2016-01-30 20:28:43 +00:00
}
};
if (this.options.smoothscroll && UI.smoothScroll) {
links.each(function(){
UI.smoothScroll(this, $this.options.smoothscroll);
});
}
fn();
2017-11-12 00:33:10 +00:00
this.element.data('scrollspynav', this);
2016-01-30 20:28:43 +00:00
this.check = fn;
scrollspynavs.push(this);
}
});
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI){
"use strict";
var toggles = [];
UI.component('toggle', {
defaults: {
target : false,
cls : 'uk-hidden',
animation : false,
duration : 200
},
boot: function(){
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-toggle]', context).each(function() {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('toggle')) {
var obj = UI.toggle(ele, UI.Utils.options(ele.attr('data-uk-toggle')));
2016-01-30 20:28:43 +00:00
}
});
setTimeout(function(){
toggles.forEach(function(toggle){
toggle.getToggles();
});
}, 0);
});
},
init: function() {
var $this = this;
this.aria = (this.options.cls.indexOf('uk-hidden') !== -1);
2017-11-12 00:33:10 +00:00
this.on('click', function(e) {
if ($this.element.is('a[href="#"]')) {
e.preventDefault();
}
2016-01-30 20:28:43 +00:00
$this.toggle();
});
toggles.push(this);
},
toggle: function() {
2017-11-12 00:33:10 +00:00
this.getToggles();
2016-01-30 20:28:43 +00:00
if(!this.totoggle.length) return;
if (this.options.animation && UI.support.animation) {
var $this = this, animations = this.options.animation.split(',');
if (animations.length == 1) {
animations[1] = animations[0];
}
animations[0] = animations[0].trim();
animations[1] = animations[1].trim();
this.totoggle.css('animation-duration', this.options.duration+'ms');
2016-03-19 01:51:35 +00:00
this.totoggle.each(function(){
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var ele = UI.$(this);
if (ele.hasClass($this.options.cls)) {
ele.toggleClass($this.options.cls);
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
UI.Utils.animate(ele, animations[0]).then(function(){
ele.css('animation-duration', '');
UI.Utils.checkDisplay(ele);
2016-01-30 20:28:43 +00:00
});
2016-03-19 01:51:35 +00:00
} else {
2016-01-30 20:28:43 +00:00
UI.Utils.animate(this, animations[1]+' uk-animation-reverse').then(function(){
2016-03-19 01:51:35 +00:00
ele.toggleClass($this.options.cls).css('animation-duration', '');
UI.Utils.checkDisplay(ele);
});
}
});
2016-01-30 20:28:43 +00:00
} else {
this.totoggle.toggleClass(this.options.cls);
UI.Utils.checkDisplay(this.totoggle);
}
this.updateAria();
},
getToggles: function() {
this.totoggle = this.options.target ? UI.$(this.options.target):[];
this.updateAria();
},
updateAria: function() {
if (this.aria && this.totoggle.length) {
2017-11-12 00:33:10 +00:00
this.totoggle.not('[aria-hidden]').each(function(){
2016-01-30 20:28:43 +00:00
UI.$(this).attr('aria-hidden', UI.$(this).hasClass('uk-hidden'));
});
}
}
});
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
UI.component('alert', {
defaults: {
2017-11-12 00:33:10 +00:00
fade: true,
duration: 200,
trigger: '.uk-alert-close'
2016-01-30 20:28:43 +00:00
},
boot: function() {
// init code
2017-11-12 00:33:10 +00:00
UI.$html.on('click.alert.uikit', '[data-uk-alert]', function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('alert')) {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
var alert = UI.alert(ele, UI.Utils.options(ele.attr('data-uk-alert')));
2016-01-30 20:28:43 +00:00
if (UI.$(e.target).is(alert.options.trigger)) {
e.preventDefault();
alert.close();
}
}
});
},
init: function() {
var $this = this;
2017-11-12 00:33:10 +00:00
this.on('click', this.options.trigger, function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
$this.close();
});
},
close: function() {
2017-11-12 00:33:10 +00:00
var element = this.trigger('close.uk.alert'),
2016-01-30 20:28:43 +00:00
removeElement = function () {
2017-11-12 00:33:10 +00:00
this.trigger('closed.uk.alert').remove();
2016-01-30 20:28:43 +00:00
}.bind(this);
if (this.options.fade) {
2017-11-12 00:33:10 +00:00
element.css('overflow', 'hidden').css("max-height", element.height()).animate({
height : 0,
opacity : 0,
paddingTop : 0,
paddingBottom : 0,
marginTop : 0,
marginBottom : 0
2016-01-30 20:28:43 +00:00
}, this.options.duration, removeElement);
} else {
removeElement();
}
}
});
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
UI.component('buttonRadio', {
defaults: {
2017-11-12 00:33:10 +00:00
activeClass: 'uk-active',
target: '.uk-button'
2016-01-30 20:28:43 +00:00
},
boot: function() {
// init code
2017-11-12 00:33:10 +00:00
UI.$html.on('click.buttonradio.uikit', '[data-uk-button-radio]', function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('buttonRadio')) {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
var obj = UI.buttonRadio(ele, UI.Utils.options(ele.attr('data-uk-button-radio'))),
2016-01-30 20:28:43 +00:00
target = UI.$(e.target);
if (target.is(obj.options.target)) {
2017-11-12 00:33:10 +00:00
target.trigger('click');
2016-01-30 20:28:43 +00:00
}
}
});
},
init: function() {
var $this = this;
// Init ARIA
2016-03-19 01:51:35 +00:00
this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true');
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
this.on('click', this.options.target, function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
if (ele.is('a[href="#"]')) e.preventDefault();
2016-03-19 01:51:35 +00:00
$this.find($this.options.target).not(ele).removeClass($this.options.activeClass).blur();
ele.addClass($this.options.activeClass);
2016-01-30 20:28:43 +00:00
// Update ARIA
$this.find($this.options.target).not(ele).attr('aria-checked', 'false');
ele.attr('aria-checked', 'true');
2017-11-12 00:33:10 +00:00
$this.trigger('change.uk.button', [ele]);
2016-01-30 20:28:43 +00:00
});
},
getSelected: function() {
2016-03-19 01:51:35 +00:00
return this.find('.' + this.options.activeClass);
2016-01-30 20:28:43 +00:00
}
});
UI.component('buttonCheckbox', {
defaults: {
2017-11-12 00:33:10 +00:00
activeClass: 'uk-active',
target: '.uk-button'
2016-01-30 20:28:43 +00:00
},
boot: function() {
2017-11-12 00:33:10 +00:00
UI.$html.on('click.buttoncheckbox.uikit', '[data-uk-button-checkbox]', function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('buttonCheckbox')) {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
var obj = UI.buttonCheckbox(ele, UI.Utils.options(ele.attr('data-uk-button-checkbox'))),
2016-01-30 20:28:43 +00:00
target = UI.$(e.target);
if (target.is(obj.options.target)) {
2017-11-12 00:33:10 +00:00
target.trigger('click');
2016-01-30 20:28:43 +00:00
}
}
});
},
init: function() {
var $this = this;
// Init ARIA
2016-03-19 01:51:35 +00:00
this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true');
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
this.on('click', this.options.target, function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
if (ele.is('a[href="#"]')) e.preventDefault();
2016-03-19 01:51:35 +00:00
ele.toggleClass($this.options.activeClass).blur();
2016-01-30 20:28:43 +00:00
// Update ARIA
2016-03-19 01:51:35 +00:00
ele.attr('aria-checked', ele.hasClass($this.options.activeClass));
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
$this.trigger('change.uk.button', [ele]);
2016-01-30 20:28:43 +00:00
});
},
getSelected: function() {
2016-03-19 01:51:35 +00:00
return this.find('.' + this.options.activeClass);
2016-01-30 20:28:43 +00:00
}
});
UI.component('button', {
defaults: {},
boot: function() {
2017-11-12 00:33:10 +00:00
UI.$html.on('click.button.uikit', '[data-uk-button]', function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('button')) {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
var obj = UI.button(ele, UI.Utils.options(ele.attr('data-uk-button')));
ele.trigger('click');
2016-01-30 20:28:43 +00:00
}
});
},
init: function() {
var $this = this;
// Init ARIA
this.element.attr('aria-pressed', this.element.hasClass("uk-active"));
2017-11-12 00:33:10 +00:00
this.on('click', function(e) {
2016-01-30 20:28:43 +00:00
if ($this.element.is('a[href="#"]')) e.preventDefault();
$this.toggle();
2017-11-12 00:33:10 +00:00
$this.trigger('change.uk.button', [$this.element.blur().hasClass('uk-active')]);
2016-01-30 20:28:43 +00:00
});
},
toggle: function() {
2017-11-12 00:33:10 +00:00
this.element.toggleClass('uk-active');
2016-01-30 20:28:43 +00:00
// Update ARIA
2017-11-12 00:33:10 +00:00
this.element.attr('aria-pressed', this.element.hasClass('uk-active'));
2016-01-30 20:28:43 +00:00
}
});
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-03-19 01:51:35 +00:00
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
2016-03-19 01:51:35 +00:00
var active = false, hoverIdle, flips = {
2017-11-12 00:33:10 +00:00
x: {
'bottom-left' : 'bottom-right',
'bottom-right' : 'bottom-left',
'bottom-center' : 'bottom-center',
'top-left' : 'top-right',
'top-right' : 'top-left',
'top-center' : 'top-center',
'left-top' : 'right-top',
'left-bottom' : 'right-bottom',
'left-center' : 'right-center',
'right-top' : 'left-top',
'right-bottom' : 'left-bottom',
'right-center' : 'left-center'
},
y: {
'bottom-left' : 'top-left',
'bottom-right' : 'top-right',
'bottom-center' : 'top-center',
'top-left' : 'bottom-left',
'top-right' : 'bottom-right',
'top-center' : 'bottom-center',
'left-top' : 'left-bottom',
'left-bottom' : 'left-top',
'left-center' : 'left-center',
'right-top' : 'right-bottom',
'right-bottom' : 'right-top',
'right-center' : 'right-center'
},
xy: {
'bottom-left' : 'top-right',
'bottom-right' : 'top-left',
'bottom-center' : 'top-center',
'top-left' : 'bottom-right',
'top-right' : 'bottom-left',
'top-center' : 'bottom-center',
'left-top' : 'right-bottom',
'left-bottom' : 'right-top',
'left-center' : 'right-center',
'right-top' : 'left-bottom',
'right-bottom' : 'left-top',
'right-center' : 'left-center'
2016-03-19 01:51:35 +00:00
}
};
2016-01-30 20:28:43 +00:00
UI.component('dropdown', {
defaults: {
2017-11-12 00:33:10 +00:00
mode : 'hover',
pos : 'bottom-left',
offset : 0,
remaintime : 800,
justify : false,
boundary : UI.$win,
delay : 0,
dropdownSelector: '.uk-dropdown,.uk-dropdown-blank',
hoverDelayIdle : 250,
preventflip : false
2016-01-30 20:28:43 +00:00
},
remainIdle: false,
boot: function() {
2017-11-12 00:33:10 +00:00
var triggerevent = UI.support.touch ? 'click' : 'mouseenter';
2016-01-30 20:28:43 +00:00
// init code
2017-11-12 00:33:10 +00:00
UI.$html.on(triggerevent+'.dropdown.uikit focus pointerdown', '[data-uk-dropdown]', function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('dropdown')) {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
var dropdown = UI.dropdown(ele, UI.Utils.options(ele.attr('data-uk-dropdown')));
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (e.type=='click' || (e.type=='mouseenter' && dropdown.options.mode=='hover')) {
2016-01-30 20:28:43 +00:00
dropdown.element.trigger(triggerevent);
}
2017-11-12 00:33:10 +00:00
if (dropdown.dropdown.length) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
}
}
});
},
init: function() {
var $this = this;
2016-03-19 01:51:35 +00:00
this.dropdown = this.find(this.options.dropdownSelector);
this.offsetParent = this.dropdown.parents().filter(function() {
return UI.$.inArray(UI.$(this).css('position'), ['relative', 'fixed', 'absolute']) !== -1;
}).slice(0,1);
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (!this.offsetParent.length) {
this.offsetParent = this.element;
}
2016-01-30 20:28:43 +00:00
this.centered = this.dropdown.hasClass('uk-dropdown-center');
this.justified = this.options.justify ? UI.$(this.options.justify) : false;
this.boundary = UI.$(this.options.boundary);
if (!this.boundary.length) {
this.boundary = UI.$win;
}
2016-03-19 01:51:35 +00:00
// legacy DEPRECATED!
if (this.dropdown.hasClass('uk-dropdown-up')) {
this.options.pos = 'top-left';
}
if (this.dropdown.hasClass('uk-dropdown-flip')) {
this.options.pos = this.options.pos.replace('left','right');
}
if (this.dropdown.hasClass('uk-dropdown-center')) {
this.options.pos = this.options.pos.replace(/(left|right)/,'center');
}
//-- end legacy
2016-01-30 20:28:43 +00:00
// Init ARIA
this.element.attr('aria-haspopup', 'true');
2017-11-12 00:33:10 +00:00
this.element.attr('aria-expanded', this.element.hasClass('uk-open'));
this.dropdown.attr('aria-hidden', 'true');
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (this.options.mode == 'click' || UI.support.touch) {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
this.on('click.uk.dropdown', function(e) {
2016-01-30 20:28:43 +00:00
var $target = UI.$(e.target);
2016-03-19 01:51:35 +00:00
if (!$target.parents($this.options.dropdownSelector).length) {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if ($target.is("a[href='#']") || $target.parent().is("a[href='#']") || ($this.dropdown.length && !$this.dropdown.is(':visible')) ){
2016-01-30 20:28:43 +00:00
e.preventDefault();
}
$target.blur();
}
if (!$this.element.hasClass('uk-open')) {
$this.show();
} else {
2017-11-12 00:33:10 +00:00
if (!$this.dropdown.find(e.target).length || $target.is('.uk-dropdown-close') || $target.parents('.uk-dropdown-close').length) {
2016-01-30 20:28:43 +00:00
$this.hide();
}
}
});
} else {
2017-11-12 00:33:10 +00:00
this.on('mouseenter', function(e) {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
$this.trigger('pointerenter.uk.dropdown', [$this]);
2016-01-30 20:28:43 +00:00
if ($this.remainIdle) {
clearTimeout($this.remainIdle);
}
if (hoverIdle) {
clearTimeout(hoverIdle);
}
if (active && active == $this) {
return;
}
// pseudo manuAim
if (active && active != $this) {
hoverIdle = setTimeout(function() {
hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
}, $this.options.hoverDelayIdle);
} else {
hoverIdle = setTimeout($this.show.bind($this), $this.options.delay);
}
2017-11-12 00:33:10 +00:00
}).on('mouseleave', function() {
2016-01-30 20:28:43 +00:00
if (hoverIdle) {
clearTimeout(hoverIdle);
}
$this.remainIdle = setTimeout(function() {
if (active && active == $this) $this.hide();
}, $this.options.remaintime);
2016-03-19 01:51:35 +00:00
$this.trigger('pointerleave.uk.dropdown', [$this]);
2017-11-12 00:33:10 +00:00
}).on('click', function(e){
2016-01-30 20:28:43 +00:00
var $target = UI.$(e.target);
if ($this.remainIdle) {
clearTimeout($this.remainIdle);
}
2016-03-19 01:51:35 +00:00
if (active && active == $this) {
2017-11-12 00:33:10 +00:00
if (!$this.dropdown.find(e.target).length || $target.is('.uk-dropdown-close') || $target.parents('.uk-dropdown-close').length) {
2016-03-19 01:51:35 +00:00
$this.hide();
}
return;
}
2016-01-30 20:28:43 +00:00
if ($target.is("a[href='#']") || $target.parent().is("a[href='#']")){
e.preventDefault();
}
$this.show();
});
}
},
show: function(){
2017-11-12 00:33:10 +00:00
UI.$html.off('click.outer.dropdown');
2016-01-30 20:28:43 +00:00
if (active && active != this) {
2016-03-19 01:51:35 +00:00
active.hide(true);
2016-01-30 20:28:43 +00:00
}
if (hoverIdle) {
clearTimeout(hoverIdle);
}
2016-03-19 01:51:35 +00:00
this.trigger('beforeshow.uk.dropdown', [this]);
2016-01-30 20:28:43 +00:00
this.checkDimensions();
this.element.addClass('uk-open');
// Update ARIA
this.element.attr('aria-expanded', 'true');
2017-11-12 00:33:10 +00:00
this.dropdown.attr('aria-hidden', 'false');
2016-01-30 20:28:43 +00:00
this.trigger('show.uk.dropdown', [this]);
UI.Utils.checkDisplay(this.dropdown, true);
2017-11-12 00:33:10 +00:00
UI.Utils.focus(this.dropdown);
2016-01-30 20:28:43 +00:00
active = this;
this.registerOuterClick();
},
2016-03-19 01:51:35 +00:00
hide: function(force) {
this.trigger('beforehide.uk.dropdown', [this, force]);
2016-01-30 20:28:43 +00:00
this.element.removeClass('uk-open');
if (this.remainIdle) {
clearTimeout(this.remainIdle);
}
this.remainIdle = false;
// Update ARIA
this.element.attr('aria-expanded', 'false');
2017-11-12 00:33:10 +00:00
this.dropdown.attr('aria-hidden', 'true');
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
this.trigger('hide.uk.dropdown', [this, force]);
2016-01-30 20:28:43 +00:00
if (active == this) active = false;
},
registerOuterClick: function(){
var $this = this;
2017-11-12 00:33:10 +00:00
UI.$html.off('click.outer.dropdown');
2016-01-30 20:28:43 +00:00
setTimeout(function() {
2017-11-12 00:33:10 +00:00
UI.$html.on('click.outer.dropdown', function(e) {
2016-01-30 20:28:43 +00:00
if (hoverIdle) {
clearTimeout(hoverIdle);
}
var $target = UI.$(e.target);
2016-03-19 01:51:35 +00:00
if (active == $this && !$this.element.find(e.target).length) {
$this.hide(true);
2017-11-12 00:33:10 +00:00
UI.$html.off('click.outer.dropdown');
2016-01-30 20:28:43 +00:00
}
});
}, 10);
},
checkDimensions: function() {
if (!this.dropdown.length) return;
2016-03-19 01:51:35 +00:00
// reset
2017-11-12 00:33:10 +00:00
this.dropdown.removeClass('uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack uk-dropdown-autoflip').css({
topLeft :'',
left :'',
marginLeft :'',
marginRight :''
2016-03-19 01:51:35 +00:00
});
2016-01-30 20:28:43 +00:00
if (this.justified && this.justified.length) {
2017-11-12 00:33:10 +00:00
this.dropdown.css('min-width', '');
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
var $this = this,
pos = UI.$.extend({}, this.offsetParent.offset(), {width: this.offsetParent[0].offsetWidth, height: this.offsetParent[0].offsetHeight}),
posoffset = this.options.offset,
dropdown = this.dropdown,
offset = dropdown.show().offset() || {left: 0, top: 0},
width = dropdown.outerWidth(),
height = dropdown.outerHeight(),
2016-01-30 20:28:43 +00:00
boundarywidth = this.boundary.width(),
2016-03-19 01:51:35 +00:00
boundaryoffset = this.boundary[0] !== window && this.boundary.offset() ? this.boundary.offset(): {top:0, left:0},
dpos = this.options.pos;
var variants = {
2017-11-12 00:33:10 +00:00
'bottom-left' : {top: 0 + pos.height + posoffset, left: 0},
'bottom-right' : {top: 0 + pos.height + posoffset, left: 0 + pos.width - width},
'bottom-center' : {top: 0 + pos.height + posoffset, left: 0 + pos.width / 2 - width / 2},
'top-left' : {top: 0 - height - posoffset, left: 0},
'top-right' : {top: 0 - height - posoffset, left: 0 + pos.width - width},
'top-center' : {top: 0 - height - posoffset, left: 0 + pos.width / 2 - width / 2},
'left-top' : {top: 0, left: 0 - width - posoffset},
'left-bottom' : {top: 0 + pos.height - height, left: 0 - width - posoffset},
'left-center' : {top: 0 + pos.height / 2 - height / 2, left: 0 - width - posoffset},
'right-top' : {top: 0, left: 0 + pos.width + posoffset},
'right-bottom' : {top: 0 + pos.height - height, left: 0 + pos.width + posoffset},
'right-center' : {top: 0 + pos.height / 2 - height / 2, left: 0 + pos.width + posoffset}
2016-03-19 01:51:35 +00:00
},
css = {},
pp;
pp = dpos.split('-');
css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
2016-01-30 20:28:43 +00:00
// justify dropdown
if (this.justified && this.justified.length) {
2016-03-19 01:51:35 +00:00
justify(dropdown.css({left:0}), this.justified, boundarywidth);
} else {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
if (this.options.preventflip !== true) {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var fdpos;
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
switch(this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
case "x":
if(this.options.preventflip !=='x') fdpos = flips['x'][dpos] || 'right-top';
break;
case "y":
if(this.options.preventflip !=='y') fdpos = flips['y'][dpos] || 'top-left';
break;
case "xy":
if(!this.options.preventflip) fdpos = flips['xy'][dpos] || 'right-bottom';
break;
}
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
if (fdpos) {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
pp = fdpos.split('-');
css = variants[fdpos] ? variants[fdpos] : variants['bottom-left'];
2017-11-12 00:33:10 +00:00
dropdown.addClass('uk-dropdown-autoflip');
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
// check flipped
if (this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
pp = dpos.split('-');
css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
}
}
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
}
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
if (width > boundarywidth) {
2017-11-12 00:33:10 +00:00
dropdown.addClass('uk-dropdown-stack');
2016-03-19 01:51:35 +00:00
this.trigger('stack.uk.dropdown', [this]);
}
2017-11-12 00:33:10 +00:00
dropdown.css(css).css('display', '').addClass('uk-dropdown-'+pp[0]);
2016-03-19 01:51:35 +00:00
},
checkBoundary: function(left, top, width, height, boundarywidth) {
var axis = "";
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
if (left < 0 || ((left - UI.$win.scrollLeft())+width) > boundarywidth) {
axis += "x";
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
if ((top - UI.$win.scrollTop()) < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) {
axis += "y";
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
return axis;
}
});
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
UI.component('dropdownOverlay', {
defaults: {
2017-11-12 00:33:10 +00:00
justify : false,
cls : '',
duration: 200
2016-03-19 01:51:35 +00:00
},
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
boot: function() {
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-dropdown-overlay]', context).each(function() {
2016-03-19 01:51:35 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('dropdownOverlay')) {
UI.dropdownOverlay(ele, UI.Utils.options(ele.attr('data-uk-dropdown-overlay')));
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
});
});
},
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
init: function() {
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var $this = this;
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
this.justified = this.options.justify ? UI.$(this.options.justify) : false;
this.overlay = this.element.find('uk-dropdown-overlay');
if (!this.overlay.length) {
this.overlay = UI.$('<div class="uk-dropdown-overlay"></div>').appendTo(this.element);
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
this.overlay.addClass(this.options.cls);
this.on({
'beforeshow.uk.dropdown': function(e, dropdown) {
$this.dropdown = dropdown;
if ($this.justified && $this.justified.length) {
2017-11-12 00:33:10 +00:00
justify($this.overlay.css({display:'block', marginLeft:'', marginRight:''}), $this.justified, $this.justified.outerWidth());
2016-03-19 01:51:35 +00:00
}
},
'show.uk.dropdown': function(e, dropdown) {
var h = $this.dropdown.dropdown.outerHeight(true);
$this.dropdown.element.removeClass('uk-open');
$this.overlay.stop().css('display', 'block').animate({height: h}, $this.options.duration, function() {
$this.dropdown.dropdown.css('visibility', '');
$this.dropdown.element.addClass('uk-open');
UI.Utils.checkDisplay($this.dropdown.dropdown, true);
});
$this.pointerleave = false;
},
'hide.uk.dropdown': function() {
$this.overlay.stop().animate({height: 0}, $this.options.duration);
},
'pointerenter.uk.dropdown': function(e, dropdown) {
clearTimeout($this.remainIdle);
},
'pointerleave.uk.dropdown': function(e, dropdown) {
$this.pointerleave = true;
}
});
this.overlay.on({
'mouseenter': function() {
if ($this.remainIdle) {
clearTimeout($this.dropdown.remainIdle);
clearTimeout($this.remainIdle);
}
},
'mouseleave': function(){
if ($this.pointerleave && active) {
$this.remainIdle = setTimeout(function() {
if(active) active.hide();
}, active.options.remaintime);
}
}
})
2016-01-30 20:28:43 +00:00
}
});
2016-03-19 01:51:35 +00:00
function justify(ele, justifyTo, boundarywidth, offset) {
ele = UI.$(ele);
justifyTo = UI.$(justifyTo);
boundarywidth = boundarywidth || window.innerWidth;
offset = offset || ele.offset();
if (justifyTo.length) {
var jwidth = justifyTo.outerWidth();
2017-11-12 00:33:10 +00:00
ele.css('min-width', jwidth);
2016-03-19 01:51:35 +00:00
if (UI.langdirection == 'right') {
var right1 = boundarywidth - (justifyTo.offset().left + jwidth),
right2 = boundarywidth - (ele.offset().left + ele.outerWidth());
2017-11-12 00:33:10 +00:00
ele.css('margin-right', right1 - right2);
2016-03-19 01:51:35 +00:00
} else {
2017-11-12 00:33:10 +00:00
ele.css('margin-left', justifyTo.offset().left - offset.left);
2016-03-19 01:51:35 +00:00
}
}
}
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
var grids = [];
UI.component('gridMatchHeight', {
defaults: {
2017-11-12 00:33:10 +00:00
target : false,
row : true,
ignorestacked : false,
observe : false
2016-01-30 20:28:43 +00:00
},
boot: function() {
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-grid-match]', context).each(function() {
2016-01-30 20:28:43 +00:00
var grid = UI.$(this), obj;
2017-11-12 00:33:10 +00:00
if (!grid.data('gridMatchHeight')) {
obj = UI.gridMatchHeight(grid, UI.Utils.options(grid.attr('data-uk-grid-match')));
2016-01-30 20:28:43 +00:00
}
});
});
},
init: function() {
var $this = this;
this.columns = this.element.children();
this.elements = this.options.target ? this.find(this.options.target) : this.columns;
if (!this.columns.length) return;
UI.$win.on('load resize orientationchange', (function() {
var fn = function() {
2017-11-12 00:33:10 +00:00
if ($this.element.is(':visible')) $this.match();
2016-01-30 20:28:43 +00:00
};
UI.$(function() { fn(); });
return UI.Utils.debounce(fn, 50);
})());
2017-11-12 00:33:10 +00:00
if (this.options.observe) {
UI.domObserve(this.element, function(e) {
if ($this.element.is(':visible')) $this.match();
});
}
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
this.on('display.uk.check', function(e) {
if(this.element.is(':visible')) this.match();
2016-01-30 20:28:43 +00:00
}.bind(this));
grids.push(this);
},
match: function() {
2017-11-12 00:33:10 +00:00
var firstvisible = this.columns.filter(':visible:first');
2016-01-30 20:28:43 +00:00
if (!firstvisible.length) return;
var stacked = Math.ceil(100 * parseFloat(firstvisible.css('width')) / parseFloat(firstvisible.parent().css('width'))) >= 100;
if (stacked && !this.options.ignorestacked) {
this.revert();
} else {
UI.Utils.matchHeights(this.elements, this.options);
}
return this;
},
revert: function() {
this.elements.css('min-height', '');
return this;
}
});
UI.component('gridMargin', {
defaults: {
2016-03-19 01:51:35 +00:00
cls : 'uk-grid-margin',
rowfirst : 'uk-row-first'
2016-01-30 20:28:43 +00:00
},
boot: function() {
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-grid-margin]', context).each(function() {
2016-01-30 20:28:43 +00:00
var grid = UI.$(this), obj;
2017-11-12 00:33:10 +00:00
if (!grid.data('gridMargin')) {
obj = UI.gridMargin(grid, UI.Utils.options(grid.attr('data-uk-grid-margin')));
2016-01-30 20:28:43 +00:00
}
});
});
},
init: function() {
var stackMargin = UI.stackMargin(this.element, this.options);
}
});
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
var active = false, activeCount = 0, $html = UI.$html, body;
2017-11-12 00:33:10 +00:00
UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){
UI.$('.uk-modal.uk-open').each(function(){
return UI.$(this).data('modal') && UI.$(this).data('modal').resize();
});
}, 150));
2016-01-30 20:28:43 +00:00
UI.component('modal', {
defaults: {
keyboard: true,
bgclose: true,
minScrollHeight: 150,
center: false,
modal: true
},
scrollable: false,
transition: false,
2016-03-19 01:51:35 +00:00
hasTransitioned: true,
2016-01-30 20:28:43 +00:00
init: function() {
if (!body) body = UI.$('body');
if (!this.element.length) return;
var $this = this;
2017-11-12 00:33:10 +00:00
this.paddingdir = 'padding-' + (UI.langdirection == 'left' ? 'right':'left');
this.dialog = this.find('.uk-modal-dialog');
2016-01-30 20:28:43 +00:00
this.active = false;
// Update ARIA
2017-11-12 00:33:10 +00:00
this.element.attr('aria-hidden', this.element.hasClass('uk-open'));
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
this.on('click', '.uk-modal-close', function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
$this.hide();
2017-11-12 00:33:10 +00:00
}).on('click', function(e) {
2016-01-30 20:28:43 +00:00
var target = UI.$(e.target);
if (target[0] == $this.element[0] && $this.options.bgclose) {
$this.hide();
}
});
2017-11-12 00:33:10 +00:00
UI.domObserve(this.element, function(e) { $this.resize(); });
2016-01-30 20:28:43 +00:00
},
toggle: function() {
2017-11-12 00:33:10 +00:00
return this[this.isActive() ? 'hide' : 'show']();
2016-01-30 20:28:43 +00:00
},
show: function() {
if (!this.element.length) return;
var $this = this;
if (this.isActive()) return;
if (this.options.modal && active) {
active.hide(true);
}
2017-11-12 00:33:10 +00:00
this.element.removeClass('uk-open').show();
this.resize(true);
2016-01-30 20:28:43 +00:00
if (this.options.modal) {
active = this;
}
this.active = true;
activeCount++;
2016-03-19 01:51:35 +00:00
if (UI.support.transition) {
this.hasTransitioned = false;
this.element.one(UI.support.transition.end, function(){
$this.hasTransitioned = true;
2017-11-12 00:33:10 +00:00
UI.Utils.focus($this.dialog, 'a[href]');
}).addClass('uk-open');
2016-03-19 01:51:35 +00:00
} else {
2017-11-12 00:33:10 +00:00
this.element.addClass('uk-open');
UI.Utils.focus(this.dialog, 'a[href]');
2016-03-19 01:51:35 +00:00
}
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
$html.addClass('uk-modal-page').height(); // force browser engine redraw
2016-01-30 20:28:43 +00:00
// Update ARIA
this.element.attr('aria-hidden', 'false');
2017-11-12 00:33:10 +00:00
this.element.trigger('show.uk.modal');
2016-01-30 20:28:43 +00:00
UI.Utils.checkDisplay(this.dialog, true);
return this;
},
hide: function(force) {
2016-03-19 01:51:35 +00:00
if (!force && UI.support.transition && this.hasTransitioned) {
2016-01-30 20:28:43 +00:00
var $this = this;
this.one(UI.support.transition.end, function() {
$this._hide();
2017-11-12 00:33:10 +00:00
}).removeClass('uk-open');
2016-01-30 20:28:43 +00:00
} else {
this._hide();
}
return this;
},
2017-11-12 00:33:10 +00:00
resize: function(force) {
if (!this.isActive() && !force) return;
2016-01-30 20:28:43 +00:00
var bodywidth = body.width();
this.scrollbarwidth = window.innerWidth - bodywidth;
body.css(this.paddingdir, this.scrollbarwidth);
this.element.css('overflow-y', this.scrollbarwidth ? 'scroll' : 'auto');
if (!this.updateScrollable() && this.options.center) {
var dh = this.dialog.outerHeight(),
pad = parseInt(this.dialog.css('margin-top'), 10) + parseInt(this.dialog.css('margin-bottom'), 10);
if ((dh + pad) < window.innerHeight) {
2017-11-12 00:33:10 +00:00
this.dialog.css({top: (window.innerHeight/2 - dh/2) - pad });
2016-01-30 20:28:43 +00:00
} else {
2017-11-12 00:33:10 +00:00
this.dialog.css({top: ''});
2016-01-30 20:28:43 +00:00
}
}
},
updateScrollable: function() {
// has scrollable?
var scrollable = this.dialog.find('.uk-overflow-container:visible:first');
if (scrollable.length) {
2016-03-19 01:51:35 +00:00
scrollable.css('height', 0);
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
var offset = Math.abs(parseInt(this.dialog.css('margin-top'), 10)),
2016-01-30 20:28:43 +00:00
dh = this.dialog.outerHeight(),
wh = window.innerHeight,
h = wh - 2*(offset < 20 ? 20:offset) - dh;
2016-03-19 01:51:35 +00:00
scrollable.css({
2017-11-12 00:33:10 +00:00
maxHeight: (h < this.options.minScrollHeight ? '':h),
height:''
2016-03-19 01:51:35 +00:00
});
2016-01-30 20:28:43 +00:00
return true;
}
return false;
},
_hide: function() {
this.active = false;
2016-03-19 01:51:35 +00:00
if (activeCount > 0) activeCount--;
else activeCount = 0;
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
this.element.hide().removeClass('uk-open');
2016-01-30 20:28:43 +00:00
// Update ARIA
this.element.attr('aria-hidden', 'true');
if (!activeCount) {
2016-03-19 01:51:35 +00:00
$html.removeClass('uk-modal-page');
2016-01-30 20:28:43 +00:00
body.css(this.paddingdir, "");
}
2017-11-12 00:33:10 +00:00
if (active===this) active = false;
2016-01-30 20:28:43 +00:00
2016-03-19 01:51:35 +00:00
this.trigger('hide.uk.modal');
2016-01-30 20:28:43 +00:00
},
isActive: function() {
2017-11-12 00:33:10 +00:00
return this.element.hasClass('uk-open');
2016-01-30 20:28:43 +00:00
}
});
UI.component('modalTrigger', {
boot: function() {
// init code
2017-11-12 00:33:10 +00:00
UI.$html.on('click.modal.uikit', '[data-uk-modal]', function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (ele.is('a')) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
}
2017-11-12 00:33:10 +00:00
if (!ele.data('modalTrigger')) {
var modal = UI.modalTrigger(ele, UI.Utils.options(ele.attr('data-uk-modal')));
2016-01-30 20:28:43 +00:00
modal.show();
}
});
// close modal on esc button
UI.$html.on('keydown.modal.uikit', function (e) {
if (active && e.keyCode === 27 && active.options.keyboard) { // ESC
e.preventDefault();
active.hide();
}
});
},
init: function() {
var $this = this;
this.options = UI.$.extend({
2017-11-12 00:33:10 +00:00
target: $this.element.is('a') ? $this.element.attr('href') : false
2016-01-30 20:28:43 +00:00
}, this.options);
this.modal = UI.modal(this.options.target, this.options);
this.on("click", function(e) {
e.preventDefault();
$this.show();
});
//methods
2017-11-12 00:33:10 +00:00
this.proxy(this.modal, 'show hide isActive');
2016-01-30 20:28:43 +00:00
}
});
UI.modal.dialog = function(content, options) {
2017-11-12 00:33:10 +00:00
var modal = UI.modal(UI.$(UI.modal.dialog.template).appendTo('body'), options);
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
modal.on('hide.uk.modal', function(){
2016-01-30 20:28:43 +00:00
if (modal.persist) {
2017-11-12 00:33:10 +00:00
modal.persist.appendTo(modal.persist.data('modalPersistParent'));
2016-01-30 20:28:43 +00:00
modal.persist = false;
}
modal.element.remove();
});
setContent(content, modal);
return modal;
};
UI.modal.dialog.template = '<div class="uk-modal"><div class="uk-modal-dialog" style="min-height:0;"></div></div>';
UI.modal.alert = function(content, options) {
options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options);
var modal = UI.modal.dialog(([
'<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
'<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-button-primary uk-modal-close">'+options.labels.Ok+'</button></div>'
]).join(""), options);
modal.on('show.uk.modal', function(){
setTimeout(function(){
modal.element.find('button:first').focus();
}, 50);
});
2016-03-19 01:51:35 +00:00
return modal.show();
2016-01-30 20:28:43 +00:00
};
2016-03-19 01:51:35 +00:00
UI.modal.confirm = function(content, onconfirm, oncancel) {
var options = arguments.length > 1 && arguments[arguments.length-1] ? arguments[arguments.length-1] : {};
2016-01-30 20:28:43 +00:00
onconfirm = UI.$.isFunction(onconfirm) ? onconfirm : function(){};
2016-03-19 01:51:35 +00:00
oncancel = UI.$.isFunction(oncancel) ? oncancel : function(){};
options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, UI.$.isFunction(options) ? {}:options);
2016-01-30 20:28:43 +00:00
var modal = UI.modal.dialog(([
'<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
2016-03-19 01:51:35 +00:00
'<div class="uk-modal-footer uk-text-right"><button class="uk-button js-modal-confirm-cancel">'+options.labels.Cancel+'</button> <button class="uk-button uk-button-primary js-modal-confirm">'+options.labels.Ok+'</button></div>'
2016-01-30 20:28:43 +00:00
]).join(""), options);
2016-03-19 01:51:35 +00:00
modal.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click", function(){
UI.$(this).is('.js-modal-confirm') ? onconfirm() : oncancel();
2016-01-30 20:28:43 +00:00
modal.hide();
});
modal.on('show.uk.modal', function(){
setTimeout(function(){
2016-03-19 01:51:35 +00:00
modal.element.find('.js-modal-confirm').focus();
2016-01-30 20:28:43 +00:00
}, 50);
});
2016-03-19 01:51:35 +00:00
return modal.show();
2016-01-30 20:28:43 +00:00
};
UI.modal.prompt = function(text, value, onsubmit, options) {
onsubmit = UI.$.isFunction(onsubmit) ? onsubmit : function(value){};
options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options);
var modal = UI.modal.dialog(([
text ? '<div class="uk-modal-content uk-form">'+String(text)+'</div>':'',
'<div class="uk-margin-small-top uk-modal-content uk-form"><p><input type="text" class="uk-width-1-1"></p></div>',
2016-03-19 01:51:35 +00:00
'<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-modal-close">'+options.labels.Cancel+'</button> <button class="uk-button uk-button-primary js-modal-ok">'+options.labels.Ok+'</button></div>'
2016-01-30 20:28:43 +00:00
]).join(""), options),
input = modal.element.find("input[type='text']").val(value || '').on('keyup', function(e){
if (e.keyCode == 13) {
2017-11-12 00:33:10 +00:00
modal.element.find('.js-modal-ok').trigger('click');
2016-01-30 20:28:43 +00:00
}
});
2017-11-12 00:33:10 +00:00
modal.element.find('.js-modal-ok').on('click', function(){
2016-01-30 20:28:43 +00:00
if (onsubmit(input.val())!==false){
modal.hide();
}
});
2016-03-19 01:51:35 +00:00
return modal.show();
2016-01-30 20:28:43 +00:00
};
UI.modal.blockUI = function(content, options) {
var modal = UI.modal.dialog(([
'<div class="uk-margin uk-modal-content">'+String(content || '<div class="uk-text-center">...</div>')+'</div>'
]).join(""), UI.$.extend({bgclose:false, keyboard:false, modal:false}, options));
modal.content = modal.element.find('.uk-modal-content:first');
2016-03-19 01:51:35 +00:00
return modal.show();
2016-01-30 20:28:43 +00:00
};
UI.modal.labels = {
2017-11-12 00:33:10 +00:00
Ok: 'Ok',
Cancel: 'Cancel'
2016-01-30 20:28:43 +00:00
};
// helper functions
function setContent(content, modal){
if(!modal) return;
if (typeof content === 'object') {
// convert DOM object to a jQuery object
content = content instanceof jQuery ? content : UI.$(content);
if(content.parent().length) {
modal.persist = content;
2017-11-12 00:33:10 +00:00
modal.persist.data('modalPersistParent', content.parent());
2016-01-30 20:28:43 +00:00
}
}else if (typeof content === 'string' || typeof content === 'number') {
// just insert the data as innerHTML
content = UI.$('<div></div>').html(content);
}else {
// unsupported data type!
2017-11-12 00:33:10 +00:00
content = UI.$('<div></div>').html('UIkit2.modal Error: Unsupported data type: ' + typeof content);
2016-01-30 20:28:43 +00:00
}
content.appendTo(modal.element.find('.uk-modal-dialog'));
return modal;
}
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
UI.component('nav', {
defaults: {
2017-11-12 00:33:10 +00:00
toggle: '>li.uk-parent > a[href="#"]',
lists: '>li.uk-parent > ul',
multiple: false
2016-01-30 20:28:43 +00:00
},
boot: function() {
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-nav]', context).each(function() {
2016-01-30 20:28:43 +00:00
var nav = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!nav.data('nav')) {
var obj = UI.nav(nav, UI.Utils.options(nav.attr('data-uk-nav')));
2016-01-30 20:28:43 +00:00
}
});
});
},
init: function() {
var $this = this;
2017-11-12 00:33:10 +00:00
this.on('click.uk.nav', this.options.toggle, function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
var ele = UI.$(this);
$this.open(ele.parent()[0] == $this.element[0] ? ele : ele.parent("li"));
});
2017-11-12 00:33:10 +00:00
this.update();
UI.domObserve(this.element, function(e) {
if ($this.element.find($this.options.lists).not('[role]').length) {
$this.update();
}
});
},
update: function() {
var $this = this;
2016-01-30 20:28:43 +00:00
this.find(this.options.lists).each(function() {
2017-11-12 00:33:10 +00:00
var $ele = UI.$(this).attr('role', 'menu'),
parent = $ele.closest('li'),
2016-01-30 20:28:43 +00:00
active = parent.hasClass("uk-active");
2017-11-12 00:33:10 +00:00
if (!parent.data('list-container')) {
$ele.wrap('<div style="overflow:hidden;height:0;position:relative;"></div>');
parent.data('list-container', $ele.parent()[active ? 'removeClass':'addClass']('uk-hidden'));
}
2016-01-30 20:28:43 +00:00
// Init ARIA
parent.attr('aria-expanded', parent.hasClass("uk-open"));
if (active) $this.open(parent, true);
});
},
open: function(li, noanimation) {
var $this = this, element = this.element, $li = UI.$(li), $container = $li.data('list-container');
if (!this.options.multiple) {
element.children('.uk-open').not(li).each(function() {
var ele = UI.$(this);
if (ele.data('list-container')) {
ele.data('list-container').stop().animate({height: 0}, function() {
UI.$(this).parent().removeClass('uk-open').end().addClass('uk-hidden');
});
}
});
}
$li.toggleClass('uk-open');
// Update ARIA
$li.attr('aria-expanded', $li.hasClass('uk-open'));
if ($container) {
if ($li.hasClass('uk-open')) {
$container.removeClass('uk-hidden');
}
if (noanimation) {
$container.stop().height($li.hasClass('uk-open') ? 'auto' : 0);
if (!$li.hasClass('uk-open')) {
$container.addClass('uk-hidden');
}
this.trigger('display.uk.check');
} else {
$container.stop().animate({
height: ($li.hasClass('uk-open') ? getHeight($container.find('ul:first')) : 0)
}, function() {
if (!$li.hasClass('uk-open')) {
$container.addClass('uk-hidden');
} else {
$container.css('height', '');
}
$this.trigger('display.uk.check');
});
}
}
}
});
// helper
function getHeight(ele) {
2017-11-12 00:33:10 +00:00
var $ele = UI.$(ele), height = 'auto';
if ($ele.is(':visible')) {
2016-01-30 20:28:43 +00:00
height = $ele.outerHeight();
} else {
2017-11-12 00:33:10 +00:00
2016-01-30 20:28:43 +00:00
var tmp = {
2017-11-12 00:33:10 +00:00
position: $ele.css('position'),
visibility: $ele.css('visibility'),
display: $ele.css('display')
2016-01-30 20:28:43 +00:00
};
height = $ele.css({position: 'absolute', visibility: 'hidden', display: 'block'}).outerHeight();
$ele.css(tmp); // reset element
}
return height;
}
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
var scrollpos = {x: window.scrollX, y: window.scrollY},
$win = UI.$win,
$doc = UI.$doc,
$html = UI.$html,
Offcanvas = {
2017-11-12 00:33:10 +00:00
show: function(element, options) {
2016-01-30 20:28:43 +00:00
element = UI.$(element);
if (!element.length) return;
2017-11-12 00:33:10 +00:00
options = UI.$.extend({mode: 'push'}, options);
2016-01-30 20:28:43 +00:00
var $body = UI.$('body'),
2017-11-12 00:33:10 +00:00
bar = element.find('.uk-offcanvas-bar:first'),
rtl = (UI.langdirection == 'right'),
flip = bar.hasClass('uk-offcanvas-bar-flip') ? -1:1,
2016-03-19 01:51:35 +00:00
dir = flip * (rtl ? -1 : 1),
scrollbarwidth = window.innerWidth - $body.width();
2016-01-30 20:28:43 +00:00
scrollpos = {x: window.pageXOffset, y: window.pageYOffset};
2017-11-12 00:33:10 +00:00
bar.attr('mode', options.mode);
element.addClass('uk-active');
$body.css({width: window.innerWidth - scrollbarwidth, height: window.innerHeight}).addClass('uk-offcanvas-page');
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (options.mode == 'push' || options.mode == 'reveal') {
$body.css((rtl ? 'margin-right' : 'margin-left'), (rtl ? -1 : 1) * (bar.outerWidth() * dir));
}
if (options.mode == 'reveal') {
bar.css('clip', 'rect(0, '+bar.outerWidth()+'px, 100vh, 0)');
}
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
$html.css('margin-top', scrollpos.y * -1).width(); // .width() - force redraw
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
bar.addClass('uk-offcanvas-bar-show');
2016-01-30 20:28:43 +00:00
this._initElement(element);
bar.trigger('show.uk.offcanvas', [element, bar]);
// Update ARIA
element.attr('aria-hidden', 'false');
},
hide: function(force) {
var $body = UI.$('body'),
2017-11-12 00:33:10 +00:00
panel = UI.$('.uk-offcanvas.uk-active'),
rtl = (UI.langdirection == 'right'),
bar = panel.find('.uk-offcanvas-bar:first'),
2016-01-30 20:28:43 +00:00
finalize = function() {
2017-11-12 00:33:10 +00:00
$body.removeClass('uk-offcanvas-page').css({width: '', height: '', marginLeft: '', marginRight: ''});
panel.removeClass('uk-active');
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
bar.removeClass('uk-offcanvas-bar-show');
2016-01-30 20:28:43 +00:00
$html.css('margin-top', '');
window.scrollTo(scrollpos.x, scrollpos.y);
bar.trigger('hide.uk.offcanvas', [panel, bar]);
// Update ARIA
panel.attr('aria-hidden', 'true');
};
if (!panel.length) return;
2017-11-12 00:33:10 +00:00
if (bar.attr('mode') == 'none') force = true;
2016-01-30 20:28:43 +00:00
if (UI.support.transition && !force) {
$body.one(UI.support.transition.end, function() {
finalize();
2017-11-12 00:33:10 +00:00
}).css((rtl ? 'margin-right' : 'margin-left'), '');
if (bar.attr('mode') == 'reveal') {
bar.css('clip', '');
}
2016-01-30 20:28:43 +00:00
setTimeout(function(){
2017-11-12 00:33:10 +00:00
bar.removeClass('uk-offcanvas-bar-show');
2016-01-30 20:28:43 +00:00
}, 0);
} else {
finalize();
}
},
_initElement: function(element) {
2017-11-12 00:33:10 +00:00
if (element.data('OffcanvasInit')) return;
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
element.on('click.uk.offcanvas swipeRight.uk.offcanvas swipeLeft.uk.offcanvas', function(e) {
2016-01-30 20:28:43 +00:00
var target = UI.$(e.target);
if (!e.type.match(/swipe/)) {
2017-11-12 00:33:10 +00:00
if (!target.hasClass('uk-offcanvas-close')) {
if (target.hasClass('uk-offcanvas-bar')) return;
if (target.parents('.uk-offcanvas-bar:first').length) return;
2016-01-30 20:28:43 +00:00
}
}
e.stopImmediatePropagation();
Offcanvas.hide();
});
2017-11-12 00:33:10 +00:00
element.on('click', 'a[href*="#"]', function(e){
2016-01-30 20:28:43 +00:00
var link = UI.$(this),
2017-11-12 00:33:10 +00:00
href = link.attr('href');
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (href == '#') {
2016-01-30 20:28:43 +00:00
return;
}
UI.$doc.one('hide.uk.offcanvas', function() {
var target;
try {
2016-03-19 01:51:35 +00:00
target = UI.$(link[0].hash);
2016-01-30 20:28:43 +00:00
} catch (e){
2016-03-19 01:51:35 +00:00
target = '';
2016-01-30 20:28:43 +00:00
}
if (!target.length) {
2016-03-19 01:51:35 +00:00
target = UI.$('[name="'+link[0].hash.replace('#','')+'"]');
2016-01-30 20:28:43 +00:00
}
2016-03-19 01:51:35 +00:00
if (target.length && UI.Utils.scrollToElement) {
2016-01-30 20:28:43 +00:00
UI.Utils.scrollToElement(target, UI.Utils.options(link.attr('data-uk-smooth-scroll') || '{}'));
} else {
window.location.href = href;
}
});
Offcanvas.hide();
});
2017-11-12 00:33:10 +00:00
element.data('OffcanvasInit', true);
2016-01-30 20:28:43 +00:00
}
};
UI.component('offcanvasTrigger', {
boot: function() {
// init code
2017-11-12 00:33:10 +00:00
$html.on('click.offcanvas.uikit', '[data-uk-offcanvas]', function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('offcanvasTrigger')) {
var obj = UI.offcanvasTrigger(ele, UI.Utils.options(ele.attr('data-uk-offcanvas')));
2016-01-30 20:28:43 +00:00
ele.trigger("click");
}
});
$html.on('keydown.uk.offcanvas', function(e) {
if (e.keyCode === 27) { // ESC
Offcanvas.hide();
}
});
},
init: function() {
var $this = this;
this.options = UI.$.extend({
2017-11-12 00:33:10 +00:00
target: $this.element.is('a') ? $this.element.attr('href') : false,
mode: 'push'
2016-01-30 20:28:43 +00:00
}, this.options);
2017-11-12 00:33:10 +00:00
this.on('click', function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
2017-11-12 00:33:10 +00:00
Offcanvas.show($this.options.target, $this.options);
2016-01-30 20:28:43 +00:00
});
}
});
UI.offcanvas = Offcanvas;
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
var Animations;
UI.component('switcher', {
defaults: {
connect : false,
2017-11-12 00:33:10 +00:00
toggle : '>*',
2016-01-30 20:28:43 +00:00
active : 0,
animation : false,
2016-03-19 01:51:35 +00:00
duration : 200,
swiping : true
2016-01-30 20:28:43 +00:00
},
animating: false,
boot: function() {
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-switcher]', context).each(function() {
2016-01-30 20:28:43 +00:00
var switcher = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!switcher.data('switcher')) {
var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr('data-uk-switcher')));
2016-01-30 20:28:43 +00:00
}
});
});
},
init: function() {
var $this = this;
2017-11-12 00:33:10 +00:00
this.on('click.uk.switcher', this.options.toggle, function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
$this.show(this);
});
2017-11-12 00:33:10 +00:00
if (!this.options.connect) {
return;
}
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
this.connect = UI.$(this.options.connect);
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (!this.connect.length) {
return;
}
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
this.connect.on('click.uk.switcher', '[data-uk-switcher-item]', function(e) {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
e.preventDefault();
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
var item = UI.$(this).attr('data-uk-switcher-item');
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if ($this.index == item) return;
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
switch(item) {
case 'next':
case 'previous':
$this.show($this.index + (item=='next' ? 1:-1));
break;
default:
$this.show(parseInt(item, 10));
}
});
2016-03-19 01:51:35 +00:00
2017-11-12 00:33:10 +00:00
if (this.options.swiping) {
2016-03-19 01:51:35 +00:00
2017-11-12 00:33:10 +00:00
this.connect.on('swipeRight swipeLeft', function(e) {
e.preventDefault();
if (!window.getSelection().toString()) {
$this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1));
2016-03-19 01:51:35 +00:00
}
2017-11-12 00:33:10 +00:00
});
}
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
this.update();
},
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
update: function() {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
this.connect.children().removeClass('uk-active').attr('aria-hidden', 'true');
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
var toggles = this.find(this.options.toggle),
active = toggles.filter('.uk-active');
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (active.length) {
this.show(active, false);
} else {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
if (this.options.active===false) return;
active = toggles.eq(this.options.active);
this.show(active.length ? active : toggles.eq(0), false);
2016-01-30 20:28:43 +00:00
}
2017-11-12 00:33:10 +00:00
// Init ARIA for toggles
toggles.not(active).attr('aria-expanded', 'false');
active.attr('aria-expanded', 'true');
2016-01-30 20:28:43 +00:00
},
show: function(tab, animate) {
if (this.animating) {
return;
}
2017-11-12 00:33:10 +00:00
var toggles = this.find(this.options.toggle);
2016-01-30 20:28:43 +00:00
if (isNaN(tab)) {
tab = UI.$(tab);
} else {
tab = tab < 0 ? toggles.length-1 : tab;
tab = toggles.eq(toggles[tab] ? tab : 0);
}
var $this = this,
active = UI.$(tab),
animation = Animations[this.options.animation] || function(current, next) {
if (!$this.options.animation) {
return Animations.none.apply($this);
}
var anim = $this.options.animation.split(',');
if (anim.length == 1) {
anim[1] = anim[0];
}
anim[0] = anim[0].trim();
anim[1] = anim[1].trim();
return coreAnimation.apply($this, [anim, current, next]);
};
if (animate===false || !UI.support.animation) {
animation = Animations.none;
}
if (active.hasClass("uk-disabled")) return;
// Update ARIA for Toggles
toggles.attr('aria-expanded', 'false');
active.attr('aria-expanded', 'true');
toggles.filter(".uk-active").removeClass("uk-active");
active.addClass("uk-active");
if (this.options.connect && this.connect.length) {
this.index = this.find(this.options.toggle).index(active);
if (this.index == -1 ) {
this.index = 0;
}
this.connect.each(function() {
var container = UI.$(this),
children = UI.$(container.children()),
current = UI.$(children.filter('.uk-active')),
next = UI.$(children.eq($this.index));
$this.animating = true;
animation.apply($this, [current, next]).then(function(){
current.removeClass("uk-active");
next.addClass("uk-active");
// Update ARIA for connect
current.attr('aria-hidden', 'true');
next.attr('aria-hidden', 'false');
UI.Utils.checkDisplay(next, true);
$this.animating = false;
2016-03-19 01:51:35 +00:00
2016-01-30 20:28:43 +00:00
});
});
}
this.trigger("show.uk.switcher", [active]);
}
});
Animations = {
'none': function() {
var d = UI.$.Deferred();
d.resolve();
return d.promise();
},
'fade': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-fade', current, next]);
},
'slide-bottom': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-slide-bottom', current, next]);
},
'slide-top': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-slide-top', current, next]);
},
'slide-vertical': function(current, next, dir) {
var anim = ['uk-animation-slide-top', 'uk-animation-slide-bottom'];
if (current && current.index() > next.index()) {
anim.reverse();
}
return coreAnimation.apply(this, [anim, current, next]);
},
'slide-left': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-slide-left', current, next]);
},
'slide-right': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-slide-right', current, next]);
},
'slide-horizontal': function(current, next, dir) {
var anim = ['uk-animation-slide-right', 'uk-animation-slide-left'];
if (current && current.index() > next.index()) {
anim.reverse();
}
return coreAnimation.apply(this, [anim, current, next]);
},
'scale': function(current, next) {
return coreAnimation.apply(this, ['uk-animation-scale-up', current, next]);
}
};
UI.switcher.animations = Animations;
// helpers
function coreAnimation(cls, current, next) {
var d = UI.$.Deferred(), clsIn = cls, clsOut = cls, release;
if (next[0]===current[0]) {
d.resolve();
return d.promise();
}
if (typeof(cls) == 'object') {
clsIn = cls[0];
clsOut = cls[1] || cls[0];
}
2016-03-19 01:51:35 +00:00
UI.$body.css('overflow-x', 'hidden'); // fix scroll jumping in iOS
2016-01-30 20:28:43 +00:00
release = function() {
if (current) current.hide().removeClass('uk-active '+clsOut+' uk-animation-reverse');
next.addClass(clsIn).one(UI.support.animation.end, function() {
2017-11-12 00:33:10 +00:00
setTimeout(function () {
next.removeClass(''+clsIn+'').css({opacity:'', display:''});
}, 0);
2016-01-30 20:28:43 +00:00
d.resolve();
2016-03-19 01:51:35 +00:00
UI.$body.css('overflow-x', '');
2016-01-30 20:28:43 +00:00
if (current) current.css({opacity:'', display:''});
}.bind(this)).show();
};
next.css('animation-duration', this.options.duration+'ms');
if (current && current.length) {
current.css('animation-duration', this.options.duration+'ms');
current.css('display', 'none').addClass(clsOut+' uk-animation-reverse').one(UI.support.animation.end, function() {
release();
}.bind(this)).css('display', '');
} else {
next.addClass('uk-active');
release();
}
return d.promise();
}
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
UI.component('tab', {
defaults: {
2017-11-12 00:33:10 +00:00
target : '>li:not(.uk-tab-responsive, .uk-disabled)',
connect : false,
active : 0,
animation : false,
duration : 200,
swiping : true
2016-01-30 20:28:43 +00:00
},
boot: function() {
// init code
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-tab]', context).each(function() {
2016-01-30 20:28:43 +00:00
var tab = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!tab.data('tab')) {
var obj = UI.tab(tab, UI.Utils.options(tab.attr('data-uk-tab')));
2016-01-30 20:28:43 +00:00
}
});
});
},
init: function() {
var $this = this;
this.current = false;
2017-11-12 00:33:10 +00:00
this.on('click.uk.tab', this.options.target, function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
if ($this.switcher && $this.switcher.animating) {
return;
}
var current = $this.find($this.options.target).not(this);
2017-11-12 00:33:10 +00:00
current.removeClass('uk-active').blur();
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
$this.trigger('change.uk.tab', [UI.$(this).addClass('uk-active'), $this.current]);
2016-01-30 20:28:43 +00:00
$this.current = UI.$(this);
// Update ARIA
if (!$this.options.connect) {
current.attr('aria-expanded', 'false');
UI.$(this).attr('aria-expanded', 'true');
}
});
if (this.options.connect) {
this.connect = UI.$(this.options.connect);
}
// init responsive tab
this.responsivetab = UI.$('<li class="uk-tab-responsive uk-active"><a></a></li>').append('<div class="uk-dropdown uk-dropdown-small"><ul class="uk-nav uk-nav-dropdown"></ul><div>');
this.responsivetab.dropdown = this.responsivetab.find('.uk-dropdown');
this.responsivetab.lst = this.responsivetab.dropdown.find('ul');
this.responsivetab.caption = this.responsivetab.find('a:first');
2017-11-12 00:33:10 +00:00
if (this.element.hasClass('uk-tab-bottom')) this.responsivetab.dropdown.addClass('uk-dropdown-up');
2016-01-30 20:28:43 +00:00
// handle click
2016-03-19 01:51:35 +00:00
this.responsivetab.lst.on('click.uk.tab', 'a', function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
e.stopPropagation();
var link = UI.$(this);
$this.element.children('li:not(.uk-tab-responsive)').eq(link.data('index')).trigger('click');
});
this.on('show.uk.switcher change.uk.tab', function(e, tab) {
$this.responsivetab.caption.html(tab.text());
});
this.element.append(this.responsivetab);
// init UIkit components
if (this.options.connect) {
2017-11-12 00:33:10 +00:00
2016-01-30 20:28:43 +00:00
this.switcher = UI.switcher(this.element, {
2017-11-12 00:33:10 +00:00
toggle : '>li:not(.uk-tab-responsive)',
connect : this.options.connect,
active : this.options.active,
animation : this.options.animation,
duration : this.options.duration,
swiping : this.options.swiping
2016-01-30 20:28:43 +00:00
});
}
2017-11-12 00:33:10 +00:00
UI.dropdown(this.responsivetab, {mode: 'click', preventflip: 'y'});
2016-01-30 20:28:43 +00:00
// init
2017-11-12 00:33:10 +00:00
$this.trigger('change.uk.tab', [this.element.find(this.options.target).not('.uk-tab-responsive').filter('.uk-active')]);
2016-01-30 20:28:43 +00:00
this.check();
UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){
2017-11-12 00:33:10 +00:00
if ($this.element.is(':visible')) $this.check();
2016-01-30 20:28:43 +00:00
}, 100));
this.on('display.uk.check', function(){
2017-11-12 00:33:10 +00:00
if ($this.element.is(':visible')) $this.check();
2016-01-30 20:28:43 +00:00
});
},
check: function() {
var children = this.element.children('li:not(.uk-tab-responsive)').removeClass('uk-hidden');
if (!children.length) {
this.responsivetab.addClass('uk-hidden');
return;
}
var top = (children.eq(0).offset().top + Math.ceil(children.eq(0).height()/2)),
doresponsive = false,
item, link, clone;
this.responsivetab.lst.empty();
children.each(function(){
if (UI.$(this).offset().top > top) {
doresponsive = true;
}
});
if (doresponsive) {
for (var i = 0; i < children.length; i++) {
item = UI.$(children.eq(i));
link = item.find('a');
if (item.css('float') != 'none' && !item.attr('uk-dropdown')) {
if (!item.hasClass('uk-disabled')) {
2017-11-12 00:33:10 +00:00
clone = UI.$(item[0].outerHTML);
clone.find('a').data('index', i);
2016-01-30 20:28:43 +00:00
this.responsivetab.lst.append(clone);
}
item.addClass('uk-hidden');
}
}
}
this.responsivetab[this.responsivetab.lst.children('li').length ? 'removeClass':'addClass']('uk-hidden');
}
});
2017-11-12 00:33:10 +00:00
})(UIkit2);
2016-01-30 20:28:43 +00:00
(function(UI){
"use strict";
UI.component('cover', {
defaults: {
automute : true
},
boot: function() {
// auto init
UI.ready(function(context) {
2017-11-12 00:33:10 +00:00
UI.$('[data-uk-cover]', context).each(function(){
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if(!ele.data('cover')) {
var plugin = UI.cover(ele, UI.Utils.options(ele.attr('data-uk-cover')));
2016-01-30 20:28:43 +00:00
}
});
});
},
init: function() {
this.parent = this.element.parent();
UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
this.check();
}.bind(this), 100));
2017-11-12 00:33:10 +00:00
this.on('display.uk.check', function(e) {
if (this.element.is(':visible')) this.check();
2016-01-30 20:28:43 +00:00
}.bind(this));
this.check();
if (this.element.is('iframe') && this.options.automute) {
var src = this.element.attr('src');
this.element.attr('src', '').on('load', function(){
this.contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*');
}).attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1'].join(''));
}
},
check: function() {
2017-11-12 00:33:10 +00:00
this.element.css({ width : '', height : '' });
2016-01-30 20:28:43 +00:00
this.dimension = {w: this.element.width(), h: this.element.height()};
if (this.element.attr('width') && !isNaN(this.element.attr('width'))) {
this.dimension.w = this.element.attr('width');
}
if (this.element.attr('height') && !isNaN(this.element.attr('height'))) {
this.dimension.h = this.element.attr('height');
}
2017-11-12 00:33:10 +00:00
this.ratio = this.dimension.w / this.dimension.h;
2016-01-30 20:28:43 +00:00
var w = this.parent.width(), h = this.parent.height(), width, height;
// if element height < parent height (gap underneath)
if ((w / this.ratio) < h) {
width = Math.ceil(h * this.ratio);
height = h;
// element width < parent width (gap to right)
} else {
width = w;
height = Math.ceil(w / this.ratio);
}
2017-11-12 00:33:10 +00:00
this.element.css({ width : width, height : height });
2016-01-30 20:28:43 +00:00
}
});
2017-11-12 00:33:10 +00:00
})(UIkit2);