Debian Codegraph @

dijit/RadioMenuItem.js

raw symbols SCIP
1 define([
2 "dojo/_base/array", // array.forEach
3 "dojo/_base/declare", // declare
4 "dojo/dom-class", // domClass.toggle
5 "dojo/query!css2", // query
6 "./CheckedMenuItem",
7 "./registry" // registry.getEnclosingWidget
8 ], function(array, declare, domClass, query, CheckedMenuItem, registry){
9
10 // module:
11 // dijit/RadioButtonMenuItem
12
13 return declare("dijit.RadioButtonMenuItem", CheckedMenuItem, {
14 // summary:
15 // A radio-button-like menu item for toggling on and off
16
17 // Use both base classes so we get styles like dijitMenuItemDisabled
18 baseClass: "dijitMenuItem dijitRadioMenuItem",
19
20 role: "menuitemradio",
21
22 // checkedChar: String
23 // Character (or string) used in place of radio button icon when display in high contrast mode
24 checkedChar: "*",
25
26 // group: String
27 // Toggling on a RadioMenuItem in a given group toggles off the other RadioMenuItems in that group.
28 group: "",
29 _setGroupAttr: "domNode", // needs to be set as an attribute so dojo/query can find it
30
31 _setCheckedAttr: function(/*Boolean*/ checked){
32 // If I am being checked then have to deselect currently checked items
33 this.inherited(arguments);
34 if(!this._created){
35 return;
36 }
37 if(checked && this.group){
38 array.forEach(this._getRelatedWidgets(), function(widget){
39 if(widget != this && widget.checked){
40 widget.set('checked', false);
41 }
42 }, this);
43 }
44 },
45
46 _onClick: function(evt){
47 // summary:
48 // Clicking this item toggles it on. If it's already on, then clicking does nothing.
49 // tags:
50 // private
51
52 if(!this.disabled && !this.checked){
53 this.set("checked", true);
54 this.onChange(true);
55 }
56 this.onClick(evt);
57 },
58
59 _getRelatedWidgets: function(){
60 // Private function needed to help iterate over all radio menu items in a group.
61 var ary = [];
62 query("[group=" + this.group + "][role=" + this.role + "]").forEach(
63 function(menuItemNode){
64 var widget = registry.getEnclosingWidget(menuItemNode);
65 if(widget){
66 ary.push(widget);
67 }
68 }
69 );
70 return ary;
71 }
72 });
73 });