Reduce bloat in composer dialog JS. b=183055, r=akkana, sr=hewitt

This commit is contained in:
cmanske%netscape.com 2002-12-02 23:05:27 +00:00
Родитель 0953aae2ad
Коммит d0ace40852
3 изменённых файлов: 11 добавлений и 48 удалений

Просмотреть файл

@ -49,11 +49,11 @@ function BuildHTMLAttributeNameList()
limitFirstChar = name.indexOf("^") >= 0;
if (limitFirstChar)
{
menuitem = AppendStringToMenulist(gDialog.AddHTMLAttributeNameInput, name.replace(/\^/g, ""));
menuitem = gDialog.AddHTMLAttributeNameInput.appendItem(name.replace(/\^/g, ""));
menuitem.setAttribute("limitFirstChar", "true");
}
else
AppendStringToMenulist(gDialog.AddHTMLAttributeNameInput, name);
gDialog.AddHTMLAttributeNameInput.appendItem(name);
}
}
else if (name == "-")
@ -80,7 +80,7 @@ function BuildHTMLAttributeNameList()
// Strip flag characters
name = name.replace(/[!^#%$+]/g, "");
menuitem = AppendStringToMenulist(gDialog.AddHTMLAttributeNameInput, name);
menuitem = gDialog.AddHTMLAttributeNameInput.appendItem(name);
if (menuitem)
{
// Signify "required" attributes by special style
@ -250,7 +250,7 @@ function onInputHTMLAttributeName()
popup.appendChild(sep);
}
} else {
AppendStringToMenulist(gDialog.AddHTMLAttributeValueMenulist, valueList[i]);
gDialog.AddHTMLAttributeValueMenulist.appendItem(valueList[i]);
}
}
}

Просмотреть файл

@ -238,47 +238,10 @@ function GetAppropriatePercentString(elementForAtt, elementInDoc)
} catch (e) { return "";}
}
function AppendStringToMenulistById(menulist, stringID)
{
return AppendStringToMenulist(menulist, GetString(stringID));
}
function AppendStringToMenulist(menulist, string)
{
if (menulist)
{
var menupopup = menulist.firstChild;
// May not have any popup yet -- so create one
if (!menupopup)
{
menupopup = document.createElementNS(XUL_NS, "menupopup");
if (menupopup)
menulist.appendChild(menupopup);
else
return null;
}
var menuItem = document.createElementNS(XUL_NS, "menuitem");
if (menuItem)
{
menuItem.setAttribute("label", string);
menupopup.appendChild(menuItem);
return menuItem;
}
}
return null;
}
function ClearMenulist(menulist)
{
// Always use "AppendStringToMenulist" so we know there's
// just one <menupopup> as 1st child of <menulist>
if (menulist) {
menulist.selectedItem = null;
var popup = menulist.firstChild;
if (popup)
while (popup.firstChild)
popup.removeChild(popup.firstChild);
}
if (menulist)
menulist.removeAllItems();
}
function ClearListbox(listbox)
@ -338,11 +301,11 @@ function InitPixelOrPercentMenulist(elementForAtt, elementInDoc, attribute, menu
}
ClearMenulist(menulist);
pixelItem = AppendStringToMenulist(menulist, GetString("Pixels"));
pixelItem = menulist.appendItem(GetString("Pixels"));
if (!pixelItem) return 0;
percentItem = AppendStringToMenulist(menulist, GetAppropriatePercentString(elementForAtt, elementInDoc));
percentItem = menulist.appendItem(GetAppropriatePercentString(elementForAtt, elementInDoc));
if (size && size.length > 0)
{
// Search for a "%" or "px"

Просмотреть файл

@ -203,7 +203,7 @@ function FillSiteList()
for (i = 0; i < count; i++)
{
var name = gPublishSiteData[i].siteName;
var menuitem = AppendStringToMenulist(gDialog.SiteList, name);
var menuitem = gDialog.SiteList.appendItem(name);
// Highlight the default site
if (name == gDefaultSiteName)
{
@ -258,8 +258,8 @@ function SelectSiteList()
{
for (var i = 0; i < gPublishSiteData[selectedSiteIndex].dirList.length; i++)
{
AppendStringToMenulist(gDialog.DocDirList, gPublishSiteData[selectedSiteIndex].dirList[i]);
AppendStringToMenulist(gDialog.OtherDirList, gPublishSiteData[selectedSiteIndex].dirList[i]);
gDialog.DocDirList.appendItem(gPublishSiteData[selectedSiteIndex].dirList[i]);
gDialog.OtherDirList.appendItem(gPublishSiteData[selectedSiteIndex].dirList[i]);
}
}
gDialog.DocDirList.value = FormatDirForPublishing(gPublishSiteData[selectedSiteIndex].docDir);