!import
1 <?xml version="1.0"?>
2
3 <bindings id="checkboxBindings"
4 xmlns="http://www.mozilla.org/xbl"
5 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
6 xmlns:xbl="http://www.mozilla.org/xbl">
7
8 <binding id="checkbox" extends="chrome://global/content/bindings/checkbox.xml#checkbox-baseline">
9 <resources>
10 <stylesheet src="chrome://global/skin/checkbox.css"/>
11 </resources>
12 </binding>
13
14 <binding id="checkbox-baseline" extends="chrome://global/content/bindings/general.xml#basetext">
15 <content>
16 <xul:image class="checkbox-check" xbl:inherits="checked,disabled"/>
17 <xul:hbox class="checkbox-label-box" flex="1">
18 <xul:image class="checkbox-icon" xbl:inherits="src"/>
19 <xul:label class="checkbox-label" xbl:inherits="xbl:text=label,accesskey,crop" flex="1"/>
20 </xul:hbox>
21 </content>
22
23 <implementation implements="nsIDOMXULCheckboxElement, nsIAccessibleProvider">
24 <property name="accessibleType" readonly="true">
get_accessibleType
25 <getter>
26 <![CDATA[
27 return Components.interfaces.nsIAccessibleProvider.XULCheckbox;
28 ]]>
29 </getter>
30 </property>
31
32 <method name="setChecked">
33 <parameter name="aValue"/>
setChecked
34 <body>
35 <![CDATA[
36 var change = (aValue != (this.getAttribute('checked') == 'true'));
37 if (aValue)
38 this.setAttribute('checked', 'true');
39 else
40 this.removeAttribute('checked');
41 if (change) {
42 var event = document.createEvent('Events');
43 event.initEvent('CheckboxStateChange', true, true);
44 this.dispatchEvent(event);
45 }
46 return aValue;
47 ]]>
48 </body>
49 </method>
50
51 <!-- public implementation -->
get_checked
set_checked
52 <property name="checked" onset="return this.setChecked(val);"
53 onget="return this.getAttribute('checked') == 'true';"/>
54 </implementation>
55
56 <handlers>
57 <!-- While it would seem we could do this by handling oncommand, we need can't
58 because any external oncommand handlers might get called before ours, and
59 then they would see the incorrect value of checked. -->
onclick
60 <handler event="click" button="0" action="if (!this.disabled) this.checked = !this.checked;"/>
onkeypress
61 <handler event="keypress" key=" ">
62 <![CDATA[
63 this.checked = !this.checked;
64 ]]>
65 </handler>
66 </handlers>
67 </binding>
68
69 <binding id="checkbox-with-spacing"
70 extends="chrome://global/content/bindings/checkbox.xml#checkbox">
71
72 <content>
73 <xul:hbox class="checkbox-spacer-box">
74 <xul:image class="checkbox-check" xbl:inherits="checked,disabled"/>
75 </xul:hbox>
76 <xul:hbox class="checkbox-label-center-box" flex="1">
77 <xul:hbox class="checkbox-label-box" flex="1">
78 <xul:image class="checkbox-icon" xbl:inherits="src"/>
79 <xul:label class="checkbox-label" xbl:inherits="xbl:text=label,accesskey,crop" flex="1"/>
80 </xul:hbox>
81 </xul:hbox>
82 </content>
83 </binding>
84
85 </bindings>