MenuManager.updateMenus Member

Syntax

object.updateMenus(document, menus);

Arguments

ArgumentSummary
document
menus

Returns

Remarks

See Also

Source Code

function mmgr_updatemenus(document, menus)
{
// Cope with one string (update just the one menu)...
if (isinstance(menus, String))
{
menus = [menus];
}
// Or nothing/nonsense (update everything).
else if ((typeof menus != "object") || !isinstance(menus, Array))
{
menus = [];
for (var k in this.menuSpecs)
{
if ((/^(mainmenu|context)/).test(k))
menus.push(k);
}
}
var menuBar = document.getElementById("mainmenu");
// Loop through this array and update everything we need to.
for (var i = 0; i < menus.length; i++)
{
var id = menus[i];
if (!(id in this.menuSpecs))
continue;
var menu = this.menuSpecs[id];
var domID;
if ("domID" in this.menuSpecs[id])
domID = this.menuSpecs[id].domID;
else
domID = id;
// Context menus need to be deleted in order to be regenerated...
if ((/^context/).test(id))
{
var cxMenuNode;
if ((cxMenuNode = document.getElementById(id)))
cxMenuNode.parentNode.removeChild(cxMenuNode);
this.createContextMenu(document, id);
}
else if ((/^mainmenu/).test(id) &&
!("uiElements" in this.menuSpecs[id]))
{
this.createMenu(menuBar, null, id, domID);
continue;
}
else if ((/^(mainmenu|popup)/).test(id) &&
("uiElements" in this.menuSpecs[id]))
{
for (var j = 0; j < menu.uiElements.length; j++)
{
var node = menu.uiElements[j];
domID = node.parentNode.id;
// Clear the menu node.
while (node.lastChild)
node.removeChild(node.lastChild);
this.createMenu(node.parentNode.parentNode,
node.parentNode.nextSibling,
id, domID);
}
}
}
}