!import
1 <?xml version="1.0"?>
2
3 <bindings id="toolbarBindings"
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="toolbar-base">
9 <resources>
10 <stylesheet src="chrome://global/skin/toolbar.css"/>
11 </resources>
12 </binding>
13
14 <binding id="toolbox" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
15 <implementation>
field_palette
16 <field name="palette">
17 null
18 </field>
19
field_toolbarset
20 <field name="toolbarset">
21 null
22 </field>
23
field_customToolbarCount
24 <field name="customToolbarCount">
25 0
26 </field>
27
constructor
28 <constructor>
29 <![CDATA[
30 // Look to see if there is a toolbarset.
31 this.toolbarset = this.firstChild;
32 while (this.toolbarset && this.toolbarset.localName != "toolbarset")
33 this.toolbarset = toolbarset.nextSibling;
34
35 if (this.toolbarset) {
36 // Create each toolbar described by the toolbarset.
37 var index = 0;
38 while (toolbarset.hasAttribute("toolbar"+(++index))) {
39 var toolbarInfo = toolbarset.getAttribute("toolbar"+index);
40 var infoSplit = toolbarInfo.split(":");
41 this.appendCustomToolbar(infoSplit[0], infoSplit[1]);
42 }
43 }
44 ]]>
45 </constructor>
46
47 <method name="appendCustomToolbar">
48 <parameter name="aName"/>
49 <parameter name="aCurrentSet"/>
appendCustomToolbar
50 <body>
51 <![CDATA[
52 var toolbar = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
53 "toolbar");
54 toolbar.id = "__customToolbar_" + aName.replace(" ", "_");
55 toolbar.setAttribute("customizable", "true");
56 toolbar.setAttribute("customindex", ++this.customToolbarCount);
57 toolbar.setAttribute("toolbarname", aName);
58 toolbar.setAttribute("currentset", aCurrentSet);
59 toolbar.setAttribute("mode", this.getAttribute("mode"));
60 toolbar.setAttribute("iconsize", this.getAttribute("iconsize"));
61 toolbar.setAttribute("context", this.toolbarset.getAttribute("context"));
62 toolbar.setAttribute("class", "chromeclass-toolbar");
63
64 this.insertBefore(toolbar, this.toolbarset);
65 return toolbar;
66 ]]>
67 </body>
68 </method>
69 </implementation>
70 </binding>
71
72 <binding id="toolbox-drag" display="xul:titlebar"
73 extends="chrome://global/content/bindings/toolbar.xml#toolbox">
74 <content allowevents="true">
75 <children/>
76 </content>
77 </binding>
78
79 <binding id="toolbar" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
80 <implementation implements="nsIAccessibleProvider">
81 <property name="accessibleType" readonly="true">
get_accessibleType
82 <getter>
83 return Components.interfaces.nsIAccessibleProvider.XULToolbar;
84 </getter>
85 </property>
field_firstPermanentChild
86 <field name="firstPermanentChild">
87 null
88 </field>
field_lastPermanentChild
89 <field name="lastPermanentChild">
90 null
91 </field>
92
get_toolbarName
set_toolbarName
93 <property name="toolbarName"
94 onget="return this.getAttribute('toolbarname');"
95 onset="this.setAttribute('toolbarname', val); return val;"/>
96
constructor
97 <constructor>
98 <![CDATA[
99 this.firstPermanentChild = this.firstChild;
100 this.lastPermanentChild = this.lastChild;
101
102 // Searching for the toolbox palette in the toolbar binding because
103 // toolbars are constructed first.
104 var toolbox = this.parentNode;
105
106 if (!toolbox.palette) {
107 // Look to see if there is a toolbarpalette.
108 var node = toolbox.firstChild;
109 while (node) {
110 if (node.localName == "toolbarpalette")
111 break;
112 node = node.nextSibling;
113 }
114
115 if (!node)
116 return;
117
118 // Hold on to the palette but remove it from the document.
119 toolbox.palette = node;
120 toolbox.removeChild(node);
121 }
122
123 // Build up our contents from the palette.
124 var currentSet = this.getAttribute("currentset");
125 if (!currentSet)
126 currentSet = this.getAttribute("defaultset");
127 if (currentSet)
128 this.currentSet = currentSet;
129 ]]>
130 </constructor>
131
132 <property name="currentSet">
get_currentSet
133 <getter>
134 <![CDATA[
135 var node = this.firstChild;
136 var currentSet = "";
137 while (node) {
138 if (node.id &&
139 node.localName == "toolbaritem" ||
140 node.localName == "toolbarbutton" ||
141 node.localName == "toolbarseparator" ||
142 node.localName == "toolbarspring" ||
143 node.localName == "toolbarspacer")
144 {
145 if (currentSet)
146 currentSet += ",";
147
148 if (node.localName == "toolbarseparator")
149 currentSet += "separator";
150 else if (node.localName == "toolbarspring")
151 currentSet += "spring";
152 else if (node.localName == "toolbarspacer")
153 currentSet += "spacer";
154 else
155 currentSet += node.id;
156 }
157 node = node.nextSibling;
158 }
159
160 return currentSet ? currentSet : "__empty";
161 ]]>
162 </getter>
163
set_currentSet
164 <setter>
165 <![CDATA[
166 // Remove all items before the first permanent child and after the last permanent child.
167 while (this.lastChild) {
168 if (this.lastChild == this.lastPermanentChild ||
169 (this.lastChild.localName == "toolbarpaletteitem" &&
170 this.lastChild.firstChild == this.lastPermanentChild))
171 break;
172 this.removeChild(this.lastChild);
173 }
174
175 while (this.firstChild) {
176 if (this.firstChild == this.firstPermanentChild ||
177 (this.firstChild.localName == "toolbarpaletteitem" &&
178 this.firstChild.firstChild == this.firstPermanentChild))
179 break;
180 this.removeChild(this.firstChild);
181 }
182
183 var firstChildID = this.firstPermanentChild ? this.firstPermanentChild.id : "";
184 var lastChildID = this.lastPermanentChild ? this.lastPermanentChild.id : "";
185
186 if (val && val != "__empty") {
187 var itemIds = val.split(",");
188 var before = true;
189 this._trackInserted = {};
190 for (var i = 0; i < itemIds.length; i++) {
191 if (itemIds[i] == firstChildID || itemIds[i] == lastChildID)
192 before = false;
193 else
194 this.insertItem(itemIds[i], null, null, before);
195 }
196 delete this._trackInserted;
197 }
198
199 return val;
200 ]]>
201 </setter>
202 </property>
203
204 <method name="insertItem">
205 <parameter name="aId"/>
206 <parameter name="aBeforeElt"/>
207 <parameter name="aWrapper"/>
208 <parameter name="aBeforePermanent"/>
insertItem
Called: XULElement:appendChild (54 calls, 58531 v-uS)
XULElement:cloneNode (41 calls, 1530 v-uS)
XULElement:createElementNS (13 calls, 369 v-uS)
XULElement:getTime (13 calls, 102 v-uS)
209 <body>
210 <![CDATA[
211 var newItem = null;
212
213 // Create special cases of palette items.
214 var uniqueId;
215 if (aId == "separator") {
216 newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
217 "toolbarseparator");
218 uniqueId = (new Date()).getTime()+this.childNodes.length;
219 newItem.id = "separator" + uniqueId;
220 newItem.className = "chromeclass-toolbar-additional";
221 } else if (aId == "spring") {
222 newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
223 "toolbarspring");
224 uniqueId = (new Date()).getTime()+this.childNodes.length;
225 newItem.flex = 1;
226 newItem.id = "spring" + uniqueId;
227 newItem.className = "chromeclass-toolbar-additional";
228 } else if (aId == "spacer") {
229 newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
230 "toolbarspacer");
231 uniqueId = (new Date()).getTime()+this.childNodes.length;
232 newItem.id = "spacer" + uniqueId;
233 newItem.className = "chromeclass-toolbar-additional";
234 } else if (this.parentNode.localName == "toolbox") {
235 if (this._trackInserted) {
236 // Protect against creating an item with the given id more than once.
237 if (aId in this._trackInserted)
238 return false;
239 this._trackInserted[aId] = null;
240 }
241 // Attempt to locate an item with a matching id within palette.
242 var paletteItem = this.parentNode.palette.firstChild;
243 while (paletteItem) {
244 var paletteId = paletteItem.id;
245 if (paletteId == aId) {
246 newItem = paletteItem.cloneNode(true);
247 break;
248 }
249 paletteItem = paletteItem.nextSibling;
250 }
251 }
252
253 if (!newItem)
254 return false;
255
256 var insertItem = newItem;
257
258 // Wrap the item in another node if so inclined.
259 if (aWrapper) {
260 aWrapper.appendChild(newItem);
261 insertItem = aWrapper;
262 }
263
264 // Insert the palette item into the toolbar.
265 if (aBeforeElt)
266 this.insertBefore(insertItem, aBeforeElt);
267 else if (aBeforePermanent && this.firstPermanentChild)
268 this.insertBefore(insertItem, this.firstPermanentChild);
269 else
270 this.appendChild(insertItem);
271
272 return newItem;
273 ]]>
274 </body>
275 </method>
276 </implementation>
277 </binding>
278
279 <binding id="menubar" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:menubar">
280 <implementation implements="nsIAccessibleProvider">
281 <property name="accessibleType" readonly="true">
get_accessibleType
282 <getter>
283 <![CDATA[
284 return Components.interfaces.nsIAccessibleProvider.XULMenubar;
285 ]]>
286 </getter>
287 </property>
field__active
288 <field name="_active">false</field>
field__statusbar
289 <field name="_statusbar">null</field>
field__originalStatusText
290 <field name="_originalStatusText">null</field>
get_statusbar
set_statusbar
291 <property name="statusbar" onget="return this.getAttribute('statusbar');"
292 onset="this.setAttribute('statusbar', val); return val;"/>
293 <method name="_updateStatusText">
294 <parameter name="itemText"/>
_updateStatusText
295 <body>
296 <![CDATA[
297 if (!this._active)
298 return;
299 var newText = itemText ? itemText : this._originalStatusText;
300 if (newText != this._statusbar.label)
301 this._statusbar.label = newText;
302 ]]>
303 </body>
304 </method>
305 </implementation>
306 <handlers>
307 <handler event="DOMMenuBarActive">
308 <![CDATA[
309 if (!this.statusbar) return;
310 this._statusbar = document.getElementById(this.statusbar);
311 if (!this._statusbar)
312 return;
313 this._active = true;
314 this._originalStatusText = this._statusbar.label;
315 ]]>
316 </handler>
317 <handler event="DOMMenuBarInactive">
318 <![CDATA[
319 if (!this._active)
320 return;
321 this._active = false;
322 this._statusbar.label = this._originalStatusText;
323 ]]>
324 </handler>
325 <handler event="DOMMenuItemActive">this._updateStatusText(event.target.statusText);</handler>
326 <handler event="DOMMenuItemInactive">this._updateStatusText("");</handler>
327 </handlers>
328 </binding>
329
330 <binding id="toolbardecoration" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
331 <implementation implements="nsIAccessibleProvider">
332 <property name="accessibleType" readonly="true">
get_accessibleType
333 <getter>
334 return Components.interfaces.nsIAccessibleProvider.XULToolbarSeparator;
335 </getter>
336 </property>
337 </implementation>
338 </binding>
339
340 <binding id="toolbarpaletteitem" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:button">
341 <content>
342 <xul:hbox class="toolbarpaletteitem-box" flex="1" xbl:inherits="type,place">
343 <children/>
344 </xul:hbox>
345 </content>
346 </binding>
347
348 <binding id="toolbarpaletteitem-palette" extends="chrome://global/content/bindings/toolbar.xml#toolbarpaletteitem">
349 <content>
350 <xul:hbox class="toolbarpaletteitem-box" xbl:inherits="type,place">
351 <children/>
352 </xul:hbox>
353 <xul:label xbl:inherits="value=title"/>
354 </content>
355 </binding>
356
357 </bindings>