MenuManager.appendSubMenu Member

Appends a sub-menu to an existing menu.

Syntax

object.appendSubMenu(parentNode, beforeNode, menuName, domId, label, accesskey, attribs);

Arguments

ArgumentSummary
parentNode DOM Node to insert into
beforeNode DOM Node already contained by parentNode, to insert before
menuName
domId ID of the sub-menu to add.
label Text to use for this sub-menu.
accesskey Accesskey to use for the sub-menu.
attribs Object containing CSS attributes to set on the element.

Returns

Remarks

See Also

Source Code

function mmgr_addsmenu(parentNode, beforeNode, menuName, domId, label,
accesskey, attribs)
{
var document = parentNode.ownerDocument;
/* sometimes the menu is already there, for overlay purposes. */
var menu = document.getElementById(domId);
if (!menu)
{
menu = document.createElement ("menu");
menu.setAttribute ("id", domId);
}
var menupopup = menu.firstChild;
if (!menupopup)
{
menupopup = document.createElement ("menupopup");
menupopup.setAttribute ("id", domId + "-popup");
menu.appendChild(menupopup);
menupopup = menu.firstChild;
}
menupopup.setAttribute ("menuName", menuName);
menu.setAttribute("accesskey", accesskey);
label = label.replace("&", "");
menu.setAttribute ("label", label);
menu.setAttribute ("isSeparator", true);
// Only attach the menu if it's not there already. This can't be in the
// if (!menu) block because the updateMenus code clears toplevel menus,
// orphaning the submenus, to (parts of?) which we keep handles in the
// uiElements array. See the updateMenus code.
if (!menu.parentNode)
parentNode.insertBefore(menu, beforeNode);
if (typeof attribs == "object")
{
for (var p in attribs)
menu.setAttribute (p, attribs[p]);
}
this.hookPopup (menupopup);
return menupopup;
}