');
this.responsivetab.dropdown = this.responsivetab.find('.uk-dropdown');
this.responsivetab.lst = this.responsivetab.dropdown.find('ul');
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.uk.tab', 'a', function(e) {
e.preventDefault();
e.stopPropagation();
var link = UI.$(this);
$this.element.children('li:not(.uk-tab-responsive)').eq(link.data('index')).trigger('click');
});
this.on('show.uk.switcher change.uk.tab', function(e, tab) {
$this.responsivetab.caption.html(tab.text());
});
this.element.append(this.responsivetab);
// init UIkit components
if (this.options.connect) {
this.switcher = UI.switcher(this.element, {
toggle : '>li:not(.uk-tab-responsive)',
connect : this.options.connect,
active : this.options.active,
animation : this.options.animation,
duration : this.options.duration,
swiping : this.options.swiping
});
}
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();
UI.$win.on('resize orientationchange', UI.Utils.debounce(function(){
if ($this.element.is(':visible')) $this.check();
}, 100));
this.on('display.uk.check', function(){
if ($this.element.is(':visible')) $this.check();
});
},
check: function() {
var children = this.element.children('li:not(.uk-tab-responsive)').removeClass('uk-hidden');
if (!children.length) {
this.responsivetab.addClass('uk-hidden');
return;
}
var top = (children.eq(0).offset().top + Math.ceil(children.eq(0).height()/2)),
doresponsive = false,
item, link, clone;
this.responsivetab.lst.empty();
children.each(function(){
if (UI.$(this).offset().top > top) {
doresponsive = true;
}
});
if (doresponsive) {
for (var i = 0; i < children.length; i++) {
item = UI.$(children.eq(i));
link = item.find('a');
if (item.css('float') != 'none' && !item.attr('uk-dropdown')) {
if (!item.hasClass('uk-disabled')) {
clone = UI.$(item[0].outerHTML);
clone.find('a').data('index', i);
this.responsivetab.lst.append(clone);
}
item.addClass('uk-hidden');
}
}
}
this.responsivetab[this.responsivetab.lst.children('li').length ? 'removeClass':'addClass']('uk-hidden');
}
});
})(UIkit);
(function(UI){
"use strict";
UI.component('cover', {
defaults: {
automute : true
},
boot: function() {
// auto init
UI.ready(function(context) {
UI.$('[data-uk-cover]', context).each(function(){
var ele = UI.$(this);
if(!ele.data('cover')) {
var plugin = UI.cover(ele, UI.Utils.options(ele.attr('data-uk-cover')));
}
});
});
},
init: function() {
this.parent = this.element.parent();
UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(){
this.check();
}.bind(this), 100));
this.on('display.uk.check', function(e) {
if (this.element.is(':visible')) this.check();
}.bind(this));
this.check();
if (this.element.is('iframe') && this.options.automute) {
var src = this.element.attr('src');
this.element.attr('src', '').on('load', function(){
this.contentWindow.postMessage('{ "event": "command", "func": "mute", "method":"setVolume", "value":0}', '*');
}).attr('src', [src, (src.indexOf('?') > -1 ? '&':'?'), 'enablejsapi=1&api=1'].join(''));
}
},
check: function() {
this.element.css({ width : '', height : '' });
this.dimension = {w: this.element.width(), h: this.element.height()};
if (this.element.attr('width') && !isNaN(this.element.attr('width'))) {
this.dimension.w = this.element.attr('width');
}
if (this.element.attr('height') && !isNaN(this.element.attr('height'))) {
this.dimension.h = this.element.attr('height');
}
this.ratio = this.dimension.w / this.dimension.h;
var w = this.parent.width(), h = this.parent.height(), width, height;
// if element height < parent height (gap underneath)
if ((w / this.ratio) < h) {
width = Math.ceil(h * this.ratio);
height = h;
// element width < parent width (gap to right)
} else {
width = w;
height = Math.ceil(w / this.ratio);
}
this.element.css({ width : width, height : height });
}
});
})(UIkit);