1 | define([ |
---|
2 | "dojo/_base/declare", |
---|
3 | "dojo/dom-construct", |
---|
4 | "dijit/form/_CheckBoxMixin", |
---|
5 | "./ToggleButton", |
---|
6 | "./sniff" |
---|
7 | ], |
---|
8 | function(declare, domConstruct, CheckBoxMixin, ToggleButton, has){ |
---|
9 | |
---|
10 | return declare("dojox.mobile.CheckBox", [ToggleButton, CheckBoxMixin], { |
---|
11 | // summary: |
---|
12 | // A non-templated checkbox widget that can be in two states |
---|
13 | // (checked or not checked). |
---|
14 | |
---|
15 | // baseClass: String |
---|
16 | // The name of the CSS class of this widget. |
---|
17 | baseClass: "mblCheckBox", |
---|
18 | |
---|
19 | // _setTypeAttr: [private] Function |
---|
20 | // Overrides the automatic assignement of type to nodes. |
---|
21 | _setTypeAttr: function(){}, // cannot be changed: IE complains w/o this |
---|
22 | |
---|
23 | buildRendering: function(){ |
---|
24 | if(!this.templateString && !this.srcNodeRef){ |
---|
25 | // The following doesn't work on IE < 8 if the default state is checked. |
---|
26 | // You have to use "<input checked>" instead but it's not worth the bytes here. |
---|
27 | this.srcNodeRef = domConstruct.create("input", {type: this.type}); |
---|
28 | } |
---|
29 | this.inherited(arguments); |
---|
30 | if(!this.templateString){ |
---|
31 | // if this widget is templated, let the template set the focusNode via an attach point |
---|
32 | this.focusNode = this.domNode; |
---|
33 | } |
---|
34 | |
---|
35 | if(has("windows-theme")){ |
---|
36 | var rootNode = domConstruct.create("span", {className: "mblCheckableInputContainer"}); |
---|
37 | rootNode.appendChild(this.domNode.cloneNode()); |
---|
38 | this.labelNode = domConstruct.create("span", {className: "mblCheckableInputDecorator"}, rootNode); |
---|
39 | this.domNode = rootNode; |
---|
40 | this.focusNode = rootNode.firstChild; |
---|
41 | } |
---|
42 | }, |
---|
43 | |
---|
44 | _getValueAttr: function(){ |
---|
45 | // tags: |
---|
46 | // private |
---|
47 | return (this.checked ? this.value : false); |
---|
48 | } |
---|
49 | }); |
---|
50 | }); |
---|