|
1 <?xml version="1.0"?> |
|
2 |
|
3 <!-- This Source Code Form is subject to the terms of the Mozilla Public |
|
4 - License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
|
6 |
|
7 <!DOCTYPE bindings [ |
|
8 <!ENTITY % checkboxDTD SYSTEM "chrome://browser/locale/checkbox.dtd"> |
|
9 %checkboxDTD; |
|
10 ]> |
|
11 |
|
12 <bindings |
|
13 xmlns="http://www.mozilla.org/xbl" |
|
14 xmlns:xbl="http://www.mozilla.org/xbl" |
|
15 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
16 |
|
17 <binding id="checkbox-radio" display="xul:box" extends="chrome://global/content/bindings/checkbox.xml#checkbox-baseline"> |
|
18 <content> |
|
19 <xul:radiogroup anonid="group" xbl:inherits="disabled"> |
|
20 <xul:radio anonid="on" class="checkbox-radio-on" label="&checkbox.yes.label;" xbl:inherits="label=onlabel"/> |
|
21 <xul:radio anonid="off" class="checkbox-radio-off" label="&checkbox.no.label;" xbl:inherits="label=offlabel"/> |
|
22 </xul:radiogroup> |
|
23 </content> |
|
24 <implementation> |
|
25 <constructor><![CDATA[ |
|
26 this.setChecked(this.checked); |
|
27 ]]></constructor> |
|
28 |
|
29 <field name="_group"> |
|
30 document.getAnonymousElementByAttribute(this, "anonid", "group"); |
|
31 </field> |
|
32 |
|
33 <field name="_on"> |
|
34 document.getAnonymousElementByAttribute(this, "anonid", "on"); |
|
35 </field> |
|
36 |
|
37 <field name="_off"> |
|
38 document.getAnonymousElementByAttribute(this, "anonid", "off"); |
|
39 </field> |
|
40 |
|
41 <property name="onlabel" |
|
42 onget="return this._on.label" |
|
43 onset="this._on.label=val"/> |
|
44 |
|
45 <property name="offlabel" |
|
46 onget="return this._off.label" |
|
47 onset="this._off.label=val"/> |
|
48 |
|
49 <method name="setChecked"> |
|
50 <parameter name="aValue"/> |
|
51 <body> |
|
52 <![CDATA[ |
|
53 var change = (aValue != this.checked); |
|
54 if (aValue) { |
|
55 this.setAttribute("checked", "true"); |
|
56 this._group.selectedItem = this._on; |
|
57 } |
|
58 else { |
|
59 this.removeAttribute("checked"); |
|
60 this._group.selectedItem = this._off; |
|
61 } |
|
62 |
|
63 if (change) { |
|
64 var event = document.createEvent("Events"); |
|
65 event.initEvent("CheckboxStateChange", true, true); |
|
66 this.dispatchEvent(event); |
|
67 } |
|
68 return aValue; |
|
69 ]]> |
|
70 </body> |
|
71 </method> |
|
72 </implementation> |
|
73 </binding> |
|
74 |
|
75 </bindings> |