|
1 <?xml version="1.0"?> |
|
2 <!-- This Source Code Form is subject to the terms of the Mozilla Public |
|
3 - License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
|
5 |
|
6 <bindings id="expanderBindings" |
|
7 xmlns="http://www.mozilla.org/xbl" |
|
8 xmlns:xbl="http://www.mozilla.org/xbl" |
|
9 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
10 |
|
11 <binding id="expander" display="xul:vbox"> |
|
12 <resources> |
|
13 <stylesheet src="chrome://global/skin/expander.css"/> |
|
14 </resources> |
|
15 <content> |
|
16 <xul:hbox align="center"> |
|
17 <xul:button type="disclosure" class="expanderButton" anonid="disclosure" xbl:inherits="disabled" mousethrough="always"/> |
|
18 <xul:label class="header expanderButton" anonid="label" xbl:inherits="value=label,disabled" mousethrough="always" flex="1"/> |
|
19 <xul:button anonid="clear-button" xbl:inherits="label=clearlabel,disabled=cleardisabled,hidden=clearhidden" mousethrough="always" icon="clear"/> |
|
20 </xul:hbox> |
|
21 <xul:vbox flex="1" anonid="settings" class="settingsContainer" collapsed="true" xbl:inherits="align"> |
|
22 <children/> |
|
23 </xul:vbox> |
|
24 </content> |
|
25 <implementation> |
|
26 <constructor><![CDATA[ |
|
27 var settings = document.getAnonymousElementByAttribute(this, "anonid", "settings"); |
|
28 var expander = document.getAnonymousElementByAttribute(this, "anonid", "disclosure"); |
|
29 var open = this.getAttribute("open") == "true"; |
|
30 settings.collapsed = !open; |
|
31 expander.open = open; |
|
32 ]]></constructor> |
|
33 <property name="open"> |
|
34 <setter> |
|
35 <![CDATA[ |
|
36 var settings = document.getAnonymousElementByAttribute(this, "anonid", "settings"); |
|
37 var expander = document.getAnonymousElementByAttribute(this, "anonid", "disclosure"); |
|
38 settings.collapsed = !val; |
|
39 expander.open = val; |
|
40 if (val) |
|
41 this.setAttribute("open", "true"); |
|
42 else |
|
43 this.setAttribute("open", "false"); |
|
44 return val; |
|
45 ]]> |
|
46 </setter> |
|
47 <getter> |
|
48 return this.getAttribute("open"); |
|
49 </getter> |
|
50 </property> |
|
51 <method name="onCommand"> |
|
52 <parameter name="aEvent"/> |
|
53 <body><![CDATA[ |
|
54 var element = aEvent.originalTarget; |
|
55 var button = element.getAttribute("anonid"); |
|
56 switch (button) { |
|
57 case "disclosure": |
|
58 case "label": |
|
59 if (this.open == "true") |
|
60 this.open = false; |
|
61 else |
|
62 this.open = true; |
|
63 break; |
|
64 case "clear-button": |
|
65 var event = document.createEvent("Events"); |
|
66 event.initEvent("clear", true, true); |
|
67 this.dispatchEvent(event); |
|
68 break; |
|
69 } |
|
70 ]]></body> |
|
71 </method> |
|
72 </implementation> |
|
73 <handlers> |
|
74 <handler event="command"><![CDATA[ |
|
75 this.onCommand(event); |
|
76 ]]></handler> |
|
77 <handler event="click"><![CDATA[ |
|
78 if (event.originalTarget.localName == "label") |
|
79 this.onCommand(event); |
|
80 ]]></handler> |
|
81 </handlers> |
|
82 </binding> |
|
83 |
|
84 </bindings> |
|
85 |
|
86 |