|
1 <?xml version="1.0" encoding="UTF-8"?> |
|
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 <bindings id="spinbuttonsBindings" |
|
8 xmlns="http://www.mozilla.org/xbl" |
|
9 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
10 xmlns:xbl="http://www.mozilla.org/xbl"> |
|
11 |
|
12 <binding id="spinbuttons" |
|
13 extends="chrome://global/content/bindings/general.xml#basecontrol"> |
|
14 |
|
15 <resources> |
|
16 <stylesheet src="chrome://global/skin/spinbuttons.css"/> |
|
17 </resources> |
|
18 |
|
19 <content> |
|
20 <xul:vbox class="spinbuttons-box" flex="1"> |
|
21 <xul:button anonid="increaseButton" type="repeat" flex="1" |
|
22 class="spinbuttons-button spinbuttons-up" |
|
23 xbl:inherits="disabled,disabled=increasedisabled"/> |
|
24 <xul:button anonid="decreaseButton" type="repeat" flex="1" |
|
25 class="spinbuttons-button spinbuttons-down" |
|
26 xbl:inherits="disabled,disabled=decreasedisabled"/> |
|
27 </xul:vbox> |
|
28 </content> |
|
29 |
|
30 <implementation> |
|
31 <property name="_increaseButton" readonly="true"> |
|
32 <getter> |
|
33 return document.getAnonymousElementByAttribute(this, "anonid", "increaseButton"); |
|
34 </getter> |
|
35 </property> |
|
36 <property name="_decreaseButton" readonly="true"> |
|
37 <getter> |
|
38 return document.getAnonymousElementByAttribute(this, "anonid", "decreaseButton"); |
|
39 </getter> |
|
40 </property> |
|
41 |
|
42 <property name="increaseDisabled" |
|
43 onget="return this._increaseButton.getAttribute('disabled') == 'true';" |
|
44 onset="if (val) this._increaseButton.setAttribute('disabled', 'true'); |
|
45 else this._increaseButton.removeAttribute('disabled'); return val;"/> |
|
46 <property name="decreaseDisabled" |
|
47 onget="return this._decreaseButton.getAttribute('disabled') == 'true';" |
|
48 onset="if (val) this._decreaseButton.setAttribute('disabled', 'true'); |
|
49 else this._decreaseButton.removeAttribute('disabled'); return val;"/> |
|
50 </implementation> |
|
51 |
|
52 <handlers> |
|
53 <handler event="mousedown"> |
|
54 <![CDATA[ |
|
55 // on the Mac, the native theme draws the spinbutton as a single widget |
|
56 // so a state attribute is set based on where the mouse button was pressed |
|
57 if (event.originalTarget == this._increaseButton) |
|
58 this.setAttribute("state", "up"); |
|
59 else if (event.originalTarget == this._decreaseButton) |
|
60 this.setAttribute("state", "down"); |
|
61 ]]> |
|
62 </handler> |
|
63 |
|
64 <handler event="mouseup"> |
|
65 this.removeAttribute("state"); |
|
66 </handler> |
|
67 <handler event="mouseout"> |
|
68 this.removeAttribute("state"); |
|
69 </handler> |
|
70 |
|
71 <handler event="command"> |
|
72 <![CDATA[ |
|
73 var eventname; |
|
74 if (event.originalTarget == this._increaseButton) |
|
75 eventname = "up"; |
|
76 else if (event.originalTarget == this._decreaseButton) |
|
77 eventname = "down"; |
|
78 |
|
79 var evt = document.createEvent("Events"); |
|
80 evt.initEvent(eventname, true, true); |
|
81 var cancel = this.dispatchEvent(evt); |
|
82 |
|
83 if (this.hasAttribute("on" + eventname)) { |
|
84 var fn = new Function("event", this.getAttribute("on" + eventname)); |
|
85 if (fn.call(this, event) == false) |
|
86 cancel = true; |
|
87 } |
|
88 |
|
89 return !cancel; |
|
90 ]]> |
|
91 </handler> |
|
92 |
|
93 </handlers> |
|
94 </binding> |
|
95 |
|
96 </bindings> |