|
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 |
|
7 <bindings id="menuitemBindings" |
|
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="menuitem-base" role="xul:menuitem" |
|
13 extends="chrome://global/content/bindings/general.xml#control-item"> |
|
14 <resources> |
|
15 <stylesheet src="chrome://global/skin/menu.css"/> |
|
16 </resources> |
|
17 <implementation implements="nsIDOMXULSelectControlItemElement, nsIDOMXULContainerItemElement"> |
|
18 <!-- nsIDOMXULSelectControlItemElement --> |
|
19 <property name="selected" readonly="true" |
|
20 onget="return this.getAttribute('selected') == 'true';"/> |
|
21 <property name="control" readonly="true"> |
|
22 <getter> |
|
23 <![CDATA[ |
|
24 var parent = this.parentNode; |
|
25 if (parent && |
|
26 parent.parentNode instanceof Components.interfaces.nsIDOMXULSelectControlElement) |
|
27 return parent.parentNode; |
|
28 return null; |
|
29 ]]> |
|
30 </getter> |
|
31 </property> |
|
32 |
|
33 <!-- nsIDOMXULContainerItemElement --> |
|
34 <property name="parentContainer" readonly="true"> |
|
35 <getter> |
|
36 for (var parent = this.parentNode; parent; parent = parent.parentNode) { |
|
37 if (parent instanceof Components.interfaces.nsIDOMXULContainerElement) |
|
38 return parent; |
|
39 } |
|
40 return null; |
|
41 </getter> |
|
42 </property> |
|
43 </implementation> |
|
44 </binding> |
|
45 |
|
46 <binding id="menu-base" |
|
47 extends="chrome://global/content/bindings/menu.xml#menuitem-base"> |
|
48 |
|
49 <implementation implements="nsIDOMXULContainerElement"> |
|
50 <property name="open" onget="return this.hasAttribute('open');"> |
|
51 <setter><![CDATA[ |
|
52 this.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject) |
|
53 .openMenu(val); |
|
54 return val; |
|
55 ]]></setter> |
|
56 </property> |
|
57 |
|
58 <property name="openedWithKey" readonly="true"> |
|
59 <getter><![CDATA[ |
|
60 return this.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject) |
|
61 .openedWithKey; |
|
62 ]]></getter> |
|
63 </property> |
|
64 |
|
65 <!-- nsIDOMXULContainerElement interface --> |
|
66 <method name="appendItem"> |
|
67 <parameter name="aLabel"/> |
|
68 <parameter name="aValue"/> |
|
69 <body> |
|
70 return this.insertItemAt(-1, aLabel, aValue); |
|
71 </body> |
|
72 </method> |
|
73 |
|
74 <method name="insertItemAt"> |
|
75 <parameter name="aIndex"/> |
|
76 <parameter name="aLabel"/> |
|
77 <parameter name="aValue"/> |
|
78 <body> |
|
79 const XUL_NS = |
|
80 "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
|
81 |
|
82 var menupopup = this.menupopup; |
|
83 if (!menupopup) { |
|
84 menupopup = this.ownerDocument.createElementNS(XUL_NS, "menupopup"); |
|
85 this.appendChild(menupopup); |
|
86 } |
|
87 |
|
88 var menuitem = this.ownerDocument.createElementNS(XUL_NS, "menuitem"); |
|
89 menuitem.setAttribute("label", aLabel); |
|
90 menuitem.setAttribute("value", aValue); |
|
91 |
|
92 var before = this.getItemAtIndex(aIndex); |
|
93 if (before) |
|
94 return menupopup.insertBefore(menuitem, before); |
|
95 return menupopup.appendChild(menuitem); |
|
96 </body> |
|
97 </method> |
|
98 |
|
99 <method name="removeItemAt"> |
|
100 <parameter name="aIndex"/> |
|
101 <body> |
|
102 <![CDATA[ |
|
103 var menupopup = this.menupopup; |
|
104 if (menupopup) { |
|
105 var item = this.getItemAtIndex(aIndex); |
|
106 if (item) |
|
107 return menupopup.removeChild(item); |
|
108 } |
|
109 return null; |
|
110 ]]> |
|
111 </body> |
|
112 </method> |
|
113 |
|
114 <property name="itemCount" readonly="true"> |
|
115 <getter> |
|
116 var menupopup = this.menupopup; |
|
117 return menupopup ? menupopup.childNodes.length : 0; |
|
118 </getter> |
|
119 </property> |
|
120 |
|
121 <method name="getIndexOfItem"> |
|
122 <parameter name="aItem"/> |
|
123 <body> |
|
124 <![CDATA[ |
|
125 var menupopup = this.menupopup; |
|
126 if (menupopup) { |
|
127 var items = menupopup.childNodes; |
|
128 var length = items.length; |
|
129 for (var index = 0; index < length; ++index) { |
|
130 if (items[index] == aItem) |
|
131 return index; |
|
132 } |
|
133 } |
|
134 return -1; |
|
135 ]]> |
|
136 </body> |
|
137 </method> |
|
138 |
|
139 <method name="getItemAtIndex"> |
|
140 <parameter name="aIndex"/> |
|
141 <body> |
|
142 <![CDATA[ |
|
143 var menupopup = this.menupopup; |
|
144 if (!menupopup || aIndex < 0 || aIndex >= menupopup.childNodes.length) |
|
145 return null; |
|
146 |
|
147 return menupopup.childNodes[aIndex]; |
|
148 ]]> |
|
149 </body> |
|
150 </method> |
|
151 |
|
152 <property name="menupopup" readonly="true"> |
|
153 <getter> |
|
154 <![CDATA[ |
|
155 const XUL_NS = |
|
156 "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; |
|
157 |
|
158 for (var child = this.firstChild; child; child = child.nextSibling) { |
|
159 if (child.namespaceURI == XUL_NS && child.localName == "menupopup") |
|
160 return child; |
|
161 } |
|
162 return null; |
|
163 ]]> |
|
164 </getter> |
|
165 </property> |
|
166 </implementation> |
|
167 </binding> |
|
168 |
|
169 <binding id="menu" |
|
170 extends="chrome://global/content/bindings/menu.xml#menu-base"> |
|
171 <content> |
|
172 <xul:label class="menu-text" xbl:inherits="value=label,accesskey,crop" crop="right"/> |
|
173 <xul:hbox class="menu-accel-container" anonid="accel"> |
|
174 <xul:label class="menu-accel" xbl:inherits="value=acceltext"/> |
|
175 </xul:hbox> |
|
176 <xul:hbox align="center" class="menu-right" xbl:inherits="_moz-menuactive,disabled"> |
|
177 <xul:image/> |
|
178 </xul:hbox> |
|
179 <children includes="menupopup"/> |
|
180 </content> |
|
181 </binding> |
|
182 |
|
183 <binding id="menuitem" extends="chrome://global/content/bindings/menu.xml#menuitem-base"> |
|
184 <content> |
|
185 <xul:label class="menu-text" xbl:inherits="value=label,accesskey,crop" crop="right"/> |
|
186 <xul:hbox class="menu-accel-container" anonid="accel"> |
|
187 <xul:label class="menu-accel" xbl:inherits="value=acceltext"/> |
|
188 </xul:hbox> |
|
189 </content> |
|
190 </binding> |
|
191 |
|
192 <binding id="menu-menubar" |
|
193 extends="chrome://global/content/bindings/menu.xml#menu-base"> |
|
194 <content> |
|
195 <xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/> |
|
196 <children includes="menupopup"/> |
|
197 </content> |
|
198 </binding> |
|
199 |
|
200 <binding id="menu-menubar-iconic" |
|
201 extends="chrome://global/content/bindings/menu.xml#menu-base"> |
|
202 <content> |
|
203 <xul:image class="menubar-left" xbl:inherits="src=image"/> |
|
204 <xul:label class="menubar-text" xbl:inherits="value=label,accesskey,crop" crop="right"/> |
|
205 <children includes="menupopup"/> |
|
206 </content> |
|
207 </binding> |
|
208 |
|
209 <binding id="menuitem-iconic" extends="chrome://global/content/bindings/menu.xml#menuitem"> |
|
210 <content> |
|
211 <xul:hbox class="menu-iconic-left" align="center" pack="center" |
|
212 xbl:inherits="selected,_moz-menuactive,disabled,checked"> |
|
213 <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/> |
|
214 </xul:hbox> |
|
215 <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/> |
|
216 <xul:hbox class="menu-accel-container" anonid="accel"> |
|
217 <xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/> |
|
218 </xul:hbox> |
|
219 </content> |
|
220 </binding> |
|
221 |
|
222 <binding id="menuitem-iconic-noaccel" extends="chrome://global/content/bindings/menu.xml#menuitem"> |
|
223 <content> |
|
224 <xul:hbox class="menu-iconic-left" align="center" pack="center" |
|
225 xbl:inherits="selected,disabled,checked"> |
|
226 <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/> |
|
227 </xul:hbox> |
|
228 <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/> |
|
229 </content> |
|
230 </binding> |
|
231 |
|
232 <binding id="menuitem-iconic-desc-noaccel" extends="chrome://global/content/bindings/menu.xml#menuitem"> |
|
233 <content> |
|
234 <xul:hbox class="menu-iconic-left" align="center" pack="center" |
|
235 xbl:inherits="selected,disabled,checked"> |
|
236 <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/> |
|
237 </xul:hbox> |
|
238 <xul:label class="menu-iconic-text" xbl:inherits="value=label,accesskey,crop" crop="right" flex="1"/> |
|
239 <xul:label class="menu-iconic-text menu-description" xbl:inherits="value=description" crop="right" flex="10000"/> |
|
240 </content> |
|
241 </binding> |
|
242 |
|
243 <binding id="menu-iconic" |
|
244 extends="chrome://global/content/bindings/menu.xml#menu-base"> |
|
245 <content> |
|
246 <xul:hbox class="menu-iconic-left" align="center" pack="center"> |
|
247 <xul:image class="menu-iconic-icon" xbl:inherits="src=image"/> |
|
248 </xul:hbox> |
|
249 <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/> |
|
250 <xul:hbox class="menu-accel-container" anonid="accel"> |
|
251 <xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/> |
|
252 </xul:hbox> |
|
253 <xul:hbox align="center" class="menu-right" xbl:inherits="_moz-menuactive,disabled"> |
|
254 <xul:image/> |
|
255 </xul:hbox> |
|
256 <children includes="menupopup|template"/> |
|
257 </content> |
|
258 </binding> |
|
259 |
|
260 <binding id="menubutton-item" extends="chrome://global/content/bindings/menu.xml#menuitem-base"> |
|
261 <content> |
|
262 <xul:label class="menubutton-text" flex="1" xbl:inherits="value=label,accesskey,crop" crop="right"/> |
|
263 <children includes="menupopup"/> |
|
264 </content> |
|
265 </binding> |
|
266 |
|
267 <binding id="menuseparator" role="xul:menuseparator" |
|
268 extends="chrome://global/content/bindings/menu.xml#menuitem-base"> |
|
269 </binding> |
|
270 |
|
271 </bindings> |