!import
1 <?xml version="1.0"?>
2
3 <bindings id="generalBindings"
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="basecontrol">
9 <implementation implements="nsIDOMXULControlElement">
10 <!-- public implementation -->
get_disabled
set_disabled
11 <property name="disabled" onset="if (val) this.setAttribute('disabled', 'true');
12 else this.removeAttribute('disabled');
13 return val;"
14 onget="return this.getAttribute('disabled') == 'true';"/>
get_tabIndex
set_tabIndex
15 <property name="tabIndex" onget="return parseInt(this.getAttribute('tabindex')) || 0"
16 onset="if (val) this.setAttribute('tabindex', val);
17 else this.removeAttribute('tabindex'); return val;"/>
18 </implementation>
19 </binding>
20
21 <binding id="basetext" extends="chrome://global/content/bindings/general.xml#basecontrol">
22 <implementation>
23 <!-- public implementation -->
get_label
set_label
24 <property name="label" onset="this.setAttribute('label',val); return val;"
25 onget="return this.getAttribute('label');"/>
get_crop
set_crop
26 <property name="crop" onset="this.setAttribute('crop',val); return val;"
27 onget="return this.getAttribute('crop');"/>
get_image
set_image
28 <property name="image" onset="this.setAttribute('image',val); return val;"
29 onget="return this.getAttribute('image');"/>
get_command
set_command
30 <property name="command" onset="this.setAttribute('command',val); return val;"
31 onget="return this.getAttribute('command');"/>
32 <property name="accessKey">
get_accessKey
33 <getter>
34 <![CDATA[
35 return this.labelElement ? this.labelElement.accessKey : this.getAttribute('accesskey');
36 ]]>
37 </getter>
set_accessKey
38 <setter>
39 <![CDATA[
40 // Always store on the control
41 this.setAttribute('accesskey', val);
42 // If there is a label, change the accesskey on the labelElement
43 // if it's also set there
44 if (this.labelElement) {
45 this.labelElement.accessKey = val;
46 }
47 return val;
48 ]]>
49 </setter>
50 </property>
51
field_labelElement
52 <field name="labelElement"/>
53 </implementation>
54 </binding>
55
56 <binding id="control-item" extends="chrome://global/content/bindings/general.xml#basetext">
57 <implementation>
get_value
set_value
58 <property name="value" onset="this.setAttribute('value', val); return val;"
59 onget="return this.getAttribute('value');"/>
60 </implementation>
61 </binding>
62
63 <!--
64 Inline Editable UI Element
65 - This binding forms the basis of the inline edit treecell and the inline edit
66 - buttons.
67 - TODO: investigate creating extensions to the wrapper widgets (tree, toolbar)
68 - to make them provide some object implementing an interface similar to
69 - tree's so we can build in some of the ILE behavior (such as going
70 - in and out of the mode, asking isEditable etc) so as to remove some of
71 - the burden from the implementor.
72 -
73 - Note that this widget will be no longer used in the bookmarks window once
74 - tree is extended to have this functionality built in.
75 -->
76 <binding id="inline-edit-base" extends="chrome://global/content/bindings/general.xml#basetext">
77 <implementation>
field__mode
78 <field name="_mode">0</field>
79 <method name="setMode">
80 <parameter name="val"/>
setMode
81 <body>
82 <![CDATA[
83 var ctr = document.getAnonymousElementByAttribute(this, "ileattr", "text-container");
84 var txt = document.getAnonymousElementByAttribute(this, "ileattr", "text");
85 this.setAttribute("mode", val);
86 if (val == "edit") {
87 var nodes = document.getAnonymousNodes(this);
88
89 if (txt.getAttribute("hidden") != "true") {
90 ctr.setAttribute("mode", "edit");
91 var width = ctr.boxObject.width;
92 txt.setAttribute("hidden", "true");
93 const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
94 var field = document.createElementNS(kXULNS, "textbox");
95 field.className = "textbox-inline-edit";
96 field.setAttribute("flex", "1");
97 field.setAttribute("value", txt.getAttribute("value"));
98 field.setAttribute("ileattr", "field");
99 field.setAttribute("rootcontent", txt.getAttribute("rootcontent"));
100 field.setAttribute("style", "width: " + width + "px");
101 ctr.appendChild(field);
102 field.addEventListener("keydown", this.fieldKeyDown, false);
103 field.addEventListener("change", this.fieldChange, false);
104 field.select();
105 }
106 }
107 else {
108 nodes = document.getAnonymousNodes(this);
109 var fld = document.getAnonymousElementByAttribute(this, "ileattr", "field");
110 if (fld && txt.getAttribute("hidden") == "true") {
111 ctr.removeAttribute("mode");
112 fld.blur();
113 ctr.removeChild(fld);
114 txt.removeAttribute("hidden");
115 }
116 }
117 ]]>
118 </body>
119 </method>
field__observers
120 <field name="_observers">
121 <![CDATA[
122 ({
123 reject: [],
124 accept: []
125 })
126 ]]>
127 </field>
field_valueIsRejected
128 <field name="valueIsRejected">false</field>
129 <method name="addObserver">
130 <parameter name="aObserver"/>
131 <parameter name="aTopic"/>
132 <parameter name="aParams"/>
addObserver
133 <body>
134 this._observers[aTopic].push({ callback: aObserver, params: aParams });
135 </body>
136 </method>
137 <method name="fieldKeyDown">
138 <parameter name="aEvent"/>
fieldKeyDown
139 <body>
140 <![CDATA[
141 var rootLocalName = aEvent.target.getAttribute("rootcontent");
142 if (rootLocalName) {
143 // Root content is the bound element.
144 var rootContent = aEvent.target;
145 while (rootContent && rootContent.localName != rootLocalName)
146 rootContent = rootContent.parentNode;
147
148 if (rootContent) {
149 var ctr = document.getAnonymousElementByAttribute(rootContent, "ileattr", "text-container");
150 if (aEvent.keyCode == 13) {
151 rootContent.valueIsRejected = false;
152 rootContent.fieldChange(aEvent);
153 }
154 if (aEvent.keyCode == 27) {
155 rootContent.valueIsRejected = true;
156 var fld = document.getAnonymousElementByAttribute(rootContent, "ileattr", "field");
157 for (i = 0; i < rootContent._observers["reject"].length; ++i)
158 rootContent._observers["reject"][i].callback(rootContent._observers["reject"][i].params.concat(fld.value), "reject");
159 if ("setMode" in rootContent)
160 rootContent.setMode("normal");
161 }
162 }
163 }
164 aEvent.stopPropagation();
165 ]]>
166 </body>
167 </method>
field_valueIsAccepted
168 <field name="valueIsAccepted">false</field>
169 <method name="fieldChange">
170 <parameter name="aEvent"/>
fieldChange
171 <body>
172 <![CDATA[
173 var rootLocalName = this.getAttribute("rootcontent");
174 if (rootLocalName) {
175 // Root content is the bound element.
176 var rootContent = this;
177 while (rootContent && rootContent.localName != rootLocalName)
178 rootContent = rootContent.parentNode;
179
180 if (rootContent) {
181 var ctr = document.getAnonymousElementByAttribute(rootContent, "ileattr", "text-container");
182 if (!rootContent.valueIsRejected) {
183 var fld = document.getAnonymousElementByAttribute(rootContent, "ileattr", "field");
184 for (var i = 0; i < rootContent._observers["accept"].length; ++i)
185 rootContent._observers["accept"][i].callback(rootContent._observers["accept"][i].params.concat(fld.value), "accept");
186 if ("setMode" in rootContent)
187 rootContent.setMode("normal");
188 }
189 }
190 }
191 ]]>
192 </body>
193 </method>
194 </implementation>
195 </binding>
196
197 <!-- inline editable buttons -->
198 <binding id="buttonleft-ile" extends="chrome://global/content/bindings/general.xml#inline-edit-base">
199 <content>
200 <xul:hbox class="button-internal-box" align="center" flex="1">
201 <xul:image class="button-icon" xbl:inherits="src"/>
202 <xul:hbox class="button-text-container" flex="1" ileattr="text-container">
203 <xul:label class="button-text" xbl:inherits="value=label,accesskey,crop,dragover-top" ileattr="text" rootcontent="button" flex="1"/>
204 </xul:hbox>
205 </xul:hbox>
206 <children includes="menupopup"/>
207 </content>
208 </binding>
209
210 <binding id="iframe">
211 <implementation implements="nsIAccessibleProvider">
212 <property name="accessibleType" readonly="true">
get_accessibleType
213 <getter>
214 <![CDATA[
215 return Components.interfaces.nsIAccessibleProvider.OuterDoc;
216 ]]>
217 </getter>
218 </property>
get_docShell
219 <property name="docShell"
220 readonly="true"
221 onget="return this.boxObject.QueryInterface(Components.interfaces.nsIContainerBoxObject).docShell"/>
get_contentWindow
222 <property name="contentWindow"
223 readonly="true"
224 onget="return this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow);"/>
get_webNavigation
225 <property name="webNavigation"
226 onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"
227 readonly="true"/>
get_contentDocument
228 <property name="contentDocument" readonly="true"
229 onget="return this.webNavigation.document;"/>
230 </implementation>
231 </binding>
232
233 <binding id="statusbarpanel" display="xul:button">
234 <content>
235 <children>
236 <xul:label class="statusbarpanel-text" xbl:inherits="value=label,crop" crop="right" flex="1"/>
237 </children>
238 </content>
239
240 <implementation implements="nsIAccessibleProvider">
241 <property name="accessibleType" readonly="true">
get_accessibleType
242 <getter>
243 <![CDATA[
244 return Components.interfaces.nsIAccessibleProvider.XULButton;
245 ]]>
246 </getter>
247 </property>
248
get_label
set_label
249 <property name="label"
250 onget="return this.getAttribute('label');"
251 onset="this.setAttribute('label',val); return val;"/>
get_image
set_image
252 <property name="image"
253 onget="return this.getAttribute('image');"
254 onset="this.setAttribute('image',val); return val;"/>
get_src
set_src
255 <property name="src"
256 onget="return this.getAttribute('src');"
257 onset="this.setAttribute('src',val); return val;"/>
258 </implementation>
259 </binding>
260
261 <binding id="statusbarpanel-menu-iconic" display="xul:menu"
262 extends="chrome://global/content/bindings/general.xml#statusbarpanel">
263 <content>
264 <xul:image class="statusbarpanel-icon" xbl:inherits="src,src=image"/>
265 <children/>
266 </content>
267 </binding>
268
269 <binding id="statusbar">
270 <content>
271 <children/>
272 <xul:statusbarpanel class="statusbar-resizerpanel">
273 <xul:resizer dir="bottomright"/>
274 </xul:statusbarpanel>
275 </content>
276
277 <implementation implements="nsIAccessibleProvider">
278 <property name="accessibleType" readonly="true">
get_accessibleType
279 <getter>
280 <![CDATA[
281 return Components.interfaces.nsIAccessibleProvider.XULStatusBar;
282 ]]>
283 </getter>
284 </property>
285 </implementation>
286 </binding>
287
288 <binding id="statusbarpanel-iconic" display="xul:button"
289 extends="chrome://global/content/bindings/general.xml#statusbarpanel">
290 <content>
291 <xul:image class="statusbarpanel-icon" xbl:inherits="src,src=image"/>
292 </content>
293 </binding>
294
295 <binding id="statusbarpanel-iconic-text" display="xul:button"
296 extends="chrome://global/content/bindings/general.xml#statusbarpanel">
297 <content>
298 <xul:image class="statusbarpanel-icon" xbl:inherits="src,src=image"/>
299 <xul:label class="statusbarpanel-text" xbl:inherits="value=label,crop"/>
300 </content>
301 </binding>
302
303 <binding id="image">
304 <implementation implements="nsIDOMXULImageElement, nsIAccessibleProvider">
get_src
set_src
305 <property name="src"
306 onget="return this.getAttribute('src');"
307 onset="this.setAttribute('src',val); return val;"/>
308 <property name="accessibleType" readonly="true">
get_accessibleType
309 <getter>
310 <![CDATA[
311 // Expose XUL images with an onclick as a toolbarbutton
312 return this.hasAttribute("onclick") ?
313 Components.interfaces.nsIAccessibleProvider.XULToolbarButton :
314 Components.interfaces.nsIAccessibleProvider.XULImage;
315 ]]>
316 </getter>
317 </property>
318 </implementation>
319 </binding>
320
321 <binding id="deck">
322 <implementation>
get_selectedIndex
323 <property name="selectedIndex"
324 onget="return this.getAttribute('selectedIndex') || '0'">
set_selectedIndex
325 <setter>
326 <![CDATA[
327 if (this.selectedIndex == val)
328 return val;
329 this.setAttribute("selectedIndex", val);
330 var event = document.createEvent('Events');
331 event.initEvent('select', true, true);
332 this.dispatchEvent(event);
333 return val;
334 ]]>
335 </setter>
336 </property>
337
338 <property name="selectedPanel">
get_selectedPanel
339 <getter>
340 <![CDATA[
341 return this.childNodes[this.selectedIndex];
342 ]]>
343 </getter>
344
set_selectedPanel
345 <setter>
346 <![CDATA[
347 var selectedIndex = -1;
348 for (var panel = val; panel != null; panel = panel.previousSibling)
349 ++selectedIndex;
350 this.selectedIndex = selectedIndex;
351 return val;
352 ]]>
353 </setter>
354 </property>
355 </implementation>
356 </binding>
357
358 <binding id="dropmarker" extends="xul:button">
359 <resources>
360 <stylesheet src="chrome://global/skin/dropmarker.css"/>
361 </resources>
362
363 <content>
364 <xul:image class="dropmarker-icon"/>
365 </content>
366
367 <implementation implements="nsIAccessibleProvider">
368 <property name="accessibleType" readonly="true">
get_accessibleType
369 <getter>
370 <![CDATA[
371 return Components.interfaces.nsIAccessibleProvider.XULDropmarker;
372 ]]>
373 </getter>
374 </property>
375 </implementation>
376 </binding>
377
378 </bindings>