From 0d6df8fc86c5b02b6146702f90a68b9094dd16a9 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Sun, 20 Oct 2002 08:03:51 +0000 Subject: [PATCH] Enable menubar customization. --- browser/base/content/browser.js | 11 +++++++---- toolkit/content/customizeToolbar.js | 17 +++++++++++------ toolkit/content/widgets/toolbar.xml | 22 +++++++--------------- toolkit/skin/win/menu.css | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index ef2044bda4c0..45dbf1cb05f5 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1329,12 +1329,14 @@ function updateToolbarStates(toolbarMenuElt) for (i = 0; i < toolbarMenuElt.childNodes.length; ++i) document.getElementById(toolbarMenuElt.childNodes[i].getAttribute("observes")).removeAttribute("checked"); var toolbars = document.getElementsByTagName("toolbar"); - for (i = 0; i < toolbars.length; ++i) { + + // Start i at 1, since we skip the menubar. + for (i = 1; i < toolbars.length; ++i) { if (toolbars[i].getAttribute("class").indexOf("chromeclass") != -1) toolbars[i].setAttribute("hidden", "true"); } var statusbars = document.getElementsByTagName("statusbar"); - for (i = 0; i < statusbars.length; ++i) { + for (i = 1; i < statusbars.length; ++i) { if (statusbars[i].getAttribute("class").indexOf("chromeclass") != -1) statusbars[i].setAttribute("hidden", "true"); } @@ -2615,7 +2617,7 @@ function openAboutDialog() function BrowserCustomizeToolbar() { - // Disable tlhe menubar and toolbar context menu items + // Disable the toolbar context menu items var menubar = document.getElementById("main-menubar"); for (var i = 0; i < menubar.childNodes.length; ++i) menubar.childNodes[i].setAttribute("disabled", true); @@ -3044,7 +3046,8 @@ function onViewToolbarsPopupShowing(aEvent) for (i = 0; i < toolbox.childNodes.length; ++i) { var toolbar = toolbox.childNodes[i]; var toolbarName = toolbar.getAttribute("toolbarname"); - if (toolbarName) { + var type = toolbar.getAttribute("type"); + if (toolbarName && type != "menubar") { var menuItem = document.createElement("menuitem"); menuItem.setAttribute("toolbarindex", i); menuItem.setAttribute("type", "checkbox"); diff --git a/toolkit/content/customizeToolbar.js b/toolkit/content/customizeToolbar.js index bc0ec5eb1d69..f8057c0690cf 100644 --- a/toolkit/content/customizeToolbar.js +++ b/toolkit/content/customizeToolbar.js @@ -131,6 +131,11 @@ function notifyParentComplete() gToolbox.customizeDone(gToolboxChanged); } +function getToolbarAt(i) +{ + return gToolbox.childNodes[i]; +} + /** * Persist the current set of buttons in all customizable toolbars to * localstore. @@ -143,7 +148,7 @@ function persistCurrentSets() var customCount = 0; for (var i = 0; i < gToolbox.childNodes.length; ++i) { // Look for customizable toolbars that need to be persisted. - var toolbar = gToolbox.childNodes[i]; + var toolbar = getToolbarAt(i); if (isCustomizableToolbar(toolbar)) { // Calculate currentset and store it in the attribute. var currentSet = toolbar.currentSet; @@ -183,7 +188,7 @@ function persistCurrentSets() function wrapToolbarItems() { for (var i = 0; i < gToolbox.childNodes.length; ++i) { - var toolbar = gToolbox.childNodes[i]; + var toolbar = getToolbarAt(i); if (isCustomizableToolbar(toolbar)) { for (var k = 0; k < toolbar.childNodes.length; ++k) { var item = toolbar.childNodes[k]; @@ -291,7 +296,7 @@ function getCurrentItemIds() { var currentItems = {}; for (var i = 0; i < gToolbox.childNodes.length; ++i) { - var toolbar = gToolbox.childNodes[i]; + var toolbar = getToolbarAt(i); if (isCustomizableToolbar(toolbar)) { var child = toolbar.firstChild; while (child) { @@ -585,7 +590,7 @@ function updateIconSize(aUseSmallIcons) gToolboxDocument.persist(gToolbox.id, "iconsize"); for (var i = 0; i < gToolbox.childNodes.length; ++i) { - var toolbar = gToolbox.childNodes[i]; + var toolbar = getToolbarAt(i); if (isCustomizableToolbar(toolbar)) { setAttribute(toolbar, "iconsize", val); gToolboxDocument.persist(toolbar.id, "iconsize"); @@ -601,7 +606,7 @@ function updateToolbarMode(aModeValue) gToolboxDocument.persist(gToolbox.id, "mode"); for (var i = 0; i < gToolbox.childNodes.length; ++i) { - var toolbar = gToolbox.childNodes[i]; + var toolbar = getToolbarAt(i); if (isCustomizableToolbar(toolbar)) { setAttribute(toolbar, "mode", aModeValue); gToolboxDocument.persist(toolbar.id, "mode"); @@ -632,7 +637,7 @@ function setAttribute(aElt, aAttr, aVal) function isCustomizableToolbar(aElt) { - return aElt.localName == "toolbar" && + return (aElt.localName == "toolbar" && aElt.getAttribute("customizable") == "true"; } diff --git a/toolkit/content/widgets/toolbar.xml b/toolkit/content/widgets/toolbar.xml index e0fd24833dd2..10d54ee9a0ec 100644 --- a/toolkit/content/widgets/toolbar.xml +++ b/toolkit/content/widgets/toolbar.xml @@ -80,11 +80,12 @@ - - - - diff --git a/toolkit/skin/win/menu.css b/toolkit/skin/win/menu.css index 0e3cc1341128..830a1016c9db 100644 --- a/toolkit/skin/win/menu.css +++ b/toolkit/skin/win/menu.css @@ -108,7 +108,7 @@ menubar > menu[_moz-menuactive="true"] { border-left: 1px solid ThreeDHighlight; } -menubar > menu[_moz-menuactive="true"][open="true"] { +menubar > menu[_moz-menuactive="true"][open="true"] { border-top: 1px solid ThreeDShadow; border-right: 1px solid ThreeDHighlight; border-bottom: 1px solid ThreeDHighlight;