]> git.wh0rd.org Git - tt-rss.git/blob - lib/dijit/form/CheckBox.js.uncompressed.js
update dojo to 1.7.3
[tt-rss.git] / lib / dijit / form / CheckBox.js.uncompressed.js
1 require({cache:{
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", [
4         "require",
5         "dojo/_base/declare", // declare
6         "dojo/dom-attr", // domAttr.set
7         "dojo/_base/kernel",
8         "dojo/query", // query
9         "dojo/ready",
10         "./ToggleButton",
11         "./_CheckBoxMixin",
12         "dojo/text!./templates/CheckBox.html",
13         "dojo/NodeList-dom" // NodeList.addClass/removeClass
14 ], function(require, declare, domAttr, kernel, query, ready, ToggleButton, _CheckBoxMixin, template){
15
16 /*=====
17         var ToggleButton = dijit.form.ToggleButton;
18         var _CheckBoxMixin = dijit.form._CheckBoxMixin;
19 =====*/
20
21         // module:
22         //              dijit/form/CheckBox
23         // summary:
24         //              Checkbox widget
25
26         // Back compat w/1.6, remove for 2.0
27         if(!kernel.isAsync){
28                 ready(0, function(){
29                         var requires = ["dijit/form/RadioButton"];
30                         require(requires);      // use indirection so modules not rolled into a build
31                 });
32         }
33
34         return declare("dijit.form.CheckBox", [ToggleButton, _CheckBoxMixin], {
35                 // summary:
36                 //              Same as an HTML checkbox, but with fancy styling.
37                 //
38                 // description:
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.
43                 //
44                 //              There are two modes:
45                 //                      1. High contrast mode
46                 //                      2. Normal mode
47                 //
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.
51
52                 templateString: template,
53
54                 baseClass: "dijitCheckBox",
55
56                 _setValueAttr: function(/*String|Boolean*/ newValue, /*Boolean*/ priorityChange){
57                         // summary:
58                         //              Handler for value= attribute to constructor, and also calls to
59                         //              set('value', val).
60                         // description:
61                         //              During initialization, just saves as attribute to the <input type=checkbox>.
62                         //
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
69                         //              specified string
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);
74                                 newValue = true;
75                         }
76                         if(this._created){
77                                 this.set('checked', newValue, priorityChange);
78                         }
79                 },
80                 _getValueAttr: function(){
81                         // summary:
82                         //              Hook so get('value') works.
83                         // description:
84                         //              If the CheckBox is checked, returns the value attribute.
85                         //              Otherwise returns false.
86                         return (this.checked ? this.value : false);
87                 },
88
89                 // Override behavior from Button, since we don't have an iconNode
90                 _setIconClassAttr: null,
91
92                 postMixInProperties: function(){
93                         this.inherited(arguments);
94
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" : "";
99                 },
100
101                  _fillContent: function(){
102                         // Override Button::_fillContent() since it doesn't make sense for CheckBox,
103                         // since CheckBox doesn't even have a container
104                 },
105
106                 _onFocus: function(){
107                         if(this.id){
108                                 query("label[for='"+this.id+"']").addClass("dijitFocusedLabel");
109                         }
110                         this.inherited(arguments);
111                 },
112
113                 _onBlur: function(){
114                         if(this.id){
115                                 query("label[for='"+this.id+"']").removeClass("dijitFocusedLabel");
116                         }
117                         this.inherited(arguments);
118                 }
119         });
120 });