1 if(!dojo._hasResource["dijit.form.CheckBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dijit.form.CheckBox"] = true;
3 dojo.provide("dijit.form.CheckBox");
5 dojo.require("dijit.form.Button");
9 dijit.form.ToggleButton,
12 // Same as an HTML checkbox, but with fancy styling.
15 // User interacts with real html inputs.
16 // On onclick (which occurs by mouse click, space-bar, or
17 // using the arrow keys to switch the selected radio button),
18 // we update the state of the checkbox/radio.
20 // There are two modes:
21 // 1. High contrast mode
23 // In case 1, the regular html inputs are shown and used by the user.
24 // In case 2, the regular html inputs are invisible but still used by
25 // the user. They are turned quasi-invisible and overlay the background-image.
27 templateString:"<div class=\"dijitReset dijitInline\" waiRole=\"presentation\"\n\t><input\n\t \ttype=\"${type}\" name=\"${name}\"\n\t\tclass=\"dijitReset dijitCheckBoxInput\"\n\t\tdojoAttachPoint=\"focusNode\"\n\t \tdojoAttachEvent=\"onmouseover:_onMouse,onmouseout:_onMouse,onclick:_onClick\"\n/></div>\n",
29 baseClass: "dijitCheckBox",
31 // Value of "type" attribute for <input>
35 // equivalent to value field on normal checkbox (if checked, the value is passed as
36 // the value when form is submitted)
39 setValue: function(/*String or Boolean*/ newValue){
41 // When passed a boolean, controls whether or not the CheckBox is checked.
42 // If passed a string, changes the value attribute of the CheckBox (the one
43 // specified as "value" when the CheckBox was constructed (ex: <input
44 // dojoType="dijit.CheckBox" value="chicken">)
45 if(typeof newValue == "string"){
46 this.setAttribute('value', newValue);
49 this.setAttribute('checked', newValue);
52 _getValueDeprecated: false, // remove when _FormWidget:_getValueDeprecated is removed
55 // If the CheckBox is checked, returns the value attribute.
56 // Otherwise returns false.
57 return (this.checked ? this.value : false);
61 this.inherited(arguments);
62 this.setAttribute('value', this._resetValueAttr);
65 postCreate: function(){
66 this.inherited(arguments);
67 this._resetValueAttr = this.value;
73 "dijit.form.RadioButton",
77 // Same as an HTML radio, but with fancy styling.
80 // Implementation details
83 // We keep track of dijit radio groups so that we can update the state
84 // of all the siblings (the "context") in a group based on input
85 // events. We don't rely on browser radio grouping.
88 baseClass: "dijitRadio",
90 // This shared object keeps track of all widgets, grouped by name
93 postCreate: function(){
94 // add this widget to _groups
95 (this._groups[this.name] = this._groups[this.name] || []).push(this);
97 this.inherited(arguments);
100 uninitialize: function(){
101 // remove this widget from _groups
102 dojo.forEach(this._groups[this.name], function(widget, i, arr){
110 setAttribute: function(/*String*/ attr, /*anything*/ value){
111 // If I am being checked then have to deselect currently checked radio button
112 this.inherited(arguments);
116 dojo.forEach(this._groups[this.name], function(widget){
117 if(widget != this && widget.checked){
118 widget.setAttribute('checked', false);
125 _clicked: function(/*Event*/ e){
127 this.setAttribute('checked', true);