]> git.wh0rd.org Git - tt-rss.git/blob - lib/dijit/form/_RadioButtonMixin.js.uncompressed.js
modify dojo rebuild script to remove uncompressed files
[tt-rss.git] / 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
7         "dojo/query", // query
8         "../registry"   // registry.getEnclosingWidget
9 ], function(array, declare, domAttr, event, lang, query, registry){
10
11         // module:
12         //              dijit/form/_RadioButtonMixin
13
14         return declare("dijit.form._RadioButtonMixin", null, {
15                 // summary:
16                 //              Mixin to provide widget functionality for an HTML radio button
17
18                 // type: [private] String
19                 //              type attribute on `<input>` node.
20                 //              Users should not change this value.
21                 type: "radio",
22
23                 _getRelatedWidgets: function(){
24                         // Private function needed to help iterate over all radio buttons in a group.
25                         var ary = [];
26                         query("input[type=radio]", this.focusNode.form || this.ownerDocument).forEach( // can't use name= since query doesn't support [] in the name
27                                 lang.hitch(this, function(inputNode){
28                                         if(inputNode.name == this.name && inputNode.form == this.focusNode.form){
29                                                 var widget = registry.getEnclosingWidget(inputNode);
30                                                 if(widget){
31                                                         ary.push(widget);
32                                                 }
33                                         }
34                                 })
35                         );
36                         return ary;
37                 },
38
39                 _setCheckedAttr: function(/*Boolean*/ value){
40                         // If I am being checked then have to deselect currently checked radio button
41                         this.inherited(arguments);
42                         if(!this._created){ return; }
43                         if(value){
44                                 array.forEach(this._getRelatedWidgets(), lang.hitch(this, function(widget){
45                                         if(widget != this && widget.checked){
46                                                 widget.set('checked', false);
47                                         }
48                                 }));
49                         }
50                 },
51
52                 _getSubmitValue: function(/*String*/ value){
53                         return value === null ? "on" : value;
54                 },
55
56                 _onClick: function(/*Event*/ e){
57                         if(this.checked || this.disabled){ // nothing to do
58                                 event.stop(e);
59                                 return false;
60                         }
61                         if(this.readOnly){ // ignored by some browsers so we have to resync the DOM elements with widget values
62                                 event.stop(e);
63                                 array.forEach(this._getRelatedWidgets(), lang.hitch(this, function(widget){
64                                         domAttr.set(this.focusNode || this.domNode, 'checked', widget.checked);
65                                 }));
66                                 return false;
67                         }
68                         return this.inherited(arguments);
69                 }
70         });
71 });