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

826 lines
25 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
})());
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;
});