зеркало из https://github.com/mozilla/pjs.git
bug 325468 - Populates View > Toolbars menu dynamically to pick up user-created toolbars. r=jminta
This commit is contained in:
Родитель
b0179f26fb
Коммит
4d60e3739a
|
@ -386,3 +386,55 @@ function hasPositiveIntegerValue(elementId)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We recreate the View > Toolbars menu each time it is opened to include any
|
||||||
|
* user-created toolbars.
|
||||||
|
*/
|
||||||
|
function sbOnViewToolbarsPopupShowing(aEvent)
|
||||||
|
{
|
||||||
|
var popup = aEvent.target;
|
||||||
|
var i;
|
||||||
|
|
||||||
|
// Empty the menu
|
||||||
|
for (i = popup.childNodes.length-1; i >= 0; i--) {
|
||||||
|
var deadItem = popup.childNodes[i];
|
||||||
|
if (deadItem.hasAttribute("toolbarindex")) {
|
||||||
|
deadItem.removeEventListener("command", sbOnViewToolbarCommand, false);
|
||||||
|
popup.removeChild(deadItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstMenuItem = popup.firstChild;
|
||||||
|
|
||||||
|
var toolbox = document.getElementById("calendar-toolbox");
|
||||||
|
for (i = 0; i < toolbox.childNodes.length; i++) {
|
||||||
|
var toolbar = toolbox.childNodes[i];
|
||||||
|
var toolbarName = toolbar.getAttribute("toolbarname");
|
||||||
|
var type = toolbar.getAttribute("type");
|
||||||
|
if (toolbarName && type != "menubar") {
|
||||||
|
var menuItem = document.createElement("menuitem");
|
||||||
|
menuItem.setAttribute("toolbarindex", i);
|
||||||
|
menuItem.setAttribute("type", "checkbox");
|
||||||
|
menuItem.setAttribute("label", toolbarName);
|
||||||
|
menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey"));
|
||||||
|
menuItem.setAttribute("checked", toolbar.getAttribute("collapsed") != "true");
|
||||||
|
popup.insertBefore(menuItem, firstMenuItem);
|
||||||
|
|
||||||
|
menuItem.addEventListener("command", sbOnViewToolbarCommand, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the visibility of the associated toolbar when fired.
|
||||||
|
*/
|
||||||
|
function sbOnViewToolbarCommand(aEvent)
|
||||||
|
{
|
||||||
|
var toolbox = document.getElementById("calendar-toolbox");
|
||||||
|
var index = aEvent.originalTarget.getAttribute("toolbarindex");
|
||||||
|
var toolbar = toolbox.childNodes[index];
|
||||||
|
|
||||||
|
toolbar.collapsed = (aEvent.originalTarget.getAttribute("checked") != "true");
|
||||||
|
document.persist(toolbar.id, "collapsed");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче