# HG changeset patch # User Ian Neal # Date 1623162001 14400 # Parent 861ffca60b651dec9f8ce9b69e59a645725c0185 Bug 1589892 - Port |Bug 440616 (command cleanup v1) Clean up Thunderbird's global scope a bit more| and |Bug 495242 cmd_close shouldn't be passed through the controllers for menu options| to SeaMonkey. r=frg a=frg diff --git a/suite/mailnews/content/mail3PaneWindowCommands.js b/suite/mailnews/content/mail3PaneWindowCommands.js --- a/suite/mailnews/content/mail3PaneWindowCommands.js +++ b/suite/mailnews/content/mail3PaneWindowCommands.js @@ -191,17 +191,16 @@ var DefaultController = case "cmd_applyFiltersToSelection": case "cmd_applyFilters": case "cmd_runJunkControls": case "cmd_deleteJunk": case "button_file": case "cmd_emptyTrash": case "cmd_compactFolder": case "cmd_settingsOffline": - case "cmd_close": case "cmd_selectAll": case "cmd_selectThread": case "cmd_selectFlagged": return true; case "cmd_downloadFlagged": case "cmd_downloadSelected": case "cmd_synchronizeOffline": return !Services.io.offline; @@ -420,23 +419,25 @@ var DefaultController = return IsPropertiesEnabled(command); case "button_getNewMessages": case "cmd_getNewMessages": case "cmd_getMsgsForAuthAccounts": return IsGetNewMessagesEnabled(); case "cmd_getNextNMessages": return IsGetNextNMessagesEnabled(); case "cmd_emptyTrash": - return IsEmptyTrashEnabled(); + { + let folder = GetSelectedMsgFolders()[0]; + return folder && folder.server.canEmptyTrashOnExit ? + IsMailFolderSelected() : false; + } case "cmd_compactFolder": return IsCompactFolderEnabled(); case "cmd_setFolderCharset": return IsFolderCharsetEnabled(); - case "cmd_close": - return true; case "cmd_downloadFlagged": return !Services.io.offline; case "cmd_downloadSelected": return IsFolderSelected() && !Services.io.offline && GetNumSelectedMessages() > 0; case "cmd_synchronizeOffline": return !Services.io.offline; case "cmd_settingsOffline": @@ -451,19 +452,16 @@ var DefaultController = { // if the user invoked a key short cut then it is possible that we got here for a command which is // really disabled. kick out if the command should be disabled. if (!this.isCommandEnabled(command)) return; switch (command) { - case "cmd_close": - MsgCloseCurrentTab(); - break; case "button_getNewMessages": case "cmd_getNewMessages": MsgGetMessage(); break; case "cmd_getMsgsForAuthAccounts": MsgGetMessagesForAllAuthenticatedAccounts(); break; case "cmd_getNextNMessages": @@ -736,16 +734,25 @@ var DefaultController = if ( event == 'blur' ) { goSetMenuValue('cmd_undo', 'valueDefault'); goSetMenuValue('cmd_redo', 'valueDefault'); } } }; +function MsgCloseTabOrWindow() +{ + var tabmail = GetTabMail(); + if (tabmail.tabInfo.length > 1) + tabmail.removeCurrentTab(); + else + window.close(); +} + function GetNumSelectedMessages() { try { return gDBView.numSelected; } catch (ex) { return 0; } diff --git a/suite/mailnews/content/mailWindowOverlay.js b/suite/mailnews/content/mailWindowOverlay.js --- a/suite/mailnews/content/mailWindowOverlay.js +++ b/suite/mailnews/content/mailWindowOverlay.js @@ -1433,21 +1433,16 @@ function MsgCreateFilter() } if (!folder) folder = GetFirstSelectedMsgFolder(); if (emailAddress) top.MsgFilters(emailAddress, folder); } -function MsgHome(url) -{ - window.open(url, "_blank", "chrome,dependent=yes,all"); -} - function MsgNewFolder(callBackFunctionName) { var preselectedFolder = GetFirstSelectedMsgFolder(); var dualUseFolders = true; var server = null; var destinationFolder = null; if (preselectedFolder) @@ -1573,21 +1568,16 @@ function MsgOpenFromFile() let uri = fp.fileURL.QueryInterface(Ci.nsIURL); uri.query = "type=application/x-message-display"; window.openDialog("chrome://messenger/content/messageWindow.xul", "_blank", "all,chrome,dialog=no,status,toolbar", uri); }); } -function MsgOpenNewWindowForMsgHdr(hdr) -{ - MsgOpenNewWindowForFolder(hdr.folder.URI, hdr.messageKey); -} - function MsgOpenNewWindowForFolder(uri, key) { var uriToOpen = uri; var keyToSelect = key; if (!uriToOpen) // use GetSelectedFolderURI() to find out which message to open instead of // GetLoadedMsgFolder().URI. @@ -2110,76 +2100,58 @@ function IsGetNextNMessagesEnabled() menuItem.removeAttribute("hidden"); return true; } menuItem.setAttribute("hidden","true"); return false; } -function IsEmptyTrashEnabled() -{ - var folderURI = GetSelectedFolderURI(); - var server = GetServer(folderURI); - return (server && server.canEmptyTrashOnExit ? IsMailFolderSelected() : false); -} - function IsCompactFolderEnabled() { var server = GetServer(GetSelectedFolderURI()); return (server && ((server.type != 'imap') || server.canCompactFoldersOnServer) && isCommandEnabled("cmd_compactFolder")); // checks e.g. if IMAP is offline } -var gReplyAllButton = null; -var gDeleteButton = null; - function SetUpToolbarButtons(uri) { - // Eventually, we might want to set up the toolbar differently for imap, - // pop, and news. For now, just tweak it based on if it is news or not. - var forNews = isNewsURI(uri); - - if(!gDeleteButton) gDeleteButton = document.getElementById("button-delete"); - if (!gReplyAllButton) gReplyAllButton = document.getElementById("button-replyall"); - - gDeleteButton.hidden = forNews; - if (forNews) { - gReplyAllButton.setAttribute("type", "menu-button"); - gReplyAllButton.setAttribute("tooltiptext", gReplyAllButton.getAttribute("tooltiptextnews")); - } - else { - gReplyAllButton.removeAttribute("type"); - gReplyAllButton.setAttribute("tooltiptext", gReplyAllButton.getAttribute("tooltiptextmail")); - } + let deleteButton = document.getElementById("button-delete"); + let replyAllButton = document.getElementById("button-replyall"); + + // Eventually, we might want to set up the toolbar differently for imap, + // pop, and news. For now, just tweak it based on if it is news or not. + let forNews = isNewsURI(uri); + + deleteButton.hidden = forNews; + if (forNews) { + replyAllButton.setAttribute("type", "menu-button"); + replyAllButton.setAttribute("tooltiptext", + replyAllButton.getAttribute("tooltiptextnews")); + } else { + replyAllButton.removeAttribute("type"); + replyAllButton.setAttribute("tooltiptext", + replyAllButton.getAttribute("tooltiptextmail")); + } } -var gMessageBrowser; - function getMessageBrowser() { - if (!gMessageBrowser) - gMessageBrowser = document.getElementById("messagepane"); - return gMessageBrowser; + return document.getElementById("messagepane"); } // The zoom manager, view source and possibly some other functions still rely // on the getBrowser function. function getBrowser() { return GetTabMail() ? GetTabMail().getBrowserForSelectedTab() : getMessageBrowser(); } -function getMarkupDocumentViewer() -{ - return getMessageBrowser().markupDocumentViewer; -} - function MsgSynchronizeOffline() { window.openDialog("chrome://messenger/content/msgSynchronize.xul", "", "centerscreen,chrome,modal,titlebar,resizable", {msgWindow:msgWindow}); } function MsgOpenAttachment() {} diff --git a/suite/mailnews/content/mailWindowOverlay.xul b/suite/mailnews/content/mailWindowOverlay.xul --- a/suite/mailnews/content/mailWindowOverlay.xul +++ b/suite/mailnews/content/mailWindowOverlay.xul @@ -86,17 +86,16 @@ - diff --git a/suite/mailnews/content/messageWindow.js b/suite/mailnews/content/messageWindow.js --- a/suite/mailnews/content/messageWindow.js +++ b/suite/mailnews/content/messageWindow.js @@ -616,17 +616,16 @@ var MessageWindowController = case "cmd_reload": case "cmd_saveAsFile": case "cmd_getNewMessages": case "button_getNewMessages": case "button_print": case "cmd_print": case "cmd_printpreview": case "cmd_printSetup": - case "cmd_close": case "cmd_settingsOffline": case "cmd_createFilterFromPopup": case "cmd_createFilterFromMenu": return true; case "cmd_synchronizeOffline": case "cmd_downloadFlagged": case "cmd_downloadSelected": return !Services.io.offline; @@ -718,17 +717,16 @@ var MessageWindowController = case "cmd_getNextNMessages": return IsGetNextNMessagesEnabled(); case "cmd_downloadFlagged": case "cmd_downloadSelected": case "cmd_synchronizeOffline": return !Services.io.offline; case "cmd_settingsOffline": return IsAccountOfflineEnabled(); - case "cmd_close": case "cmd_nextMsg": case "button_next": case "cmd_nextUnreadMsg": case "cmd_nextFlaggedMsg": case "cmd_nextUnreadThread": case "cmd_previousMsg": case "cmd_previousUnreadMsg": case "cmd_previousFlaggedMsg": @@ -766,19 +764,16 @@ var MessageWindowController = // if the user invoked a key short cut then it is possible that we got here for a command which is // really disabled. kick out if the command should be disabled. if (!this.isCommandEnabled(command)) return; var navigationType = nsMsgNavigationType.nextUnreadMessage; switch ( command ) { - case "cmd_close": - CloseMailWindow(); - break; case "cmd_getNewMessages": MsgGetMessage(); break; case "cmd_undo": messenger.undo(msgWindow); break; case "cmd_redo": messenger.redo(msgWindow); diff --git a/suite/mailnews/content/messageWindow.xul b/suite/mailnews/content/messageWindow.xul --- a/suite/mailnews/content/messageWindow.xul +++ b/suite/mailnews/content/messageWindow.xul @@ -61,16 +61,17 @@ +