Updated the footable Lib.

This commit is contained in:
2016-03-19 03:51:35 +02:00
parent 1cad434a39
commit 3bc71a935c
801 changed files with 8543 additions and 3032 deletions

View File

@@ -1,19 +1,66 @@
/*! UIkit 2.21.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*! UIkit 2.25.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(UI) {
"use strict";
var active = false, hoverIdle;
var active = false, hoverIdle, flips = {
'x': {
"bottom-left" : 'bottom-right',
"bottom-right" : 'bottom-left',
"bottom-center" : 'bottom-center',
"top-left" : 'top-right',
"top-right" : 'top-left',
"top-center" : 'top-center',
"left-top" : 'right-top',
"left-bottom" : 'right-bottom',
"left-center" : 'right-center',
"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" : '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', {
defaults: {
'mode' : 'hover',
'remaintime' : 800,
'justify' : false,
'boundary' : UI.$win,
'delay' : 0,
'hoverDelayIdle' : 250
'mode' : 'hover',
'pos' : 'bottom-left',
'offset' : 0,
'remaintime' : 800,
'justify' : false,
'boundary' : UI.$win,
'delay' : 0,
'dropdownSelector': '.uk-dropdown,.uk-dropdown-blank',
'hoverDelayIdle' : 250,
'preventflip' : false
},
remainIdle: false,
@@ -35,7 +82,7 @@
dropdown.element.trigger(triggerevent);
}
if (dropdown.element.find('.uk-dropdown').length) {
if (dropdown.element.find(dropdown.options.dropdownSelector).length) {
e.preventDefault();
}
}
@@ -46,29 +93,43 @@
var $this = this;
this.dropdown = this.find('.uk-dropdown');
this.dropdown = this.find(this.options.dropdownSelector);
this.offsetParent = this.dropdown.parents().filter(function() {
return UI.$.inArray(UI.$(this).css('position'), ['relative', 'fixed', 'absolute']) !== -1;
}).slice(0,1);
this.centered = this.dropdown.hasClass('uk-dropdown-center');
this.justified = this.options.justify ? UI.$(this.options.justify) : false;
this.boundary = UI.$(this.options.boundary);
this.flipped = this.dropdown.hasClass('uk-dropdown-flip');
if (!this.boundary.length) {
this.boundary = UI.$win;
}
// legacy DEPRECATED!
if (this.dropdown.hasClass('uk-dropdown-up')) {
this.options.pos = 'top-left';
}
if (this.dropdown.hasClass('uk-dropdown-flip')) {
this.options.pos = this.options.pos.replace('left','right');
}
if (this.dropdown.hasClass('uk-dropdown-center')) {
this.options.pos = this.options.pos.replace(/(left|right)/,'center');
}
//-- end legacy
// Init ARIA
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(".uk-dropdown").length) {
if (!$target.parents($this.options.dropdownSelector).length) {
if ($target.is("a[href='#']") || $target.parent().is("a[href='#']") || ($this.dropdown.length && !$this.dropdown.is(":visible")) ){
e.preventDefault();
@@ -83,7 +144,7 @@
} else {
if ($target.is("a:not(.js-uk-prevent)") || $target.is(".uk-dropdown-close") || !$this.dropdown.find(e.target).length) {
if (!$this.dropdown.find(e.target).length || $target.is(".uk-dropdown-close") || $target.parents(".uk-dropdown-close").length) {
$this.hide();
}
}
@@ -93,6 +154,8 @@
this.on("mouseenter", function(e) {
$this.trigger('pointerenter.uk.dropdown', [$this]);
if ($this.remainIdle) {
clearTimeout($this.remainIdle);
}
@@ -127,6 +190,8 @@
if (active && active == $this) $this.hide();
}, $this.options.remaintime);
$this.trigger('pointerleave.uk.dropdown', [$this]);
}).on("click", function(e){
var $target = UI.$(e.target);
@@ -135,6 +200,13 @@
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();
}
@@ -149,13 +221,15 @@
UI.$html.off("click.outer.dropdown");
if (active && active != this) {
active.hide();
active.hide(true);
}
if (hoverIdle) {
clearTimeout(hoverIdle);
}
this.trigger('beforeshow.uk.dropdown', [this]);
this.checkDimensions();
this.element.addClass('uk-open');
@@ -170,7 +244,10 @@
this.registerOuterClick();
},
hide: function() {
hide: function(force) {
this.trigger('beforehide.uk.dropdown', [this, force]);
this.element.removeClass('uk-open');
if (this.remainIdle) {
@@ -182,7 +259,7 @@
// Update ARIA
this.element.attr('aria-expanded', 'false');
this.trigger('hide.uk.dropdown', [this]);
this.trigger('hide.uk.dropdown', [this, force]);
if (active == this) active = false;
},
@@ -203,8 +280,8 @@
var $target = UI.$(e.target);
if (active == $this && ($target.is("a:not(.js-uk-prevent)") || $target.is(".uk-dropdown-close") || !$this.dropdown.find(e.target).length)) {
$this.hide();
if (active == $this && !$this.element.find(e.target).length) {
$this.hide(true);
UI.$html.off("click.outer.dropdown");
}
});
@@ -215,82 +292,234 @@
if (!this.dropdown.length) return;
// reset
this.dropdown.removeClass('uk-dropdown-top uk-dropdown-bottom uk-dropdown-left uk-dropdown-right uk-dropdown-stack').css({
'top-left':'',
'left':'',
'margin-left' :'',
'margin-right':''
});
if (this.justified && this.justified.length) {
this.dropdown.css("min-width", "");
}
var $this = this,
dropdown = this.dropdown.css("margin-" + UI.langdirection, ""),
offset = dropdown.show().offset(),
width = dropdown.outerWidth(),
var $this = this,
pos = UI.$.extend({}, this.offsetParent.offset(), {width: this.offsetParent[0].offsetWidth, height: this.offsetParent[0].offsetHeight}),
posoffset = this.options.offset,
dropdown = this.dropdown,
offset = dropdown.show().offset() || {left: 0, top: 0},
width = dropdown.outerWidth(),
height = dropdown.outerHeight(),
boundarywidth = this.boundary.width(),
boundaryoffset = this.boundary.offset() ? this.boundary.offset().left:0;
boundaryoffset = this.boundary[0] !== window && this.boundary.offset() ? this.boundary.offset(): {top:0, left:0},
dpos = this.options.pos;
// centered dropdown
if (this.centered) {
dropdown.css("margin-" + UI.langdirection, (parseFloat(width) / 2 - dropdown.parent().width() / 2) * -1);
offset = dropdown.offset();
var variants = {
"bottom-left" : {top: 0 + pos.height + posoffset, left: 0},
"bottom-right" : {top: 0 + pos.height + posoffset, left: 0 + pos.width - width},
"bottom-center" : {top: 0 + pos.height + posoffset, left: 0 + pos.width / 2 - width / 2},
"top-left" : {top: 0 - height - posoffset, left: 0},
"top-right" : {top: 0 - height - posoffset, left: 0 + pos.width - width},
"top-center" : {top: 0 - height - posoffset, left: 0 + pos.width / 2 - width / 2},
"left-top" : {top: 0, left: 0 - width - posoffset},
"left-bottom" : {top: 0 + pos.height - height, left: 0 - width - posoffset},
"left-center" : {top: 0 + pos.height / 2 - height / 2, left: 0 - width - posoffset},
"right-top" : {top: 0, left: 0 + pos.width + posoffset},
"right-bottom" : {top: 0 + pos.height - height, left: 0 + pos.width + posoffset},
"right-center" : {top: 0 + pos.height / 2 - height / 2, left: 0 + pos.width + posoffset}
},
css = {},
pp;
// reset dropdown
if ((width + offset.left) > boundarywidth || offset.left < 0) {
dropdown.css("margin-" + UI.langdirection, "");
offset = dropdown.offset();
}
}
pp = dpos.split('-');
css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
// justify dropdown
if (this.justified && this.justified.length) {
justify(dropdown.css({left:0}), this.justified, boundarywidth);
} else {
var jwidth = this.justified.outerWidth();
if (this.options.preventflip !== true) {
dropdown.css("min-width", jwidth);
var fdpos;
if (UI.langdirection == 'right') {
var right1 = boundarywidth - (this.justified.offset().left + jwidth),
right2 = boundarywidth - (dropdown.offset().left + dropdown.outerWidth());
dropdown.css("margin-right", right1 - right2);
} else {
dropdown.css("margin-left", this.justified.offset().left - offset.left);
}
offset = dropdown.offset();
}
if ((width + (offset.left-boundaryoffset)) > boundarywidth) {
dropdown.addClass('uk-dropdown-flip');
offset = dropdown.offset();
}
if ((offset.left-boundaryoffset) < 0) {
dropdown.addClass("uk-dropdown-stack");
if (dropdown.hasClass('uk-dropdown-flip')) {
if (!this.flipped) {
dropdown.removeClass('uk-dropdown-flip');
offset = dropdown.offset();
dropdown.addClass('uk-dropdown-flip');
switch(this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
case "x":
if(this.options.preventflip !=='x') fdpos = flips['x'][dpos] || 'right-top';
break;
case "y":
if(this.options.preventflip !=='y') fdpos = flips['y'][dpos] || 'top-left';
break;
case "xy":
if(!this.options.preventflip) fdpos = flips['xy'][dpos] || 'right-bottom';
break;
}
setTimeout(function(){
if (fdpos) {
if ((dropdown.offset().left-boundaryoffset) < 0 || !$this.flipped && (dropdown.outerWidth() + (offset.left-boundaryoffset)) < boundarywidth) {
dropdown.removeClass('uk-dropdown-flip');
pp = fdpos.split('-');
css = variants[fdpos] ? variants[fdpos] : variants['bottom-left'];
// check flipped
if (this.checkBoundary(pos.left + css.left, pos.top + css.top, width, height, boundarywidth)) {
pp = dpos.split('-');
css = variants[dpos] ? variants[dpos] : variants['bottom-left'];
}
}, 0);
}
}
}
if (width > boundarywidth) {
dropdown.addClass("uk-dropdown-stack");
this.trigger('stack.uk.dropdown', [this]);
}
dropdown.css("display", "");
dropdown.css(css).css("display", "").addClass('uk-dropdown-'+pp[0]);
},
checkBoundary: function(left, top, width, height, boundarywidth) {
var axis = "";
if (left < 0 || ((left - UI.$win.scrollLeft())+width) > boundarywidth) {
axis += "x";
}
if ((top - UI.$win.scrollTop()) < 0 || ((top - UI.$win.scrollTop())+height) > window.innerHeight) {
axis += "y";
}
return axis;
}
});
UI.component('dropdownOverlay', {
defaults: {
'justify' : false,
'cls' : '',
'duration': 200
},
boot: function() {
// init code
UI.ready(function(context) {
UI.$("[data-uk-dropdown-overlay]", context).each(function() {
var ele = UI.$(this);
if (!ele.data("dropdownOverlay")) {
UI.dropdownOverlay(ele, UI.Utils.options(ele.attr("data-uk-dropdown-overlay")));
}
});
});
},
init: function() {
var $this = this;
this.justified = this.options.justify ? UI.$(this.options.justify) : false;
this.overlay = this.element.find('uk-dropdown-overlay');
if (!this.overlay.length) {
this.overlay = UI.$('<div class="uk-dropdown-overlay"></div>').appendTo(this.element);
}
this.overlay.addClass(this.options.cls);
this.on({
'beforeshow.uk.dropdown': function(e, dropdown) {
$this.dropdown = dropdown;
if ($this.justified && $this.justified.length) {
justify($this.overlay.css({'display':'block', 'margin-left':'','margin-right':''}), $this.justified, $this.justified.outerWidth());
}
},
'show.uk.dropdown': function(e, dropdown) {
var h = $this.dropdown.dropdown.outerHeight(true);
$this.dropdown.element.removeClass('uk-open');
$this.overlay.stop().css('display', 'block').animate({height: h}, $this.options.duration, function() {
$this.dropdown.dropdown.css('visibility', '');
$this.dropdown.element.addClass('uk-open');
UI.Utils.checkDisplay($this.dropdown.dropdown, true);
});
$this.pointerleave = false;
},
'hide.uk.dropdown': function() {
$this.overlay.stop().animate({height: 0}, $this.options.duration);
},
'pointerenter.uk.dropdown': function(e, dropdown) {
clearTimeout($this.remainIdle);
},
'pointerleave.uk.dropdown': function(e, dropdown) {
$this.pointerleave = true;
}
});
this.overlay.on({
'mouseenter': function() {
if ($this.remainIdle) {
clearTimeout($this.dropdown.remainIdle);
clearTimeout($this.remainIdle);
}
},
'mouseleave': function(){
if ($this.pointerleave && active) {
$this.remainIdle = setTimeout(function() {
if(active) active.hide();
}, active.options.remaintime);
}
}
})
}
});
function justify(ele, justifyTo, boundarywidth, offset) {
ele = UI.$(ele);
justifyTo = UI.$(justifyTo);
boundarywidth = boundarywidth || window.innerWidth;
offset = offset || ele.offset();
if (justifyTo.length) {
var jwidth = justifyTo.outerWidth();
ele.css("min-width", jwidth);
if (UI.langdirection == 'right') {
var right1 = boundarywidth - (justifyTo.offset().left + jwidth),
right2 = boundarywidth - (ele.offset().left + ele.outerWidth());
ele.css("margin-right", right1 - right2);
} else {
ele.css("margin-left", justifyTo.offset().left - offset.left);
}
}
}
})(UIkit);