forked from olton/Metro-UI-CSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttonset.js
34 lines (29 loc) · 845 Bytes
/
buttonset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(function($){
$.fn.ButtonSet = function( options ){
var defaults = {
};
var $this = $(this)
, $buttons = $this.find("button")
;
var initButtons = function(buttons){
buttons.on('click', function(e){
e.preventDefault();
var $a = $(this);
if ( $a.hasClass('active') ) return false;
$buttons.removeClass("active");
$(this).addClass("active");
});
}
return this.each(function(){
if ( options ) {
$.extend(defaults, options)
}
initButtons($buttons);
});
}
$(function () {
$('[data-role="button-set"]').each(function () {
$(this).ButtonSet();
})
})
})(window.jQuery);