2019-08-14 01:50:35 +00:00
|
|
|
/*! UIkit 2.27.5 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
2016-03-06 00:50:22 +00:00
|
|
|
(function(UI) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
UI.component('buttonRadio', {
|
|
|
|
|
|
|
|
defaults: {
|
2018-05-05 13:35:10 +00:00
|
|
|
activeClass: 'uk-active',
|
|
|
|
target: '.uk-button'
|
2016-03-06 00:50:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
boot: function() {
|
|
|
|
|
|
|
|
// init code
|
2018-05-05 13:35:10 +00:00
|
|
|
UI.$html.on('click.buttonradio.uikit', '[data-uk-button-radio]', function(e) {
|
2016-03-06 00:50:22 +00:00
|
|
|
|
|
|
|
var ele = UI.$(this);
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
if (!ele.data('buttonRadio')) {
|
2016-03-06 00:50:22 +00:00
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
var obj = UI.buttonRadio(ele, UI.Utils.options(ele.attr('data-uk-button-radio'))),
|
2016-03-06 00:50:22 +00:00
|
|
|
target = UI.$(e.target);
|
|
|
|
|
|
|
|
if (target.is(obj.options.target)) {
|
2018-05-05 13:35:10 +00:00
|
|
|
target.trigger('click');
|
2016-03-06 00:50:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
var $this = this;
|
|
|
|
|
|
|
|
// Init ARIA
|
2018-05-05 13:35:10 +00:00
|
|
|
this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true');
|
2016-03-06 00:50:22 +00:00
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
this.on('click', this.options.target, function(e) {
|
2016-03-06 00:50:22 +00:00
|
|
|
|
|
|
|
var ele = UI.$(this);
|
|
|
|
|
|
|
|
if (ele.is('a[href="#"]')) e.preventDefault();
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
$this.find($this.options.target).not(ele).removeClass($this.options.activeClass).blur();
|
|
|
|
ele.addClass($this.options.activeClass);
|
2016-03-06 00:50:22 +00:00
|
|
|
|
|
|
|
// Update ARIA
|
|
|
|
$this.find($this.options.target).not(ele).attr('aria-checked', 'false');
|
|
|
|
ele.attr('aria-checked', 'true');
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
$this.trigger('change.uk.button', [ele]);
|
2016-03-06 00:50:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
getSelected: function() {
|
2018-05-05 13:35:10 +00:00
|
|
|
return this.find('.' + this.options.activeClass);
|
2016-03-06 00:50:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
UI.component('buttonCheckbox', {
|
|
|
|
|
|
|
|
defaults: {
|
2018-05-05 13:35:10 +00:00
|
|
|
activeClass: 'uk-active',
|
|
|
|
target: '.uk-button'
|
2016-03-06 00:50:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
boot: function() {
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
UI.$html.on('click.buttoncheckbox.uikit', '[data-uk-button-checkbox]', function(e) {
|
2016-03-06 00:50:22 +00:00
|
|
|
var ele = UI.$(this);
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
if (!ele.data('buttonCheckbox')) {
|
2016-03-06 00:50:22 +00:00
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
var obj = UI.buttonCheckbox(ele, UI.Utils.options(ele.attr('data-uk-button-checkbox'))),
|
2016-03-06 00:50:22 +00:00
|
|
|
target = UI.$(e.target);
|
|
|
|
|
|
|
|
if (target.is(obj.options.target)) {
|
2018-05-05 13:35:10 +00:00
|
|
|
target.trigger('click');
|
2016-03-06 00:50:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
var $this = this;
|
|
|
|
|
|
|
|
// Init ARIA
|
2018-05-05 13:35:10 +00:00
|
|
|
this.find($this.options.target).attr('aria-checked', 'false').filter('.' + $this.options.activeClass).attr('aria-checked', 'true');
|
2016-03-06 00:50:22 +00:00
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
this.on('click', this.options.target, function(e) {
|
2016-03-06 00:50:22 +00:00
|
|
|
var ele = UI.$(this);
|
|
|
|
|
|
|
|
if (ele.is('a[href="#"]')) e.preventDefault();
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
ele.toggleClass($this.options.activeClass).blur();
|
2016-03-06 00:50:22 +00:00
|
|
|
|
|
|
|
// Update ARIA
|
2018-05-05 13:35:10 +00:00
|
|
|
ele.attr('aria-checked', ele.hasClass($this.options.activeClass));
|
2016-03-06 00:50:22 +00:00
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
$this.trigger('change.uk.button', [ele]);
|
2016-03-06 00:50:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
getSelected: function() {
|
2018-05-05 13:35:10 +00:00
|
|
|
return this.find('.' + this.options.activeClass);
|
2016-03-06 00:50:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
UI.component('button', {
|
|
|
|
|
|
|
|
defaults: {},
|
|
|
|
|
|
|
|
boot: function() {
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
UI.$html.on('click.button.uikit', '[data-uk-button]', function(e) {
|
2016-03-06 00:50:22 +00:00
|
|
|
var ele = UI.$(this);
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
if (!ele.data('button')) {
|
2016-03-06 00:50:22 +00:00
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
var obj = UI.button(ele, UI.Utils.options(ele.attr('data-uk-button')));
|
|
|
|
ele.trigger('click');
|
2016-03-06 00:50:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
var $this = this;
|
|
|
|
|
|
|
|
// Init ARIA
|
|
|
|
this.element.attr('aria-pressed', this.element.hasClass("uk-active"));
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
this.on('click', function(e) {
|
2016-03-06 00:50:22 +00:00
|
|
|
|
|
|
|
if ($this.element.is('a[href="#"]')) e.preventDefault();
|
|
|
|
|
|
|
|
$this.toggle();
|
2018-05-05 13:35:10 +00:00
|
|
|
$this.trigger('change.uk.button', [$this.element.blur().hasClass('uk-active')]);
|
2016-03-06 00:50:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
toggle: function() {
|
2018-05-05 13:35:10 +00:00
|
|
|
this.element.toggleClass('uk-active');
|
2016-03-06 00:50:22 +00:00
|
|
|
|
|
|
|
// Update ARIA
|
2018-05-05 13:35:10 +00:00
|
|
|
this.element.attr('aria-pressed', this.element.hasClass('uk-active'));
|
2016-03-06 00:50:22 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-05-05 13:35:10 +00:00
|
|
|
})(UIkit2);
|