]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/CheckBox.js.uncompressed.js
2 'url:dijit/form/templates/CheckBox.html':"<div class=\"dijit dijitReset dijitInline\" role=\"presentation\"\n\t><input\n\t \t${!nameAttrSetting} type=\"${type}\" ${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
12 "dojo/text!./templates/CheckBox.html",
13 "dojo/NodeList-dom" // NodeList.addClass/removeClass
14 ], function(require
, declare
, domAttr
, kernel
, query
, ready
, ToggleButton
, _CheckBoxMixin
, template
){
17 var ToggleButton = dijit.form.ToggleButton;
18 var _CheckBoxMixin = dijit.form._CheckBoxMixin;
22 // dijit/form/CheckBox
26 // Back compat w/1.6, remove for 2.0
29 var requires
= ["dijit/form/RadioButton"];
30 require(requires
); // use indirection so modules not rolled into a build
34 return declare("dijit.form.CheckBox", [ToggleButton
, _CheckBoxMixin
], {
36 // Same as an HTML checkbox, but with fancy styling.
39 // User interacts with real html inputs.
40 // On onclick (which occurs by mouse click, space-bar, or
41 // using the arrow keys to switch the selected radio button),
42 // we update the state of the checkbox/radio.
44 // There are two modes:
45 // 1. High contrast mode
48 // In case 1, the regular html inputs are shown and used by the user.
49 // In case 2, the regular html inputs are invisible but still used by
50 // the user. They are turned quasi-invisible and overlay the background-image.
52 templateString
: template
,
54 baseClass
: "dijitCheckBox",
56 _setValueAttr: function(/*String|Boolean*/ newValue
, /*Boolean*/ priorityChange
){
58 // Handler for value= attribute to constructor, and also calls to
61 // During initialization, just saves as attribute to the <input type=checkbox>.
63 // After initialization,
64 // when passed a boolean, controls whether or not the CheckBox is checked.
65 // If passed a string, changes the value attribute of the CheckBox (the one
66 // specified as "value" when the CheckBox was constructed (ex: <input
67 // data-dojo-type="dijit.CheckBox" value="chicken">)
68 // widget.set('value', string) will check the checkbox and change the value to the
70 // widget.set('value', boolean) will change the checked state.
71 if(typeof newValue
== "string"){
72 this._set("value", newValue
);
73 domAttr
.set(this.focusNode
, 'value', newValue
);
77 this.set('checked', newValue
, priorityChange
);
80 _getValueAttr: function(){
82 // Hook so get('value') works.
84 // If the CheckBox is checked, returns the value attribute.
85 // Otherwise returns false.
86 return (this.checked
? this.value
: false);
89 // Override behavior from Button, since we don't have an iconNode
90 _setIconClassAttr
: null,
92 postMixInProperties: function(){
93 this.inherited(arguments
);
95 // Need to set initial checked state as part of template, so that form submit works.
96 // domAttr.set(node, "checked", bool) doesn't work on IE until node has been attached
97 // to <body>, see #8666
98 this.checkedAttrSetting
= this.checked
? "checked" : "";
101 _fillContent: function(){
102 // Override Button::_fillContent() since it doesn't make sense for CheckBox,
103 // since CheckBox doesn't even have a container
106 _onFocus: function(){
108 query("label[for='"+this.id
+"']").addClass("dijitFocusedLabel");
110 this.inherited(arguments
);
115 query("label[for='"+this.id
+"']").removeClass("dijitFocusedLabel");
117 this.inherited(arguments
);