]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_RadioButtonMixin.js.uncompressed.js
1 define("dijit/form/_RadioButtonMixin", [
2 "dojo/_base/array", // array.forEach
3 "dojo/_base/declare", // declare
4 "dojo/dom-attr", // domAttr.set
5 "dojo/_base/event", // event.stop
6 "dojo/_base/lang", // lang.hitch
8 "dojo/_base/window", // win.doc
9 "../registry" // registry.getEnclosingWidget
10 ], function(array
, declare
, domAttr
, event
, lang
, query
, win
, registry
){
13 // dijit/form/_RadioButtonMixin
15 // Mixin to provide widget functionality for an HTML radio button
17 return declare("dijit.form._RadioButtonMixin", null, {
19 // Mixin to provide widget functionality for an HTML radio button
21 // type: [private] String
22 // type attribute on <input> node.
23 // Users should not change this value.
26 _getRelatedWidgets: function(){
27 // Private function needed to help iterate over all radio buttons in a group.
29 query("input[type=radio]", this.focusNode
.form
|| win
.doc
).forEach( // can't use name= since query doesn't support [] in the name
30 lang
.hitch(this, function(inputNode
){
31 if(inputNode
.name
== this.name
&& inputNode
.form
== this.focusNode
.form
){
32 var widget
= registry
.getEnclosingWidget(inputNode
);
42 _setCheckedAttr: function(/*Boolean*/ value
){
43 // If I am being checked then have to deselect currently checked radio button
44 this.inherited(arguments
);
45 if(!this._created
){ return; }
47 array
.forEach(this._getRelatedWidgets(), lang
.hitch(this, function(widget
){
48 if(widget
!= this && widget
.checked
){
49 widget
.set('checked', false);
55 _onClick: function(/*Event*/ e
){
56 if(this.checked
|| this.disabled
){ // nothing to do
60 if(this.readOnly
){ // ignored by some browsers so we have to resync the DOM elements with widget values
62 array
.forEach(this._getRelatedWidgets(), lang
.hitch(this, function(widget
){
63 domAttr
.set(this.focusNode
|| this.domNode
, 'checked', widget
.checked
);
67 return this.inherited(arguments
);