gecko-dev/toolkit/content/widgets/toolbar.xml

247 строки
8.4 KiB
XML
Исходник Обычный вид История

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>
<binding id="toolbox" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base">
2002-08-05 11:21:57 +04:00
<implementation>
<field name="palette">
null
</field>
<field name="toolbarset">
null
</field>
<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
}
}
]]>
</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");
toolbar.id = "__customToolbar_" + aName.replace(" ", "");
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"));
this.insertBefore(toolbar, this.toolbarset);
return toolbar;
2002-08-06 11:22:38 +04:00
]]>
</body>
</method>
</implementation>
</binding>
<binding id="toolbar" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base">
<implementation>
<field name="lastPermanentChild">
null
</field>
<property name="toolbarName"
onget="return this.getAttribute('toolbarname');"
onset="this.setAttribute('toolbarname', val); return val;"/>
<constructor>
<![CDATA[
this.lastPermanentChild = this.firstChild;
// Searching for the toolbox palette in the toolbar binding because
// toolbars are constructed first.
var toolbox = this.parentNode;
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;
// 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" ||
node.localName == "spacer")
{
if (currentSet)
currentSet += ",";
if (node.localName == "toolbarseparator")
currentSet += "separator";
else if (node.localName == "spacer")
currentSet += "spacer";
else
currentSet += node.id;
2002-08-06 11:22:38 +04:00
}
node = node.nextSibling;
}
2002-08-05 11:21:57 +04:00
return currentSet ? currentSet : "__empty";
]]>
</getter>
<setter>
<![CDATA[
// Remove all items before the last permanent child.
if (this.lastPermanentChild) {
while (this.lastPermanentChild.previousSibling)
this.removeChild(this.lastPermanentChild.previousSibling);
} else {
while (this.lastChild)
this.removeChild(this.lastChild);
2002-08-06 11:22:38 +04:00
}
2002-08-06 05:52:11 +04:00
if (val == "__empty")
return;
2002-08-10 05:59:12 +04:00
if (val) {
var itemIds = val.split(",");
for (var i = 0; i < itemIds.length; i++)
this.insertItem(itemIds[i], null);
}
]]>
</setter>
</property>
<method name="insertItem">
<parameter name="aId"/>
<parameter name="aBeforeElt"/>
<parameter name="aWrapper"/>
<body>
<![CDATA[
var newItem = null;
// Create special cases of palette items.
if (aId == "separator") {
newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"toolbarseparator");
var uniqueId = (new Date()).getTime();
newItem.id = "separator" + uniqueId;
} else if (aId == "spacer") {
newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"spacer");
var uniqueId = (new Date()).getTime();
newItem.flex = 1;
newItem.id = "spacer" + uniqueId;
} else {
// 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) {
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-28 10:25:03 +04:00
if (!newItem)
return;
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.
if (aBeforeElt || this.lastPermanentChild)
this.insertBefore(insertItem, aBeforeElt ? aBeforeElt : this.lastPermanentChild);
else
this.appendChild(insertItem);
return newItem;
2002-08-05 11:21:57 +04:00
]]>
</body>
</method>
2002-08-05 11:21:57 +04:00
</implementation>
</binding>
2002-08-05 08:19:42 +04:00
<binding id="menubar" extends="xul:menubar">
<resources>
<stylesheet src="chrome://global/skin/toolbar.css"/>
</resources>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return accService.createXULMenubarAccessible(this);
]]>
</getter>
</property>
</implementation>
</binding>
2002-08-05 11:12:53 +04:00
<binding id="toolbarseparator" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base"/>
2002-08-05 08:19:42 +04:00
<binding id="toolbarpaletteitem" extends="chrome://global/content/widgets/toolbar.xml#toolbar-base" display="xul:button"/>
2002-08-05 08:19:42 +04:00
</bindings>