/
checkbox.js
39 lines (35 loc) · 981 Bytes
/
checkbox.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
35
36
37
38
39
/**
* @module checkbox
*/
modules.define('checkbox', ['i-bem__dom', 'control'], function(provide, BEMDOM, Control) {
/**
* @exports
* @class checkbox
* @augments control
* @bem
*/
provide(BEMDOM.decl({ block : this.name, baseBlock : Control }, /** @lends checkbox.prototype */{
onSetMod : {
'checked' : {
'true' : function() {
this.elem('control')
.attr('checked', true)
.prop('checked', true);
},
'' : function() {
this.elem('control')
.removeAttr('checked')
.prop('checked', false);
}
}
},
_onChange : function() {
this.setMod('checked', this.elem('control').prop('checked'));
}
}, /** @lends checkbox */{
live : function() {
this.liveBindTo('control', 'change', this.prototype._onChange);
return this.__base.apply(this, arguments);
}
}));
});