Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | <bindings id="checkboxBindings" |
michael@0 | 8 | xmlns="http://www.mozilla.org/xbl" |
michael@0 | 9 | xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 10 | xmlns:xbl="http://www.mozilla.org/xbl"> |
michael@0 | 11 | |
michael@0 | 12 | <binding id="checkbox" extends="chrome://global/content/bindings/checkbox.xml#checkbox-baseline"> |
michael@0 | 13 | <resources> |
michael@0 | 14 | <stylesheet src="chrome://global/skin/checkbox.css"/> |
michael@0 | 15 | </resources> |
michael@0 | 16 | </binding> |
michael@0 | 17 | |
michael@0 | 18 | <binding id="checkbox-baseline" role="xul:checkbox" |
michael@0 | 19 | extends="chrome://global/content/bindings/general.xml#basetext"> |
michael@0 | 20 | <content> |
michael@0 | 21 | <xul:image class="checkbox-check" xbl:inherits="checked,disabled"/> |
michael@0 | 22 | <xul:hbox class="checkbox-label-box" flex="1"> |
michael@0 | 23 | <xul:image class="checkbox-icon" xbl:inherits="src"/> |
michael@0 | 24 | <xul:label class="checkbox-label" xbl:inherits="xbl:text=label,accesskey,crop" flex="1"/> |
michael@0 | 25 | </xul:hbox> |
michael@0 | 26 | </content> |
michael@0 | 27 | |
michael@0 | 28 | <implementation implements="nsIDOMXULCheckboxElement"> |
michael@0 | 29 | <method name="setChecked"> |
michael@0 | 30 | <parameter name="aValue"/> |
michael@0 | 31 | <body> |
michael@0 | 32 | <![CDATA[ |
michael@0 | 33 | var change = (aValue != (this.getAttribute('checked') == 'true')); |
michael@0 | 34 | if (aValue) |
michael@0 | 35 | this.setAttribute('checked', 'true'); |
michael@0 | 36 | else |
michael@0 | 37 | this.removeAttribute('checked'); |
michael@0 | 38 | if (change) { |
michael@0 | 39 | var event = document.createEvent('Events'); |
michael@0 | 40 | event.initEvent('CheckboxStateChange', true, true); |
michael@0 | 41 | this.dispatchEvent(event); |
michael@0 | 42 | } |
michael@0 | 43 | return aValue; |
michael@0 | 44 | ]]> |
michael@0 | 45 | </body> |
michael@0 | 46 | </method> |
michael@0 | 47 | |
michael@0 | 48 | <!-- public implementation --> |
michael@0 | 49 | <property name="checked" onset="return this.setChecked(val);" |
michael@0 | 50 | onget="return this.getAttribute('checked') == 'true';"/> |
michael@0 | 51 | </implementation> |
michael@0 | 52 | |
michael@0 | 53 | <handlers> |
michael@0 | 54 | <!-- While it would seem we could do this by handling oncommand, we need can't |
michael@0 | 55 | because any external oncommand handlers might get called before ours, and |
michael@0 | 56 | then they would see the incorrect value of checked. --> |
michael@0 | 57 | <handler event="click" button="0" action="if (!this.disabled) this.checked = !this.checked;"/> |
michael@0 | 58 | <handler event="keypress" key=" "> |
michael@0 | 59 | <![CDATA[ |
michael@0 | 60 | this.checked = !this.checked; |
michael@0 | 61 | ]]> |
michael@0 | 62 | </handler> |
michael@0 | 63 | </handlers> |
michael@0 | 64 | </binding> |
michael@0 | 65 | |
michael@0 | 66 | <binding id="checkbox-with-spacing" |
michael@0 | 67 | extends="chrome://global/content/bindings/checkbox.xml#checkbox"> |
michael@0 | 68 | |
michael@0 | 69 | <content> |
michael@0 | 70 | <xul:hbox class="checkbox-spacer-box"> |
michael@0 | 71 | <xul:image class="checkbox-check" xbl:inherits="checked,disabled"/> |
michael@0 | 72 | </xul:hbox> |
michael@0 | 73 | <xul:hbox class="checkbox-label-center-box" flex="1"> |
michael@0 | 74 | <xul:hbox class="checkbox-label-box" flex="1"> |
michael@0 | 75 | <xul:image class="checkbox-icon" xbl:inherits="src"/> |
michael@0 | 76 | <xul:label class="checkbox-label" xbl:inherits="xbl:text=label,accesskey,crop" flex="1"/> |
michael@0 | 77 | </xul:hbox> |
michael@0 | 78 | </xul:hbox> |
michael@0 | 79 | </content> |
michael@0 | 80 | </binding> |
michael@0 | 81 | |
michael@0 | 82 | </bindings> |