home *** CD-ROM | disk | FTP | other *** search
- <?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>
- <implementation implements="nsIAccessibleProvider">
- <property name="accessible">
- <getter>
- <![CDATA[
- var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
- if (this.localName == "toolbarseparator")
- return accService.createXULToolbarSeparatorAccessible(this);
- else
- return accService.createXULToolbarAccessible(this);
- ]]>
- </getter>
- </property>
- <constructor>
- <![CDATA[
- this.debug("TOOLBAR-BASE : Constructor, localName : " + this.localName + "\n");
- ]]>
- </constructor>
- <method name="debug">
- <parameter name="aStr"/>
- <body>
- //dump ("MULTIBAR: " + aStr);
- </body>
- </method>
- </implementation>
- </binding>
-
- <binding id="toolbox" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
- <implementation name="toolboxImp">
- <field name="palette">
- null
- </field>
-
- <field name="toolbarset">
- null
- </field>
-
- <field name="customToolbarCount">
- 0
- </field>
-
- <field name="customMultibarCount">
- 0
- </field>
-
- <constructor>
- <![CDATA[
-
- this.debug("TOOLBOX : Constructor, localName : " + this.localName + "\n");
- // 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(":");
- // JMC MERC - Added to handle spui components in custom bars
- var toolbarName = infoSplit.shift();
- var toolbarcontents = infoSplit.join(":");
- toolbar = this.appendCustomToolbar(toolbarName, toolbarcontents, true); // Dont add to set
- toolbar.setAttribute("iconsize", this.toolbarset.getAttribute("toolbariconsize"+index));
- toolbar.setAttribute("mode", this.toolbarset.getAttribute("toolbarmode"+index));
- }
-
- index = 0;
- while (toolbarset.hasAttribute("multibar"+(++index))) {
- this.debug ("Inserting a multibar\n");
- var multibarInfo = toolbarset.getAttribute("multibar"+index);
- if (multibarInfo) {
- var infoSplit = multibarInfo.split(":");
- // JMC MERC - Added to handle spui components in custom bars
- var multibarName = infoSplit.shift();
- var multibarcontents = infoSplit.join(":");
- var currentIdx = this.toolbarset.getAttribute("multibarselected"+index);
- var multibarshowtitle = this.toolbarset.getAttribute("multibarshowtitle"+index);
- var multibariconsize = this.toolbarset.getAttribute("multibariconsize"+index);
- var multibarmode = this.toolbarset.getAttribute("multibarmode"+index);
- var multibar = this.appendCustomMultibar(multibarName, multibarcontents, true); // Dont add to set
- multibar.setAttribute("currentIndex", currentIdx);
- multibar.setAttribute("iconsize", multibariconsize);
- multibar.setAttribute("mode", multibarmode);
- this.debug ("The multibar will show title : " + multibarshowtitle + "\n");
- multibar.setAttribute('showtitle', multibarshowtitle);
- }
- }
- }
-
- this.reorderToolbars();
- ]]>
- </constructor>
-
- <method name="removeToolbar">
- <parameter name="aElt"/>
- <body>
- <![CDATA[
- this.debug("TOOLBOX: Gonna delete toolbar called " + aElt.id + "\n");
-
- if (aElt.localName == 'toolbar' || aElt.localName == 'multibar') {
- var orderSplit = this.toolbarset.getAttribute("toolbarorder").split(",");
- var currentIndex = null;
- this.debug(' - orderSplit has '+orderSplit.length+' items:\n');
- for (var i=0; i < orderSplit.length; i++) {
- this.debug(' - ['+i+'] = '+orderSplit[i]+'\n');
- if (orderSplit[i] == aElt.id) {
- currentIndex = i;
- break;
- }
- }
- this.debug(' - currentIndex = '+currentIndex+'\n');
-
- if (currentIndex != null) {
- orderSplit.splice(currentIndex,1);
- var newToolbarOrder = orderSplit.join(',');
- this.debug(' - newToolbarOrder = '+newToolbarOrder+'\n');
- this.toolbarset.setAttribute("toolbarorder", newToolbarOrder);
- this.reorderToolbars();
- }
- }
- this.removeChild(aElt);
- ]]>
- </body>
- </method>
-
- <method name="renameToolbar">
- <parameter name="aToolbar"/>
- <parameter name="aName"/>
- <body>
- <![CDATA[
-
- if (aToolbar.localName == 'toolbar' || aToolbar.localName == 'multibar') {
- var orderSplit = this.toolbarset.getAttribute("toolbarorder").split(",");
- var currentIndex;
- for (var i=0; i < orderSplit.length; i++) {
- if (orderSplit[i] == aToolbar.id) {
- currentIndex = i;
- break;
- }
- }
-
- var oldId = aToolbar.id;
-
- // aToolbar.id = '';
- if (aToolbar.localName == 'toolbar')
- {
- if (aToolbar.id != 'nav-bar') {
- aToolbar.id = "__customToolbar_" + aName.replace(" ", "_");
- }
- } else if (aToolbar.id != 'PersonalToolbar') {
- aToolbar.id = "__customMultibar_" + aName.replace(" ", "_");
- }
-
- if (this.toolbarset.getAttribute('showsearch') == oldId) {
- this.toolbarset.setAttribute('showsearch', aToolbar.id);
- document.persist(this.toolbarset.id, "showsearch");
- }
-
- aToolbar.setAttribute('toolbarname', aName);
- orderSplit[currentIndex] = aToolbar.id;
- this.toolbarset.setAttribute("toolbarorder", orderSplit.join(","));
- this.reorderToolbars();
- }
- ]]>
- </body>
- </method>
-
- <method name="appendCustomToolbar">
- <parameter name="aName"/>
- <parameter name="aCurrentSet"/>
- <parameter name="bDontAddToSet"/>
- <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("currentSetAtLoadTime", aCurrentSet);
- toolbar.setAttribute("mode", this.getAttribute("mode"));
- toolbar.setAttribute("iconsize", this.getAttribute("iconsize"));
- toolbar.setAttribute("context", this.toolbarset.getAttribute("context"));
- toolbar.setAttribute("class", "chromeclass-toolbar toolbar-primary");
- toolbar.enableOverflowMenu = true;
-
- this.insertBefore(toolbar, this.toolbarset);
- if (!bDontAddToSet)
- this.assignOrdinal(toolbar);
- return toolbar;
- ]]>
- </body>
- </method>
-
- <method name="appendCustomMultibar">
- <parameter name="aName"/>
- <parameter name="aCurrentSet"/>
- <parameter name="bDontAddToSet"/>
- <body>
- <![CDATA[
- var toolbar = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- "multibar");
- // JMC: Ugly custom case hack! Fixme
- if (aName == 'PersonalToolbar') {
- toolbar.id = aName;
- } else {
- toolbar.id = "__customMultibar_" + aName.replace(" ", "_");
- }
- toolbar.setAttribute("customizable", "true");
- toolbar.setAttribute("customindex", ++this.customMultibarCount);
- toolbar.setAttribute("toolbarname", aName);
- toolbar.setAttribute("currentset", aCurrentSet); // JMC: Subtle change from above
- toolbar.setAttribute("currentSetAtLoadTime", aCurrentSet);
- toolbar.setAttribute("mode", this.getAttribute("mode"));
- toolbar.setAttribute("iconsize", this.getAttribute("iconsize"));
- toolbar.setAttribute("context", this.toolbarset.getAttribute("context"));
- toolbar.setAttribute("class", "chromeclass-toolbar");
-
- this.insertBefore(toolbar, this.toolbarset);
- if (!bDontAddToSet)
- this.assignOrdinal(toolbar);
- return toolbar;
- ]]>
- </body>
- </method>
-
- <method name="reorderToolbars">
- <body>
- <![CDATA[
-
- // dump ("Calling reorderToolbars... \n\n");
-
- if (this.toolbarset && this.toolbarset.hasAttribute("toolbarorder")) {
- var thisChild = this.firstChild;
- while (thisChild) {
- if (thisChild.localName == 'toolbar' ||
- thisChild.localName == 'multibar') {
- thisChild.removeAttribute('ordinal');
- }
- thisChild = thisChild.nextSibling;
- }
-
-
- var orderSplit = this.toolbarset.getAttribute("toolbarorder").split(",");
- var lowestOrdinal = 0;
- for (var i = 0; i < orderSplit.length; i++) {
- // dump ("Trying to assign ordinal for toolbar with id of " + orderSplit[i] + "\n\n");
- var toolbar = document.getElementById(orderSplit[i]);
- if (toolbar) {
- toolbar.setAttribute('ordinal', i+1);
- toolbar.removeAttribute('highestToolbar');
- // dump ("Set ordinal " + i + " for toolbar with id of " + orderSplit[i] + "\n\n");
- if (i == lowestOrdinal)
- {
- if (toolbar.getAttribute('collapsed') == 'true')
- lowestOrdinal = lowestOrdinal + 1;
- else
- toolbar.setAttribute('highestToolbar','true');
- }
- }
- }
- }
- ]]>
- </body>
- </method>
-
- <method name="assignOrdinal">
- <parameter name="aToolbar"/>
- <body>
- <![CDATA[
-
- // JMC - add it to the ordering in the toolbarset
- if (this.toolbarset) {
- var barOrder = this.toolbarset.getAttribute("toolbarorder");
- this.toolbarset.setAttribute("toolbarorder", barOrder + "," + aToolbar.id);
- document.persist(this.toolbarset.id, "toolbarorder");
- }
- // }
- ]]>
- </body>
- </method>
-
- <method name="moveToolbarUp">
- <parameter name="aToolbar"/>
- <body>
- <![CDATA[
-
- if (aToolbar.localName == 'multibartray') {
- aToolbar.parentNode.moveTrayUp(aToolbar);
- return;
- }
-
- var orderSplit = this.toolbarset.getAttribute("toolbarorder").split(",");
- var currentIndex;
- for (var i=0; i < orderSplit.length; i++) {
- if (orderSplit[i] == aToolbar.id) {
- currentIndex = i;
- break;
- }
- }
-
- if (currentIndex > 0) {
- var previousToolbarId = orderSplit[currentIndex - 1];
- orderSplit[currentIndex] = previousToolbarId;
- orderSplit[currentIndex - 1] = aToolbar.id;
-
- this.toolbarset.setAttribute("toolbarorder", orderSplit.join(","));
- this.reorderToolbars();
- }
-
- ]]>
- </body>
- </method>
-
-
- <method name="moveToolbarDown">
- <parameter name="aToolbar"/>
- <body>
- <![CDATA[
-
- if (aToolbar.localName == 'multibartray') {
- aToolbar.parentNode.moveTrayDown(aToolbar);
- return;
- }
-
- var orderSplit = this.toolbarset.getAttribute("toolbarorder").split(",");
- var currentIndex;
- for (var i=0; i < orderSplit.length; i++) {
- if (orderSplit[i] == aToolbar.id) {
- currentIndex = i;
- break;
- }
- }
-
- if (currentIndex < orderSplit.length - 1) {
- var nextToolbarId = orderSplit[currentIndex + 1];
- orderSplit[currentIndex] = nextToolbarId;
- orderSplit[currentIndex + 1] = aToolbar.id;
-
- this.toolbarset.setAttribute("toolbarorder", orderSplit.join(","));
- this.reorderToolbars();
- }
-
- ]]>
- </body>
- </method>
- </implementation>
- </binding>
-
- <binding id="toolbar" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base">
- <implementation name="toolbarimp">
- <field name="firstPermanentChild">
- null
- </field>
- <field name="lastPermanentChild">
- null
- </field>
-
- <property name="toolbarName"
- onget="return this.getAttribute('toolbarname');"
- onset="this.setAttribute('toolbarname', val); return val;"/>
- <property name="joshtemp">
- <getter>
- <![CDATA[
- if (this.hasAttribute('customindex'))
- return this.toolbox.toolbarset.getAttribute('joshtemp' + this.getAttribute('customindex'));
- ]]>
- </getter>
- <setter>
- <![CDATA[
- if (this.hasAttribute('customindex'))
- {
- this.toolbox.toolbarset.setAttribute('joshtemp' + this.getAttribute('customindex'), val);
- document.persist(this.toolbox.toolbarset.id, 'joshtemp' + this.getAttribute('customindex'));
- } else {
- this.debug('ACK! no customindex attribute.\n');
- this.setAttribute('joshtemp', val);
- }
- return val;
- ]]>
- </setter>
- </property>
- <constructor>
- <![CDATA[
- this.debug("TOOLBAR : Constructor, localName : " + this.localName + "\n");
- if (this.currentSetAtLoadTime)
- return;
-
- this.firstPermanentChild = this.firstChild;
- this.lastPermanentChild = this.lastChild;
-
-
- // Searching for the toolbox palette in the toolbar binding because
- // toolbars are constructed first.
- if (!this.toolbox || this.toolbox.localName != 'toolbox') {
- if (this.parentNode.localName == 'toolbox')
- this.toolbox = this.parentNode;
- else
- this.toolbox = this.parentNode.parentNode;
- }
-
- if (!this.toolbox.palette) {
- // Look to see if there is a toolbarpalette.
- var node = this.toolbox.firstChild;
- while (node) {
- if (node.localName == "toolbarpalette")
- break;
- node = node.nextSibling;
- }
-
- if (!node || node.localName != "toolbarpalette")
- return;
-
- // Hold on to the palette but remove it from the document.
- this.toolbox.palette = node;
- this.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;
- // Merc: save the initial value of currentSet for asynchronous SPUI loading
- this.currentSetAtLoadTime = currentSet;
-
- // JMC: All toolbars have overflow by default
- if (this.localName == 'multibartray')
- this.enableOverflowMenu = true;
- ]]>
- </constructor>
-
- <property name="currentSetAtLoadTime"/>
- <property name="toolbox"/>
- <property name="currentSet">
- <getter>
- <![CDATA[
-
- /*
-
- MERC: Need to preserve the instance id (for multiple buttons) in current set,
- so that preferences can be kept for each button instance.
-
- */
-
-
- var node = this.firstChild;
- var currentSet = "";
- while (node) {
- if (node.id &&
- node.localName == "toolbaritem" ||
- node.localName == "toolbarbutton" ||
- node.localName == "toolbarseparator" ||
- node.localName == "toolbarspring" ||
- node.localName == "toolbarspacer")
- {
- if (currentSet)
- currentSet += ",";
-
- if (node.localName == "toolbarseparator")
- currentSet += "separator";
- else if (node.localName == "toolbarspring")
- currentSet += "spring";
- else if (node.localName == "toolbarspacer")
- currentSet += "spacer";
- else
- currentSet += node.id;
- }
- node = node.nextSibling;
- }
-
- return currentSet ? currentSet : "__empty";
- ]]>
- </getter>
-
- <setter>
- <![CDATA[
- // Remove all items before the first permanent child and after the last permanent child.
- while (this.lastChild) {
- if (this.localName != 'multibartray' && (this.lastChild == this.lastPermanentChild ||
- (this.lastChild.localName == "toolbarpaletteitem" &&
- this.lastChild.firstChild == this.lastPermanentChild)))
- break;
- this.removeChild(this.lastChild);
- }
-
- while (this.firstChild) {
- if (this.localName != 'multibartray' && (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 : "";
-
- if (val == "__empty")
- return;
-
- if (val) {
- // dump("TOOLBAR: Setting current set to : " + val + "\n");
- var itemIds = val.split(",");
- var before = true;
- for (var i = 0; i < itemIds.length; i++) {
- if ((itemIds[i] == firstChildID) || (itemIds[i] == lastChildID)) {
- before = false;
- this.insertItem(itemIds[i], null, null, before);
- }
- else if (itemIds[i].indexOf("spui:") == -1 || this.toolbox) {
- // Don't bother inserting spui now
- // JMC : HACK
- if (this.localName == 'multibartray')
- before = false;
- this.insertItem(itemIds[i], null, null, before);
- }
- }
- }
- ]]>
- </setter>
- </property>
-
- <method name="reorderItems">
- <body>
- <![CDATA[
-
- if ((this.getAttribute('customindex')
- || this.parentNode.getAttribute('customindex'))
- && this.currentSet != "__empty") {
-
- var thisChild = this.firstChild;
- while (thisChild) {
- thisChild.removeAttribute('ordinal');
- thisChild = thisChild.nextSibling;
- }
-
- var orderSplit = this.currentSet.split(",");
- for (var i = 0; i < orderSplit.length; i++) {
- var toolItem = document.getElementById(orderSplit[i]);
- if (toolItem)
- toolItem.setAttribute('ordinal', i+1);
- }
- }
- ]]>
- </body>
- </method>
-
- <method name="insertItem">
- <parameter name="aId"/>
- <parameter name="aBeforeElt"/>
- <parameter name="aWrapper"/>
- <parameter name="aBeforePermanent"/>
- <body>
- <![CDATA[
-
- // dump("Insert Item named " + aId + "\n");
-
- var newItem = null;
-
- // Create special cases of palette items.
- var uniqueId;
- if (aId == "separator") {
- newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- "toolbarseparator");
- uniqueId = (new Date()).getTime()+this.childNodes.length;
- newItem.id = "separator" + uniqueId;
- } else if (aId == "spring") {
- newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- "toolbarspring");
- uniqueId = (new Date()).getTime()+this.childNodes.length;
- newItem.flex = 1;
- newItem.id = "spring" + uniqueId;
- } else if (aId == "spacer") {
- newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- "toolbarspacer");
- uniqueId = (new Date()).getTime()+this.childNodes.length;
- newItem.id = "spacer" + uniqueId;
- } else {
-
- var prefix;
- if (aId.indexOf("|") > -1) // This has a unique id
- {
- prefix = aId.substring(aId.indexOf("|") + 1,aId.length);
- aId = aId.substring(0, aId.indexOf("|"));
- }
- // JMC: if this is the second instance, add a unique prefix
- // var bIsDuplicate;
- // var toolbarItem = this.parentNode.
-
- if (!this.toolbox || !this.toolbox.palette.firstChild) {
- this.debug("++++ Toolbar/multitray bug - no palette available! \n\n");
- return;
- }
-
- // Attempt to locate an item with a matching id within palette.
- var paletteItem = this.toolbox.palette.firstChild;
- while (paletteItem) {
- var paletteId = paletteItem.id;
- // JMC - allow arbitrary id extensions
-
- if (paletteId == aId) {
- newItem = paletteItem.cloneNode(true);
- if (newItem.getAttribute("allowDuplicate")) {
- // JMC: Try a quick hack - give every button a unique
- if (!prefix) {
- prefix = (new Date()).getTime()+this.childNodes.length;
- }
-
- }
- if (prefix) {
- newItem.id = newItem.id + "|" + prefix;
- // JMC: Evil Hack - for spui buttons, find the iframe and change that id, too
-
- if (newItem.id.substring(0,5) == "spui:" ) {
- var iframe;
- var itemChild = newItem.firstChild;
- var bFound;
- while (itemChild && !bFound) {
- if (itemChild.localName == "stack") {
- var stackChild = itemChild.firstChild;
- while (stackChild && !bFound) {
- if (stackChild.localName == "vbox") {
- var vboxChild = stackChild.firstChild;
- while (vboxChild && !bFound) {
- if (vboxChild.localName == "iframe") {
- iframe = vboxChild;
- iframe.id = newItem.id + "-iframe";
- bFound = true;
- }
- vboxChild = vboxChild.nextSibling;
- }
- }
- stackChild = stackChild.nextSibling;
- }
- }
- itemChild = itemChild.nextSibling;
- }
- }
- }
- this.debug("inserting toolbar item from palette: "+paletteId+"\n");
- break;
- }
- paletteItem = paletteItem.nextSibling;
- }
- if (!newItem)
- this.debug("unable to find palette item for: "+aId+"\n");
- }
-
- if (!newItem)
- return false;
-
- var insertItem = newItem;
-
- // Wrap the item in another node if so inclined.
- if (aWrapper) {
- aWrapper.appendChild(newItem);
- insertItem = aWrapper;
- }
-
- if (this.firstPermanentChild)
- this.debug('First permanent child: '+this.firstPermanentChild.id+'\n');
-
- // Insert the palette item into the toolbar.
- if (aBeforeElt)
- {
- this.insertBefore(insertItem, aBeforeElt);
- }
- else if (aBeforePermanent && this.firstPermanentChild)
- {
- // dump ("TOOLBAR: Insert before permanent, firstpermanent is : " + this.firstPermanentChild + "\n");
- this.insertBefore(insertItem, this.firstPermanentChild);
- }
- else {
- this.appendChild(insertItem);
- }
-
- return newItem;
- ]]>
- </body>
- </method>
- </implementation>
- </binding>
-
- <binding id="toolbar-overflow" extends="chrome://global/content/bindings/toolbar.xml#toolbar">
- <implementation>
- <property name="enableOverflowMenu"/>
- <property name="allocating"/>
- <property name="lastWidth"/>
- <method name="allocateItems">
- <parameter name="aForce"/>
- <body>
- <![CDATA[
- // Only do the overflow menu allocation if specifically enabled
- if (!this.enableOverflowMenu) return;
-
- // If the toolbar has not actually changed width, bail out
- // (this helps avoid too-frequent calls)
- if (!aForce && this.boxObject.width == this.lastWidth) return;
- this.lastWidth = this.boxObject.width;
-
- // Function is not re-entrant
- if (this.allocating) return;
- this.allocating = true;
-
- // Clear out the overflow menu
- var oMenu = document.getAnonymousElementByAttribute(this, 'anonid', 'overflow-menu');
- while (oMenu.firstChild) {
- oMenu.removeChild(oMenu.firstChild);
- }
-
- // Iterate through the visible toolbar items
- var node = this.firstChild;
- // var tbRightExtent = this.boxObject.x + this.boxObject.width;
- var tbRightExtent = this.boxObject.screenX + this.boxObject.width;
- var oButton = document.getAnonymousElementByAttribute(this, 'anonid', 'overflow-button');
- var oWidth=oButton.boxObject.width;
- this.debug(' oWidth:'+oWidth+'\n');
- this.debug(' x:'+this.boxObject.screenX+' w:'+this.boxObject.width+' r:'+tbRightExtent+'\n');
- while (node) {
- var nodeRightExtent = node.boxObject.screenX + node.boxObject.width;
- this.debug(' node: #'+node.id+'# right:'+nodeRightExtent+'\n');
- if (!node.hasAttribute("disableoverflow") && nodeRightExtent > tbRightExtent - oWidth + 2) {
- node.setAttribute('toolbaroverflow','true');
- if (node.localName == 'toolbarbutton' || node.localName == 'toolbaritem') {
- var newMenuItem = document.createElement('menuitem');
- var menuLabel = '<no name>';
- if (node.hasAttribute('label')) {
- menuLabel = node.getAttribute('label');
- } else if (node.id) {
- menuLabel = node.id;
- }
- //this.debug(' overflow: '+menuLabel+'\n');
- newMenuItem.setAttribute('label', menuLabel);
- newMenuItem.setAttribute('buttonId', node.id);
- newMenuItem.setAttribute('oncommand', 'OverflowMenuCommand("'+node.id+'");');
- oMenu.appendChild(newMenuItem);
- }
- } else {
- node.removeAttribute('toolbaroverflow');
- }
- node = node.nextSibling;
- }
-
- // Show or hide overflow button
- var oButton = document.getAnonymousElementByAttribute(this, 'anonid', 'overflow-button');
- if (oMenu.childNodes.length > 0) {
- oButton.hidden = false;
- } else {
- oButton.hidden = true;
- }
-
- this.allocating = false;
- ]]>
- </body>
- </method>
- </implementation>
- <content>
- <xul:hbox flex="1">
- <xul:hbox flex="1" align="center" class="toolbar-inner-container toolbar-left-margin">
- <children/>
- </xul:hbox>
- <xul:toolbarbutton anonid="overflow-button" type="menu"
- class="toolbar-overflow-button" hidden="true">
- <xul:menupopup anonid="overflow-menu" class="toolbar-overflow-menu"/>
- </xul:toolbarbutton>
- </xul:hbox>
- </content>
- <handlers>
- <handler event="overflow">
- <![CDATA[
- //this.debug('toolbar.xml: toolbar *overflow* event for "'+this.toolbarName+'"\n');
- this.allocateItems();
- ]]>
- </handler>
- <handler event="underflow">
- <![CDATA[
- //this.debug('toolbar.xml: toolbar *underflow* event for "'+this.toolbarName+'"\n');
- this.allocateItems();
- ]]>
- </handler>
- </handlers>
- </binding>
-
- // for now, empty binding to deal with -moz-binding rules from communicator.css
- // (see bug 227993) we may need that binding one day to propagate
- // the text/icons/both state to other windows. If we don't, this binding
- // should be removed after we stop shipping the seamonkey communicator.css skin files.
- <binding id="toolbar-primary" extends="chrome://global/content/bindings/toolbar.xml#toolbar"/>
-
- <binding id="menubar" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:menubar">
- <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>
- <field name="_active">false</field>
- <field name="_statusbar">null</field>
- <field name="_originalStatusText">null</field>
- <property name="statusbar" onget="return this.getAttribute('statusbar');"
- onset="return this.setAttribute('statusbar', val)"/>
- <method name="updateStatusText">
- <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>
- </implementation>
- <handlers>
- <handler event="DOMMenuBarActive">
- if (!this.statusbar) return;
- this._statusbar = document.getElementById(this.statusbar);
- if (!this._statusbar)
- return;
- this._active = true;
- this._originalStatusText = this._statusbar.label;
- </handler>
- <handler event="DOMMenuBarInactive">
- <![CDATA[
- if (!this._active)
- return;
- this._active = false;
- this._statusbar.label = this._originalStatusText;
- ]]>
- </handler>
- <handler event="DOMMenuItemActive">this.updateStatusText(event.target.statusText);</handler>
- <handler event="DOMMenuItemInactive">this.updateStatusText("");</handler>
- </handlers>
- </binding>
-
- <binding id="toolbardecoration" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base"/>
-
- <binding id="toolbarpaletteitem" extends="chrome://global/content/bindings/toolbar.xml#toolbar-base" display="xul:button">
- <content>
- <xul:hbox class="toolbarpaletteitem-box" flex="1" xbl:inherits="type,place">
- <children/>
- </xul:hbox>
- </content>
- </binding>
-
- <binding id="toolbarpaletteitem-palette" extends="chrome://global/content/bindings/toolbar.xml#toolbarpaletteitem">
- <content>
- <xul:hbox class="toolbarpaletteitem-box" xbl:inherits="type,place">
- <children/>
- </xul:hbox>
- <xul:label xbl:inherits="value=title"/>
- </content>
- </binding>
-
- </bindings>
-