home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
-
- <!DOCTYPE bindings [
- <!ENTITY % multibarDTD SYSTEM "chrome://global/locale/multibar.dtd" >
- %multibarDTD;
- ]>
- <bindings id="multibarBindings" 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="multibar">
- <implementation>
- <method name="debug">
- <parameter name="aStr"/>
- <body>
- // dump ("MULTIBAR: " + aStr);
- </body>
- </method>
- <constructor><![CDATA[
-
- this.debug("MULTIBAR : Constructor, localName : " + this.localName + "\n");
- // Searching for the toolbox palette in the toolbar binding because
- // toolbars are constructed first.
- if (!this.toolbox || this.toolbox.localName != 'toolbox') {
- if (this.parentNode && this.parentNode.localName == 'toolbox')
- this.toolbox = this.parentNode;
- } else {
- return;
- }
-
- 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)
- return;
-
- // Hold on to the palette but remove it from the document.
- this.toolbox.palette = node;
- this.toolbox.removeChild(node);
- }
-
-
- this.debug("\nConstructor for a multibar : " + this + "\n\n");
- // Build up our contents from the palette.
- var mycurrentSet = this.getAttribute("currentset");
- if (!mycurrentSet)
- mycurrentSet = this.getAttribute("defaultset");
- if (mycurrentSet) {
- this.currentSet = mycurrentSet;
- } else {
- addNewTray("default");
- addNewTray("second_tray");
- }
-
- if (this.toolbox.toolbarset.getAttribute("showsearch") == this.id) {
- var newItem;
- var paletteItem = this.toolbox.palette.firstChild;
- while (paletteItem) {
- if (paletteItem.id == 'search-container') {
- newItem = paletteItem.cloneNode(true);
- break;
- }
- paletteItem = paletteItem.nextSibling;
- }
- if (newItem)
- this.searchParent.appendChild(newItem);
- }
-
- // this.showTrayTitle = this.showTrayTitle;
-
- if (this.hasAttribute("currentIndex"))
- {
- this.showTray(this.getAttribute("currentIndex"));
- } else {
- this.showTray(0);
- }
-
-
- ]]></constructor>
- <property name="searchParent"
- onget="return document.getAnonymousElementByAttribute(this,'anonid','multibar-searchbar-parent');"/>
- <property name="searchBar" onget="return this.searchParent.firstChild;"/>
- <property name="mLabel"
- onget="return document.getAnonymousElementByAttribute(this,'anonid','multibar-tray-label');"/>
- <property name="mTrayDeck"
- onget="return document.getAnonymousElementByAttribute(this,'anonid','multibar-deck');"/>
- <property name="mTrays" onget="return this.childNodes;"/>
- <property name="mTrayBox" onget="return this.boxObject;"/>
- <property name="currentTrayIndex" onget="return parseInt(this.mTrayDeck.selectedIndex);"
- onset="this.mTrayDeck.selectedIndex=val;"/>
- <property name="currentTrayOrdinal"
- onget="return this.mCurrentControlButton.getAttribute('ordinal');"/>
- <property name="currentTray" onget="return this.mTrays[this.currentTrayIndex]"/>
- <property name="mCurrentControlButton"
- onget="return this.mControlContainer.childNodes[this.currentTrayIndex];"/>
- <property name="mControlContainer"
- onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'multibar-control').childNodes[1];"/>
- <property name="toolbox"/>
- <method name="get_persisted_prop">
- <parameter name="propertyName"/>
- <body><![CDATA[
- var result;
- if (this.hasAttribute('customindex')) {
- result = this.toolbox.toolbarset.getAttribute(propertyName + this.getAttribute('customindex'));
- } else {
- result = this.getAttribute(propertyName);
- }
- if (result == 'true') return true;
- if (result == 'false') return false;
- return result;
- ]]></body>
- </method>
- <method name="persist_prop">
- <parameter name="propertyName"/>
- <parameter name="val"/>
- <body><![CDATA[
- if (val == null)
- return;
-
- if (this.hasAttribute('customindex'))
- {
- this.toolbox.toolbarset.setAttribute(propertyName + this.getAttribute('customindex'), val.toString());
- document.persist(this.toolbox.toolbarset.id, propertyName + this.getAttribute('customindex'));
- } else {
- this.debug('ACK! no customindex attribute.\n');
- this.setAttribute(propertyName, val.toString());
- }
- return val;
- ]]></body>
- </method>
- <property name="mMenuDropMarker"
- onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'spawnPopup');"/>
- <property name="currentSet">
- <getter><![CDATA[
-
- // JMC - little hack to make sure everything has an ordinal
- // this.reorderTrays();
-
- var currentSet = "";
-
- for (var i =0 ; i < this.mTrays.length; i++)
- {
- var node = this.getTrayByOrdinal(i);
- if (node)
- {
- if (currentSet)
- currentSet += ";";
- currentSet += node.getAttribute('toolbarname') + ":" + node.currentSet;
- }
- }
-
- return currentSet ? currentSet : "__empty";
- ]]></getter>
- <setter><![CDATA[
-
- // Remove all items before the first permanent child and after the last permanent child.
-
- this.debug("Setting current set for multibar\n\n");
- this.setAttribute("currentset", val);
-
- var node = this.mTrays[0];
- while (node) {
- this.removeChild(node);
- // remove the control button
- this.mControlContainer.removeChild(this.mControlContainer.childNodes[0]);
- node = this.mTrays[0];
- }
-
- if (val == "__empty")
- return;
-
- if (val) {
- var itemIds = val.split(";");
- for (var i = 0; i < itemIds.length; i++) {
- var infoSplit = itemIds[i].split(":");
- var multibarName = infoSplit.shift();
-
- this.debug("Going to add a tray called " + multibarName + "\n\n");
- var multibarcontents = infoSplit.join(":");
- var thisTray = this.addNewTray(multibarName, true);
- this.debug('Attempted to add a new tray... do we have a tray? : ' + thisTray + '\n');
- if (thisTray)
- {
- thisTray.setAttribute("currentset",multibarcontents);
- if (thisTray.currentSet != multibarcontents)
- {
- thisTray.currentSet = multibarcontents;
- } else
- {
- this.debug("Not setting currentSet because it already matches.\n");
- }
- }
- else
- {
- this.debug("Attempting bad or duplicate tray name add.\n");
- }
- }
- }
-
- this.persist_prop('multibar', this.getAttribute('toolbarname') + ":" + val);
- ]]></setter>
- </property>
- <method name="getTrayByName">
- <parameter name="trayName"/>
- <body><![CDATA[
-
- for (var i = 0; i < this.mTrays.length; i++) {
- if (this.mTrays[i].getAttribute("toolbarname") == trayName)
- return this.mTrays[i];
- }
-
- ]]></body>
- </method>
- <method name="getTrayByOrdinal">
- <parameter name="trayOrdinal"/>
- <body><![CDATA[
-
- for (var i =0; i < this.mTrays.length; i++)
- {
- if (this.mControlContainer.childNodes[i].getAttribute("ordinal") == trayOrdinal) {
- return this.getTrayByName(this.mControlContainer.childNodes[i].getAttribute("tooltiptext"));
- }
- }
-
- ]]></body>
- </method>
- <method name="propagateAttribute">
- <parameter name="parent"/>
- <parameter name="attributeName"/>
- <parameter name="attributeValue"/>
- <parameter name="depth"/>
- <body><![CDATA[
- if(parent && depth > 0) {
- this.debug(parent.localName);
- if(parent.localName != "stack") {
- parent.setAttribute(attributeName, attributeValue);
- this.debug("-" + attributeName + " = " + parent.getAttribute(attributeName) + "(" + attributeValue + ")\n");
- }
- for(var thisChild = parent.firstChild; thisChild; thisChild = thisChild.nextSibling) {
- this.propagateAttribute(thisChild, attributeName, attributeValue, depth - 1);
- }
- }
- ]]></body>
- </method>
- <method name="showTray">
- <parameter name="trayIndex"/>
- <body><![CDATA[
- this.debug("Trying to show tray numba : " + trayIndex + "\n");
- if (this.mTrays.length <= trayIndex) return;
- // save the old tray index
- var oldTrayIndex = this.mTrayDeck.getAttribute('selectedIndex');
- this.mTrayDeck.setAttribute('selectedIndex', trayIndex);
-
- var labelText = this.mTrays[trayIndex].getAttribute('toolbarname');
- this.mLabel.setAttribute('value', labelText);
-
- //
- // set attribute for selected control icon
- //
- if (oldTrayIndex != null) {
- this.debug("The old tray was at index " + oldTrayIndex + "\n\n");
- var oldTray = this.mControlContainer.childNodes[parseInt(oldTrayIndex)];
- if (oldTray) {
- this.debug("The old tray was an " + oldTray.localName + "\n\n");
- this.debug("The old tray was called " + oldTray.getAttribute('toolbarname') + "\n\n");
- this.propagateAttribute(this.mTrays[parseInt(oldTrayIndex)], 'isActive', 'false', 5);
- oldTray.setAttribute('selected', 'false');
- }
- }
- this.mControlContainer.childNodes[this.currentTrayIndex].setAttribute('selected', 'true');
- this.propagateAttribute(this.mTrays[this.currentTrayIndex], 'isActive', 'true', 5);
-
- // make sure the multibar label text isn't greyed out
- this.mLabel.removeAttribute('rollover');
-
- // JMC: Persist this sucka
- this.persist_prop('multibarselected', this.currentTrayIndex);
-
- this.setAttribute('currentIndex', this.currentTrayIndex);
-
- ]]></body>
- </method>
- <method name="showTrayByObj">
- <parameter name="aTray"/>
- <body><![CDATA[
-
- for (var i = 0; i < this.mTrays.length; i++) {
- if (this.mTrays[i] == aTray) {
- this.showTray(i);
- return;
- }
- }
-
- ]]></body>
- </method>
- <method name="getIndexOfTray">
- <parameter name="aTray"/>
- <body><![CDATA[
- for (var i = 0; i < this.mTrays.length; i++) {
- if (this.mTrays[i] == aTray) {
- return i;
- }
- }
- ]]></body>
- </method>
- <method name="isInvalidName">
- <parameter name="aName"/>
- <parameter name="aType"/>
- <body><![CDATA[
- var errorCode = null;
- if (!aName) {
- errorCode = "empty";
- } else if (aName.indexOf(",") > -1 || aName.indexOf("|") > -1 || aName.indexOf(":") > -1 ||
- aName.indexOf(";") > -1 || aName.indexOf(".") > -1|| aName.indexOf("?") > -1) {
- errorCode = "invalid";
- } else {
- for (var i =0; i < this.mTrays.length; i++) {
- if (this.mTrays[i].getAttribute("toolbarname") == aName) {
- // JMC/JVL - Don't show error if renaming same tray to same name
- if (this.mTrays[i] == this.currentTray && aType == "rename")
- errorCode = "rename";
- else
- errorCode = "duplicate";
- }
- }
- }
- return errorCode;
-
- ]]></body>
- </method>
- <method name="checkDelete">
- <parameter name="aTrayIndex"/>
- <body><![CDATA[
- var msgTitle = "";
- var msgText = "";
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- msgTitle = "Confirm Delete Tray";
- msgText = "You are about to delete the tray " + this.mTrays[aTrayIndex].getAttribute('toolbarname') +
- " permanently. Are you sure you wish to proceed?";
-
- return promptService.confirm(null, msgTitle, msgText);
- ]]></body>
- </method>
- <method name="checkName">
- <parameter name="aName"/>
- <parameter name="aType"/>
- <body><![CDATA[
- var errorCode = null;
- var msgTitle = "";
- var msgText = "";
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- errorCode = this.isInvalidName(aName, aType);
- if (errorCode) {
- switch (errorCode) {
- case "empty":
- default:
- msgTitle = "Missing tray name";
- msgText = "Please enter a tray name.";
- break;
-
- case "invalid":
- msgTitle = "Invalid tray name";
- msgText = "Tray names cannot contain these characters: ',', '&', '=', ':', ';', '?'.";
- break;
-
- case "duplicate":
- msgTitle = "Duplicate tray name";
- msgText = "You cannot have two trays with the same name.";
- break;
-
- case "rename":
- return false;
- }
- promptService.alert(null, msgTitle, msgText);
- return false;
- }
- return true;
- ]]></body>
- </method>
- <method name="addNewTray">
- <parameter name="trayName"/>
- <parameter name="bSuppressOrdinal"/>
- <body><![CDATA[
-
- trayName = trayName.replace(/^\s+/, "").replace(/\s+$/, "");
-
- if (this.mTrays.length > 9) {
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
- var msgTitle = "Too many trays";
- var msgText = "You can have only 10 trays per multibar. \nTry creating a new multibar, \nor remove some of your existing trays.";
- promptService.alert(null, msgTitle, msgText);
- return false;
-
- } else if (!this.checkName(trayName, 'add')) {
- this.debug('Bad tray name!!!\n');
- return null;
- }
-
- this.debug("\nAdding a tray named : " + trayName + "\n\n");
- var trayId = trayName.replace(/\s/g,"_");
- //*
- //* add tray control button
- //*
- // create image elem
- var newImage = document.createElement('image');
- newImage.setAttribute('class', 'multibar-control-btn-icon');
- // create label elem
- var newLabel = document.createElement('label');
- newLabel.setAttribute('class', 'multibar-control-btn-label');
- // create stack elem and attach children
- var newStack = document.createElement('stack');
- newLabel.setAttribute('value', this.mControlContainer.childNodes.length + 1);
- newStack.appendChild(newImage);
- newStack.appendChild(newLabel);
- // create toolbarbutton elem and attach stack
-
- var newButton = document.createElement('toolbarbutton');
- newButton.setAttribute('trayIndex', this.mControlContainer.childNodes.length);
- newButton.setAttribute('tooltiptext', trayName);
- newButton.setAttribute('trayName', trayId);
- newButton.setAttribute('onmouseover', "var mb=this; while (mb.localName!='multibar') mb=mb.parentNode; mb.changeLabel(this);");
- newButton.setAttribute('onmouseout', "var mb=this; while (mb.localName!='multibar') mb=mb.parentNode; mb.changeLabel();");
-
- newButton.appendChild(newStack);
-
-
- // append new tray control
- this.mControlContainer.appendChild(newButton);
-
- //*
- //* add tray
- //*
- // create multibar tray elem
- var newTray = document.createElement('multibartray');
- newTray.setAttribute('toolbarname', trayName);
- newTray.setAttribute("customizable", "true");
- suffix = (new Date()).getTime()+this.childNodes.length;
- newTray.id = this.getAttribute("toolbarname").replace(/\s/g,"_") + "_" + trayId;
-
- // append the new tray
- this.appendChild(newTray);
- if (!bSuppressOrdinal)
- this.assignOrdinal(newTray);
-
- this.reorderTrays();
- this.persist_prop('multibar', this.getAttribute('toolbarname') + ":" + this.currentSet);
- // select the newly added tray
- if (!bSuppressOrdinal)
- this.showTray(this.mControlContainer.childNodes.length-1);
-
- this.printControl();
- this.debug('number of trays: ' + this.childNodes.length + '\n');
- return newTray;
- ]]></body>
- </method>
- <method name="changeLabel">
- <parameter name="aButton"/>
- <body><![CDATA[
- var labelText;
-
- if (aButton && (aButton != this.mCurrentControlButton)) {
- labelText = aButton.getAttribute('tooltiptext');
- this.mLabel.setAttribute("rollover", "true");
- } else {
- labelText = this.currentTray.getAttribute('toolbarname');
- this.mLabel.removeAttribute("rollover");
- }
- this.mLabel.setAttribute('value', labelText);
- ]]></body>
- </method>
- <method name="insertItem">
- <parameter name="aId"/>
- <parameter name="aBeforeElt"/>
- <parameter name="aWrapper"/>
- <parameter name="aBeforePermanent"/>
- <body><![CDATA[
-
- // Just insert this to the current tray
- var newItem = this.mTrays[this.currentTrayIndex].insertItem(aId, aBeforeElt, aWrapper, aBeforePermanent);
- this.setAttribute("currentset",this.currentSet);
- return newItem;
- ]]></body>
- </method>
- <method name="renameTray">
- <parameter name="trayIndex"/>
- <parameter name="trayName"/>
- <body><![CDATA[
-
- // JMC - If this tray is showing the search widget, update the toolbarset to point to its' new toolbarname_
-
- var oldTrayId = this.mTrays[trayIndex].id;
-
- trayName = trayName.replace(/^\s+/, "").replace(/\s+$/, "");
- trayId = trayName.replace(/\s/g,"_");
-
- if (!this.checkName(trayName, 'rename')) {
- return false;
- }
- // change the tray name attribute
- this.mTrays[trayIndex].setAttribute('toolbarname', trayName);
- this.mTrays[trayIndex].id = trayId;
-
- if (this.toolbox.toolbarset.getAttribute('showsearch') == oldTrayId) {
- this.toolbox.toolbarset.setAttribute('showsearch', trayId);
- document.persist(this.toolbox.toolbarset.id, "showsearch");
- }
-
- // change the control button tooltip
- this.mControlContainer.childNodes[trayIndex].setAttribute('tooltiptext', trayName);
- this.mControlContainer.childNodes[trayIndex].setAttribute('trayName', trayId);
-
- // change the control label if current tray
- if(trayIndex == this.currentTrayIndex) {
- this.mLabel.setAttribute('value', trayName);
- }
- this.setAttribute('currentset', this.currentSet);
- this.reorderTrays();
- this.persist_prop('multibar', this.getAttribute('toolbarname') + ":" + this.currentSet);
- return true;
-
- ]]></body>
- </method>
- <method name="deleteTrayByObj">
- <parameter name="trayObj"/>
- <parameter name="aForce"/>
- <body><![CDATA[
-
- this.deleteTray(this.getIndexOfTray(trayObj), aForce);
-
- ]]></body>
- </method>
- <method name="deleteTray">
- <parameter name="trayIndex"/>
- <parameter name="aForce"/>
- <body><![CDATA[
-
- if (!aForce && !this.checkDelete(trayIndex)) // Early exit prevents prompting
- {
- return false;
- }
-
- var oldOrdinal = this.mControlContainer.childNodes[trayIndex].getAttribute("ordinal");
- var currentOrdinal = this.mControlContainer.childNodes[this.currentTrayIndex].getAttribute("ordinal");
- this.debug("MULTIBAR: doing delete, old currentset is : " + this.currentSet + "\n\n");
-
- var orderSplit = this.currentSet.split(";");
- orderSplit.splice(oldOrdinal,1);
- this.debug("MULTIBAR: doing delete, new currentset is : " + orderSplit.join(";") + "\n\n");
- this.setAttribute("currentset", orderSplit.join(";"));
-
- this.reorderTrays();
-
- // remove the tray from multibar
- this.removeChild(this.mTrays[trayIndex]);
-
- // remove the control button
- this.mControlContainer.removeChild(this.mControlContainer.childNodes[trayIndex]);
-
- // Reset the trayIndex attribute in case delete or add has changed them
- for (var i=0; i < this.mTrays.length; i++)
- {
- this.mControlContainer.childNodes[i].setAttribute('trayIndex', i);
- }
-
- // Get tray with ordinal one less than this one
- if (oldOrdinal <= currentOrdinal)
- this.showTrayByObj(this.getTrayByOrdinal((oldOrdinal > 0) ? (oldOrdinal - 1) : 0));
- else
- this.showTrayByObj(this.getTrayByOrdinal(currentOrdinal));
-
-
- this.persist_prop('multibar', this.getAttribute('toolbarname') + ":" + this.currentSet);
-
- return true;
- ]]></body>
- </method>
- <method name="showPopup">
- <body><![CDATA[
- this.debug('***** showPopup() *******\n');
- var dropmarker = this.mMenuDropMarker;
- var popup = document.getElementById('multibarMenu');
-
- //
- // first delete all menuitems associated with trays
- //
- this.debug('**** number of trays: ' + this.mTrays.length + '\n');
- while(popup.firstChild.hasAttribute("trayOrdinal")) {
- popup.removeChild(popup.firstChild);
- }
-
- //
- // add a menuitem for each tray
- //
- var traySeparatorItem = popup.firstChild;
- var menuitem;
- for(var j = 0; j < this.mTrays.length; j++) {
- menuitem = document.createElement("menuitem");
- menuitem.setAttribute("type", "checkbox");
- menuitem.setAttribute("label", this.mControlContainer.childNodes[this.ordinalToIndex(j)].getAttribute("trayName"));
- menuitem.setAttribute("trayOrdinal", j);
- if(this.ordinalToIndex(j) == this.currentTrayIndex) {
- menuitem.setAttribute("checked", "true");
- }
- popup.insertBefore(menuitem, traySeparatorItem);
- }
- /*
- // check/uncheck Show Tray Title menu item
- var showTrayTitleMenuItem = document.getElementById('multibarShowTrayTitleMenuItem');
- if(this.showTrayTitle)
- {
- showTrayTitleMenuItem.setAttribute('checked', 'true');
- }
- else
- {
- showTrayTitleMenuItem.removeAttribute('checked');
- }
- */
-
- popup.multibar = this;
- this.debug("x: "+ dropmarker.boxObject.screenX + " y: " + dropmarker.boxObject.screenY + dropmarker.boxObject.height);
- popup.showPopup(dropmarker,
- -1,
- -1,
- "popup", "bottomleft", "topleft");
- ]]></body>
- </method>
- <method name="menuCommand">
- <parameter name="event"/>
- <body><![CDATA[
- if(event.target.hasAttribute("trayOrdinal")) {
- this.showTray(this.ordinalToIndex(event.target.getAttribute("trayOrdinal")));
- } else if(event.target.id == "multibarAddMenuItem") {
- window.openDialog("chrome://global/content/addRenameTrayDialog.xul", "addRenameTrayDialog",
- "centerscreen,modal=yes", 'add', this);
- } else if(event.target.id == "multibarRenameMenuItem") {
- window.openDialog("chrome://global/content/addRenameTrayDialog.xul", "addRenameTrayDialog",
- "centerscreen,modal=yes", 'rename', this);
- } else if(event.target.id == "multibarEditMenuItem") {
- window.openDialog("chrome://global/content/editTrayDialog.xul", "editTrayDialog",
- "centerscreen,modal=yes", this);
- } else if(event.target.id == "multibarShowTrayTitleMenuItem") {
- this.debug("Toggling show title\n");
- this.showTrayTitle = !this.showTrayTitle;
- } else if(event.target.id == "multibarCustomizeMenuItem") {
- BrowserCustomizeToolbar();
- }
- ]]></body>
- </method>
- <!-- debug -->
- <method name="printControl">
- <body><![CDATA[
- if(!this.mControlContainer) {
- this.debug('Can not find the control\n');
- return;
- }
-
- this.debug('number of controls: ' + this.mControlContainer.childNodes.length + '\n');
- ]]></body>
- </method>
- <method name="reorderTrays">
- <body><![CDATA[
- this.debug("multibar: gonna reorder Trays\n\n");
- var thisChild = this.firstChild;
- while (thisChild) {
- if (thisChild.localName == 'multibartray') {
- thisChild.removeAttribute('ordinal');
- }
- thisChild = thisChild.nextSibling;
- }
-
- var orderSplit = this.getAttribute("currentset").split(";");
- var ordinalCount = 0;
- for (var i = 0; i < orderSplit.length; i++) {
- var trayCSet = orderSplit[i];
- var trayName = trayCSet.split(":").shift();
- this.debug ("Trying to find the tray called : " + trayName + "\n\n");
- this.debug("multibar: Looking for button with trayName " + trayName + "\n\n");
- var thisButton = document.getAnonymousElementByAttribute(this, "tooltiptext", trayName);
- if (thisButton)
- {
- this.debug("multibar: Setting ordinal " + (ordinalCount) + "\n\n");
- thisButton.setAttribute('ordinal', ordinalCount);
- thisButton.childNodes[0].childNodes[1].setAttribute('value', ordinalCount+1);
- ordinalCount++;
- }
- }
- ]]></body>
- </method>
- <method name="assignOrdinal">
- <parameter name="aTray"/>
- <body><![CDATA[
- var barOrder = this.getAttribute("currentset");
- this.setAttribute("currentset", barOrder + ";"
- + aTray.getAttribute("toolbarname") + ":"
- + aTray.currentSet);
-
- ]]></body>
- </method>
- <method name="moveTrayUp">
- <parameter name="aTray"/>
- <body><![CDATA[
- var orderSplit = this.currentSet.split(";");
- var currentIndex;
- var trayCSet;
- for (var i=0; i < orderSplit.length; i++) {
- trayCSet = orderSplit[i];
- var trayName = trayCSet.split(":").shift();
- if (trayName == aTray.getAttribute("toolbarname")) {
- currentIndex = i;
- break;
- }
- }
-
- if (currentIndex > 0) {
- var previousTrayCSet = orderSplit[currentIndex - 1];
- var previousTrayName = previousTrayCSet.split(":").shift();
- orderSplit[currentIndex] = previousTrayCSet;
- orderSplit[currentIndex - 1] = trayCSet;
-
- this.setAttribute("currentset", orderSplit.join(";"));
- // this.parentNode.setAttribute("currentset", this.parentNode.getAttribute("currentSet"));
- this.reorderTrays();
- this.persist_prop('multibar', this.getAttribute('toolbarname') + ":" + this.currentSet);
- this.persist_prop('multibarselected', this.currentTrayIndex);
- this.persist_prop('currentIndex', this.currentTrayIndex);
- }
-
- ]]></body>
- </method>
- <method name="moveTrayDown">
- <parameter name="aTray"/>
- <body><![CDATA[
- var orderSplit = this.currentSet.split(";");
- var currentIndex;
- var trayCSet;
- for (var i=0; i < orderSplit.length; i++) {
- trayCSet = orderSplit[i];
- var trayName = trayCSet.split(":").shift();
- if (trayName == aTray.getAttribute("toolbarname")) {
- currentIndex = i;
- break;
- }
- }
-
- if (currentIndex < orderSplit.length - 1) {
- var previousTrayCSet = orderSplit[currentIndex + 1];
- var previousTrayName = previousTrayCSet.split(":").shift();
- orderSplit[currentIndex] = previousTrayCSet;
- orderSplit[currentIndex + 1] = trayCSet;
-
- this.setAttribute("currentset", orderSplit.join(";"));
- // this.parentNode.setAttribute("currentset", this.parentNode.getAttribute("currentSet"));
- this.reorderTrays();
- this.persist_prop('multibar', this.getAttribute('toolbarname') + ":" + this.currentSet);
- this.persist_prop('multibarselected', this.currentTrayIndex);
- this.persist_prop('currentIndex', this.currentTrayIndex);
- }
-
- ]]></body>
- </method>
- <method name="ordinalToIndex">
- <parameter name="aOrdinal"/>
- <body><![CDATA[
- for(var i = 0; i < this.mTrays.length; i++) {
- if(aOrdinal == this.mControlContainer.childNodes[i].getAttribute('ordinal'))
- return i;
- }
- this.debug("**** ERROR - could not find ordinal!\n");
- ]]></body>
- </method>
- </implementation>
- <content>
- <xul:hbox class="multibar toolbar-left-margin toolbar-right-margin" flex="1">
-
- <xul:vbox class="multibar-main-control" align="stretch" pack="stretch">
- <xul:button tooltiptext="&multibarDropDown.tooltiptext;" anonid="spawnPopup" class="multibar-top-button-target " align="stretch" pack="end" flex="1">
- <xul:stack align="stretch" pack="stretch" flex="1">
- <xul:vbox align="stretch" pack="stretch" flex="1">
- <xul:hbox class="multibar-main-button"/>
- <xul:hbox class="multibar-main-horiz-line" align="stretch" pack="stretch" flex="1"/>
- </xul:vbox>
- <xul:hbox class="multibar-label-and-drop" align="center" pack="end">
- <xul:spacer flex="1"/>
- <xul:label anonid="multibar-tray-label" class="multibar-tray-label" crop="end" />
- <xul:spacer flex="1"/>
- <xul:image class="multibar-drop" context=""/>
- </xul:hbox>
- </xul:stack>
- </xul:button>
- <xul:hbox pack="end">
- <xul:toolbarbutton tooltiptext="&multibarLeftButton.tooltiptext;" class="multibar-left-button" prevTray="true" context=""/>
- <xul:toolbarbutton tooltiptext="&multibarRightButton.tooltiptext;" class="multibar-right-button" nextTray="true" context=""/>
- </xul:hbox>
- </xul:vbox>
-
-
- <xul:vbox style="display:none;" anonid="multibar-control" class="multibar-control"
- align="center" pack="center">
- <xul:hbox align="start" pack="center">
- <xul:label anonid="multibar-tray-label-old" class="multibar-tray-label-old"
- crop="end"/>
- </xul:hbox>
- <xul:hbox anonid="multibar-control-container" class="multibar-control-container"
- align="center" pack="center"/>
- </xul:vbox>
-
- <xul:vbox flex="1">
- <xul:hbox class="multibartray-top-edge" align="stretch" pack="stretch"/>
- <xul:hbox pack="stretch" flex="10">
- <xul:hbox anonid="multibar-searchbar-parent"/>
- <xul:deck anonid="multibar-deck" flex="10" class="multibar-deck" selectedIndex="0">
- <children/>
- </xul:deck>
- </xul:hbox>
- <xul:hbox class="multibartray-bottom-edge" align="stretch" pack="stretch"/>
- </xul:vbox>
- <xul:hbox>
- <xul:vbox pack="stretch" align="stretch">
- <xul:hbox class="multibar-ctl-right-top">
- <xul:image/>
- </xul:hbox>
- <xul:hbox class="multibar-ctl-right-middle" flex="1"/>
- <xul:hbox class="multibar-ctl-right-bottom">
- <xul:image/>
- </xul:hbox>
- </xul:vbox>
- </xul:hbox>
- </xul:hbox>
- </content>
- <handlers>
- <handler event="command"><![CDATA[
-
- if (event.originalTarget.hasAttribute('trayIndex')) {
- this.debug('catch all command handler\n');
- var idx = parseInt(event.originalTarget.getAttribute('trayIndex'));
- this.showTray(idx);
-
- /*
- if (idx >= this.mTrays.length-1) {
- this.showTray(0);
- this.showTrayTitle = false;
- } else {
- this.showTray(idx + 1);
- this.showTrayTitle = true;
- }
- */
- }
-
- if(event.originalTarget.hasAttribute('nextTray')) {
- var newOrdinal;
- if(this.currentTrayOrdinal == this.mTrays.length - 1) {
- newOrdinal = 0;
- } else {
- newOrdinal = parseInt(this.currentTrayOrdinal) + 1;
- }
- showTrayByObj(this.getTrayByOrdinal(newOrdinal));
- } else if(event.originalTarget.hasAttribute('prevTray')) {
- var newOrdinal;
- if(this.currentTrayOrdinal == 0) {
- newOrdinal = this.mTrays.length - 1;
- } else {
- newOrdinal = parseInt(this.currentTrayOrdinal) - 1;
- }
- showTrayByObj(this.getTrayByOrdinal(newOrdinal));
- }
- ]]></handler>
- <handler event="click" button="0"><![CDATA[
- // if(event.originalTarget.parentNode == this.mMenuDropMarker) {
- if(event.originalTarget == this.mMenuDropMarker) {
- this.showPopup();
- }
- event.preventBubble();
- ]]></handler>
- <handler event="click" button="2"><![CDATA[
- // MERC (rpaul) prevent multibar dropmarker menu and toolbar
- // contect menu from simultaneously appearing
- // if(event.originalTarget.parentNode == this.mMenuDropMarker) {
- if(event.originalTarget == this.mMenuDropMarker) {
- return;
- }
- event.preventBubble();
- ]]></handler>
- </handlers>
- </binding>
- <binding id="multibartray" extends="chrome://global/content/bindings/toolbar.xml#toolbar-overflow">
- <content>
- <xul:hbox flex="1" class="multibartray-left-margin">
- <xul:hbox flex="1" align="center" class="toolbar-inner-container ">
- <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>
- <implementation>
- <property name="mode" onget="return this.parentNode.getAttribute('mode');"/>
- <property name="iconsize" onget="return this.parentNode.getAttribute('iconsize');"/>
- <constructor><![CDATA[
- this.debug("MULTIBARTRAY : Constructor, localName : " + this.localName + "\n");
- ]]></constructor>
- </implementation>
- </binding>
- </bindings>
-