зеркало из https://github.com/mozilla/gecko-dev.git
Implement "Empty Junk" for the Junk folder context menu. b=189911 r+sr=bienvenu
This commit is contained in:
Родитель
fca239b836
Коммит
4149173a99
|
@ -394,3 +394,6 @@ pref("browser.urlbar.clickSelectsAll", false);
|
|||
|
||||
// prevent status-bar spoofing even if people are foolish enough to turn on JS
|
||||
pref("dom.disable_window_status_change", true);
|
||||
|
||||
// For the Empty Junk confirmation dialog
|
||||
pref("mail.emptyJunk.dontAskAgain", false);
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
var gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
function DoRDFCommand(dataSource, command, srcArray, argumentArray)
|
||||
{
|
||||
var commandResource = RDF.GetResource(command);
|
||||
|
@ -773,6 +776,75 @@ function JunkSelectedMessages(setAsJunk)
|
|||
: nsMsgViewCommandType.unjunk);
|
||||
}
|
||||
|
||||
function confirmToProceed(commandName)
|
||||
{
|
||||
const kDontAskAgainPref = "mail."+commandName+".dontAskAgain";
|
||||
// default to ask user if the pref is not set
|
||||
var dontAskAgain = false;
|
||||
try {
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
dontAskAgain = pref.getBoolPref(kDontAskAgainPref);
|
||||
} catch (ex) {}
|
||||
|
||||
if (!dontAskAgain)
|
||||
{
|
||||
var checkbox = {value:false};
|
||||
var choice = gPromptService.confirmEx(
|
||||
window,
|
||||
gMessengerBundle.getString(commandName+"Title"),
|
||||
gMessengerBundle.getString(commandName+"Message"),
|
||||
gPromptService.STD_YES_NO_BUTTONS,
|
||||
null, null, null,
|
||||
gMessengerBundle.getString(commandName+"DontAsk"),
|
||||
checkbox);
|
||||
try {
|
||||
if (checkbox.value)
|
||||
pref.setBoolPref(kDontAskAgainPref, true);
|
||||
} catch (ex) {}
|
||||
|
||||
if (choice != 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function deleteAllInFolder(commandName)
|
||||
{
|
||||
var folder = GetMsgFolderFromUri(GetSelectedFolderURI(), true);
|
||||
if (!folder)
|
||||
return;
|
||||
|
||||
if (!confirmToProceed(commandName))
|
||||
return;
|
||||
|
||||
var children = Components.classes["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
|
||||
// Delete sub-folders.
|
||||
var iter = folder.GetSubFolders();
|
||||
while (true) {
|
||||
try {
|
||||
children.AppendElement(iter.currentItem());
|
||||
iter.next();
|
||||
} catch (ex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < children.Count(); ++i) {
|
||||
folder.propagateDelete(children.GetElementAt(i), true, msgWindow);
|
||||
}
|
||||
children.Clear();
|
||||
|
||||
// Delete messages.
|
||||
iter = folder.getMessages(msgWindow);
|
||||
while (iter.hasMoreElements()) {
|
||||
children.AppendElement(iter.getNext());
|
||||
}
|
||||
folder.deleteMessages(children, msgWindow, true, false, null, false);
|
||||
children.Clear();
|
||||
}
|
||||
|
||||
function deleteJunkInFolder()
|
||||
{
|
||||
MsgJunkMailInfo(true);
|
||||
|
|
|
@ -324,6 +324,8 @@ function fillFolderPaneContextMenu()
|
|||
ShowMenuItem("folderPaneContext-copy-location", !isServer && !isVirtualFolder);
|
||||
ShowMenuItem("folderPaneContext-emptyTrash", (numSelected <= 1) && (specialFolder == 'Trash'));
|
||||
EnableMenuItem("folderPaneContext-emptyTrash", true);
|
||||
ShowMenuItem("folderPaneContext-emptyJunk", (numSelected <= 1) && (specialFolder == 'Junk'));
|
||||
EnableMenuItem("folderPaneContext-emptyJunk", true);
|
||||
|
||||
var showSendUnsentMessages = (numSelected <= 1)
|
||||
&& (specialFolder == 'Unsent Messages' || specialFolder == 'Unsent');
|
||||
|
|
|
@ -781,6 +781,10 @@
|
|||
label="&folderContextEmptyTrash.label;"
|
||||
accesskey="&folderContextEmptyTrash.accesskey;"
|
||||
oncommand="MsgEmptyTrash();"/>
|
||||
<menuitem id="folderPaneContext-emptyJunk"
|
||||
label="&folderContextEmptyJunk.label;"
|
||||
accesskey="&folderContextEmptyJunk.accesskey;"
|
||||
oncommand="deleteAllInFolder('emptyJunk');"/>
|
||||
<menuitem id="folderPaneContext-sendUnsentMessages"
|
||||
label="&folderContextSendUnsentMessages.label;"
|
||||
accesskey="&folderContextSendUnsentMessages.accesskey;"
|
||||
|
|
|
@ -507,6 +507,8 @@
|
|||
<!ENTITY folderContextCompact.accesskey "C">
|
||||
<!ENTITY folderContextEmptyTrash.label "Empty Trash">
|
||||
<!ENTITY folderContextEmptyTrash.accesskey "y">
|
||||
<!ENTITY folderContextEmptyJunk.label "Empty Junk">
|
||||
<!ENTITY folderContextEmptyJunk.accesskey "J">
|
||||
<!ENTITY folderContextSendUnsentMessages.label "Send Unsent Messages">
|
||||
<!ENTITY folderContextSendUnsentMessages.accesskey "d">
|
||||
<!ENTITY folderContextUnsubscribe.label "Unsubscribe">
|
||||
|
|
|
@ -425,3 +425,8 @@ alwaysLoadRemoteContentForSender=Click here to always load remote images from %1
|
|||
# Strings for growl notifications on Mac OS X
|
||||
subjectNotificationTitle=Subject: "%1$S"
|
||||
senderNotificationText=Sender: "%1$S"
|
||||
|
||||
# mailCommands.js
|
||||
emptyJunkTitle=Confirm
|
||||
emptyJunkMessage=Are you sure you want to permanently delete all messages and subfolders in the Junk folder?
|
||||
emptyJunkDontAsk=Don't ask me again.
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
function DoRDFCommand(dataSource, command, srcArray, argumentArray)
|
||||
{
|
||||
var commandResource = RDF.GetResource(command);
|
||||
|
@ -702,6 +705,75 @@ function JunkSelectedMessages(setAsJunk)
|
|||
: nsMsgViewCommandType.unjunk);
|
||||
}
|
||||
|
||||
function confirmToProceed(commandName)
|
||||
{
|
||||
const kDontAskAgainPref = "mailnews."+commandName+".dontAskAgain";
|
||||
// default to ask user if the pref is not set
|
||||
var dontAskAgain = false;
|
||||
try {
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
dontAskAgain = pref.getBoolPref(kDontAskAgainPref);
|
||||
} catch (ex) {}
|
||||
|
||||
if (!dontAskAgain)
|
||||
{
|
||||
var checkbox = {value:false};
|
||||
var choice = gPromptService.confirmEx(
|
||||
window,
|
||||
gMessengerBundle.getString(commandName+"Title"),
|
||||
gMessengerBundle.getString(commandName+"Message"),
|
||||
gPromptService.STD_YES_NO_BUTTONS,
|
||||
null, null, null,
|
||||
gMessengerBundle.getString(commandName+"DontAsk"),
|
||||
checkbox);
|
||||
try {
|
||||
if (checkbox.value)
|
||||
pref.setBoolPref(kDontAskAgainPref, true);
|
||||
} catch (ex) {}
|
||||
|
||||
if (choice != 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function deleteAllInFolder(commandName)
|
||||
{
|
||||
var folder = GetMsgFolderFromUri(GetSelectedFolderURI(), true);
|
||||
if (!folder)
|
||||
return;
|
||||
|
||||
if (!confirmToProceed(commandName))
|
||||
return;
|
||||
|
||||
var children = Components.classes["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
|
||||
// Delete sub-folders.
|
||||
var iter = folder.GetSubFolders();
|
||||
while (true) {
|
||||
try {
|
||||
children.AppendElement(iter.currentItem());
|
||||
iter.next();
|
||||
} catch (ex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < children.Count(); ++i) {
|
||||
folder.propagateDelete(children.GetElementAt(i), true, msgWindow);
|
||||
}
|
||||
children.Clear();
|
||||
|
||||
// Delete messages.
|
||||
iter = folder.getMessages(msgWindow);
|
||||
while (iter.hasMoreElements()) {
|
||||
children.AppendElement(iter.getNext());
|
||||
}
|
||||
folder.deleteMessages(children, msgWindow, true, false, null, false);
|
||||
children.Clear();
|
||||
}
|
||||
|
||||
function deleteJunkInFolder()
|
||||
{
|
||||
MsgJunkMailInfo(true);
|
||||
|
|
|
@ -309,6 +309,8 @@ function fillFolderPaneContextMenu()
|
|||
ShowMenuItem("folderPaneContext-copy-location", !isServer && !isVirtualFolder);
|
||||
ShowMenuItem("folderPaneContext-emptyTrash", (numSelected <= 1) && (specialFolder == 'Trash'));
|
||||
EnableMenuItem("folderPaneContext-emptyTrash", true);
|
||||
ShowMenuItem("folderPaneContext-emptyJunk", (numSelected <= 1) && (specialFolder == 'Junk'));
|
||||
EnableMenuItem("folderPaneContext-emptyJunk", true);
|
||||
|
||||
var showSendUnsentMessages = (numSelected <= 1) && (specialFolder == 'Unsent Messages');
|
||||
ShowMenuItem("folderPaneContext-sendUnsentMessages", showSendUnsentMessages);
|
||||
|
|
|
@ -699,6 +699,10 @@
|
|||
label="&folderContextEmptyTrash.label;"
|
||||
accesskey="&folderContextEmptyTrash.accesskey;"
|
||||
oncommand="MsgEmptyTrash();"/>
|
||||
<menuitem id="folderPaneContext-emptyJunk"
|
||||
label="&folderContextEmptyJunk.label;"
|
||||
accesskey="&folderContextEmptyJunk.accesskey;"
|
||||
oncommand="deleteAllInFolder('emptyJunk');"/>
|
||||
<menuitem id="folderPaneContext-sendUnsentMessages"
|
||||
label="&folderContextSendUnsentMessages.label;"
|
||||
accesskey="&folderContextSendUnsentMessages.accesskey;"
|
||||
|
|
|
@ -534,6 +534,8 @@
|
|||
<!ENTITY folderContextCompact.accesskey "F">
|
||||
<!ENTITY folderContextEmptyTrash.label "Empty Trash">
|
||||
<!ENTITY folderContextEmptyTrash.accesskey "y">
|
||||
<!ENTITY folderContextEmptyJunk.label "Empty Junk">
|
||||
<!ENTITY folderContextEmptyJunk.accesskey "J">
|
||||
<!ENTITY folderContextSendUnsentMessages.label "Send Unsent Messages">
|
||||
<!ENTITY folderContextSendUnsentMessages.accesskey "d">
|
||||
<!ENTITY folderContextUnsubscribe.label "Unsubscribe">
|
||||
|
|
|
@ -381,3 +381,8 @@ confirmPhishingUrl2=%1$S thinks this site is suspicious! It may be trying to imp
|
|||
|
||||
#LOCALIZATION NOTE %1$S is the e-mail address of the person we will allow remote content for
|
||||
alwaysLoadRemoteContentForSender=Click here to always load remote content from %1$S.
|
||||
|
||||
# mailCommands.js
|
||||
emptyJunkTitle=Confirm
|
||||
emptyJunkMessage=Are you sure you want to permanently delete all messages and subfolders in the Junk folder?
|
||||
emptyJunkDontAsk=Don't ask me again.
|
||||
|
|
|
@ -753,3 +753,6 @@ pref("mail.signature_date", 0);
|
|||
#ifdef XP_OS2
|
||||
pref("mail.compose.max_recycled_windows", 0);
|
||||
#endif
|
||||
|
||||
// For the Empty Junk confirmation dialog
|
||||
pref("mailnews.emptyJunk.dontAskAgain", false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче