updated Uikit v2
This commit is contained in:
@@ -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,7 @@
|
||||
|
||||
defaults: {
|
||||
connect : false,
|
||||
toggle : ">*",
|
||||
toggle : '>*',
|
||||
active : 0,
|
||||
animation : false,
|
||||
duration : 200,
|
||||
@@ -23,11 +23,11 @@
|
||||
// init code
|
||||
UI.ready(function(context) {
|
||||
|
||||
UI.$("[data-uk-switcher]", context).each(function() {
|
||||
UI.$('[data-uk-switcher]', context).each(function() {
|
||||
var switcher = UI.$(this);
|
||||
|
||||
if (!switcher.data("switcher")) {
|
||||
var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr("data-uk-switcher")));
|
||||
if (!switcher.data('switcher')) {
|
||||
var obj = UI.switcher(switcher, UI.Utils.options(switcher.attr('data-uk-switcher')));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -37,74 +37,72 @@
|
||||
|
||||
var $this = this;
|
||||
|
||||
this.on("click.uk.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) {
|
||||
if (!this.options.connect) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.connect = UI.$(this.options.connect);
|
||||
this.connect = UI.$(this.options.connect);
|
||||
|
||||
this.connect.find(".uk-active").removeClass(".uk-active");
|
||||
if (!this.connect.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// delegate switch commands within container content
|
||||
if (this.connect.length) {
|
||||
this.connect.on('click.uk.switcher', '[data-uk-switcher-item]', function(e) {
|
||||
|
||||
// Init ARIA for connect
|
||||
this.connect.children().attr('aria-hidden', 'true');
|
||||
e.preventDefault();
|
||||
|
||||
this.connect.on("click", '[data-uk-switcher-item]', function(e) {
|
||||
var item = UI.$(this).attr('data-uk-switcher-item');
|
||||
|
||||
e.preventDefault();
|
||||
if ($this.index == item) return;
|
||||
|
||||
var item = UI.$(this).attr('data-uk-switcher-item');
|
||||
switch(item) {
|
||||
case 'next':
|
||||
case 'previous':
|
||||
$this.show($this.index + (item=='next' ? 1:-1));
|
||||
break;
|
||||
default:
|
||||
$this.show(parseInt(item, 10));
|
||||
}
|
||||
});
|
||||
|
||||
if ($this.index == item) return;
|
||||
if (this.options.swiping) {
|
||||
|
||||
switch(item) {
|
||||
case 'next':
|
||||
case 'previous':
|
||||
$this.show($this.index + (item=='next' ? 1:-1));
|
||||
break;
|
||||
default:
|
||||
$this.show(parseInt(item, 10));
|
||||
}
|
||||
});
|
||||
|
||||
if (this.options.swiping) {
|
||||
|
||||
this.connect.on('swipeRight swipeLeft', function(e) {
|
||||
e.preventDefault();
|
||||
if(!window.getSelection().toString()) {
|
||||
$this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1));
|
||||
}
|
||||
});
|
||||
this.connect.on('swipeRight swipeLeft', function(e) {
|
||||
e.preventDefault();
|
||||
if (!window.getSelection().toString()) {
|
||||
$this.show($this.index + (e.type == 'swipeLeft' ? 1 : -1));
|
||||
}
|
||||
}
|
||||
|
||||
var toggles = this.find(this.options.toggle),
|
||||
active = toggles.filter(".uk-active");
|
||||
|
||||
if (active.length) {
|
||||
this.show(active, false);
|
||||
} else {
|
||||
|
||||
if (this.options.active===false) return;
|
||||
|
||||
active = toggles.eq(this.options.active);
|
||||
this.show(active.length ? active : toggles.eq(0), false);
|
||||
}
|
||||
|
||||
// Init ARIA for toggles
|
||||
toggles.not(active).attr('aria-expanded', 'false');
|
||||
active.attr('aria-expanded', 'true');
|
||||
|
||||
this.on('changed.uk.dom', function() {
|
||||
$this.connect = UI.$($this.options.connect);
|
||||
});
|
||||
}
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
update: function() {
|
||||
|
||||
this.connect.children().removeClass('uk-active').attr('aria-hidden', 'true');
|
||||
|
||||
var toggles = this.find(this.options.toggle),
|
||||
active = toggles.filter('.uk-active');
|
||||
|
||||
if (active.length) {
|
||||
this.show(active, false);
|
||||
} else {
|
||||
|
||||
if (this.options.active===false) return;
|
||||
|
||||
active = toggles.eq(this.options.active);
|
||||
this.show(active.length ? active : toggles.eq(0), false);
|
||||
}
|
||||
|
||||
// Init ARIA for toggles
|
||||
toggles.not(active).attr('aria-expanded', 'false');
|
||||
active.attr('aria-expanded', 'true');
|
||||
},
|
||||
|
||||
show: function(tab, animate) {
|
||||
@@ -113,18 +111,16 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var toggles = this.find(this.options.toggle);
|
||||
|
||||
if (isNaN(tab)) {
|
||||
tab = UI.$(tab);
|
||||
} else {
|
||||
|
||||
var toggles = this.find(this.options.toggle);
|
||||
|
||||
tab = tab < 0 ? toggles.length-1 : tab;
|
||||
tab = toggles.eq(toggles[tab] ? tab : 0);
|
||||
}
|
||||
|
||||
var $this = this,
|
||||
toggles = this.find(this.options.toggle),
|
||||
active = UI.$(tab),
|
||||
animation = Animations[this.options.animation] || function(current, next) {
|
||||
|
||||
@@ -277,7 +273,9 @@
|
||||
|
||||
next.addClass(clsIn).one(UI.support.animation.end, function() {
|
||||
|
||||
next.removeClass(''+clsIn+'').css({opacity:'', display:''});
|
||||
setTimeout(function () {
|
||||
next.removeClass(''+clsIn+'').css({opacity:'', display:''});
|
||||
}, 0);
|
||||
|
||||
d.resolve();
|
||||
|
||||
@@ -306,4 +304,4 @@
|
||||
return d.promise();
|
||||
}
|
||||
|
||||
})(UIkit);
|
||||
})(UIkit2);
|
||||
|
Reference in New Issue
Block a user