]> git.wh0rd.org Git - tt-rss.git/blob - lib/dijit/form/_CheckBoxMixin.js.uncompressed.js
update dojo to 1.7.3
[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         // summary:
10         //              Mixin to provide widget functionality corresponding to an HTML checkbox
11
12         return declare("dijit.form._CheckBoxMixin", null, {
13                 // summary:
14                 //              Mixin to provide widget functionality corresponding to an HTML checkbox
15                 //
16                 // description:
17                 //              User interacts with real html inputs.
18                 //              On onclick (which occurs by mouse click, space-bar, or
19                 //              using the arrow keys to switch the selected radio button),
20                 //              we update the state of the checkbox/radio.
21                 //
22
23                 // type: [private] String
24                 //              type attribute on <input> node.
25                 //              Overrides `dijit.form.Button.type`.  Users should not change this value.
26                 type: "checkbox",
27
28                 // value: String
29                 //              As an initialization parameter, equivalent to value field on normal checkbox
30                 //              (if checked, the value is passed as the value when form is submitted).
31                 value: "on",
32
33                 // readOnly: Boolean
34                 //              Should this widget respond to user input?
35                 //              In markup, this is specified as "readOnly".
36                 //              Similar to disabled except readOnly form values are submitted.
37                 readOnly: false,
38                 
39                 // aria-pressed for toggle buttons, and aria-checked for checkboxes
40                 _aria_attr: "aria-checked",
41
42                 _setReadOnlyAttr: function(/*Boolean*/ value){
43                         this._set("readOnly", value);
44                         domAttr.set(this.focusNode, 'readOnly', value);
45                         this.focusNode.setAttribute("aria-readonly", value);
46                 },
47
48                 // Override dijit.form.Button._setLabelAttr() since we don't even have a containerNode.
49                 // Normally users won't try to set label, except when CheckBox or RadioButton is the child of a dojox.layout.TabContainer
50                 _setLabelAttr: undefined,
51
52                 postMixInProperties: function(){
53                         if(this.value == ""){
54                                 this.value = "on";
55                         }
56                         this.inherited(arguments);
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 });