зеркало из https://github.com/mozilla/gecko-dev.git
bug 325468 - Populates View > Toolbars menu dynamically to pick up user-created toolbars. r=jminta
This commit is contained in:
Родитель
26ab1065f4
Коммит
b2dbde18e6
|
@ -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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,21 +199,12 @@
|
||||||
<menu id="menu_View"
|
<menu id="menu_View"
|
||||||
label="&viewMenu.label;"
|
label="&viewMenu.label;"
|
||||||
accesskey="&viewMenu.accesskey;">
|
accesskey="&viewMenu.accesskey;">
|
||||||
<menupopup id="mppView">
|
<menupopup id="menu_viewPopup">
|
||||||
<menu id="menu_Toolbars"
|
<menu id="menu_Toolbars"
|
||||||
label="&toolbarsMenu.label;"
|
label="&toolbarsMenu.label;"
|
||||||
accesskey="&toolbarsMenu.accesskey;">
|
accesskey="&toolbarsMenu.accesskey;"
|
||||||
|
onpopupshowing="sbOnViewToolbarsPopupShowing(event);">
|
||||||
<menupopup>
|
<menupopup>
|
||||||
<!-- XXX This eventually needs to be RDF-driven so toolbars created
|
|
||||||
by the user are selectable. Also there's no good way to delete
|
|
||||||
a user-created toolbar without resetting all your other toolbars
|
|
||||||
to the defaults. Should that be fixed here? -->
|
|
||||||
|
|
||||||
<menuitem id="menu_showCalendarToolbar"
|
|
||||||
type="checkbox"
|
|
||||||
label="&calendar.toolbar.label;"
|
|
||||||
command="cmd_showCalendarToolbar"
|
|
||||||
checked="true"/>
|
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem id="calendar-view-menu-customize"
|
<menuitem id="calendar-view-menu-customize"
|
||||||
command="cmd_CustomizeToolbars"
|
command="cmd_CustomizeToolbars"
|
||||||
|
|
|
@ -102,7 +102,6 @@
|
||||||
<command id="wizard_command" oncommand="launchWizard()" collapsed="true"/>
|
<command id="wizard_command" oncommand="launchWizard()" collapsed="true"/>
|
||||||
|
|
||||||
<command id="cmd_CustomizeToolbars" oncommand="CalendarCustomizeToolbar()"/>
|
<command id="cmd_CustomizeToolbars" oncommand="CalendarCustomizeToolbar()"/>
|
||||||
<command id="cmd_showCalendarToolbar" oncommand="goToggleToolbar('calendar-bar', 'menu_showCalendarToolbar');"/>
|
|
||||||
<command id="cmd_showSearchToolbar" oncommand="goToggleToolbar('searchBox', 'menu_showSearchToolbar');"/>
|
<command id="cmd_showSearchToolbar" oncommand="goToggleToolbar('searchBox', 'menu_showSearchToolbar');"/>
|
||||||
<command id="cmd_showStatusBar" oncommand="goToggleToolbar('status-bar', 'menu_showStatusBar');"/>
|
<command id="cmd_showStatusBar" oncommand="goToggleToolbar('status-bar', 'menu_showStatusBar');"/>
|
||||||
<command id="cmd_showTaskBox" oncommand="goToggleToolbar('taskBox', 'menu_showTaskBox'); goToggleToolbar('calendar-todo-splitter');"/>
|
<command id="cmd_showTaskBox" oncommand="goToggleToolbar('taskBox', 'menu_showTaskBox'); goToggleToolbar('calendar-todo-splitter');"/>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче