updated Uikit v2

This commit is contained in:
2017-11-12 02:33:10 +02:00
parent 7d27af5d59
commit 1cc40dbfe4
437 changed files with 9171 additions and 5797 deletions

View File

@@ -1,4 +1,4 @@
/*! 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(UI) {
"use strict";
@@ -9,7 +9,8 @@
defaults: {
cls: 'uk-margin-small-top',
rowfirst: false
rowfirst: false,
observe: false
},
boot: function() {
@@ -17,12 +18,12 @@
// init code
UI.ready(function(context) {
UI.$("[data-uk-margin]", context).each(function() {
UI.$('[data-uk-margin]', context).each(function() {
var ele = UI.$(this);
if (!ele.data("stackMargin")) {
UI.stackMargin(ele, UI.Utils.options(ele.attr("data-uk-margin")));
if (!ele.data('stackMargin')) {
UI.stackMargin(ele, UI.Utils.options(ele.attr('data-uk-margin')));
}
});
});
@@ -40,20 +41,23 @@
UI.$(function() {
fn();
UI.$win.on("load", fn);
UI.$win.on('load', fn);
});
return UI.Utils.debounce(fn, 20);
})());
UI.$html.on("changed.uk.dom", function(e) {
$this.process();
});
this.on("display.uk.check", function(e) {
if (this.element.is(":visible")) this.process();
this.on('display.uk.check', function(e) {
if (this.element.is(':visible')) this.process();
}.bind(this));
if (this.options.observe) {
UI.domObserve(this.element, function(e) {
if ($this.element.is(':visible')) $this.process();
});
}
stacks.push(this);
},
@@ -63,18 +67,25 @@
UI.Utils.stackMargin(columns, this.options);
if (!this.options.rowfirst) {
if (!this.options.rowfirst || !columns.length) {
return this;
}
// Mark first column elements
var pos_cache = columns.removeClass(this.options.rowfirst).filter(':visible').first().position();
var group = {}, minleft = false;
if (pos_cache) {
columns.each(function() {
UI.$(this)[UI.$(this).position().left == pos_cache.left ? 'addClass':'removeClass']($this.options.rowfirst);
});
}
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);
return this;
}
@@ -95,7 +106,7 @@
ratio = (width / iwidth),
height = Math.floor(ratio * ele.data('height'));
ele.css({'height': (width < iwidth) ? height : ele.data('height')});
ele.css({height: (width < iwidth) ? height : ele.data('height')});
};
UI.component('responsiveElement', {
@@ -107,11 +118,11 @@
// init code
UI.ready(function(context) {
UI.$("iframe.uk-responsive-width, [data-uk-responsive]", context).each(function() {
UI.$('iframe.uk-responsive-width, [data-uk-responsive]', context).each(function() {
var ele = UI.$(this), obj;
if (!ele.data("responsiveElement")) {
if (!ele.data('responsiveElement')) {
obj = UI.responsiveElement(ele, {});
}
});
@@ -125,10 +136,8 @@
if (ele.attr('width') && ele.attr('height')) {
ele.data({
'width' : ele.attr('width'),
'height': ele.attr('height')
width : ele.attr('width'),
height: ele.attr('height')
}).on('display.uk.check', function(){
check(ele);
});
@@ -151,40 +160,50 @@
})();
// helper
UI.Utils.stackMargin = function(elements, options) {
options = UI.$.extend({
'cls': 'uk-margin-small-top'
cls: 'uk-margin-small-top'
}, options);
options.cls = options.cls;
elements = UI.$(elements).removeClass(options.cls);
var skip = false,
firstvisible = elements.filter(":visible:first"),
offset = firstvisible.length ? (firstvisible.position().top + firstvisible.outerHeight()) - 1 : false; // (-1): weird firefox bug when parent container is display:flex
var min = false;
if (offset === false || elements.length == 1) return;
elements.each(function(offset, height, pos, $ele){
elements.each(function() {
$ele = UI.$(this);
var column = UI.$(this);
if ($ele.css('display') != 'none') {
if (column.is(":visible")) {
offset = $ele.offset();
height = $ele.outerHeight();
pos = offset.top + height;
if (skip) {
column.addClass(options.cls);
} else {
$ele.data({
ukMarginPos: pos,
ukMarginTop: offset.top
});
if (column.position().top >= offset) {
skip = column.addClass(options.cls);
}
if (min === false || (offset.top < min.top) ) {
min = {
top : offset.top,
left : offset.left,
pos : pos
};
}
}
}).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);
}
});
};
@@ -294,4 +313,23 @@
})({});
})(UIkit);
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);