vendor/assets/javascripts/uikit.js in uikit2-rails-0.1.4 vs vendor/assets/javascripts/uikit.js in uikit2-rails-0.1.5
- old
+ new
@@ -1,6 +1,6 @@
-/*! UIkit 2.24.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
+/*! UIkit 2.24.3 | 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.0';
+ UI.version = '2.24.3';
UI.noConflict = function() {
// restore UIkit version
if (_UI) {
global.UIkit = _UI;
@@ -258,12 +258,16 @@
return elements;
};
UI.Utils.options = function(string) {
- if ($.isPlainObject(string)) return string;
+ if ($.type(string)!='string') return string;
+ if (string.indexOf(':') != -1 && string.trim().substr(-1) != '}') {
+ string = '{'+string+'}';
+ }
+
var start = (string ? string.indexOf("{") : -1), options = {};
if (start != -1) {
try {
options = UI.Utils.str2json(string.substr(start));
@@ -616,90 +620,100 @@
UI.init();
if (UI.domready) UI.Utils.checkDisplay();
});
- $(function(){
+ document.addEventListener('DOMContentLoaded', function(){
- UI.$body = UI.$('body');
+ var domReady = function() {
- UI.ready(function(context){
- UI.domObserve('[data-uk-observe]');
- });
+ UI.$body = UI.$('body');
- UI.on('changed.uk.dom', function(e) {
- UI.init(e.target);
- UI.Utils.checkDisplay(e.target);
- });
+ UI.ready(function(context){
+ UI.domObserve('[data-uk-observe]');
+ });
- UI.trigger('beforeready.uk.dom');
+ UI.on('changed.uk.dom', function(e) {
+ UI.init(e.target);
+ UI.Utils.checkDisplay(e.target);
+ });
- UI.component.bootComponents();
+ UI.trigger('beforeready.uk.dom');
- // custom scroll observer
- requestAnimationFrame((function(){
+ UI.component.bootComponents();
- var memory = {x: window.pageXOffset, y:window.pageYOffset}, dir;
+ // custom scroll observer
+ requestAnimationFrame((function(){
- var fn = function(){
+ var memory = {x: window.pageXOffset, y:window.pageYOffset}, dir;
- if (memory.x != window.pageXOffset || memory.y != window.pageYOffset) {
+ var fn = function(){
- dir = {x: 0 , y: 0};
+ if (memory.x != window.pageXOffset || memory.y != window.pageYOffset) {
- 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;
+ dir = {x: 0 , y: 0};
- memory = {
- "dir": dir, "x": window.pageXOffset, "y": window.pageYOffset
- };
+ 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;
- UI.$doc.trigger('scrolling.uk.document', [memory]);
- }
+ memory = {
+ "dir": dir, "x": window.pageXOffset, "y": window.pageYOffset
+ };
- requestAnimationFrame(fn);
- };
+ UI.$doc.trigger('scrolling.uk.document', [memory]);
+ }
- if (UI.support.touch) {
- UI.$html.on('touchmove touchend MSPointerMove MSPointerUp pointermove pointerup', fn);
- }
+ requestAnimationFrame(fn);
+ };
- if (memory.x || memory.y) fn();
+ if (UI.support.touch) {
+ UI.$html.on('touchmove touchend MSPointerMove MSPointerUp pointermove pointerup', fn);
+ }
- return fn;
+ if (memory.x || memory.y) fn();
- })());
+ return fn;
- // run component init functions on dom
- UI.trigger('domready.uk.dom');
+ })());
- if (UI.support.touch) {
+ // run component init functions on dom
+ UI.trigger('domready.uk.dom');
- // remove css hover rules for touch devices
- // UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/);
+ if (UI.support.touch) {
- // viewport unit fix for uk-height-viewport - should be fixed in iOS 8
- if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
+ // remove css hover rules for touch devices
+ // UI.Utils.removeCssRules(/\.uk-(?!navbar).*:hover/);
- UI.$win.on('load orientationchange resize', UI.Utils.debounce((function(){
+ // viewport unit fix for uk-height-viewport - should be fixed in iOS 8
+ if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
- var fn = function() {
- $('.uk-height-viewport').css('height', window.innerHeight);
- return fn;
- };
+ UI.$win.on('load orientationchange resize', UI.Utils.debounce((function(){
- return fn();
+ var fn = function() {
+ $('.uk-height-viewport').css('height', window.innerHeight);
+ return fn;
+ };
- })(), 100));
+ return fn();
+
+ })(), 100));
+ }
}
+
+ UI.trigger('afterready.uk.dom');
+
+ // mark that domready is left behind
+ UI.domready = true;
+ };
+
+ if (document.readyState == 'complete' || document.readyState == 'interactive') {
+ setTimeout(domReady);
}
- UI.trigger('afterready.uk.dom');
+ return domReady;
- // mark that domready is left behind
- UI.domready = true;
- });
+ }());
// add touch identifier class
UI.$html.addClass(UI.support.touch ? "uk-touch" : "uk-notouch");
// add uk-hover class on tap to support overlays on touch devices
@@ -911,11 +925,12 @@
var stacks = [];
UI.component('stackMargin', {
defaults: {
- 'cls': 'uk-margin-small-top'
+ cls: 'uk-margin-small-top',
+ rowfirst: false
},
boot: function() {
// init code
@@ -963,14 +978,29 @@
stacks.push(this);
},
process: function() {
+ var $this = this;
+
this.columns = this.element.children();
UI.Utils.stackMargin(this.columns, this.options);
+ if (!this.options.rowfirst) {
+ return this;
+ }
+
+ // Mark first column elements
+ var pos_cache = this.columns.removeClass(this.options.rowfirst).filter(':visible').first().position();
+
+ if (pos_cache) {
+ this.columns.each(function() {
+ UI.$(this)[UI.$(this).position().left == pos_cache.left ? 'addClass':'removeClass']($this.options.rowfirst);
+ });
+ }
+
return this;
},
revert: function() {
this.columns.removeClass(this.options.cls);
@@ -1063,11 +1093,11 @@
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
- if (offset === false) return;
+ if (offset === false || elements.length == 1) return;
elements.each(function() {
var column = UI.$(this);
@@ -1433,11 +1463,11 @@
})();
if (!target) return;
if ($this.options.closest) {
- links.closest(clsClosest).removeClass(clsActive);
+ links.blur().closest(clsClosest).removeClass(clsActive);
navitems = links.filter("a[href='#"+target.attr("id")+"']").closest(clsClosest).addClass(clsActive);
} else {
navitems = links.removeClass(clsActive).filter("a[href='#"+target.attr("id")+"']").addClass(clsActive);
}
@@ -1995,10 +2025,13 @@
if ($this.remainIdle) {
clearTimeout($this.remainIdle);
}
if (active && active == $this) {
+ if (!$this.dropdown.find(e.target).length || $target.is(".uk-dropdown-close") || $target.parents(".uk-dropdown-close").length) {
+ $this.hide();
+ }
return;
}
if ($target.is("a[href='#']") || $target.parent().is("a[href='#']")){
e.preventDefault();
@@ -2403,11 +2436,12 @@
});
UI.component('gridMargin', {
defaults: {
- "cls": "uk-grid-margin"
+ cls : 'uk-grid-margin',
+ rowfirst : 'uk-row-first'
},
boot: function() {
// init code
@@ -2574,18 +2608,21 @@
// has scrollable?
var scrollable = this.dialog.find('.uk-overflow-container:visible:first');
if (scrollable.length) {
- scrollable.css("height", 0);
+ scrollable.css('height', 0);
- var offset = Math.abs(parseInt(this.dialog.css("margin-top"), 10)),
+ var offset = Math.abs(parseInt(this.dialog.css('margin-top'), 10)),
dh = this.dialog.outerHeight(),
wh = window.innerHeight,
h = wh - 2*(offset < 20 ? 20:offset) - dh;
- scrollable.css("height", h < this.options.minScrollHeight ? "":h);
+ scrollable.css({
+ 'max-height': (h < this.options.minScrollHeight ? '':h),
+ 'height':''
+ });
return true;
}
return false;
@@ -2595,23 +2632,23 @@
this.active = false;
if (activeCount > 0) activeCount--;
else activeCount = 0;
- this.element.hide().removeClass("uk-open");
+ this.element.hide().removeClass('uk-open');
// Update ARIA
this.element.attr('aria-hidden', 'true');
if (!activeCount) {
- $html.removeClass("uk-modal-page");
+ $html.removeClass('uk-modal-page');
body.css(this.paddingdir, "");
}
if(active===this) active = false;
- this.trigger("hide.uk.modal");
+ this.trigger('hide.uk.modal');
},
isActive: function() {
return this.active;
}
@@ -2707,22 +2744,25 @@
});
return modal.show();
};
- UI.modal.confirm = function(content, onconfirm, options) {
+ UI.modal.confirm = function(content, onconfirm, oncancel) {
+ var options = arguments.length > 1 && arguments[arguments.length-1] ? arguments[arguments.length-1] : {};
+
onconfirm = UI.$.isFunction(onconfirm) ? onconfirm : function(){};
- options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, options);
+ oncancel = UI.$.isFunction(oncancel) ? oncancel : function(){};
+ options = UI.$.extend(true, {bgclose:false, keyboard:false, modal:false, labels:UI.modal.labels}, UI.$.isFunction(options) ? {}:options);
var modal = UI.modal.dialog(([
'<div class="uk-margin uk-modal-content">'+String(content)+'</div>',
- '<div class="uk-modal-footer uk-text-right"><button class="uk-button uk-modal-close">'+options.labels.Cancel+'</button> <button class="uk-button uk-button-primary js-modal-confirm">'+options.labels.Ok+'</button></div>'
+ '<div class="uk-modal-footer uk-text-right"><button class="uk-button js-modal-confirm-cancel">'+options.labels.Cancel+'</button> <button class="uk-button uk-button-primary js-modal-confirm">'+options.labels.Ok+'</button></div>'
]).join(""), options);
- modal.element.find(".js-modal-confirm").on("click", function(){
- onconfirm();
+ modal.element.find(".js-modal-confirm, .js-modal-confirm-cancel").on("click", function(){
+ UI.$(this).is('.js-modal-confirm') ? onconfirm() : oncancel();
modal.hide();
});
modal.on('show.uk.modal', function(){
setTimeout(function(){
@@ -3045,11 +3085,11 @@
e.stopImmediatePropagation();
Offcanvas.hide();
});
- element.on("click", "a[href^='#']", function(e){
+ element.on("click", "a[href*='#']", function(e){
var link = UI.$(this),
href = link.attr("href");
if (href == "#") {
@@ -3059,19 +3099,19 @@
UI.$doc.one('hide.uk.offcanvas', function() {
var target;
try {
- target = UI.$(href);
+ target = UI.$(link[0].hash);
} catch (e){
- target = "";
+ target = '';
}
if (!target.length) {
- target = UI.$('[name="'+href.replace('#','')+'"]');
+ target = UI.$('[name="'+link[0].hash.replace('#','')+'"]');
}
- if (target.length && link.attr('data-uk-smooth-scroll') && UI.Utils.scrollToElement) {
+ if (target.length && UI.Utils.scrollToElement) {
UI.Utils.scrollToElement(target, UI.Utils.options(link.attr('data-uk-smooth-scroll') || '{}'));
} else {
window.location.href = href;
}
});