forked from fex-team/kityminder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuix.js
45 lines (41 loc) · 1.25 KB
/
fuix.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
/**
* @fileOverview
*
* 拓展 FUI 组件的功能
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
kity.extendClass(FUI.Widget, {
setEnable: function(value) {
if (value === false) this.disable();
else this.enable();
},
setActive: function(value) {
if (value === false) this.removeClass('active');
else this.addClass('active');
},
bindExecution: function(event, fn) {
var widget = this;
widget.on(event, function() {
if (widget.interactFlag) return;
fn.apply(widget, arguments);
});
},
bindCommandState: function(minder, command, valueHandle) {
var widget = this;
minder.on('interactchange', function() {
widget.interactFlag = true;
if (valueHandle) {
var value = this.queryCommandValue(command);
if (value != widget.lastHandleCommandValue) {
valueHandle.call(widget, value);
widget.lastHandleCommandValue = value;
}
}
widget.setEnable(this.queryCommandState(command) !== -1);
widget.setActive(this.queryCommandState(command) === 1);
widget.interactFlag = false;
});
}
});