2002-08-05 08:19:42 +04:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<bindings id="toolbarBindings"
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
xmlns:xbl="http://www.mozilla.org/xbl">
|
|
|
|
|
|
|
|
<binding id="toolbar-base">
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/toolbar.css"/>
|
|
|
|
</resources>
|
|
|
|
</binding>
|
|
|
|
|
2007-04-19 20:46:22 +04:00
|
|
|
<binding id="toolbox" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
|
2002-08-05 11:21:57 +04:00
|
|
|
<implementation>
|
|
|
|
<field name="palette">
|
|
|
|
null
|
|
|
|
</field>
|
2002-08-06 11:34:59 +04:00
|
|
|
|
2002-09-27 08:06:56 +04:00
|
|
|
<field name="toolbarset">
|
2002-08-06 11:34:59 +04:00
|
|
|
null
|
|
|
|
</field>
|
2002-09-27 08:06:56 +04:00
|
|
|
|
|
|
|
<field name="customToolbarCount">
|
|
|
|
0
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
|
|
|
// Look to see if there is a toolbarset.
|
|
|
|
this.toolbarset = this.firstChild;
|
|
|
|
while (this.toolbarset && this.toolbarset.localName != "toolbarset")
|
|
|
|
this.toolbarset = toolbarset.nextSibling;
|
|
|
|
|
|
|
|
if (this.toolbarset) {
|
|
|
|
// Create each toolbar described by the toolbarset.
|
|
|
|
var index = 0;
|
|
|
|
while (toolbarset.hasAttribute("toolbar"+(++index))) {
|
|
|
|
var toolbarInfo = toolbarset.getAttribute("toolbar"+index);
|
|
|
|
var infoSplit = toolbarInfo.split(":");
|
|
|
|
this.appendCustomToolbar(infoSplit[0], infoSplit[1]);
|
2002-08-06 11:22:38 +04:00
|
|
|
}
|
2002-09-27 08:06:56 +04:00
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</constructor>
|
|
|
|
|
|
|
|
<method name="appendCustomToolbar">
|
|
|
|
<parameter name="aName"/>
|
|
|
|
<parameter name="aCurrentSet"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var toolbar = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
|
|
|
"toolbar");
|
2004-12-01 07:48:44 +03:00
|
|
|
toolbar.id = "__customToolbar_" + aName.replace(" ", "_");
|
2002-09-27 08:06:56 +04:00
|
|
|
toolbar.setAttribute("customizable", "true");
|
|
|
|
toolbar.setAttribute("customindex", ++this.customToolbarCount);
|
|
|
|
toolbar.setAttribute("toolbarname", aName);
|
|
|
|
toolbar.setAttribute("currentset", aCurrentSet);
|
|
|
|
toolbar.setAttribute("mode", this.getAttribute("mode"));
|
|
|
|
toolbar.setAttribute("iconsize", this.getAttribute("iconsize"));
|
|
|
|
toolbar.setAttribute("context", this.toolbarset.getAttribute("context"));
|
2003-08-11 02:48:52 +04:00
|
|
|
toolbar.setAttribute("class", "chromeclass-toolbar");
|
|
|
|
|
2002-09-27 08:06:56 +04:00
|
|
|
this.insertBefore(toolbar, this.toolbarset);
|
|
|
|
return toolbar;
|
2002-08-06 11:22:38 +04:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2002-09-27 08:06:56 +04:00
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2003-11-20 08:14:08 +03:00
|
|
|
<binding id="toolbar" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
|
2007-04-19 20:46:22 +04:00
|
|
|
<implementation implements="nsIAccessibleProvider">
|
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
|
|
|
return Components.interfaces.nsIAccessibleProvider.XULToolbar;
|
|
|
|
</getter>
|
|
|
|
</property>
|
2002-10-29 03:13:49 +03:00
|
|
|
<field name="firstPermanentChild">
|
|
|
|
null
|
|
|
|
</field>
|
2002-09-27 08:06:56 +04:00
|
|
|
<field name="lastPermanentChild">
|
|
|
|
null
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<property name="toolbarName"
|
|
|
|
onget="return this.getAttribute('toolbarname');"
|
|
|
|
onset="this.setAttribute('toolbarname', val); return val;"/>
|
|
|
|
|
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
2002-10-29 03:13:49 +03:00
|
|
|
this.firstPermanentChild = this.firstChild;
|
2002-10-20 12:03:51 +04:00
|
|
|
this.lastPermanentChild = this.lastChild;
|
2002-09-27 08:06:56 +04:00
|
|
|
|
|
|
|
// Searching for the toolbox palette in the toolbar binding because
|
|
|
|
// toolbars are constructed first.
|
|
|
|
var toolbox = this.parentNode;
|
2002-10-20 12:03:51 +04:00
|
|
|
|
2002-09-27 08:06:56 +04:00
|
|
|
if (!toolbox.palette) {
|
|
|
|
// Look to see if there is a toolbarpalette.
|
|
|
|
var node = toolbox.firstChild;
|
|
|
|
while (node) {
|
|
|
|
if (node.localName == "toolbarpalette")
|
|
|
|
break;
|
|
|
|
node = node.nextSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!node)
|
2002-08-06 11:03:36 +04:00
|
|
|
return;
|
|
|
|
|
2002-09-27 08:06:56 +04:00
|
|
|
// Hold on to the palette but remove it from the document.
|
|
|
|
toolbox.palette = node;
|
|
|
|
toolbox.removeChild(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build up our contents from the palette.
|
|
|
|
var currentSet = this.getAttribute("currentset");
|
|
|
|
if (!currentSet)
|
|
|
|
currentSet = this.getAttribute("defaultset");
|
|
|
|
if (currentSet)
|
|
|
|
this.currentSet = currentSet;
|
|
|
|
]]>
|
|
|
|
</constructor>
|
|
|
|
|
|
|
|
<property name="currentSet">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
var node = this.firstChild;
|
|
|
|
var currentSet = "";
|
|
|
|
while (node) {
|
|
|
|
if (node.id &&
|
|
|
|
node.localName == "toolbaritem" ||
|
|
|
|
node.localName == "toolbarbutton" ||
|
|
|
|
node.localName == "toolbarseparator" ||
|
2002-09-28 19:11:50 +04:00
|
|
|
node.localName == "toolbarspring" ||
|
2007-11-15 06:38:16 +03:00
|
|
|
node.localName == "toolbarspacer")
|
2002-09-27 08:06:56 +04:00
|
|
|
{
|
|
|
|
if (currentSet)
|
|
|
|
currentSet += ",";
|
|
|
|
|
|
|
|
if (node.localName == "toolbarseparator")
|
|
|
|
currentSet += "separator";
|
2002-09-28 19:11:50 +04:00
|
|
|
else if (node.localName == "toolbarspring")
|
|
|
|
currentSet += "spring";
|
|
|
|
else if (node.localName == "toolbarspacer")
|
2002-09-27 08:06:56 +04:00
|
|
|
currentSet += "spacer";
|
|
|
|
else
|
|
|
|
currentSet += node.id;
|
2002-08-06 11:22:38 +04:00
|
|
|
}
|
2002-09-27 08:06:56 +04:00
|
|
|
node = node.nextSibling;
|
|
|
|
}
|
2002-08-05 11:21:57 +04:00
|
|
|
|
2002-09-27 08:06:56 +04:00
|
|
|
return currentSet ? currentSet : "__empty";
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
2002-10-29 03:13:49 +03:00
|
|
|
// Remove all items before the first permanent child and after the last permanent child.
|
2002-10-20 12:13:18 +04:00
|
|
|
while (this.lastChild) {
|
|
|
|
if (this.lastChild == this.lastPermanentChild ||
|
|
|
|
(this.lastChild.localName == "toolbarpaletteitem" &&
|
|
|
|
this.lastChild.firstChild == this.lastPermanentChild))
|
|
|
|
break;
|
2002-10-20 12:03:51 +04:00
|
|
|
this.removeChild(this.lastChild);
|
2002-10-20 12:13:18 +04:00
|
|
|
}
|
|
|
|
|
2002-10-29 03:13:49 +03:00
|
|
|
while (this.firstChild) {
|
|
|
|
if (this.firstChild == this.firstPermanentChild ||
|
|
|
|
(this.firstChild.localName == "toolbarpaletteitem" &&
|
|
|
|
this.firstChild.firstChild == this.firstPermanentChild))
|
|
|
|
break;
|
|
|
|
this.removeChild(this.firstChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
var firstChildID = this.firstPermanentChild ? this.firstPermanentChild.id : "";
|
|
|
|
var lastChildID = this.lastPermanentChild ? this.lastPermanentChild.id : "";
|
|
|
|
|
2007-04-19 20:46:22 +04:00
|
|
|
if (val && val != "__empty") {
|
2002-09-27 08:06:56 +04:00
|
|
|
var itemIds = val.split(",");
|
2002-10-29 03:13:49 +03:00
|
|
|
var before = true;
|
2008-04-04 13:03:05 +04:00
|
|
|
this._trackInserted = {};
|
2002-10-29 03:13:49 +03:00
|
|
|
for (var i = 0; i < itemIds.length; i++) {
|
|
|
|
if (itemIds[i] == firstChildID || itemIds[i] == lastChildID)
|
|
|
|
before = false;
|
|
|
|
else
|
|
|
|
this.insertItem(itemIds[i], null, null, before);
|
|
|
|
}
|
2008-04-04 13:03:05 +04:00
|
|
|
delete this._trackInserted;
|
2002-09-27 08:06:56 +04:00
|
|
|
}
|
2007-04-19 20:46:22 +04:00
|
|
|
|
|
|
|
return val;
|
2002-09-27 08:06:56 +04:00
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="insertItem">
|
|
|
|
<parameter name="aId"/>
|
|
|
|
<parameter name="aBeforeElt"/>
|
|
|
|
<parameter name="aWrapper"/>
|
2002-10-29 03:13:49 +03:00
|
|
|
<parameter name="aBeforePermanent"/>
|
2002-09-27 08:06:56 +04:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var newItem = null;
|
|
|
|
|
|
|
|
// Create special cases of palette items.
|
2003-07-23 18:24:05 +04:00
|
|
|
var uniqueId;
|
2002-09-27 08:06:56 +04:00
|
|
|
if (aId == "separator") {
|
|
|
|
newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
|
|
|
"toolbarseparator");
|
2003-07-23 18:24:05 +04:00
|
|
|
uniqueId = (new Date()).getTime()+this.childNodes.length;
|
2002-09-27 08:06:56 +04:00
|
|
|
newItem.id = "separator" + uniqueId;
|
2007-11-13 13:45:38 +03:00
|
|
|
newItem.className = "chromeclass-toolbar-additional";
|
2002-09-28 19:11:50 +04:00
|
|
|
} else if (aId == "spring") {
|
2002-09-27 08:06:56 +04:00
|
|
|
newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
2002-09-28 19:11:50 +04:00
|
|
|
"toolbarspring");
|
2003-07-23 18:24:05 +04:00
|
|
|
uniqueId = (new Date()).getTime()+this.childNodes.length;
|
2002-09-27 08:06:56 +04:00
|
|
|
newItem.flex = 1;
|
2002-09-28 19:11:50 +04:00
|
|
|
newItem.id = "spring" + uniqueId;
|
2007-11-13 13:45:38 +03:00
|
|
|
newItem.className = "chromeclass-toolbar-additional";
|
2002-09-28 19:11:50 +04:00
|
|
|
} else if (aId == "spacer") {
|
|
|
|
newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
|
|
|
"toolbarspacer");
|
2003-07-23 18:24:05 +04:00
|
|
|
uniqueId = (new Date()).getTime()+this.childNodes.length;
|
2002-09-27 08:06:56 +04:00
|
|
|
newItem.id = "spacer" + uniqueId;
|
2007-11-13 13:45:38 +03:00
|
|
|
newItem.className = "chromeclass-toolbar-additional";
|
2007-04-19 20:46:22 +04:00
|
|
|
} else if (this.parentNode.localName == "toolbox") {
|
2008-04-04 13:03:05 +04:00
|
|
|
if (this._trackInserted) {
|
|
|
|
// Protect against creating an item with the given id more than once.
|
|
|
|
if (aId in this._trackInserted)
|
|
|
|
return false;
|
|
|
|
this._trackInserted[aId] = null;
|
|
|
|
}
|
2002-09-27 08:06:56 +04:00
|
|
|
// Attempt to locate an item with a matching id within palette.
|
|
|
|
var paletteItem = this.parentNode.palette.firstChild;
|
2002-08-05 11:21:57 +04:00
|
|
|
while (paletteItem) {
|
2002-09-27 08:06:56 +04:00
|
|
|
var paletteId = paletteItem.id;
|
|
|
|
if (paletteId == aId) {
|
|
|
|
newItem = paletteItem.cloneNode(true);
|
2002-08-05 11:37:56 +04:00
|
|
|
break;
|
2002-08-05 11:21:57 +04:00
|
|
|
}
|
|
|
|
paletteItem = paletteItem.nextSibling;
|
|
|
|
}
|
|
|
|
}
|
2002-09-27 08:06:56 +04:00
|
|
|
|
2002-09-28 10:25:03 +04:00
|
|
|
if (!newItem)
|
2003-07-23 18:24:05 +04:00
|
|
|
return false;
|
2002-09-28 10:25:03 +04:00
|
|
|
|
2002-09-27 08:06:56 +04:00
|
|
|
var insertItem = newItem;
|
|
|
|
|
|
|
|
// Wrap the item in another node if so inclined.
|
|
|
|
if (aWrapper) {
|
|
|
|
aWrapper.appendChild(newItem);
|
|
|
|
insertItem = aWrapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Insert the palette item into the toolbar.
|
2002-10-20 12:03:51 +04:00
|
|
|
if (aBeforeElt)
|
|
|
|
this.insertBefore(insertItem, aBeforeElt);
|
2002-10-29 03:13:49 +03:00
|
|
|
else if (aBeforePermanent && this.firstPermanentChild)
|
2005-02-25 12:07:58 +03:00
|
|
|
this.insertBefore(insertItem, this.firstPermanentChild);
|
2002-09-27 08:06:56 +04:00
|
|
|
else
|
2005-02-25 12:07:58 +03:00
|
|
|
this.appendChild(insertItem);
|
2002-09-27 08:06:56 +04:00
|
|
|
|
|
|
|
return newItem;
|
2002-08-05 11:21:57 +04:00
|
|
|
]]>
|
|
|
|
</body>
|
2002-09-27 08:06:56 +04:00
|
|
|
</method>
|
2002-08-05 11:21:57 +04:00
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2003-11-20 08:14:08 +03:00
|
|
|
<binding id="menubar" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:menubar">
|
2002-08-05 08:19:42 +04:00
|
|
|
<implementation implements="nsIAccessibleProvider">
|
2006-07-24 20:12:08 +04:00
|
|
|
<property name="accessibleType" readonly="true">
|
2002-08-05 08:19:42 +04:00
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
2006-07-24 20:12:08 +04:00
|
|
|
return Components.interfaces.nsIAccessibleProvider.XULMenubar;
|
2002-08-05 08:19:42 +04:00
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
2003-08-13 05:55:39 +04:00
|
|
|
<field name="_active">false</field>
|
|
|
|
<field name="_statusbar">null</field>
|
|
|
|
<field name="_originalStatusText">null</field>
|
|
|
|
<property name="statusbar" onget="return this.getAttribute('statusbar');"
|
2007-04-19 20:46:22 +04:00
|
|
|
onset="this.setAttribute('statusbar', val); return val;"/>
|
|
|
|
<method name="_updateStatusText">
|
2003-08-13 05:55:39 +04:00
|
|
|
<parameter name="itemText"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this._active)
|
|
|
|
return;
|
|
|
|
var newText = itemText ? itemText : this._originalStatusText;
|
|
|
|
if (newText != this._statusbar.label)
|
|
|
|
this._statusbar.label = newText;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2002-08-05 08:19:42 +04:00
|
|
|
</implementation>
|
2003-08-13 05:55:39 +04:00
|
|
|
<handlers>
|
|
|
|
<handler event="DOMMenuBarActive">
|
2005-02-25 12:07:58 +03:00
|
|
|
<![CDATA[
|
2003-08-13 23:54:24 +04:00
|
|
|
if (!this.statusbar) return;
|
|
|
|
this._statusbar = document.getElementById(this.statusbar);
|
2003-08-13 05:55:39 +04:00
|
|
|
if (!this._statusbar)
|
2005-02-25 12:07:58 +03:00
|
|
|
return;
|
2003-08-13 05:55:39 +04:00
|
|
|
this._active = true;
|
|
|
|
this._originalStatusText = this._statusbar.label;
|
2005-02-25 12:07:58 +03:00
|
|
|
]]>
|
2003-08-13 05:55:39 +04:00
|
|
|
</handler>
|
|
|
|
<handler event="DOMMenuBarInactive">
|
|
|
|
<![CDATA[
|
|
|
|
if (!this._active)
|
2005-02-25 12:07:58 +03:00
|
|
|
return;
|
2003-08-13 05:55:39 +04:00
|
|
|
this._active = false;
|
|
|
|
this._statusbar.label = this._originalStatusText;
|
|
|
|
]]>
|
|
|
|
</handler>
|
2007-04-19 20:46:22 +04:00
|
|
|
<handler event="DOMMenuItemActive">this._updateStatusText(event.target.statusText);</handler>
|
|
|
|
<handler event="DOMMenuItemInactive">this._updateStatusText("");</handler>
|
2003-08-13 05:55:39 +04:00
|
|
|
</handlers>
|
2002-08-05 08:19:42 +04:00
|
|
|
</binding>
|
|
|
|
|
2007-04-19 20:46:22 +04:00
|
|
|
<binding id="toolbardecoration" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
|
|
|
|
<implementation implements="nsIAccessibleProvider">
|
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
|
|
|
return Components.interfaces.nsIAccessibleProvider.XULToolbarSeparator;
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
2002-09-28 19:11:50 +04:00
|
|
|
|
2003-11-20 08:14:08 +03:00
|
|
|
<binding id="toolbarpaletteitem" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:button">
|
2002-09-28 19:11:50 +04:00
|
|
|
<content>
|
|
|
|
<xul:hbox class="toolbarpaletteitem-box" flex="1" xbl:inherits="type,place">
|
|
|
|
<children/>
|
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
2003-11-20 08:14:08 +03:00
|
|
|
<binding id="toolbarpaletteitem-palette" extends="chrome://global/content/bindings/toolbar.xml#toolbarpaletteitem">
|
2002-09-28 19:11:50 +04:00
|
|
|
<content>
|
|
|
|
<xul:hbox class="toolbarpaletteitem-box" xbl:inherits="type,place">
|
|
|
|
<children/>
|
|
|
|
</xul:hbox>
|
|
|
|
<xul:label xbl:inherits="value=title"/>
|
|
|
|
</content>
|
|
|
|
</binding>
|
2002-08-05 08:19:42 +04:00
|
|
|
|
|
|
|
</bindings>
|
|
|
|
|