]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_CheckBoxMixin.js.uncompressed.js
1 define("dijit/form/_CheckBoxMixin", [
2 "dojo/_base/declare", // declare
3 "dojo/dom-attr", // domAttr.set
4 "dojo/_base/event" // event.stop
5 ], function(declare
, domAttr
, event
){
8 // dijit/form/_CheckBoxMixin
10 return declare("dijit.form._CheckBoxMixin", null, {
12 // Mixin to provide widget functionality corresponding to an HTML checkbox
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.
21 // type: [private] String
22 // type attribute on `<input>` node.
23 // Overrides `dijit/form/Button.type`. Users should not change this value.
27 // As an initialization parameter, equivalent to value field on normal checkbox
28 // (if checked, the value is passed as the value when form is submitted).
32 // Should this widget respond to user input?
33 // In markup, this is specified as "readOnly".
34 // Similar to disabled except readOnly form values are submitted.
37 // aria-pressed for toggle buttons, and aria-checked for checkboxes
38 _aria_attr
: "aria-checked",
40 _setReadOnlyAttr: function(/*Boolean*/ value
){
41 this._set("readOnly", value
);
42 domAttr
.set(this.focusNode
, 'readOnly', value
);
45 // Override dijit/form/Button._setLabelAttr() since we don't even have a containerNode.
46 // Normally users won't try to set label, except when CheckBox or RadioButton is the child of a dojox/layout/TabContainer
47 _setLabelAttr
: undefined,
49 _getSubmitValue: function(/*String*/ value
){
50 return !value
&& value
!== 0 ? "on" : value
;
53 _setValueAttr: function(newValue
){
54 newValue
= this._getSubmitValue(newValue
); // "on" to match browser native behavior when value unspecified
55 this._set("value", newValue
);
56 domAttr
.set(this.focusNode
, "value", newValue
);
60 this.inherited(arguments
);
61 // Handle unlikely event that the <input type=checkbox> value attribute has changed
62 this._set("value", this.params
.value
|| "on");
63 domAttr
.set(this.focusNode
, 'value', this.value
);
66 _onClick: function(/*Event*/ e
){
68 // Internal function to handle click actions - need to check
69 // readOnly, since button no longer does that check.
74 return this.inherited(arguments
);