-
Notifications
You must be signed in to change notification settings - Fork 89
/
checkbox_type_button.js
56 lines (50 loc) · 1.66 KB
/
checkbox_type_button.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @module checkbox
*/
modules.define('checkbox', ['button'], function(provide, _, Checkbox) {
/**
* @exports
* @class checkbox
* @bem
*/
provide(Checkbox.decl({ modName : 'type', modVal : 'button' }, /** @lends checkbox.prototype */{
onSetMod : {
'js' : {
'inited' : function() {
this.__base.apply(this, arguments);
this._button = this.findBlockInside('button')
.on(
{ modName : 'checked', modVal : '*' },
proxyModFromButton,
this)
.on(
{ modName : 'focused', modVal : '*' },
proxyModFromButton,
this);
}
},
'checked' : function(_, checked) {
proxyModToButton.apply(this, arguments);
this._button.domElem
.removeAttr('aria-pressed') // checkbox accepts aria-checked instead of aria-pressed
.attr('aria-checked', !!checked);
},
'disabled' : proxyModToButton,
'focused' : function(modName, modVal) {
proxyModToButton.call(this, modName, modVal, false);
}
}
}, /** @lends checkbox */{
live : function() {
this.liveInitOnBlockInsideEvent({ modName : 'js', modVal : 'inited' }, 'button');
return this.__base.apply(this, arguments);
}
}));
function proxyModToButton(modName, modVal, callBase) {
callBase !== false && this.__base.apply(this, arguments);
this._button.setMod(modName, modVal);
}
function proxyModFromButton(_, data) {
this.setMod(data.modName, data.modVal);
}
});