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
57
hui.ui.Radiobuttons = function(options) {
this.options = options;
this.element = hui.get(options.element);
this.name = options.name;
this.radios = [];
this.value = options.value;
this.defaultValue = this.value;
this.enabled = true;
hui.ui.extend(this);
};
hui.ui.Radiobuttons.prototype = {
updateUI : function() {
for (var i=0; i < this.radios.length; i++) {
var radio = this.radios[i];
hui.cls.set(hui.get(radio.id),'hui_radiobutton_selected',radio.value==this.value);
}
},
setValue : function(value) {
this.value = value;
this.updateUI();
},
getValue : function() {
if (!this.enabled) {
return null;
}
return this.value;
},
reset : function() {
this.setValue(this.defaultValue);
},
setEnabled : function(enabled) {
this.enabled = !!enabled;
hui.cls.set(this.element,'hui_radiobuttons_disabled',!this.enabled);
},
registerRadiobutton : function(radio) {
this.radios.push(radio);
var element = hui.get(radio.id);
var self = this;
element.onclick = function() {
if (!self.enabled) {
return;
}
self.setValue(radio.value);
self.fire('valueChanged',radio.value);
hui.ui.callAncestors(self,'childValueChanged',radio.value);
};
}
};