vendor/assets/javascripts/uikit.js in uikit2-rails-0.1.6 vs vendor/assets/javascripts/uikit.js in uikit2-rails-0.1.7
- old
+ new
@@ -1,6 +1,6 @@
-/*! UIkit 2.24.3 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
+/*! UIkit 2.26.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(core) {
if (typeof define == "function" && define.amd) { // AMD
define("uikit", function(){
@@ -42,11 +42,11 @@
"use strict";
var UI = {}, _UI = global.UIkit ? Object.create(global.UIkit) : undefined;
- UI.version = '2.24.3';
+ UI.version = '2.26.1';
UI.noConflict = function() {
// restore UIkit version
if (_UI) {
global.UIkit = _UI;
@@ -280,16 +280,15 @@
UI.Utils.animate = function(element, cls) {
var d = $.Deferred();
element = UI.$(element);
- cls = cls;
element.css('display', 'none').addClass(cls).one(UI.support.animation.end, function() {
element.removeClass(cls);
d.resolve();
- }).width();
+ });
element.css('display', '');
return d.promise();
};
@@ -642,26 +641,33 @@
UI.component.bootComponents();
// custom scroll observer
requestAnimationFrame((function(){
- var memory = {x: window.pageXOffset, y:window.pageYOffset}, dir;
+ var memory = {dir: {x:0, y:0}, x: window.pageXOffset, y:window.pageYOffset};
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;
- if (memory.x != window.pageXOffset || memory.y != window.pageYOffset) {
+ // Did the scroll position change since the last time we were here?
+ if (memory.x != wpxo || memory.y != wpyo) {
- dir = {x: 0 , y: 0};
+ // 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; }
- if (window.pageXOffset != memory.x) dir.x = window.pageXOffset > memory.x ? 1:-1;
- if (window.pageYOffset != memory.y) dir.y = window.pageYOffset > memory.y ? 1:-1;
+ memory.x = wpxo;
+ memory.y = wpyo;
- memory = {
- "dir": dir, "x": window.pageXOffset, "y": window.pageYOffset
- };
-
- UI.$doc.trigger('scrolling.uk.document', [memory]);
+ // 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
+ }]);
}
requestAnimationFrame(fn);
};
@@ -936,25 +942,23 @@
// init code
UI.ready(function(context) {
UI.$("[data-uk-margin]", context).each(function() {
- var ele = UI.$(this), obj;
+ var ele = UI.$(this);
if (!ele.data("stackMargin")) {
- obj = UI.stackMargin(ele, UI.Utils.options(ele.attr("data-uk-margin")));
+ UI.stackMargin(ele, UI.Utils.options(ele.attr("data-uk-margin")));
}
});
});
},
init: function() {
var $this = this;
- this.columns = [];
-
UI.$win.on('resize orientationchange', (function() {
var fn = function() {
$this.process();
};
@@ -978,36 +982,37 @@
stacks.push(this);
},
process: function() {
- var $this = this;
+ var $this = this, columns = this.element.children();
- this.columns = this.element.children();
+ UI.Utils.stackMargin(columns, this.options);
- UI.Utils.stackMargin(this.columns, this.options);
-
- if (!this.options.rowfirst) {
+ if (!this.options.rowfirst || !columns.length) {
return this;
}
// Mark first column elements
- var pos_cache = this.columns.removeClass(this.options.rowfirst).filter(':visible').first().position();
+ var group = {}, minleft = false;
- if (pos_cache) {
- this.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){
- return this;
- },
+ $ele = UI.$(this);
- revert: function() {
- this.columns.removeClass(this.options.cls);
+ 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;
}
+
});
// responsive element e.g. iframes
@@ -1036,11 +1041,11 @@
UI.$("iframe.uk-responsive-width, [data-uk-responsive]", context).each(function() {
var ele = UI.$(this), obj;
- if (!ele.data("responsiveIframe")) {
+ if (!ele.data("responsiveElement")) {
obj = UI.responsiveElement(ele, {});
}
});
});
},
@@ -1085,35 +1090,46 @@
options = UI.$.extend({
'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);
+ }
});
};
UI.Utils.matchHeights = function(elements, options) {
@@ -1370,10 +1386,11 @@
if (!inview && inviewstate && $this.options.repeat) {
if (element.data('scrollspy-idle')) {
clearTimeout(element.data('scrollspy-idle'));
+ element.data('scrollspy-idle', false);
}
element.removeClass("uk-scrollspy-inview").toggleClass(toggle);
element.data('inviewstate', false);
@@ -1454,11 +1471,11 @@
var navitems,
scrollTop = $win.scrollTop(),
target = (function(){
for(var i=0; i< inviews.length;i++){
- if(inviews[i].offset().top >= scrollTop){
+ if(inviews[i].offset().top + inviews[i].outerHeight() >= scrollTop){
return inviews[i];
}
}
})();
@@ -1842,37 +1859,48 @@
var active = false, hoverIdle, flips = {
'x': {
"bottom-left" : 'bottom-right',
"bottom-right" : 'bottom-left',
- "bottom-center" : 'bottom-right',
+ "bottom-center" : 'bottom-center',
"top-left" : 'top-right',
"top-right" : 'top-left',
- "top-center" : 'top-right',
- "left-top" : 'right',
+ "top-center" : 'top-center',
+ "left-top" : 'right-top',
"left-bottom" : 'right-bottom',
"left-center" : 'right-center',
- "right-top" : 'left',
+ "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" : 'top-left',
- "left-bottom" : 'left-bottom',
- "left-center" : 'top-left',
- "right-top" : 'top-left',
- "right-bottom" : 'bottom-left',
- "right-center" : 'top-left'
+ "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'
}
};
UI.component('dropdown', {
@@ -1949,11 +1977,11 @@
this.element.attr('aria-haspopup', 'true');
this.element.attr('aria-expanded', this.element.hasClass("uk-open"));
if (this.options.mode == "click" || UI.support.touch) {
- this.on("click.uikit.dropdown", function(e) {
+ this.on("click.uk.dropdown", function(e) {
var $target = UI.$(e.target);
if (!$target.parents($this.options.dropdownSelector).length) {
@@ -2469,10 +2497,16 @@
"use strict";
var active = false, activeCount = 0, $html = UI.$html, body;
+ UI.$win.on("resize orientationchange", UI.Utils.debounce(function(){
+ UI.$('.uk-modal.uk-open').each(function(){
+ UI.$(this).data('modal').resize();
+ });
+ }, 150));
+
UI.component('modal', {
defaults: {
keyboard: true,
bgclose: true,
@@ -2509,11 +2543,11 @@
var target = UI.$(e.target);
if (target[0] == $this.element[0] && $this.options.bgclose) {
$this.hide();
}
- });
+ }).on("changed.uk.dom", this.resize.bind(this));
},
toggle: function() {
return this[this.isActive() ? "hide" : "show"]();
},
@@ -2681,14 +2715,10 @@
if (active && e.keyCode === 27 && active.options.keyboard) { // ESC
e.preventDefault();
active.hide();
}
});
-
- UI.$win.on("resize orientationchange", UI.Utils.debounce(function(){
- if (active) active.resize();
- }, 150));
},
init: function() {
var $this = this;
@@ -2881,11 +2911,11 @@
init: function() {
var $this = this;
- this.on("click.uikit.nav", this.options.toggle, function(e) {
+ this.on("click.uk.nav", this.options.toggle, function(e) {
e.preventDefault();
var ele = UI.$(this);
$this.open(ele.parent()[0] == $this.element[0] ? ele : ele.parent("li"));
});
@@ -3204,20 +3234,20 @@
init: function() {
var $this = this;
- this.on("click.uikit.switcher", this.options.toggle, function(e) {
+ this.on("click.uk.switcher", this.options.toggle, function(e) {
e.preventDefault();
$this.show(this);
});
if (this.options.connect) {
this.connect = UI.$(this.options.connect);
- this.connect.find(".uk-active").removeClass(".uk-active");
+ this.connect.children().removeClass("uk-active");
// delegate switch commands within container content
if (this.connect.length) {
// Init ARIA for connect
@@ -3512,11 +3542,11 @@
var $this = this;
this.current = false;
- this.on("click.uikit.tab", this.options.target, function(e) {
+ this.on("click.uk.tab", this.options.target, function(e) {
e.preventDefault();
if ($this.switcher && $this.switcher.animating) {
return;
@@ -3549,11 +3579,11 @@
this.responsivetab.caption = this.responsivetab.find('a:first');
if (this.element.hasClass("uk-tab-bottom")) this.responsivetab.dropdown.addClass("uk-dropdown-up");
// handle click
- this.responsivetab.lst.on('click.uikit.tab', 'a', function(e) {
+ this.responsivetab.lst.on('click.uk.tab', 'a', function(e) {
e.preventDefault();
e.stopPropagation();
var link = UI.$(this);
@@ -3577,10 +3607,10 @@
'duration' : this.options.duration,
'swiping' : this.options.swiping
});
}
- UI.dropdown(this.responsivetab, {"mode": "click"});
+ UI.dropdown(this.responsivetab, {"mode": "click", "preventflip": "y"});
// init
$this.trigger("change.uk.tab", [this.element.find(this.options.target).not('.uk-tab-responsive').filter('.uk-active')]);
this.check();