updated Uikit v2
This commit is contained in:
@@ -1,18 +1,24 @@
|
||||
/*! UIkit 2.25.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
(function(core) {
|
||||
|
||||
if (typeof define == "function" && define.amd) { // AMD
|
||||
var uikit;
|
||||
|
||||
define("uikit", function(){
|
||||
if (!window.jQuery) {
|
||||
throw new Error('UIkit 2.x requires jQuery');
|
||||
} else {
|
||||
uikit = core(window.jQuery);
|
||||
}
|
||||
|
||||
var uikit = window.UIkit || core(window, window.jQuery, window.document);
|
||||
if (typeof define == 'function' && define.amd) { // AMD
|
||||
|
||||
define('uikit', function(){
|
||||
|
||||
uikit.load = function(res, req, onload, config) {
|
||||
|
||||
var resources = res.split(','), load = [], i, base = (config.config && config.config.uikit && config.config.uikit.base ? config.config.uikit.base : "").replace(/\/+$/g, "");
|
||||
var resources = res.split(','), load = [], i, base = (config.config && config.config.uikit && config.config.uikit.base ? config.config.uikit.base : '').replace(/\/+$/g, '');
|
||||
|
||||
if (!base) {
|
||||
throw new Error( "Please define base path to UIkit in the requirejs config." );
|
||||
throw new Error('Please define base path to UIkit in the requirejs config.');
|
||||
}
|
||||
|
||||
for (i = 0; i < resources.length; i += 1) {
|
||||
@@ -29,27 +35,22 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (!window.jQuery) {
|
||||
throw new Error( "UIkit requires jQuery" );
|
||||
}
|
||||
|
||||
if (window && window.jQuery) {
|
||||
core(window, window.jQuery, window.document);
|
||||
}
|
||||
|
||||
|
||||
})(function(global, $, doc) {
|
||||
})(function($) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var UI = {}, _UI = global.UIkit ? Object.create(global.UIkit) : undefined;
|
||||
if (window.UIkit2) {
|
||||
return window.UIkit2;
|
||||
}
|
||||
|
||||
UI.version = '2.25.0';
|
||||
var UI = {}, _UI = window.UIkit || undefined;
|
||||
|
||||
UI.version = '2.27.4';
|
||||
|
||||
UI.noConflict = function() {
|
||||
// restore UIkit version
|
||||
if (_UI) {
|
||||
global.UIkit = _UI;
|
||||
window.UIkit = _UI;
|
||||
$.UIkit = _UI;
|
||||
$.fn.uk = _UI.fn;
|
||||
}
|
||||
@@ -57,9 +58,11 @@
|
||||
return UI;
|
||||
};
|
||||
|
||||
UI.prefix = function(str) {
|
||||
return str;
|
||||
};
|
||||
window.UIkit2 = UI;
|
||||
|
||||
if (!_UI) {
|
||||
window.UIkit = UI;
|
||||
}
|
||||
|
||||
// cache jQuery
|
||||
UI.$ = $;
|
||||
@@ -73,7 +76,7 @@
|
||||
|
||||
var transitionEnd = (function() {
|
||||
|
||||
var element = doc.body || doc.documentElement,
|
||||
var element = document.body || document.documentElement,
|
||||
transEndEventNames = {
|
||||
WebkitTransition : 'webkitTransitionEnd',
|
||||
MozTransition : 'transitionend',
|
||||
@@ -93,7 +96,7 @@
|
||||
|
||||
var animationEnd = (function() {
|
||||
|
||||
var element = doc.body || doc.documentElement,
|
||||
var element = document.body || document.documentElement,
|
||||
animEndEventNames = {
|
||||
WebkitAnimation : 'webkitAnimationEnd',
|
||||
MozAnimation : 'animationend',
|
||||
@@ -137,13 +140,13 @@
|
||||
|
||||
UI.support.touch = (
|
||||
('ontouchstart' in document) ||
|
||||
(global.DocumentTouch && document instanceof global.DocumentTouch) ||
|
||||
(global.navigator.msPointerEnabled && global.navigator.msMaxTouchPoints > 0) || //IE 10
|
||||
(global.navigator.pointerEnabled && global.navigator.maxTouchPoints > 0) || //IE >=11
|
||||
(window.DocumentTouch && document instanceof window.DocumentTouch) ||
|
||||
(window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 0) || //IE 10
|
||||
(window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 0) || //IE >=11
|
||||
false
|
||||
);
|
||||
|
||||
UI.support.mutationobserver = (global.MutationObserver || global.WebKitMutationObserver || null);
|
||||
UI.support.mutationobserver = (window.MutationObserver || window.WebKitMutationObserver || null);
|
||||
|
||||
UI.Utils = {};
|
||||
|
||||
@@ -161,7 +164,7 @@
|
||||
.replace(/'([^']+)'/g, function(_, $1){return '"'+$1+'"';})
|
||||
);
|
||||
} else {
|
||||
return (new Function("", "var json = " + str + "; return JSON.parse(JSON.stringify(json));"))();
|
||||
return (new Function('', 'var json = ' + str + '; return JSON.parse(JSON.stringify(json));'))();
|
||||
}
|
||||
} catch(e) { return false; }
|
||||
};
|
||||
@@ -181,6 +184,19 @@
|
||||
};
|
||||
};
|
||||
|
||||
UI.Utils.throttle = function (func, limit) {
|
||||
var wait = false;
|
||||
return function () {
|
||||
if (!wait) {
|
||||
func.call();
|
||||
wait = true;
|
||||
setTimeout(function () {
|
||||
wait = false;
|
||||
}, limit);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
UI.Utils.removeCssRules = function(selectorRegEx) {
|
||||
var idx, idxs, stylesheet, _i, _j, _k, _len, _len1, _len2, _ref;
|
||||
|
||||
@@ -247,7 +263,7 @@
|
||||
|
||||
var ele = UI.$(this),
|
||||
cls = ele.attr('class'),
|
||||
anim = cls.match(/uk\-animation\-(.+)/);
|
||||
anim = cls.match(/uk-animation-(.+)/);
|
||||
|
||||
ele.removeClass(anim[0]).width();
|
||||
|
||||
@@ -314,30 +330,30 @@
|
||||
|
||||
switch(cmd) {
|
||||
case '~':
|
||||
output.push("for(var $i=0;$i<"+prop+".length;$i++) { var $item = "+prop+"[$i];");
|
||||
output.push('for(var $i=0;$i<'+prop+'.length;$i++) { var $item = '+prop+'[$i];');
|
||||
openblocks++;
|
||||
break;
|
||||
case ':':
|
||||
output.push("for(var $key in "+prop+") { var $val = "+prop+"[$key];");
|
||||
output.push('for(var $key in '+prop+') { var $val = '+prop+'[$key];');
|
||||
openblocks++;
|
||||
break;
|
||||
case '#':
|
||||
output.push("if("+prop+") {");
|
||||
output.push('if('+prop+') {');
|
||||
openblocks++;
|
||||
break;
|
||||
case '^':
|
||||
output.push("if(!"+prop+") {");
|
||||
output.push('if(!'+prop+') {');
|
||||
openblocks++;
|
||||
break;
|
||||
case '/':
|
||||
output.push("}");
|
||||
output.push('}');
|
||||
openblocks--;
|
||||
break;
|
||||
case '!':
|
||||
output.push("__ret.push("+prop+");");
|
||||
output.push('__ret.push('+prop+');');
|
||||
break;
|
||||
default:
|
||||
output.push("__ret.push(escape("+prop+"));");
|
||||
output.push('__ret.push(escape('+prop+'));');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -358,11 +374,43 @@
|
||||
return data ? fn(data) : fn;
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
UI.Utils.events = {};
|
||||
UI.Utils.events.click = UI.support.touch ? 'tap' : 'click';
|
||||
|
||||
global.UIkit = UI;
|
||||
|
||||
// deprecated
|
||||
|
||||
UI.fn = function(command, options) {
|
||||
@@ -370,7 +418,7 @@
|
||||
var args = arguments, cmd = command.match(/^([a-z\-]+)(?:\.([a-z]+))?/i), component = cmd[1], method = cmd[2];
|
||||
|
||||
if (!UI[component]) {
|
||||
$.error("UIkit component [" + component + "] does not exist.");
|
||||
$.error('UIkit component [' + component + '] does not exist.');
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -388,7 +436,11 @@
|
||||
|
||||
UI.components = {};
|
||||
|
||||
UI.component = function(name, def) {
|
||||
UI.component = function(name, def, override) {
|
||||
|
||||
if (UI.components[name] && !override) {
|
||||
return UI.components[name];
|
||||
}
|
||||
|
||||
var fn = function(element, options) {
|
||||
|
||||
@@ -488,7 +540,7 @@
|
||||
switch(arguments.length) {
|
||||
case 1:
|
||||
|
||||
if (typeof arguments[0] === "string" || arguments[0].nodeType || arguments[0] instanceof jQuery) {
|
||||
if (typeof arguments[0] === 'string' || arguments[0].nodeType || arguments[0] instanceof jQuery) {
|
||||
element = $(arguments[0]);
|
||||
} else {
|
||||
options = arguments[0];
|
||||
@@ -592,9 +644,9 @@
|
||||
try {
|
||||
|
||||
var observer = new UI.support.mutationobserver(UI.Utils.debounce(function(mutations) {
|
||||
fn.apply(element, []);
|
||||
fn.apply(element, [$element]);
|
||||
$element.trigger('changed.uk.dom');
|
||||
}, 50));
|
||||
}, 50), {childList: true, subtree: true});
|
||||
|
||||
// pass in the target node, as well as the observer options
|
||||
observer.observe(element, { childList: true, subtree: true });
|
||||
@@ -627,21 +679,12 @@
|
||||
|
||||
UI.$body = UI.$('body');
|
||||
|
||||
UI.ready(function(context){
|
||||
UI.domObserve('[data-uk-observe]');
|
||||
});
|
||||
|
||||
UI.on('changed.uk.dom', function(e) {
|
||||
UI.init(e.target);
|
||||
UI.Utils.checkDisplay(e.target);
|
||||
});
|
||||
|
||||
UI.trigger('beforeready.uk.dom');
|
||||
|
||||
UI.component.bootComponents();
|
||||
|
||||
// custom scroll observer
|
||||
requestAnimationFrame((function(){
|
||||
var rafToken = requestAnimationFrame((function(){
|
||||
|
||||
var memory = {dir: {x:0, y:0}, x: window.pageXOffset, y:window.pageYOffset};
|
||||
|
||||
@@ -664,11 +707,12 @@
|
||||
// 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', [{
|
||||
"dir": {"x": memory.dir.x, "y": memory.dir.y}, "x": wpxo, "y": wpyo
|
||||
dir: {x: memory.dir.x, y: memory.dir.y}, x: wpxo, y: wpyo
|
||||
}]);
|
||||
}
|
||||
|
||||
requestAnimationFrame(fn);
|
||||
cancelAnimationFrame(rafToken);
|
||||
rafToken = requestAnimationFrame(fn);
|
||||
};
|
||||
|
||||
if (UI.support.touch) {
|
||||
@@ -709,6 +753,37 @@
|
||||
|
||||
// mark that domready is left behind
|
||||
UI.domready = true;
|
||||
|
||||
// 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});
|
||||
}
|
||||
};
|
||||
|
||||
if (document.readyState == 'complete' || document.readyState == 'interactive') {
|
||||
@@ -720,7 +795,7 @@
|
||||
}());
|
||||
|
||||
// add touch identifier class
|
||||
UI.$html.addClass(UI.support.touch ? "uk-touch" : "uk-notouch");
|
||||
UI.$html.addClass(UI.support.touch ? 'uk-touch' : 'uk-notouch');
|
||||
|
||||
// add uk-hover class on tap to support overlays on touch devices
|
||||
if (UI.support.touch) {
|
||||
|
Reference in New Issue
Block a user