From 65e2af214eedcba9c158ccbca56df3572f32aab6 Mon Sep 17 00:00:00 2001 From: "steffen.wilberg%web.de" Date: Sat, 5 Mar 2005 01:22:30 +0000 Subject: [PATCH] Bug 214707: Don't allow creation of nameless toolbars. p=gavin.sharp@gmail.com, r=bsmedberg --- toolkit/content/customizeToolbar.js | 24 +++++++++++++------ .../chrome/global/customizeToolbar.properties | 1 + 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/toolkit/content/customizeToolbar.js b/toolkit/content/customizeToolbar.js index fdbf9630bbb4..fabfa84761aa 100644 --- a/toolkit/content/customizeToolbar.js +++ b/toolkit/content/customizeToolbar.js @@ -527,28 +527,38 @@ function addNewToolbar() var stringBundle = document.getElementById("stringBundle"); var message = stringBundle.getString("enterToolbarName"); var title = stringBundle.getString("enterToolbarTitle"); - + var name = {}; + while (true) { + if (!promptService.prompt(window, title, message, name, null, {})) return; - + + if (!name.value) { + message = stringBundle.getFormattedString("enterToolbarBlank", [name.value]); + continue; + } + var dupeFound = false; - + // Check for an existing toolbar with the same display name for (i = 0; i < gToolbox.childNodes.length; ++i) { var toolbar = gToolbox.childNodes[i]; var toolbarName = toolbar.getAttribute("toolbarname"); - if (toolbarName == name.value && toolbar.getAttribute("type") != "menubar") { + + if (toolbarName == name.value && + toolbar.getAttribute("type") != "menubar" && + toolbar.nodeName == 'toolbar') { dupeFound = true; break; } - } + } if (!dupeFound) break; - - message = stringBundle.getFormattedString("enterToolbarDup", [name.value]); + + message = stringBundle.getFormattedString("enterToolbarDup", [name.value]); } gToolbox.appendCustomToolbar(name.value, ""); diff --git a/toolkit/locales/en-US/chrome/global/customizeToolbar.properties b/toolkit/locales/en-US/chrome/global/customizeToolbar.properties index 8ca35e65068b..d985ceee0860 100644 --- a/toolkit/locales/en-US/chrome/global/customizeToolbar.properties +++ b/toolkit/locales/en-US/chrome/global/customizeToolbar.properties @@ -1,6 +1,7 @@ enterToolbarTitle=New Toolbar enterToolbarName=Enter a name for this toolbar: enterToolbarDup=There is already a toolbar with the name "%S". Please enter a different name. +enterToolbarBlank=You must enter a name to create a new toolbar. separatorTitle=Separator springTitle=Flexible Space spacerTitle=Space