Bug 464653 Toolbar context menu improvements and fixes. r=Neil.

This commit is contained in:
Philip Chee 2011-03-18 22:54:01 +08:00
Родитель cecc366902
Коммит 7289358950
10 изменённых файлов: 45 добавлений и 59 удалений

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

@ -65,10 +65,11 @@
</stringbundleset>
<menupopup id="view_toolbars_popup">
<menu label="&linkToolbar.label;" position="3"
<menu label="&linkToolbar.label;"
accesskey="&linkToolbar.accesskey;"
oncommand="linkToolbarUI.toggleLinkToolbar(event.target)"
onpopupshowing="linkToolbarUI.initLinkbarVisibilityMenu()">
insertbefore="menuitem_showhide_tabbar"
onpopupshowing="linkToolbarUI.initLinkbarVisibilityMenu();"
oncommand="linkToolbarUI.toggleLinkToolbar(event.target);">
<menupopup>
<menuitem label="&linkToolbarAlways.label;"
accesskey="&linkToolbarAlways.accesskey;"

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

@ -2378,8 +2378,9 @@ function updateComponentBarBroadcaster()
}
}
function updateToolbarStates(toolbarMenuElt)
function updateToolbarStates(aEvent)
{
onViewToolbarsPopupShowing(aEvent);
updateComponentBarBroadcaster();
const tabbarMenuItem = document.getElementById("menuitem_showhide_tabbar");

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

@ -201,7 +201,6 @@
grippytooltiptext="&navigationToolbar.tooltip;"
fullscreentoolbar="true" customizable="true"
toolbarname="&navbarCmd.label;" accesskey="&navbarCmd.accesskey;"
togglemenuitem="cmd_viewnavbar"
defaultset="back-button,forward-button,reload-button,stop-button,nav-bar-inner,search-button-container,print-button,throbber-box,window-controls"
context="toolbar-context-menu">
@ -229,7 +228,6 @@
grippytooltiptext="&personalToolbar.tooltip;"
toolbarname="&personalbarCmd.label;"
nowindowdrag="true"
togglemenuitem="cmd_viewpersonaltoolbar"
customizable="true"
defaultset="home-button,separator,bookmarks-button,personal-bookmarks"
mode="full"

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

@ -222,8 +222,6 @@
<broadcaster id="canGoForward" disabled="true"/>
<broadcaster id="canGoUp" disabled="true"/>
<broadcaster id="Communicator:WorkMode"/>
<broadcaster id="cmd_viewnavbar" oncommand="goToggleToolbar( 'nav-bar','cmd_viewnavbar');" checked="true"/>
<broadcaster id="cmd_viewpersonaltoolbar" oncommand="goToggleToolbar('PersonalToolbar','cmd_viewpersonaltoolbar');" checked="true"/>
<broadcaster id="cmd_viewtaskbar" oncommand="goToggleToolbar('status-bar','cmd_viewtaskbar'); updateWindowResizer();" checked="true"/>
<broadcaster id="cmd_viewcomponentbar" oncommand="goToggleToolbar('component-bar', 'cmd_viewcomponentbar');" checked="true"/>
<broadcaster id="isImage"/>
@ -317,9 +315,9 @@
<menu id="menu_View" accesskey="&viewMenu.accesskey;" label="&viewMenu.label;">
<menupopup id="menu_View_Popup">
<menu label="&toolbarsCmd.label;" accesskey="&toolbarsCmd.accesskey;" id="menu_Toolbars">
<menupopup id="view_toolbars_popup" onpopupshowing="updateToolbarStates(this);">
<menuitem label="&navbarCmd.label;" accesskey="&navbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" observes="cmd_viewnavbar" />
<menuitem label="&personalbarCmd.label;" accesskey="&personalbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" observes="cmd_viewpersonaltoolbar" />
<menupopup id="view_toolbars_popup"
onpopupshowing="updateToolbarStates(event);"
oncommand="onViewToolbarCommand(event);">
<menuitem id="menuitem_showhide_tabbar" label="&tabbarCmd.label;" accesskey="&tabbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" oncommand="showHideTabbar();" checked="true"/>
<menuitem label="&taskbarCmd.label;" accesskey="&taskbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" observes="cmd_viewtaskbar" />
<menuitem label="&componentbarCmd.label;" accesskey="&componentbarCmd.accesskey;" class="menuitem-iconic" type="checkbox" observes="cmd_viewcomponentbar"/>

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

@ -318,36 +318,50 @@ function goCustomizeToolbar(toolbox)
}
}
function onViewToolbarsPopupShowing(aEvent)
function onViewToolbarsPopupShowing(aEvent, aInsertPoint)
{
var popup = aEvent.target;
if (popup != aEvent.currentTarget)
return;
// Empty the menu
var deadItems = popup.getElementsByAttribute("toolbarid", "*");
for (let i = deadItems.length - 1; i >= 0; --i)
popup.removeChild(deadItems[i]);
var firstMenuItem = popup.firstChild;
var firstMenuItem = aInsertPoint || popup.firstChild;
var toolbar = document.popupNode;
var toolbar = document.popupNode || popup;
while (toolbar.localName != "toolbar")
toolbar = toolbar.parentNode;
var toolbox = toolbar.parentNode;
var toolbox = toolbar.toolbox;
var toolbars = toolbox.getElementsByAttribute("toolbarname", "*");
for (let i = 0; i < toolbars.length; ++i) {
let bar = toolbars[i];
var toolbars = Array.slice(toolbox.getElementsByAttribute("toolbarname", "*"));
toolbars = toolbars.concat(toolbox.externalToolbars);
toolbars.forEach(function(bar) {
let menuItem = document.createElement("menuitem");
menuItem.setAttribute("id", "toggle_" + bar.id);
menuItem.setAttribute("toolbarid", bar.id);
menuItem.setAttribute("type", "checkbox");
menuItem.setAttribute("label", bar.getAttribute("toolbarname"));
menuItem.setAttribute("accesskey", bar.getAttribute("accesskey"));
menuItem.setAttribute("checked", !bar.hidden);
popup.insertBefore(menuItem, firstMenuItem);
}
});
}
function onToolbarModePopupShowing(aEvent)
{
var popup = aEvent.target;
var toolbar = document.popupNode;
while (toolbar.localName != "toolbar")
toolbar = toolbar.parentNode;
var toolbox = toolbar.toolbox;
var mode = toolbar.getAttribute("mode") || "full";
var modePopup = document.getElementById("toolbarmodePopup");
var modePopup = document.getElementById("toolbarModePopup");
var radio = modePopup.getElementsByAttribute("value", mode);
radio[0].setAttribute("checked", "true");
@ -389,8 +403,8 @@ function onViewToolbarsPopupShowing(aEvent)
function onViewToolbarCommand(aEvent)
{
var toolbar = aEvent.originalTarget.getAttribute("toolbarid");
var menuitem = document.getElementById(toolbar).getAttribute("togglemenuitem");
goToggleToolbar(toolbar, menuitem);
if (toolbar)
goToggleToolbar(toolbar);
}
function goSetToolbarState(aEvent)

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

@ -81,8 +81,8 @@
<menu id="toolbarmode-context-menu"
label="&customizeToolbar.toolbarmode.label;"
accesskey="&customizeToolbar.toolbarmode.accesskey;">
<menupopup id="toolbarmodePopup"
onpopupshowing="event.stopPropagation();"
<menupopup id="toolbarModePopup"
onpopupshowing="onToolbarModePopupShowing(event);"
oncommand="goSetToolbarState(event);">
<menuitem type="radio" name="mode" value="icons"
label="&customizeToolbar.icons.label;"

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

@ -289,12 +289,9 @@
<menu id="menu_View">
<menupopup id="menu_View_Popup">
<menu id="menu_Toolbars">
<menupopup id="view_toolbars_popup">
<menuitem id="menu_showAbToolbar"
label="&showAbToolbarCmd.label;"
accesskey="&showAbToolbarCmd.accesskey;"
oncommand="goToggleToolbar('ab-bar2', 'menu_showAbToolbar')"
checked="true" type="checkbox"/>
<menupopup id="view_toolbars_popup"
onpopupshowing="onViewToolbarsPopupShowing(event)"
oncommand="onViewToolbarCommand(event);">
<menuitem id="menu_showTaskbar"/>
<menuseparator/>
<menuitem id="menu_showCardPane"
@ -420,7 +417,6 @@
toolbarname="&showAbToolbarCmd.label;"
accesskey="&showAbToolbarCmd.accesskey;"
defaultset="button-newcard,button-newlist,separator,button-editcard,button-newmessage,button-newim,button-abdelete,spring,searchBox,throbber-box"
togglemenuitem="menu_showAbToolbar"
context="toolbar-context-menu">
<toolbarbutton id="button-newcard"
class="toolbarbutton-1"

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

@ -139,11 +139,6 @@
<command id="cmd_openAttachment" oncommand="goDoCommand('cmd_openAttachment')"/>
<command id="cmd_account" oncommand="goDoCommand('cmd_account')"/>
<!-- View Menu -->
<command id="cmd_viewComposeToolbar"
oncommand="goToggleToolbar('composeToolbar', 'cmd_viewComposeToolbar');"
checked="true"/>
<!-- Options Menu -->
<command id="cmd_selectAddress" oncommand="goDoCommand('cmd_selectAddress')"/>
<command id="cmd_outputFormat" oncommand="OutputFormatMenuSelect(event.target)"/>
@ -416,12 +411,9 @@
<menu id="menu_View">
<menupopup id="menu_View_Popup">
<menu id="menu_Toolbars">
<menupopup id="view_toolbars_popup">
<menuitem id="menu_showComposeToolbar"
type="checkbox"
label="&showComposeToolbarCmd.label;"
accesskey="&showComposeToolbarCmd.accesskey;"
command="cmd_viewComposeToolbar"/>
<menupopup id="view_toolbars_popup"
onpopupshowing="onViewToolbarsPopupShowing(event)"
oncommand="onViewToolbarCommand(event);">
<menuitem id="menu_showFormatToolbar"
type="checkbox"
label="&showFormatToolbarCmd.label;"
@ -580,7 +572,6 @@
accesskey="&showComposeToolbarCmd.accesskey;"
customizable="true"
defaultset="button-send,separator,button-address,button-attach,spellingButton,button-security,separator,button-save,spring,throbber-box"
togglemenuitem="cmd_viewComposeToolbar"
context="toolbar-context-menu">
</toolbar>

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

@ -1152,20 +1152,9 @@
<menu id="menu_View">
<menupopup id="menu_View_Popup" onpopupshowing="view_init()">
<menu id="menu_Toolbars">
<menupopup id="view_toolbars_popup">
<menuitem id="menu_showMessengerToolbar"
type="checkbox"
checked="true"
label="&showMessengerToolbarCmd.label;"
accesskey="&showMessengerToolbarCmd.accesskey;"
oncommand="goToggleToolbar('msgToolbar', 'menu_showMessengerToolbar');"/>
<menuitem id="menu_showSearchToolbar"
type="checkbox"
checked="true"
label="&showSearchToolbarCmd.label;"
accesskey="&showSearchToolbarCmd.accesskey;"
observes="mailHideMenus"
oncommand="goToggleToolbar('searchToolbar', 'menu_showSearchToolbar');"/>
<menupopup id="view_toolbars_popup"
onpopupshowing="onViewToolbarsPopupShowing(event)"
oncommand="onViewToolbarCommand(event);">
<menuitem id="menu_showTaskbar"/>
</menupopup>
</menu>
@ -1937,7 +1926,6 @@
accesskey="&showMessengerToolbarCmd.accesskey;"
customizable="true"
defaultset="button-getmsg,button-newmsg,separator,button-reply,button-replyall,button-forward,separator,button-goback,button-goforward,button-next,button-junk,button-delete,button-mark,spring,throbber-box"
togglemenuitem="menu_showMessengerToolbar"
context="toolbar-context-menu">
</toolbar>
<toolbarset id="customToolbars" context="toolbar-context-menu"/>

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

@ -168,7 +168,6 @@
defaulticonsize="small"
defaultlabelalign="end"
defaultset="mailviews-container,spring,search-container,button-search-container"
togglemenuitem="menu_showSearchToolbar"
context="toolbar-context-menu"/>
</toolbox>