]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/_CheckBoxMixin.js.uncompressed.js
upgrade dojo to 1.8.3 (refs #570)
[tt-rss.git] / 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){
6
7 // module:
8 // dijit/form/_CheckBoxMixin
9
10 return declare("dijit.form._CheckBoxMixin", null, {
11 // summary:
12 // Mixin to provide widget functionality corresponding to an HTML checkbox
13 //
14 // description:
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.
19 //
20
21 // type: [private] String
22 // type attribute on `<input>` node.
23 // Overrides `dijit/form/Button.type`. Users should not change this value.
24 type: "checkbox",
25
26 // value: String
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).
29 value: "on",
30
31 // readOnly: Boolean
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.
35 readOnly: false,
36
37 // aria-pressed for toggle buttons, and aria-checked for checkboxes
38 _aria_attr: "aria-checked",
39
40 _setReadOnlyAttr: function(/*Boolean*/ value){
41 this._set("readOnly", value);
42 domAttr.set(this.focusNode, 'readOnly', value);
43 },
44
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,
48
49 _getSubmitValue: function(/*String*/ value){
50 return !value && value !== 0 ? "on" : value;
51 },
52
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);
57 },
58
59 reset: function(){
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);
64 },
65
66 _onClick: function(/*Event*/ e){
67 // summary:
68 // Internal function to handle click actions - need to check
69 // readOnly, since button no longer does that check.
70 if(this.readOnly){
71 event.stop(e);
72 return false;
73 }
74 return this.inherited(arguments);
75 }
76 });
77 });