| 1 |
define([ |
| 2 |
"dojo/_base/array", |
| 3 |
"dojo/_base/declare", |
| 4 |
"dojo/dom-class", |
| 5 |
"dojo/query!css2", |
| 6 |
"./CheckedMenuItem", |
| 7 |
"./registry" |
| 8 |
], function(array, declare, domClass, query, CheckedMenuItem, registry){ |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
return declare("dijit.RadioButtonMenuItem", CheckedMenuItem, { |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
baseClass: "dijitMenuItem dijitRadioMenuItem", |
| 19 |
|
| 20 |
role: "menuitemradio", |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
checkedChar: "*", |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
group: "", |
| 29 |
_setGroupAttr: "domNode", |
| 30 |
|
| 31 |
_setCheckedAttr: function( checked){ |
| 32 |
|
| 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 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 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 |
|
| 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 |
}); |