2 'url:dijit/form/templates/CheckBox.html':"<div class=\"dijit dijitReset dijitInline\" role=\"presentation\"\n\t><input\n\t \t${!nameAttrSetting} type=\"${type}\" role=\"${type}\" aria-checked=\"false\" ${checkedAttrSetting}\n\t\tclass=\"dijitReset dijitCheckBoxInput\"\n\t\tdata-dojo-attach-point=\"focusNode\"\n\t \tdata-dojo-attach-event=\"onclick:_onClick\"\n/></div>\n"}});
3 define("dijit/form/CheckBox", [
5 "dojo/_base/declare", // declare
6 "dojo/dom-attr", // domAttr.set
7 "dojo/has", // has("dijit-legacy-requires")
12 "dojo/text!./templates/CheckBox.html",
13 "dojo/NodeList-dom" // NodeList.addClass/removeClass
14 ], function(require, declare, domAttr, has, query, ready, ToggleButton, _CheckBoxMixin, template){
17 // dijit/form/CheckBox
19 // Back compat w/1.6, remove for 2.0
20 if(has("dijit-legacy-requires")){
22 var requires = ["dijit/form/RadioButton"];
23 require(requires); // use indirection so modules not rolled into a build
27 return declare("dijit.form.CheckBox", [ToggleButton, _CheckBoxMixin], {
29 // Same as an HTML checkbox, but with fancy styling.
32 // User interacts with real html inputs.
33 // On onclick (which occurs by mouse click, space-bar, or
34 // using the arrow keys to switch the selected radio button),
35 // we update the state of the checkbox/radio.
37 // There are two modes:
39 // 1. High contrast mode
42 // In case 1, the regular html inputs are shown and used by the user.
43 // In case 2, the regular html inputs are invisible but still used by
44 // the user. They are turned quasi-invisible and overlay the background-image.
46 templateString: template,
48 baseClass: "dijitCheckBox",
50 _setValueAttr: function(/*String|Boolean*/ newValue, /*Boolean*/ priorityChange){
52 // Handler for value= attribute to constructor, and also calls to
55 // During initialization, just saves as attribute to the `<input type=checkbox>`.
57 // After initialization,
58 // when passed a boolean, controls whether or not the CheckBox is checked.
59 // If passed a string, changes the value attribute of the CheckBox (the one
60 // specified as "value" when the CheckBox was constructed
61 // (ex: `<input data-dojo-type="dijit/CheckBox" value="chicken">`).
63 // `widget.set('value', string)` will check the checkbox and change the value to the
66 // `widget.set('value', boolean)` will change the checked state.
68 if(typeof newValue == "string"){
69 this.inherited(arguments);
73 this.set('checked', newValue, priorityChange);
76 _getValueAttr: function(){
78 // Hook so get('value') works.
80 // If the CheckBox is checked, returns the value attribute.
81 // Otherwise returns false.
82 return (this.checked ? this.value : false);
85 // Override behavior from Button, since we don't have an iconNode
86 _setIconClassAttr: null,
88 postMixInProperties: function(){
89 this.inherited(arguments);
91 // Need to set initial checked state as part of template, so that form submit works.
92 // domAttr.set(node, "checked", bool) doesn't work on IE until node has been attached
93 // to <body>, see #8666
94 this.checkedAttrSetting = this.checked ? "checked" : "";
97 _fillContent: function(){
98 // Override Button::_fillContent() since it doesn't make sense for CheckBox,
99 // since CheckBox doesn't even have a container
102 _onFocus: function(){
104 query("label[for='"+this.id+"']").addClass("dijitFocusedLabel");
106 this.inherited(arguments);
111 query("label[for='"+this.id+"']").removeClass("dijitFocusedLabel");
113 this.inherited(arguments);