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