vendor/assets/javascripts/uikit/core/utility.js in uikit2-rails-0.1.9 vs vendor/assets/javascripts/uikit/core/utility.js in uikit2-rails-0.1.10
- old
+ new
@@ -1,6 +1,6 @@
-/*! UIkit 2.26.3 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
+/*! UIkit 2.27.2 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(UI) {
"use strict";
var stacks = [];
@@ -16,16 +16,16 @@
boot: function() {
// 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')));
}
});
});
},
@@ -39,24 +39,24 @@
$this.process();
};
UI.$(function() {
fn();
- UI.$win.on("load", fn);
+ UI.$win.on('load', fn);
});
return UI.Utils.debounce(fn, 20);
})());
- 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();
+ if ($this.element.is(':visible')) $this.process();
});
}
stacks.push(this);
},
@@ -104,11 +104,11 @@
var width = ele.parent().width(),
iwidth = ele.data('width'),
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', {
defaults: {},
@@ -116,15 +116,15 @@
boot: function() {
// 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, {});
}
});
});
},
@@ -134,14 +134,12 @@
var ele = this.element;
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);
});
check(ele);
@@ -160,17 +158,16 @@
}, 15));
})();
-
// helper
UI.Utils.stackMargin = function(elements, options) {
options = UI.$.extend({
- 'cls': 'uk-margin-small-top'
+ cls: 'uk-margin-small-top'
}, options);
elements = UI.$(elements).removeClass(options.cls);
var min = false;
@@ -184,12 +181,12 @@
offset = $ele.offset();
height = $ele.outerHeight();
pos = offset.top + height;
$ele.data({
- 'ukMarginPos': pos,
- 'ukMarginTop': offset.top
+ ukMarginPos: pos,
+ ukMarginTop: offset.top
});
if (min === false || (offset.top < min.top) ) {
min = {
@@ -313,7 +310,26 @@
UI.ready(function(context) {
UI.Utils.inlineSvg('[data-uk-svg]', context);
});
})({});
+
+ 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;
+ }
})(UIkit);