-
Notifications
You must be signed in to change notification settings - Fork 45
/
RadioMenuItem.js
64 lines (51 loc) · 1.81 KB
/
RadioMenuItem.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
57
58
59
60
61
62
63
64
define([
"dojo/_base/declare", // declare
"dojo/dom-class", // domClass.toggle
"./CheckedMenuItem"
], function(declare, domClass, CheckedMenuItem){
// module:
// dijit/RadioButtonMenuItem
return declare("dijit.RadioButtonMenuItem", CheckedMenuItem, {
// summary:
// A radio-button-like menu item for toggling on and off
baseClass: "dijitRadioMenuItem",
role: "menuitemradio",
// checkedChar: String
// Character (or string) used in place of radio button icon when display in high contrast mode
checkedChar: "*",
// group: String
// Toggling on a RadioMenuItem in a given group toggles off the other RadioMenuItems in that group.
group: "",
// mapping from group name to checked widget within that group (or null if no widget is checked)
_currentlyChecked: {},
_setCheckedAttr: function(/*Boolean*/ checked){
// summary:
// Hook so attr('checked', bool) works.
// Sets the class and state for the check box.
if(checked && this.group && this._currentlyChecked[this.group] && this._currentlyChecked[this.group] != this){
// if another RadioMenuItem in my group is checked, uncheck it
this._currentlyChecked[this.group].set("checked", false);
}
this.inherited(arguments);
// set the currently checked widget to this, or null if we are clearing the currently checked widget
if(this.group){
if(checked){
this._currentlyChecked[this.group] = this;
}else if(this._currentlyChecked[this.group] == this){
this._currentlyChecked[this.group] = null;
}
}
},
_onClick: function(evt){
// summary:
// Clicking this item toggles it on. If it's already on, then clicking does nothing.
// tags:
// private
if(!this.disabled && !this.checked){
this.set("checked", true);
this.onChange(true);
}
this.onClick(evt);
}
});
});