From 3fdb31428a980f7995f356e18cebcfdf8ca3a9d4 Mon Sep 17 00:00:00 2001 From: "bugzilla%arlen.demon.co.uk" Date: Tue, 7 Jun 2005 23:26:57 +0000 Subject: [PATCH] Bug 295542 Add New -> Saved Search in mail window file menu p=me r=mnyromyr sr=bienvenu a=asa --- mail/base/jar.mn | 2 - .../chrome/messenger/renameFolderDialog.dtd | 5 +- mail/locales/jar.mn | 1 - .../base/resources/content/commandglue.js | 15 ---- .../resources/content/mailWindowOverlay.js | 11 +-- .../resources/content/mailWindowOverlay.xul | 3 + .../resources/content/msgMail3PaneWindow.js | 5 +- mailnews/base/resources/content/searchBar.js | 19 +++-- .../resources/content/virtualFolderName.js | 82 ------------------- .../resources/content/virtualFolderName.xul | 56 ------------- .../base/resources/locale/en-US/messenger.dtd | 3 +- .../locale/en-US/messenger.properties | 2 + .../locale/en-US/renameFolderDialog.dtd | 3 - .../locale/en-US/virtualFolderName.dtd | 40 --------- .../locale/en-US/virtualFolderProperties.dtd | 2 +- mailnews/jar.mn | 3 - 16 files changed, 24 insertions(+), 228 deletions(-) delete mode 100755 mailnews/base/resources/content/virtualFolderName.js delete mode 100755 mailnews/base/resources/content/virtualFolderName.xul delete mode 100644 mailnews/base/resources/locale/en-US/virtualFolderName.dtd diff --git a/mail/base/jar.mn b/mail/base/jar.mn index 7c4fb2786345..acba5d74d353 100644 --- a/mail/base/jar.mn +++ b/mail/base/jar.mn @@ -63,8 +63,6 @@ messenger.jar: content/messenger/msgFolderPickerOverlay.xul (/mailnews/base/resources/content/msgFolderPickerOverlay.xul) content/messenger/renameFolderDialog.xul (/mailnews/base/resources/content/renameFolderDialog.xul) content/messenger/renameFolderDialog.js (/mailnews/base/resources/content/renameFolderDialog.js) - content/messenger/virtualFolderName.xul (/mailnews/base/resources/content/virtualFolderName.xul) - content/messenger/virtualFolderName.js (/mailnews/base/resources/content/virtualFolderName.js) content/messenger/virtualFolderProperties.xul (/mailnews/base/resources/content/virtualFolderProperties.xul) content/messenger/virtualFolderProperties.js (/mailnews/base/resources/content/virtualFolderProperties.js) content/messenger/virtualFolderListDialog.xul (/mailnews/base/resources/content/virtualFolderListDialog.xul) diff --git a/mail/locales/en-US/chrome/messenger/renameFolderDialog.dtd b/mail/locales/en-US/chrome/messenger/renameFolderDialog.dtd index b04c754ecae5..98590f1b8f95 100644 --- a/mail/locales/en-US/chrome/messenger/renameFolderDialog.dtd +++ b/mail/locales/en-US/chrome/messenger/renameFolderDialog.dtd @@ -38,7 +38,4 @@ - - - - + diff --git a/mail/locales/jar.mn b/mail/locales/jar.mn index 3f8b574cc6a6..e3f0864a9f8a 100644 --- a/mail/locales/jar.mn +++ b/mail/locales/jar.mn @@ -39,7 +39,6 @@ locale/@AB_CD@/messenger/folderpane.dtd (%chrome/messenger/folderpane.dtd) locale/@AB_CD@/messenger/newFolderDialog.dtd (%chrome/messenger/newFolderDialog.dtd) locale/@AB_CD@/messenger/renameFolderDialog.dtd (%chrome/messenger/renameFolderDialog.dtd) - locale/@AB_CD@/messenger/virtualFolderName.dtd (%chrome/messenger/virtualFolderName.dtd) locale/@AB_CD@/messenger/folderProps.dtd (%chrome/messenger/folderProps.dtd) locale/@AB_CD@/messenger/subscribe.dtd (%chrome/messenger/subscribe.dtd) locale/@AB_CD@/messenger/subscribe.properties (%chrome/messenger/subscribe.properties) diff --git a/mailnews/base/resources/content/commandglue.js b/mailnews/base/resources/content/commandglue.js index 2186959770b3..826821ba5da8 100644 --- a/mailnews/base/resources/content/commandglue.js +++ b/mailnews/base/resources/content/commandglue.js @@ -1035,21 +1035,6 @@ function RemoveMailOfflineObserver() observerService.removeObserver(mailOfflineObserver,"network:offline-status-changed"); } -function getViewName(okCallbackFunc, defaultViewName) -{ - var preselectedURI = GetSelectedFolderURI(); - var folderTree = GetFolderTree(); - - var name = GetFolderNameFromUri(preselectedURI, folderTree); - name += defaultViewName + "-view"; - var dialog = window.openDialog( - "chrome://messenger/content/virtualFolderName.xul", - "newFolder", - "chrome,titlebar,modal", - {siblingFolderURI: preselectedURI, searchFolderURIs: preselectedURI, - okCallback: okCallbackFunc, name: name}); -} - function getSearchTermString(searchTerms) { var searchIndex; diff --git a/mailnews/base/resources/content/mailWindowOverlay.js b/mailnews/base/resources/content/mailWindowOverlay.js index 7f45cebe5e5c..ebccaa1bf339 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.js +++ b/mailnews/base/resources/content/mailWindowOverlay.js @@ -110,16 +110,11 @@ function menu_new_init() .getService(Components.interfaces.nsIIOService); var showNew = ((serverType != 'nntp') && canCreateNew) || isInbox; ShowMenuItem("menu_newFolder", showNew); + ShowMenuItem("menu_newVirtualFolder", showNew); EnableMenuItem("menu_newFolder", !isIMAPFolder || !ioService.offline); + EnableMenuItem("menu_newVirtualFolder", true); if (showNew) - { - if (isServer || isInbox) - SetMenuItemLabel("menu_NewFolder", - gMessengerBundle.getString("newFolder")); - else - SetMenuItemLabel("menu_NewFolder", - gMessengerBundle.getString("newSubfolder")); - } + SetMenuItemLabel("menu_newFolder", gMessengerBundle.getString((isServer || isInbox) ? "newFolderMenuItem" : "newSubfolderMenuItem")); } function goUpdateMailMenuItems(commandset) diff --git a/mailnews/base/resources/content/mailWindowOverlay.xul b/mailnews/base/resources/content/mailWindowOverlay.xul index 55c110e990c5..9c30e31f0605 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.xul +++ b/mailnews/base/resources/content/mailWindowOverlay.xul @@ -1041,6 +1041,9 @@ + diff --git a/mailnews/base/resources/content/msgMail3PaneWindow.js b/mailnews/base/resources/content/msgMail3PaneWindow.js index 89b9b6c22fc2..6658f98b283b 100644 --- a/mailnews/base/resources/content/msgMail3PaneWindow.js +++ b/mailnews/base/resources/content/msgMail3PaneWindow.js @@ -259,16 +259,13 @@ var folderListener = { else if (gVirtualFolderTerms) { gDefaultSearchViewTerms = null; - ViewChangeByValue(-1); // override current view viewDebug("searching gVirtualFolderTerms\n"); - Search(""); - // gVirtualFolderTerms = null; + loadVirtualFolder(); } else if (gMsgFolderSelected.flags & MSG_FOLDER_FLAG_VIRTUAL) { viewDebug("selected folder is virtual\n"); gDefaultSearchViewTerms = null; - ViewChangeByValue(-1); // override current view } else { diff --git a/mailnews/base/resources/content/searchBar.js b/mailnews/base/resources/content/searchBar.js index 9e9bb55b1c9b..5c5615bfdd80 100644 --- a/mailnews/base/resources/content/searchBar.js +++ b/mailnews/base/resources/content/searchBar.js @@ -540,15 +540,18 @@ function Search(str) function saveViewAsVirtualFolder() { -// prompt for view name - create virtual folder in ok callback. - getViewName(CreateView, gSearchInput.value); + openNewVirtualFolderDialogWithArgs(gSearchInput.value, gSearchSession.searchTerms); } -function CreateView(newName, origFolderURI) +// When the front end has finished loading a virtual folder, it calls openVirtualFolder +// to actually perform the folder search. We use this method instead of calling Search("") directly +// from FolderLoaded in order to avoid moving focus into the search bar. +function loadVirtualFolder() { - var selectedFolder = GetResourceFromUri(origFolderURI); - var folderToSearch = selectedFolder.QueryInterface(Components.interfaces.nsIMsgFolder); - CreateVirtualFolder(newName, folderToSearch.parent, origFolderURI, gSearchSession.searchTerms); + // bit of a hack...if the underlying real folder is loaded with the same view value + // as the value for the virtual folder being searched, then ViewChangeByValue + // fails to change the view because it thinks the view is already correctly loaded. + // so set gCurrentViewValue back to All. + gCurrentViewValue = 0; + onEnterInSearchBar(); } - - diff --git a/mailnews/base/resources/content/virtualFolderName.js b/mailnews/base/resources/content/virtualFolderName.js deleted file mode 100755 index 0be30c883099..000000000000 --- a/mailnews/base/resources/content/virtualFolderName.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla.org code - * - * The Initial Developer of the Original Code is - * David Bienvenu. - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * David Bienvenu - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var dialog; - -function onLoad() -{ - var arguments = window.arguments[0]; - - dialog = {}; - - dialog.OKButton = document.documentElement.getButton("accept"); - - dialog.nameField = document.getElementById("name"); - dialog.nameField.value = arguments.name; - dialog.nameField.select(); - dialog.nameField.focus(); - - // call this when OK is pressed - dialog.okCallback = arguments.okCallback; - - // pre select the folderPicker, based on what they selected in the folder pane - dialog.siblingFolderURI = arguments.siblingFolderURI; - dialog.searchFolderURIs = arguments.searchFolderURIs - moveToAlertPosition(); - doEnabling(); -} - -function onOK() -{ - dialog.okCallback(dialog.nameField.value, dialog.siblingFolderURI, dialog.searchFolderURIs); - - return true; -} - -function doEnabling() -{ - if (dialog.nameField.value) { - if (dialog.OKButton.disabled) - dialog.OKButton.disabled = false; - } else { - if (!dialog.OKButton.disabled) - dialog.OKButton.disabled = true; - } -} - diff --git a/mailnews/base/resources/content/virtualFolderName.xul b/mailnews/base/resources/content/virtualFolderName.xul deleted file mode 100755 index 756d7c2a7576..000000000000 --- a/mailnews/base/resources/content/virtualFolderName.xul +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - -