mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-23 21:17:52 +00:00
Bug #294094 --> Redesign filter actions to simplify the Filter Rule Dialog
r=neil sr=bienvenu a=chofmann
This commit is contained in:
parent
8271626e99
commit
16e29cc346
@ -96,6 +96,42 @@ searchterm {
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#searchterm");
|
||||
}
|
||||
|
||||
.ruleaction {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleaction");
|
||||
}
|
||||
|
||||
.ruleactiontype {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontype-menulist");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-base");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="movemessage"], .ruleactiontarget[type="copymessage"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-folder");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="labelmessageas"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-label");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="setpriorityto"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-priority");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="setjunkscore"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-junkscore");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="forwardmessage"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-forwardto");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="replytomessage"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-replyto");
|
||||
}
|
||||
|
||||
dummy.usesMailWidgets {
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#dummy");
|
||||
}
|
||||
@ -115,6 +151,11 @@ dummy.usesMailWidgets {
|
||||
-moz-user-focus: none;
|
||||
}
|
||||
|
||||
.folderTargetPopup {
|
||||
display: -moz-popup;
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#folderTargetPopup");
|
||||
}
|
||||
|
||||
.searchPopup {
|
||||
display: -moz-popup;
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#searchpopup");
|
||||
|
@ -87,6 +87,7 @@ messenger.jar:
|
||||
content/messenger/CustomHeaders.js (/mailnews/base/search/resources/content/CustomHeaders.js)
|
||||
content/messenger/FilterEditor.xul (/mailnews/base/search/resources/content/FilterEditor.xul)
|
||||
content/messenger/FilterEditor.js (/mailnews/base/search/resources/content/FilterEditor.js)
|
||||
* content/messenger/searchWidgets.xml (/mailnews/base/search/resources/content/searchWidgets.xml)
|
||||
content/messenger/viewLog.xul (/mailnews/base/search/resources/content/viewLog.xul)
|
||||
content/messenger/viewLog.js (/mailnews/base/search/resources/content/viewLog.js)
|
||||
content/messenger/junkLog.xul (/mailnews/base/resources/content/junkLog.xul)
|
||||
|
@ -15,20 +15,6 @@
|
||||
<!ENTITY body.label "body">
|
||||
<!ENTITY contains.label "contains">
|
||||
<!ENTITY nocontains.label "doesn't contain">
|
||||
<!ENTITY moveToFolder.label "Move to folder:">
|
||||
<!ENTITY copyToFolder.label "Copy to folder:">
|
||||
<!ENTITY changePriority.label "Change the priority to:">
|
||||
<!ENTITY delete.label "Delete the message">
|
||||
<!ENTITY markRead.label "Mark the message as read">
|
||||
<!ENTITY markFlagged.label "Flag the message">
|
||||
<!ENTITY label.label "Label the message:">
|
||||
<!ENTITY killThread.label "Ignore thread">
|
||||
<!ENTITY watchThread.label "Watch thread">
|
||||
<!ENTITY deleteFromServer.label "Delete from POP server">
|
||||
<!ENTITY fetchBodyFromServer.label "Fetch body from POP server">
|
||||
<!ENTITY setJunkScore.label "Set Junk Status to:">
|
||||
<!ENTITY forwardTo.label "Forward to:">
|
||||
<!ENTITY replyWithTemplate.label "Reply with template:">
|
||||
<!ENTITY filterName.label "Filter name:">
|
||||
<!ENTITY filterName.accesskey "i">
|
||||
|
||||
@ -48,3 +34,20 @@
|
||||
<!ENTITY newFolderButton.label "New Folder...">
|
||||
<!ENTITY newFolderButton.accesskey "N">
|
||||
|
||||
<!-- New Style Filter Rule Actions -->
|
||||
<!ENTITY moveMessage.label "Move Message to">
|
||||
<!ENTITY copyMessage.label "Copy Message to">
|
||||
<!ENTITY forwardTo.label "Forward Message to">
|
||||
<!ENTITY replyWithTemplate.label "Reply with Template">
|
||||
<!ENTITY markMessageRead.label "Mark As Read">
|
||||
<!ENTITY markMessageFlagged.label "Mark As Flagged">
|
||||
<!ENTITY labelMessage.label "Label Message As">
|
||||
<!ENTITY setPriority.label "Set Priority to">
|
||||
<!ENTITY setJunkScore.label "Set Junk Status to">
|
||||
<!ENTITY deleteMessage.label "Delete Message">
|
||||
<!ENTITY deleteFromPOP.label "Delete From POP Server">
|
||||
<!ENTITY fetchFromPOP.label "Fetch From POP Server">
|
||||
<!ENTITY ignoreThread.label "Ignore Thread">
|
||||
<!ENTITY watchThread.label "Watch Thread">
|
||||
|
||||
|
||||
|
@ -90,3 +90,10 @@ textbox {
|
||||
min-height:1px;
|
||||
}
|
||||
|
||||
.filler {
|
||||
padding-right: 22px;
|
||||
}
|
||||
|
||||
.ruleactionitem {
|
||||
min-width: 13em;
|
||||
}
|
@ -80,3 +80,10 @@ textbox {
|
||||
min-height:1px;
|
||||
}
|
||||
|
||||
.filler {
|
||||
padding-right: 22px;
|
||||
}
|
||||
|
||||
.ruleactionitem {
|
||||
min-width: 15em;
|
||||
}
|
||||
|
@ -1854,6 +1854,49 @@
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="folderTargetPopup" extends="chrome://messenger/content/mailWidgets.xml#popup-base">
|
||||
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<tree class="foldersTree" flex="1" datasources="rdf:msgaccountmanager rdf:mailnewsfolders" ref="msgaccounts:/" flags="dont-build-content" selstyle="primary" hidecolumnpicker="true">
|
||||
<treecols>
|
||||
<treecol flex="1" primary="true" sort="rdf:http://home.netscape.com/NC-rdf#FolderTreeName?sort=true" sortActive="true" sortDirection="ascending" crop="center" hideheader="true"/>
|
||||
</treecols>
|
||||
<treechildren class="foldersTreeChildren"/>
|
||||
<template>
|
||||
<rule nc:CanFileMessagesOnServer="true" nc:CanFileMessages="true" nc:CanSearchMessages="true">
|
||||
<treechildren>
|
||||
<treeitem uri="rdf:*">
|
||||
<treerow sort="rdf:http://home.netscape.com/NC-rdf#FolderTreeName?sort=true">
|
||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#FolderTreeSimpleName"
|
||||
properties="folderNameCol specialFolder-rdf:http://home.netscape.com/NC-rdf#SpecialFolder isServer-rdf:http://home.netscape.com/NC-rdf#IsServer isSecure-rdf:http://home.netscape.com/NC-rdf#IsSecure serverType-rdf:http://home.netscape.com/NC-rdf#ServerType noSelect-rdf:http://home.netscape.com/NC-rdf#NoSelect"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</rule>
|
||||
<rule nc:CanFileMessagesOnServer="true" nc:CanFileMessages="false" nc:CanSearchMessages="true" nc:Virtual="false">
|
||||
<treechildren>
|
||||
<treeitem uri="rdf:*">
|
||||
<treerow sort="rdf:http://home.netscape.com/NC-rdf#FolderTreeName?sort=true">
|
||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#FolderTreeSimpleName"
|
||||
properties="folderNameCol specialFolder-rdf:http://home.netscape.com/NC-rdf#SpecialFolder isServer-rdf:http://home.netscape.com/NC-rdf#IsServer isSecure-rdf:http://home.netscape.com/NC-rdf#IsSecure serverType-rdf:http://home.netscape.com/NC-rdf#ServerType noSelect-rdf:http://home.netscape.com/NC-rdf#NoSelect"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</rule>
|
||||
<rule nc:CanFileMessagesOnServer="true" nc:CanFileMessages="true" nc:Virtual="false">
|
||||
<treechildren>
|
||||
<treeitem uri="rdf:*">
|
||||
<treerow sort="rdf:http://home.netscape.com/NC-rdf#FolderTreeName?sort=true">
|
||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#FolderTreeSimpleName"
|
||||
properties="folderNameCol specialFolder-rdf:http://home.netscape.com/NC-rdf#SpecialFolder isServer-rdf:http://home.netscape.com/NC-rdf#IsServer isSecure-rdf:http://home.netscape.com/NC-rdf#IsSecure serverType-rdf:http://home.netscape.com/NC-rdf#ServerType noSelect-rdf:http://home.netscape.com/NC-rdf#NoSelect"/>
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</rule>
|
||||
</template>
|
||||
</tree>
|
||||
</xbl:content>
|
||||
</binding>
|
||||
|
||||
<binding id="locationpopup" extends="chrome://messenger/content/mailWidgets.xml#popup-base">
|
||||
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<tree class="foldersTree" flex="1" datasources="rdf:null" flags="dont-build-content" selstyle="primary" hidecolumnpicker="true">
|
||||
@ -1899,4 +1942,5 @@
|
||||
</tree>
|
||||
</xbl:content>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
|
@ -92,6 +92,47 @@ searchterm {
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#searchterm");
|
||||
}
|
||||
|
||||
.ruleaction {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleaction");
|
||||
}
|
||||
|
||||
.ruleactiontype {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontype-menulist");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-base");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="movemessage"], .ruleactiontarget[type="copymessage"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-folder");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="labelmessageas"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-label");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="setpriorityto"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-priority");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="setjunkscore"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-junkscore");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="forwardmessage"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-forwardto");
|
||||
}
|
||||
|
||||
.ruleactiontarget[type="replytomessage"] {
|
||||
-moz-binding: url("chrome://messenger/content/searchWidgets.xml#ruleactiontarget-replyto");
|
||||
}
|
||||
|
||||
.folderTargetPopup {
|
||||
display: -moz-popup;
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#folderTargetPopup");
|
||||
}
|
||||
|
||||
.searchPopup {
|
||||
display: -moz-popup;
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#searchpopup");
|
||||
|
@ -85,9 +85,8 @@ function PickedMsgFolder(selection,pickerID)
|
||||
SetFolderPicker(selectedUri,pickerID);
|
||||
}
|
||||
|
||||
function SetFolderPicker(uri,pickerID)
|
||||
function SetFolderPickerElement(uri, picker)
|
||||
{
|
||||
var picker = document.getElementById(pickerID);
|
||||
var msgfolder = GetMsgFolderFromUri(uri, true);
|
||||
|
||||
if (!msgfolder)
|
||||
@ -106,7 +105,7 @@ function SetFolderPicker(uri,pickerID)
|
||||
serverName = "???";
|
||||
}
|
||||
|
||||
if (pickerID == "runFiltersFolder")
|
||||
if (picker.id == "runFiltersFolder")
|
||||
selectedValue = msgfolder.name;
|
||||
else {
|
||||
if (!gMessengerBundle)
|
||||
@ -119,3 +118,8 @@ function SetFolderPicker(uri,pickerID)
|
||||
picker.setAttribute("label",selectedValue);
|
||||
picker.setAttribute("uri",uri);
|
||||
}
|
||||
|
||||
function SetFolderPicker(uri,pickerID)
|
||||
{
|
||||
SetFolderPickerElement(uri, document.getElementById(pickerID));
|
||||
}
|
||||
|
@ -40,128 +40,113 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
var gPromptService = GetPromptService();
|
||||
var gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
// the actual filter that we're editing
|
||||
var gFilter;
|
||||
// cache the key elements we need
|
||||
var gFilterList;
|
||||
var gFilterNameElement;
|
||||
var gActionTargetElement;
|
||||
var gActionTargetMoveElement;
|
||||
var gActionTargetCopyElement;
|
||||
var gActionValueDeck;
|
||||
var gActionPriority;
|
||||
var gActionLabel;
|
||||
var gActionJunkScore;
|
||||
var gActionForwardTo;
|
||||
var gReplyWithTemplateUri;
|
||||
var gFilterBundle;
|
||||
var gPreFillName;
|
||||
var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
|
||||
var gPrefBranch;
|
||||
var gMailSession = null;
|
||||
var gMoveToFolderCheckbox;
|
||||
var gCopyToFolderCheckbox;
|
||||
var gLabelCheckbox;
|
||||
var gChangePriorityCheckbox;
|
||||
var gJunkScoreCheckbox;
|
||||
var gForwardToCheckbox;
|
||||
var gReplyWithTemplateCheckbox;
|
||||
var gMarkReadCheckbox;
|
||||
var gMarkFlaggedCheckbox;
|
||||
var gDeleteCheckbox;
|
||||
var gDeleteFromServerCheckbox;
|
||||
var gFetchBodyFromServerCheckbox;
|
||||
var gKillCheckbox;
|
||||
var gWatchCheckbox;
|
||||
var gFilterActionList;
|
||||
var gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
|
||||
var gFilterActionStrings = ["none", "movemessage", "setpriorityto", "deletemessage",
|
||||
"markasread", "ignorethread", "watchthread", "markasflagged",
|
||||
"labelmessageas", "replytomessage", "forwardmessage", "stopexecution",
|
||||
"deletefrompopserver", "leaveonpopserver", "setjunkscore",
|
||||
"fetchfrompopserver", "copymessage"];
|
||||
|
||||
var nsMsgFilterAction = Components.interfaces.nsMsgFilterAction;
|
||||
|
||||
var gFilterEditorMsgWindow = null;
|
||||
|
||||
|
||||
function filterEditorOnLoad()
|
||||
{
|
||||
initializeSearchWidgets();
|
||||
initializeFilterWidgets();
|
||||
initializeSearchWidgets();
|
||||
initializeFilterWidgets();
|
||||
|
||||
gPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null);
|
||||
gFilterBundle = document.getElementById("bundle_filter");
|
||||
InitMessageLabel();
|
||||
if ("arguments" in window && window.arguments[0]) {
|
||||
var args = window.arguments[0];
|
||||
gPrefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null);
|
||||
gFilterBundle = document.getElementById("bundle_filter");
|
||||
InitMessageLabel();
|
||||
if ("arguments" in window && window.arguments[0])
|
||||
{
|
||||
var args = window.arguments[0];
|
||||
|
||||
if ("filterList" in args) {
|
||||
gFilterList = args.filterList;
|
||||
}
|
||||
if ("filterList" in args)
|
||||
gFilterList = args.filterList;
|
||||
|
||||
if ("filter" in args) {
|
||||
// editing a filter
|
||||
gFilter = window.arguments[0].filter;
|
||||
initializeDialog(gFilter);
|
||||
PopulateTemplateMenu();
|
||||
}
|
||||
else {
|
||||
if (gFilterList)
|
||||
setSearchScope(getScopeFromFilterList(gFilterList));
|
||||
|
||||
PopulateTemplateMenu();
|
||||
// if doing prefill filter create a new filter and populate it.
|
||||
if ("filterName" in args) {
|
||||
gPreFillName = args.filterName;
|
||||
gFilter = gFilterList.createFilter(gPreFillName);
|
||||
var term = gFilter.createTerm();
|
||||
|
||||
term.attrib = Components.interfaces.nsMsgSearchAttrib.Sender;
|
||||
term.op = Components.interfaces.nsMsgSearchOp.Is;
|
||||
|
||||
var termValue = term.value;
|
||||
termValue.attrib = term.attrib;
|
||||
termValue.str = gPreFillName;
|
||||
|
||||
term.value = termValue;
|
||||
|
||||
gFilter.appendTerm(term);
|
||||
|
||||
// the default action for news filters is Delete
|
||||
// for everything else, it's MoveToFolder
|
||||
var filterAction = gFilter.createAction();
|
||||
filterAction.type = (getScopeFromFilterList(gFilterList) == Components.interfaces.nsMsgSearchScope.newsFilter) ? nsMsgFilterAction.Delete : nsMsgFilterAction.MoveToFolder;
|
||||
gFilter.appendAction(filterAction);
|
||||
initializeDialog(gFilter);
|
||||
// Clear the default action added above now that the dialog is initialized.
|
||||
gFilter.clearActionList();
|
||||
}
|
||||
else{
|
||||
// fake the first more button press
|
||||
onMore(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!gFilter)
|
||||
if ("filter" in args)
|
||||
{
|
||||
var stub = gFilterBundle.getString("untitledFilterName");
|
||||
var count = 1;
|
||||
var name = stub;
|
||||
|
||||
// Set the default filter name to be "Untitled Filter"
|
||||
while (duplicateFilterNameExists(name))
|
||||
// editing a filter
|
||||
gFilter = window.arguments[0].filter;
|
||||
initializeDialog(gFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gFilterList)
|
||||
setSearchScope(getScopeFromFilterList(gFilterList));
|
||||
// if doing prefill filter create a new filter and populate it.
|
||||
if ("filterName" in args)
|
||||
{
|
||||
count++;
|
||||
name = stub + " " + count.toString();
|
||||
}
|
||||
gFilterNameElement.value = name;
|
||||
gPreFillName = args.filterName;
|
||||
gFilter = gFilterList.createFilter(gPreFillName);
|
||||
var term = gFilter.createTerm();
|
||||
|
||||
SetUpFilterActionList(getScopeFromFilterList(gFilterList));
|
||||
term.attrib = Components.interfaces.nsMsgSearchAttrib.Sender;
|
||||
term.op = Components.interfaces.nsMsgSearchOp.Is;
|
||||
|
||||
var termValue = term.value;
|
||||
termValue.attrib = term.attrib;
|
||||
termValue.str = gPreFillName;
|
||||
|
||||
term.value = termValue;
|
||||
|
||||
gFilter.appendTerm(term);
|
||||
|
||||
// the default action for news filters is Delete
|
||||
// for everything else, it's MoveToFolder
|
||||
var filterAction = gFilter.createAction();
|
||||
filterAction.type = (getScopeFromFilterList(gFilterList) == Components.interfaces.nsMsgSearchScope.newsFilter) ? nsMsgFilterAction.Delete : nsMsgFilterAction.MoveToFolder;
|
||||
gFilter.appendAction(filterAction);
|
||||
initializeDialog(gFilter);
|
||||
// Clear the default action added above now that the dialog is initialized.
|
||||
gFilter.clearActionList();
|
||||
}
|
||||
else
|
||||
{
|
||||
// fake the first more button press
|
||||
onMore(null);
|
||||
}
|
||||
}
|
||||
gFilterNameElement.select();
|
||||
// This call is required on mac and linux. It has no effect
|
||||
// under win32. See bug 94800.
|
||||
gFilterNameElement.focus();
|
||||
moveToAlertPosition();
|
||||
}
|
||||
|
||||
// in the case of a new filter, we may not have an action row yet.
|
||||
ensureActionRow();
|
||||
|
||||
if (!gFilter)
|
||||
{
|
||||
var stub = gFilterBundle.getString("untitledFilterName");
|
||||
var count = 1;
|
||||
var name = stub;
|
||||
|
||||
// Set the default filter name to be "Untitled Filter"
|
||||
while (duplicateFilterNameExists(name))
|
||||
{
|
||||
count++;
|
||||
name = stub + " " + count.toString();
|
||||
}
|
||||
gFilterNameElement.value = name;
|
||||
}
|
||||
|
||||
gFilterNameElement.select();
|
||||
// This call is required on mac and linux. It has no effect under win32. See bug 94800.
|
||||
gFilterNameElement.focus();
|
||||
moveToAlertPosition();
|
||||
}
|
||||
|
||||
function filterEditorOnUnload()
|
||||
@ -177,57 +162,58 @@ function onEnterInSearchTerm()
|
||||
|
||||
function onAccept()
|
||||
{
|
||||
if (!saveFilter()) return false;
|
||||
if (!saveFilter())
|
||||
return false;
|
||||
|
||||
// parent should refresh filter list..
|
||||
// this should REALLY only happen when some criteria changes that
|
||||
// are displayed in the filter dialog, like the filter name
|
||||
window.arguments[0].refresh = true;
|
||||
return true;
|
||||
// parent should refresh filter list..
|
||||
// this should REALLY only happen when some criteria changes that
|
||||
// are displayed in the filter dialog, like the filter name
|
||||
window.arguments[0].refresh = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// the folderListener object
|
||||
var gFolderListener = {
|
||||
OnItemAdded: function(parentItem, item) {},
|
||||
OnItemAdded: function(parentItem, item) {},
|
||||
|
||||
OnItemRemoved: function(parentItem, item){},
|
||||
OnItemRemoved: function(parentItem, item){},
|
||||
|
||||
OnItemPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
OnItemPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
|
||||
OnItemIntPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
OnItemIntPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
|
||||
OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
|
||||
OnItemUnicharPropertyChanged: function(item, property, oldValue, newValue){},
|
||||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {},
|
||||
OnItemUnicharPropertyChanged: function(item, property, oldValue, newValue){},
|
||||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {},
|
||||
|
||||
OnItemEvent: function(folder, event) {
|
||||
var eventType = event.toString();
|
||||
OnItemEvent: function(folder, event)
|
||||
{
|
||||
var eventType = event.toString();
|
||||
|
||||
if (eventType == "FolderCreateCompleted") {
|
||||
SetFolderPicker(folder.URI, gActionTargetElement.id);
|
||||
SetBusyCursor(window, false);
|
||||
}
|
||||
else if (eventType == "FolderCreateFailed") {
|
||||
SetBusyCursor(window, false);
|
||||
}
|
||||
|
||||
}
|
||||
if (eventType == "FolderCreateCompleted")
|
||||
{
|
||||
SetFolderPicker(folder.URI, gActionTargetElement.id);
|
||||
SetBusyCursor(window, false);
|
||||
}
|
||||
else if (eventType == "FolderCreateFailed")
|
||||
SetBusyCursor(window, false);
|
||||
}
|
||||
}
|
||||
|
||||
function duplicateFilterNameExists(filterName)
|
||||
{
|
||||
if (gFilterList)
|
||||
for (var i = 0; i < gFilterList.filterCount; i++) {
|
||||
for (var i = 0; i < gFilterList.filterCount; i++)
|
||||
if (filterName == gFilterList.getFilterAt(i).filterName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getScopeFromFilterList(filterList)
|
||||
{
|
||||
if (!filterList) {
|
||||
if (!filterList)
|
||||
{
|
||||
dump("yikes, null filterList\n");
|
||||
return nsMsgSearchScope.offlineMail;
|
||||
}
|
||||
@ -239,195 +225,44 @@ function getScope(filter)
|
||||
return getScopeFromFilterList(filter.filterList);
|
||||
}
|
||||
|
||||
function setLabelAttributes(labelID, menuItemID)
|
||||
{
|
||||
var color;
|
||||
var prefString;
|
||||
|
||||
try
|
||||
{
|
||||
if (labelID)
|
||||
color = gPrefBranch.getCharPref("mailnews.labels.color." + labelID);
|
||||
else
|
||||
color = "none";
|
||||
|
||||
prefString = gPrefBranch.getComplexValue("mailnews.labels.description." + labelID,
|
||||
Components.interfaces.nsIPrefLocalizedString);
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
dump("bad! " + ex + "\n");
|
||||
}
|
||||
|
||||
document.getElementById(menuItemID).setAttribute("label", prefString);
|
||||
|
||||
// the following is commented out for now until UE decides on how to show the
|
||||
// Labels menu items in the drop down list menu.
|
||||
//document.getElementById(menuItemID).setAttribute("style", ("color: " + color));
|
||||
}
|
||||
|
||||
function initializeFilterWidgets()
|
||||
{
|
||||
gFilterNameElement = document.getElementById("filterName");
|
||||
gActionTargetMoveElement = document.getElementById("actionTargetFolder");
|
||||
gActionTargetCopyElement = document.getElementById("actionTargetFolder2");
|
||||
gActionValueDeck = document.getElementById("actionValueDeck");
|
||||
gActionPriority = document.getElementById("actionValuePriority");
|
||||
gActionJunkScore = document.getElementById("actionValueJunkScore");
|
||||
gActionLabel = document.getElementById("actionValueLabel");
|
||||
gActionForwardTo = document.getElementById("actionValueForward");
|
||||
gMoveToFolderCheckbox = document.getElementById("moveToFolder");
|
||||
gCopyToFolderCheckbox = document.getElementById("copyToFolder");
|
||||
gLabelCheckbox = document.getElementById("label");
|
||||
gChangePriorityCheckbox = document.getElementById("changePriority");
|
||||
gJunkScoreCheckbox = document.getElementById("setJunkScore");
|
||||
gForwardToCheckbox = document.getElementById("forwardTo");
|
||||
gReplyWithTemplateCheckbox = document.getElementById("replyWithTemplate");
|
||||
gMarkReadCheckbox = document.getElementById("markRead");
|
||||
gMarkFlaggedCheckbox = document.getElementById("markFlagged");
|
||||
gDeleteCheckbox = document.getElementById("delete");
|
||||
gDeleteFromServerCheckbox = document.getElementById("deleteFromServer");
|
||||
gFetchBodyFromServerCheckbox = document.getElementById("fetchBodyFromServer");
|
||||
gKillCheckbox = document.getElementById("kill");
|
||||
gWatchCheckbox = document.getElementById("watch");
|
||||
gFilterActionList = document.getElementById("filterActionList");
|
||||
gFilterNameElement = document.getElementById("filterName");
|
||||
gFilterActionList = document.getElementById("filterActionList");
|
||||
}
|
||||
|
||||
function initializeDialog(filter)
|
||||
{
|
||||
gFilterNameElement.value = filter.filterName;
|
||||
var actionList = filter.actionList;
|
||||
var numActions = actionList.Count();
|
||||
|
||||
for (var actionIndex=0; actionIndex < numActions; actionIndex++)
|
||||
{
|
||||
var filterAction = actionList.QueryElementAt(actionIndex, Components.interfaces.nsIMsgRuleAction);
|
||||
|
||||
if (filterAction.type == nsMsgFilterAction.MoveToFolder)
|
||||
{
|
||||
// preselect target folder
|
||||
gMoveToFolderCheckbox.checked = true;
|
||||
var target = filterAction.targetFolderUri;
|
||||
if (target)
|
||||
SetFolderPicker(target, gActionTargetMoveElement.id);
|
||||
}
|
||||
else if (filterAction.type == nsMsgFilterAction.CopyToFolder)
|
||||
{
|
||||
// preselect target folder
|
||||
gCopyToFolderCheckbox.checked = true;
|
||||
var target = filterAction.targetFolderUri;
|
||||
if (target)
|
||||
SetFolderPicker(target, gActionTargetCopyElement.id);
|
||||
}
|
||||
else if (filterAction.type == nsMsgFilterAction.ChangePriority)
|
||||
{
|
||||
gChangePriorityCheckbox.checked = true;
|
||||
// initialize priority
|
||||
var selectedPriority = gActionPriority.getElementsByAttribute("value", filterAction.priority).item(0);
|
||||
|
||||
if (selectedPriority)
|
||||
gActionPriority.selectedItem = selectedPriority;
|
||||
}
|
||||
else if (filterAction.type == nsMsgFilterAction.Label)
|
||||
{
|
||||
gLabelCheckbox.checked = true;
|
||||
// initialize label
|
||||
var selectedLabel = gActionLabel.getElementsByAttribute("value", filterAction.label).item(0);
|
||||
if (selectedLabel)
|
||||
gActionLabel.selectedItem = selectedLabel;
|
||||
}
|
||||
else if (filterAction.type == nsMsgFilterAction.JunkScore)
|
||||
{
|
||||
gJunkScoreCheckbox.checked = true;
|
||||
// initialize junk score
|
||||
var selectedJunkScore = gActionJunkScore.getElementsByAttribute("value", filterAction.junkScore).item(0);
|
||||
|
||||
if (selectedJunkScore)
|
||||
gActionJunkScore.selectedItem = selectedJunkScore;
|
||||
}
|
||||
else if (filterAction.type == nsMsgFilterAction.Forward)
|
||||
{
|
||||
gForwardToCheckbox.checked = true;
|
||||
gActionForwardTo.value = filterAction.strValue;
|
||||
}
|
||||
else if (filterAction.type == nsMsgFilterAction.Reply)
|
||||
{
|
||||
gReplyWithTemplateCheckbox.checked = true;
|
||||
gReplyWithTemplateUri = filterAction.strValue;
|
||||
}
|
||||
else if (filterAction.type == nsMsgFilterAction.MarkRead)
|
||||
gMarkReadCheckbox.checked = true;
|
||||
else if (filterAction.type == nsMsgFilterAction.MarkFlagged)
|
||||
gMarkFlaggedCheckbox.checked = true;
|
||||
else if (filterAction.type == nsMsgFilterAction.Delete)
|
||||
gDeleteCheckbox.checked = true;
|
||||
else if (filterAction.type == nsMsgFilterAction.WatchThread)
|
||||
gWatchCheckbox.checked = true;
|
||||
else if (filterAction.type == nsMsgFilterAction.KillThread)
|
||||
gKillCheckbox.checked = true;
|
||||
else if (filterAction.type == nsMsgFilterAction.DeleteFromPop3Server)
|
||||
gDeleteFromServerCheckbox.checked = true;
|
||||
else if (filterAction.type == nsMsgFilterAction.FetchBodyFromPop3Server)
|
||||
gFetchBodyFromServerCheckbox.checked = true;
|
||||
|
||||
SetUpFilterActionList(getScope(filter));
|
||||
}
|
||||
|
||||
var scope = getScope(filter);
|
||||
setSearchScope(scope);
|
||||
initializeSearchRows(scope, filter.searchTerms);
|
||||
}
|
||||
|
||||
function InitMessageLabel()
|
||||
{
|
||||
/* this code gets the label strings and changes the menu labels */
|
||||
var lastLabel = 5;
|
||||
for (var i = 0; i <= lastLabel; i++)
|
||||
setLabelAttributes(i, "labelMenuItem" + i);
|
||||
|
||||
/* We set the label attribute for labels here because they have to be read from prefs. Default selection
|
||||
is always 0 and the picker thinks that it is already showing the label but it is not. Just setting selectedIndex
|
||||
to 0 doesn't do it because it thinks that it is already showing 0. So we need to set it to something else than 0
|
||||
and then back to 0, to make it show the default case- probably some sort of dom optimization*/
|
||||
|
||||
gActionLabel.selectedIndex = 1;
|
||||
gActionLabel.selectedIndex = 0;
|
||||
|
||||
document.commandDispatcher.updateCommands('create-menu-label');
|
||||
}
|
||||
|
||||
function PopulateTemplateMenu()
|
||||
{
|
||||
try
|
||||
gFilterNameElement.value = filter.filterName;
|
||||
var actionList = filter.actionList;
|
||||
var numActions = actionList.Count();
|
||||
|
||||
for (var actionIndex=0; actionIndex < numActions; actionIndex++)
|
||||
{
|
||||
var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
|
||||
var identity = accountManager.getFirstIdentityForServer(gFilterList.folder.server);
|
||||
var resource = gRDF.GetResource(identity.stationeryFolder);
|
||||
var msgFolder = resource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
var msgWindow = GetFilterEditorMsgWindow();
|
||||
var msgDatabase = msgFolder.getMsgDatabase(msgWindow);
|
||||
var enumerator = msgDatabase.EnumerateMessages();
|
||||
var templateListPopup = document.getElementById('actionValueReplyWithTemplate');
|
||||
var filterAction = actionList.QueryElementAt(actionIndex, Components.interfaces.nsIMsgRuleAction);
|
||||
|
||||
if ( enumerator )
|
||||
{
|
||||
while (enumerator.hasMoreElements())
|
||||
{
|
||||
var header = enumerator.getNext();
|
||||
if (header instanceof Components.interfaces.nsIMsgDBHdr)
|
||||
{
|
||||
var msgHdr = header.QueryInterface(Components.interfaces.nsIMsgDBHdr);
|
||||
var msgTemplateUri = msgFolder.URI + "?messageId="+msgHdr.messageId + '&subject=' + msgHdr.subject;
|
||||
var newItem = templateListPopup.appendItem(msgHdr.subject, msgTemplateUri);
|
||||
// ### TODO we really want to match based on messageId first, and if we don't get
|
||||
// any hits, we'll match on subject
|
||||
if (gReplyWithTemplateUri == msgTemplateUri)
|
||||
templateListPopup.selectedItem = newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
var newActionRow = document.createElement('listitem');
|
||||
newActionRow.setAttribute('initialActionIndex', actionIndex);
|
||||
newActionRow.className = 'ruleaction';
|
||||
gFilterActionList.appendChild(newActionRow);
|
||||
newActionRow.setAttribute('value', gFilterActionStrings[filterAction.type]);
|
||||
}
|
||||
|
||||
var scope = getScope(filter);
|
||||
setSearchScope(scope);
|
||||
initializeSearchRows(scope, filter.searchTerms);
|
||||
}
|
||||
|
||||
function ensureActionRow()
|
||||
{
|
||||
// make sure we have at least one action row visible to the user
|
||||
if (!gFilterActionList.getRowCount())
|
||||
{
|
||||
var newActionRow = document.createElement('listitem');
|
||||
newActionRow.className = 'ruleaction';
|
||||
gFilterActionList.appendChild(newActionRow);
|
||||
newActionRow.mRemoveButton.disabled = true;
|
||||
}
|
||||
catch (ex) {dump(ex);}
|
||||
}
|
||||
|
||||
// move to overlay
|
||||
@ -451,82 +286,24 @@ function saveFilter()
|
||||
// have an original filter name (i.e. we are editing a filter), then
|
||||
// we must check that the original is not the current as that is what
|
||||
// the duplicateFilterNameExists function will have picked up.
|
||||
if ((!gFilter || gFilter.filterName != filterName) &&
|
||||
duplicateFilterNameExists(filterName)) {
|
||||
if ((!gFilter || gFilter.filterName != filterName) && duplicateFilterNameExists(filterName))
|
||||
{
|
||||
if (gPromptService)
|
||||
gPromptService.alert(window,
|
||||
gFilterBundle.getString("cannotHaveDuplicateFilterTitle"),
|
||||
gFilterBundle.getString("cannotHaveDuplicateFilterMessage")
|
||||
);
|
||||
gPromptService.alert(window,gFilterBundle.getString("cannotHaveDuplicateFilterTitle"),
|
||||
gFilterBundle.getString("cannotHaveDuplicateFilterMessage"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(gMoveToFolderCheckbox.checked ||
|
||||
gCopyToFolderCheckbox.checked ||
|
||||
gLabelCheckbox.checked ||
|
||||
gChangePriorityCheckbox.checked ||
|
||||
gJunkScoreCheckbox.checked ||
|
||||
gForwardToCheckbox.checked ||
|
||||
gReplyWithTemplateCheckbox.checked ||
|
||||
gMarkReadCheckbox.checked ||
|
||||
gMarkFlaggedCheckbox.checked ||
|
||||
gDeleteCheckbox.checked ||
|
||||
gDeleteFromServerCheckbox.checked ||
|
||||
gFetchBodyFromServerCheckbox.checked ||
|
||||
gKillCheckbox.checked ||
|
||||
gWatchCheckbox.checked))
|
||||
// before we go any further, validate each specified filter action, abort the save
|
||||
// if any of the actions is invalid...
|
||||
for (var index = 0; index < gFilterActionList.getRowCount(); index++)
|
||||
{
|
||||
if (gPromptService)
|
||||
gPromptService.alert(window, null,
|
||||
gFilterBundle.getString("mustSelectAction"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gMoveToFolderCheckbox.checked)
|
||||
{
|
||||
if (gActionTargetMoveElement)
|
||||
targetUri = gActionTargetMoveElement.getAttribute("uri");
|
||||
if (!targetUri || targetUri == "")
|
||||
{
|
||||
if (gPromptService)
|
||||
gPromptService.alert(window, null,
|
||||
gFilterBundle.getString("mustSelectFolder"));
|
||||
var listItem = gFilterActionList.getItemAtIndex(index);
|
||||
if (!listItem.validateAction())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (gForwardToCheckbox.checked &&
|
||||
(gActionForwardTo.value.length < 3 || gActionForwardTo.value.indexOf('@') < 2))
|
||||
{
|
||||
if (gPromptService)
|
||||
gPromptService.alert(window, null,
|
||||
gFilterBundle.getString("enterValidEmailAddress"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gReplyWithTemplateCheckbox.checked)
|
||||
{
|
||||
var templateListPopup = document.getElementById('actionValueReplyWithTemplate');
|
||||
if (!templateListPopup.selectedItem)
|
||||
{
|
||||
if (gPromptService)
|
||||
gPromptService.alert(window, null, gFilterBundle.getString("pickTemplateToReplyWith"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (gCopyToFolderCheckbox.checked)
|
||||
{
|
||||
if (gActionTargetCopyElement)
|
||||
targetUri = gActionTargetCopyElement.getAttribute("uri");
|
||||
if (!targetUri || targetUri == "")
|
||||
{
|
||||
if (gPromptService)
|
||||
gPromptService.alert(window, null,
|
||||
gFilterBundle.getString("mustSelectFolder"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if we made it here, all of the actions are valid, so go ahead and save the filter
|
||||
|
||||
if (!gFilter)
|
||||
{
|
||||
@ -550,120 +327,9 @@ function saveFilter()
|
||||
}
|
||||
}
|
||||
|
||||
if (gMoveToFolderCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.MoveToFolder;
|
||||
filterAction.targetFolderUri = targetUri;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gCopyToFolderCheckbox.checked)
|
||||
{
|
||||
if (gActionTargetCopyElement)
|
||||
targetUri = gActionTargetCopyElement.getAttribute("uri");
|
||||
if (!targetUri || targetUri == "")
|
||||
{
|
||||
str = gFilterBundle.getString("mustSelectFolder");
|
||||
window.alert(str);
|
||||
return false;
|
||||
}
|
||||
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.CopyToFolder;
|
||||
filterAction.targetFolderUri = targetUri;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gChangePriorityCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.ChangePriority;
|
||||
filterAction.priority = gActionPriority.selectedItem.getAttribute("value");
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gLabelCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.Label;
|
||||
filterAction.label = gActionLabel.selectedItem.getAttribute("value");
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gJunkScoreCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.JunkScore;
|
||||
filterAction.junkScore = gActionJunkScore.selectedItem.getAttribute("value");
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
if (gForwardToCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.Forward;
|
||||
filterAction.strValue = gActionForwardTo.value;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gReplyWithTemplateCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.Reply;
|
||||
var templateListPopup = document.getElementById('actionValueReplyWithTemplate');
|
||||
filterAction.strValue = templateListPopup.selectedItem.getAttribute("value");
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
|
||||
if (gMarkReadCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.MarkRead;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gMarkFlaggedCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.MarkFlagged;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gDeleteCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.Delete;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gWatchCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.WatchThread;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gKillCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.KillThread;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gDeleteFromServerCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.DeleteFromPop3Server;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
|
||||
if (gFetchBodyFromServerCheckbox.checked)
|
||||
{
|
||||
filterAction = gFilter.createAction();
|
||||
filterAction.type = nsMsgFilterAction.FetchBodyFromPop3Server;
|
||||
gFilter.appendAction(filterAction);
|
||||
}
|
||||
// add each filteraction to the filter
|
||||
for (index = 0; index < gFilterActionList.getRowCount(); index++)
|
||||
gFilterActionList.getItemAtIndex(index).saveToFilter(gFilter);
|
||||
|
||||
if (getScope(gFilter) == Components.interfaces.nsMsgSearchScope.newsFilter)
|
||||
gFilter.filterType = Components.interfaces.nsMsgFilterType.NewsRule;
|
||||
@ -682,92 +348,14 @@ function saveFilter()
|
||||
return true;
|
||||
}
|
||||
|
||||
function SetUpFilterActionList(aScope)
|
||||
{
|
||||
var element, elements, i;
|
||||
|
||||
// disable / enable all elements in the "filteractionlist"
|
||||
// based on the scope and the "enablefornews" attribute
|
||||
elements = gFilterActionList.getElementsByAttribute("enablefornews","true");
|
||||
for (i=0;i<elements.length;i++)
|
||||
{
|
||||
element = elements[i];
|
||||
|
||||
if (aScope == Components.interfaces.nsMsgSearchScope.newsFilter)
|
||||
element.removeAttribute("disabled");
|
||||
else
|
||||
element.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
elements = gFilterActionList.getElementsByAttribute("enablefornews","false");
|
||||
for (i=0;i<elements.length;i++)
|
||||
{
|
||||
element = elements[i];
|
||||
|
||||
if (aScope != Components.interfaces.nsMsgSearchScope.newsFilter)
|
||||
element.removeAttribute("disabled");
|
||||
else
|
||||
element.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
elements = gFilterActionList.getElementsByAttribute("enableforpop3","true");
|
||||
for (i=0;i<elements.length;i++)
|
||||
{
|
||||
element = elements[i];
|
||||
|
||||
if (aScope == Components.interfaces.nsMsgSearchScope.offlineMailFilter)
|
||||
element.removeAttribute("disabled");
|
||||
else
|
||||
element.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
// ensure that the first checked action is visible in the listbox of actions.
|
||||
elements = gFilterActionList.getElementsByTagName("checkbox");
|
||||
for (i=0;i<elements.length;i++)
|
||||
{
|
||||
element = elements[i];
|
||||
if (element.checked)
|
||||
{
|
||||
gFilterActionList.ensureElementIsVisible(getListItemForElement(element));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getListItemForElement(element)
|
||||
{
|
||||
for (var parent = element.parentNode; parent; parent = parent.parentNode)
|
||||
{
|
||||
if (parent.localName == "listitem")
|
||||
return parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function onLabelListChanged(event)
|
||||
{
|
||||
var menuitem = event.target;
|
||||
showLabelColorFor(menuitem);
|
||||
}
|
||||
|
||||
function showLabelColorFor(menuitem)
|
||||
{
|
||||
if (!menuitem) return;
|
||||
var indexValue = menuitem.getAttribute("value");
|
||||
var labelID = gActionLabel.selectedItem.getAttribute("value");
|
||||
|
||||
gActionLabel.setAttribute("selectedIndex", indexValue);
|
||||
setLabelAttributes(labelID, "actionValueLabel");
|
||||
}
|
||||
|
||||
function GetFirstSelectedMsgFolder()
|
||||
{
|
||||
var selectedFolder = gActionTargetElement.getAttribute("uri");
|
||||
if (!selectedFolder)
|
||||
return null;
|
||||
var selectedFolder = gActionTargetElement.getAttribute("uri");
|
||||
if (!selectedFolder)
|
||||
return null;
|
||||
|
||||
var msgFolder = GetMsgFolderFromUri(selectedFolder, true);
|
||||
return msgFolder;
|
||||
var msgFolder = GetMsgFolderFromUri(selectedFolder, true);
|
||||
return msgFolder;
|
||||
}
|
||||
|
||||
function SearchNewFolderOkCallback(name, uri)
|
||||
@ -830,16 +418,17 @@ function GetFilterEditorMsgWindow()
|
||||
|
||||
function SetBusyCursor(window, enable)
|
||||
{
|
||||
// setCursor() is only available for chrome windows.
|
||||
// However one of our frames is the start page which
|
||||
// is a non-chrome window, so check if this window has a
|
||||
// setCursor method
|
||||
if ("setCursor" in window) {
|
||||
if (enable)
|
||||
window.setCursor("wait");
|
||||
else
|
||||
window.setCursor("auto");
|
||||
}
|
||||
// setCursor() is only available for chrome windows.
|
||||
// However one of our frames is the start page which
|
||||
// is a non-chrome window, so check if this window has a
|
||||
// setCursor method
|
||||
if ("setCursor" in window)
|
||||
{
|
||||
if (enable)
|
||||
window.setCursor("wait");
|
||||
else
|
||||
window.setCursor("auto");
|
||||
}
|
||||
}
|
||||
|
||||
function doHelpButton()
|
||||
@ -847,13 +436,3 @@ function doHelpButton()
|
||||
openHelp("mail-filters");
|
||||
}
|
||||
|
||||
function GetPromptService()
|
||||
{
|
||||
try {
|
||||
return Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
}
|
||||
catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -87,165 +87,15 @@
|
||||
|
||||
<separator/>
|
||||
|
||||
<vbox flex="1">
|
||||
<vbox>
|
||||
<label value="&filterActionDesc.label;" accesskey="&filterActionDesc.accesskey;" control="filterActionList"/>
|
||||
<hbox flex="1">
|
||||
<vbox flex="1">
|
||||
<listbox flex="1" id="filterActionList">
|
||||
<listbox id="filterActionList" flex="1" rows="4">
|
||||
<listcols>
|
||||
<listcol/>
|
||||
<listcol flex="1"/>
|
||||
<listcol flex="1"/>
|
||||
<listcol flex="1"/>
|
||||
</listcols>
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="moveToFolder" enablefornews="false" label="&moveToFolder.label;"/>
|
||||
</listcell>
|
||||
<listcell>
|
||||
<menulist id="actionTargetFolder" enablefornews="false" flex="1"/>
|
||||
</listcell>
|
||||
<listcell>
|
||||
<button id="newFolderButton" enablefornews="false" label="&newFolderButton.label;"
|
||||
accesskey="&newFolderButton.accesskey;"
|
||||
oncommand="gActionTargetElement = gActionTargetMoveElement;
|
||||
MsgNewFolder(SearchNewFolderOkCallback);"/>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="copyToFolder" label="©ToFolder.label;"/>
|
||||
</listcell>
|
||||
<listcell>
|
||||
<menulist id="actionTargetFolder2" flex="1"/>
|
||||
</listcell>
|
||||
<listcell>
|
||||
<button id="copyNewFolderButton" label="&newFolderButton.label;"
|
||||
accesskey="&newFolderButton.accesskey;"
|
||||
oncommand="gActionTargetElement = gActionTargetCopyElement;
|
||||
MsgNewFolder(SearchNewFolderOkCallback);"/>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="label" label="&label.label;"/>
|
||||
</listcell>
|
||||
<listcell>
|
||||
<menulist id="actionValueLabel" flex="1">
|
||||
<menupopup>
|
||||
<!-- see MailNewsTypes2.idl -->
|
||||
<menuitem id="labelMenuItem0" value="0"/>
|
||||
<menuitem id="labelMenuItem1" value="1"/>
|
||||
<menuitem id="labelMenuItem2" value="2"/>
|
||||
<menuitem id="labelMenuItem3" value="3"/>
|
||||
<menuitem id="labelMenuItem4" value="4"/>
|
||||
<menuitem id="labelMenuItem5" value="5"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="changePriority" label="&changePriority.label;"/>
|
||||
</listcell>
|
||||
<listcell>
|
||||
<menulist id="actionValuePriority" flex="1">
|
||||
<menupopup>
|
||||
<!-- see MailNewsTypes2.idl -->
|
||||
<menuitem value="6" label="&highestPriorityCmd.label;"/>
|
||||
<menuitem value="5" label="&highPriorityCmd.label;"/>
|
||||
<menuitem value="4" label="&normalPriorityCmd.label;"/>
|
||||
<menuitem value="3" label="&lowPriorityCmd.label;"/>
|
||||
<menuitem value="2" label="&lowestPriorityCmd.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="setJunkScore" enablefornews="false" label="&setJunkScore.label;"/>
|
||||
</listcell>
|
||||
<listcell>
|
||||
<menulist enablefornews="false" id="actionValueJunkScore" flex="1">
|
||||
<menupopup>
|
||||
<!-- see MailNewsTypes2.idl -->
|
||||
<menuitem value="100" label="&junk.label;"/>
|
||||
<menuitem value="0" label="¬Junk.label;"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="forwardTo" label="&forwardTo.label;"/>
|
||||
</listcell>
|
||||
<listcell>
|
||||
<textbox id="actionValueForward" flex="1" />
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="replyWithTemplate" label="&replyWithTemplate.label;"/>
|
||||
</listcell>
|
||||
<listcell>
|
||||
<menulist enablefornews="false" id="actionValueReplyWithTemplate" flex="1">
|
||||
<menupopup id="templateListPopup">
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="markRead" label="&markRead.label;"/>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="markFlagged" label="&markFlagged.label;"/>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="delete" label="&delete.label;"/>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="deleteFromServer" enableforpop3="true" label="&deleteFromServer.label;"/>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="fetchBodyFromServer" enableforpop3="true" label="&fetchBodyFromServer.label;"/>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="kill" enablefornews="true" label="&killThread.label;"/>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
<listitem allowevents="true">
|
||||
<listcell>
|
||||
<checkbox id="watch" enablefornews="true" label="&watchThread.label;"/>
|
||||
</listcell>
|
||||
</listitem>
|
||||
|
||||
|
||||
<listcol class="filler"/>
|
||||
</listcols>
|
||||
</listbox>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</vbox>
|
||||
|
||||
</dialog>
|
||||
|
516
mailnews/base/search/resources/content/searchWidgets.xml
Normal file
516
mailnews/base/search/resources/content/searchWidgets.xml
Normal file
@ -0,0 +1,516 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- ***** 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 Filter Action Rules.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Scott MacGregor <mscott@mozilla.org>.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2005
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either 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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<!--
|
||||
This file has the following external dependencies:
|
||||
-gFilterActionStrings from FilterEditor.js
|
||||
-gFilterList from FilterEditor.js
|
||||
-gPromptService from FilterEditor.js
|
||||
-gMessengerBundle from msgFolderPickerOverlay.js
|
||||
-GetMsgFolderFromUri, SetFolderPickerElement from msgFolderPickerOverlay.js
|
||||
-->
|
||||
|
||||
<!DOCTYPE dialog [
|
||||
<!ENTITY % filterEditorDTD SYSTEM "chrome://messenger/locale/FilterEditor.dtd" >
|
||||
%filterEditorDTD;
|
||||
<!ENTITY % msgFolderPickerOverlayDTD SYSTEM "chrome://messenger/locale/msgFolderPickerOverlay.dtd" >
|
||||
%msgFolderPickerOverlayDTD;
|
||||
]>
|
||||
|
||||
<bindings id="filterBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
|
||||
<binding id="ruleactiontype-menulist">
|
||||
<content>
|
||||
<xul:menulist flex="1" class="ruleactionitem">
|
||||
<xul:menupopup>
|
||||
<xul:menuitem label="&moveMessage.label;" value="movemessage" enablefornews="false"/>
|
||||
<xul:menuitem label="©Message.label;" value="copymessage"/>
|
||||
<xul:menuseparator enablefornews="false"/>
|
||||
<xul:menuitem label="&forwardTo.label;" value="forwardmessage" enablefornews="false"/>
|
||||
<xul:menuitem label="&replyWithTemplate.label;" value="replytomessage" enablefornews="false"/>
|
||||
<xul:menuseparator/>
|
||||
<xul:menuitem label="&markMessageRead.label;" value="markasread"/>
|
||||
<xul:menuitem label="&markMessageFlagged.label;" value="markasflagged"/>
|
||||
<xul:menuitem label="&labelMessage.label;" value="labelmessageas"/>
|
||||
<xul:menuitem label="&setPriority.label;" value="setpriorityto"/>
|
||||
<xul:menuitem label="&setJunkScore.label;" value="setjunkscore" enablefornews="false"/>
|
||||
<xul:menuseparator enableforpop3="true"/>
|
||||
<xul:menuitem label="&deleteMessage.label;" value="deletemessage" enableforpop3="true"/>
|
||||
<xul:menuitem label="&deleteFromPOP.label;" value="deletefrompopserver" enableforpop3="true"/>
|
||||
<xul:menuitem label="&fetchFromPOP.label;" value="fetchfrompopserver" enableforpop3="true"/>
|
||||
<xul:menuseparator enablefornews="true"/>
|
||||
<xul:menuitem label="&ignoreThread.label;" value="ignorethread" enablefornews="true"/>
|
||||
<xul:menuitem label="&watchThread.label;" value="watchthread" enablefornews="true"/>
|
||||
</xul:menupopup>
|
||||
</xul:menulist>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.hideInvalidActions();
|
||||
// differentiate between creating a new, next available action,
|
||||
// and creating a row which will be initialized with an action
|
||||
if (!this.parentNode.hasAttribute('initialActionIndex'))
|
||||
{
|
||||
var unavailableActions = this.usedActionsList();
|
||||
// select the first one that's not in the list
|
||||
var menuItems = this.menupopup.getElementsByTagName('menuitem');
|
||||
for (var index = 0; index < menuItems.length; index++)
|
||||
{
|
||||
var menu = menuItems[index];
|
||||
if (!(menu.value in unavailableActions) && !menu.hidden)
|
||||
{
|
||||
this.menulist.value = menu.value;
|
||||
this.parentNode.setAttribute('value', menu.value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.parentNode.mActionTypeInitialized = true;
|
||||
this.parentNode.clearInitialActionIndex();
|
||||
}
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
<field name="menupopup">document.getAnonymousNodes(this)[0].menupopup</field>
|
||||
<field name="menulist">document.getAnonymousNodes(this)[0]</field>
|
||||
|
||||
<method name="hideInvalidActions">
|
||||
<body>
|
||||
<![CDATA[
|
||||
var scope = getScopeFromFilterList(gFilterList);
|
||||
|
||||
// walk through the list of filter actions and hide any actions which aren't valid
|
||||
// for our given scope (news, imap, pop, etc)
|
||||
var elements, i;
|
||||
|
||||
// disable / enable all elements in the "filteractionlist"
|
||||
// based on the scope and the "enablefornews" attribute
|
||||
elements = this.menupopup.getElementsByAttribute("enablefornews", "true");
|
||||
for (i = 0; i < elements.length; i++)
|
||||
elements[i].hidden = scope != Components.interfaces.nsMsgSearchScope.newsFilter;
|
||||
|
||||
elements = this.menupopup.getElementsByAttribute("enablefornews", "false");
|
||||
for (i = 0; i < elements.length; i++)
|
||||
elements[i].hidden = scope == Components.interfaces.nsMsgSearchScope.newsFilter;
|
||||
|
||||
elements = this.menupopup.getElementsByAttribute("enableforpop3", "true");
|
||||
for (i = 0; i < elements.length; i++)
|
||||
elements[i].hidden = scope != Components.interfaces.nsMsgSearchScope.offlineMailFilter;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="numVisibleActions">
|
||||
<body>
|
||||
<![CDATA[
|
||||
var numVisibleActions = 0;
|
||||
var menuItems = this.menupopup.getElementsByTagName('menuitem');
|
||||
// only count the items that are visible
|
||||
for (var index = 0; index < menuItems.length; index++)
|
||||
if (!menuItems[index].hidden)
|
||||
numVisibleActions++;
|
||||
return numVisibleActions;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- returns a hash containing all of the filter actions which are currently being used by other filteractionrows -->
|
||||
<method name="usedActionsList">
|
||||
<body>
|
||||
<![CDATA[
|
||||
var usedActions = {};
|
||||
var currentFilterActionRow = this.parentNode;
|
||||
var listBox = currentFilterActionRow.mListBox; // need to account for the list item
|
||||
// now iterate over each list item in the list box
|
||||
for (var index = 0; index < listBox.getRowCount(); index++)
|
||||
{
|
||||
var filterActionRow = listBox.getItemAtIndex(index);
|
||||
if (filterActionRow != currentFilterActionRow)
|
||||
usedActions[filterActionRow.getAttribute('value')] = true;
|
||||
}
|
||||
return usedActions;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="command">
|
||||
<![CDATA[
|
||||
this.parentNode.setAttribute('value', this.menulist.value);
|
||||
]]>
|
||||
</handler>
|
||||
|
||||
<handler event="popupshowing">
|
||||
<![CDATA[
|
||||
var unavailableActions = this.usedActionsList();
|
||||
var menuItems = this.menupopup.getElementsByTagName('menuitem');
|
||||
for (var index = 0; index < menuItems.length; index++)
|
||||
{
|
||||
var menu = menuItems[index];
|
||||
menu.setAttribute('disabled', menu.value in unavailableActions);
|
||||
}
|
||||
]]>
|
||||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<binding id="ruleaction">
|
||||
<content allowevents="true">
|
||||
<xul:listcell class="ruleactiontype"/>
|
||||
<xul:listcell class="ruleactiontarget" xbl:inherits="type=value"/>
|
||||
<xul:listcell>
|
||||
<xul:button class="small-button" label="+" onclick="this.parentNode.parentNode.addRow();"/>
|
||||
<xul:button class="small-button" label="-" onclick="this.parentNode.parentNode.removeRow();" anonid="removeButton"/>
|
||||
</xul:listcell>
|
||||
<xul:listcell/>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<field name="mListBox">this.parentNode</field>
|
||||
<field name="mRemoveButton">document.getAnonymousElementByAttribute(this, "anonid", "removeButton")</field>
|
||||
<field name="mActionTypeInitialized">false</field>
|
||||
<field name="mRuleActionTargetInitialized">false</field>
|
||||
|
||||
<method name="clearInitialActionIndex">
|
||||
<body>
|
||||
<![CDATA[
|
||||
// we should only remove the initialActionIndex after we have been told that
|
||||
// both the rule action type and the rule action target hvae both been built since they both need
|
||||
// this piece of information. This complication arises because both of these child elements are getting
|
||||
// bound asynchronously after the search row has been constructed
|
||||
|
||||
if (this.mActionTypeInitialized && this.mRuleActionTargetInitialized)
|
||||
this.removeAttribute('initialActionIndex');
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="initWithAction">
|
||||
<parameter name="aFilterAction"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var filterActionStr = gFilterActionStrings[aFilterAction.type];
|
||||
document.getAnonymousNodes(document.getAnonymousNodes(this)[0])[0].value = filterActionStr;
|
||||
var actionTarget = document.getAnonymousNodes(this)[1];
|
||||
switch (gFilterActionStrings[aFilterAction.type])
|
||||
{
|
||||
case "movemessage":
|
||||
case "copymessage":
|
||||
gPicker = actionTarget;
|
||||
SetFolderPickerElement(aFilterAction.targetFolderUri, actionTarget.menulist);
|
||||
break;
|
||||
case "replytomessage":
|
||||
case "forwardmessage":
|
||||
document.getAnonymousNodes(actionTarget)[0].value = aFilterAction.strValue;
|
||||
break;
|
||||
case "labelmessageas":
|
||||
document.getAnonymousNodes(actionTarget)[0].value = aFilterAction.label;
|
||||
break;
|
||||
case "setpriorityto":
|
||||
document.getAnonymousNodes(actionTarget)[0].value = aFilterAction.priority;
|
||||
break;
|
||||
case "setjunkscore":
|
||||
document.getAnonymousNodes(actionTarget)[0].value = aFilterAction.junkScore;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
this.mRuleActionTargetInitialized = true;
|
||||
this.clearInitialActionIndex();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="validateAction">
|
||||
<body>
|
||||
<![CDATA[
|
||||
// returns true if this row represents a valid filter action and false otherwise.
|
||||
// This routine also prompts the user.
|
||||
var filterActionString = this.getAttribute('value');
|
||||
var actionTarget = document.getAnonymousNodes(this)[1];
|
||||
var errorString;
|
||||
|
||||
switch (filterActionString)
|
||||
{
|
||||
case "movemessage":
|
||||
case "copymessage":
|
||||
if (!actionTarget.uri || actionTarget.uri == "")
|
||||
errorString = "mustSelectFolder";
|
||||
break;
|
||||
case "forwardmessage":
|
||||
if (document.getAnonymousNodes(actionTarget)[0].value.length < 3 ||
|
||||
document.getAnonymousNodes(actionTarget)[0].value.indexOf('@') < 2)
|
||||
errorString = "enterValidEmailAddress";
|
||||
break;
|
||||
case "replytomessage":
|
||||
if (!document.getAnonymousNodes(actionTarget)[0].selectedItem)
|
||||
errorString = "pickTemplateToReplyWith";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (errorString && gPromptService)
|
||||
gPromptService.alert(window, null, gFilterBundle.getString(errorString));
|
||||
|
||||
return !errorString;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="saveToFilter">
|
||||
<parameter name="aFilter"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
// create a new filter action, fill it in, and then append it to the filter
|
||||
var filterAction = aFilter.createAction();
|
||||
var filterActionString = this.getAttribute('value');
|
||||
filterAction.type = gFilterActionStrings.indexOf(filterActionString);
|
||||
var actionTarget = document.getAnonymousNodes(this)[1];
|
||||
|
||||
switch (filterActionString)
|
||||
{
|
||||
case "labelmessageas":
|
||||
filterAction.label = document.getAnonymousNodes(actionTarget)[0].getAttribute("value");
|
||||
break;
|
||||
case "setpriorityto":
|
||||
filterAction.priority = document.getAnonymousNodes(actionTarget)[0].getAttribute("value");
|
||||
break;
|
||||
case "movemessage":
|
||||
case "copymessage":
|
||||
filterAction.targetFolderUri = actionTarget.uri;
|
||||
break;
|
||||
case "setjunkscore":
|
||||
filterAction.junkScore = document.getAnonymousNodes(actionTarget)[0].value;
|
||||
break;
|
||||
case "replytomessage":
|
||||
case "forwardmessage":
|
||||
filterAction.strValue = document.getAnonymousNodes(actionTarget)[0].value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
aFilter.appendAction(filterAction);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="addRow">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.mListBox.getRowCount() < document.getAnonymousNodes(this)[0].numVisibleActions())
|
||||
{
|
||||
var listItem = document.createElement('listitem');
|
||||
listItem.className = 'ruleaction';
|
||||
this.mListBox.insertBefore(listItem, this.nextSibling);
|
||||
this.mListBox.ensureElementIsVisible(listItem);
|
||||
|
||||
// make sure the first remove button is enabled
|
||||
this.mListBox.getItemAtIndex(0).mRemoveButton.disabled = false;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="removeRow">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.mListBox.getRowCount() > 1)
|
||||
this.mListBox.removeChild(this);
|
||||
// if we only have one row left, then disable the remove button for that row
|
||||
this.mListBox.getItemAtIndex(0).mRemoveButton.disabled = this.mListBox.getRowCount() == 1;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="ruleactiontarget-base">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
if (this.parentNode.hasAttribute('initialActionIndex'))
|
||||
{
|
||||
var actionIndex = this.parentNode.getAttribute('initialActionIndex');
|
||||
var filterAction = gFilter.actionList.QueryElementAt(actionIndex, Components.interfaces.nsIMsgRuleAction);
|
||||
this.parentNode.initWithAction(filterAction);
|
||||
}
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="ruleactiontarget-label" extends="chrome://messenger/content/searchWidgets.xml#ruleactiontarget-base">
|
||||
<content>
|
||||
<xul:menulist class="ruleactionitem">
|
||||
<xul:menupopup>
|
||||
<xul:menuitem value="0"/>
|
||||
<xul:menuitem value="1"/>
|
||||
<xul:menuitem value="2"/>
|
||||
<xul:menuitem value="3"/>
|
||||
<xul:menuitem value="4"/>
|
||||
<xul:menuitem value="5"/>
|
||||
</xul:menupopup>
|
||||
</xul:menulist>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
var menuItems = document.getAnonymousNodes(this)[0].menupopup.childNodes;
|
||||
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null);
|
||||
|
||||
for (var index = 0; index < menuItems.length; index++)
|
||||
{
|
||||
var menuEl = menuItems[index];
|
||||
var prefString = prefBranch.getComplexValue("mailnews.labels.description." + menuEl.value,
|
||||
Components.interfaces.nsIPrefLocalizedString);
|
||||
menuEl.setAttribute("label", prefString);
|
||||
}
|
||||
|
||||
// propagating a pre-existing hack to make the label get displayed correctly in the menulist
|
||||
// now that we've changed the labels for each menu list. We need to use the current selectedIndex
|
||||
// (if its defined) to handle the case where we were initialized with a filter action already.
|
||||
var currentItem = document.getAnonymousNodes(this)[0].selectedItem;
|
||||
document.getAnonymousNodes(this)[0].selectedItem = null;
|
||||
document.getAnonymousNodes(this)[0].selectedItem = currentItem;
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="ruleactiontarget-priority" extends="chrome://messenger/content/searchWidgets.xml#ruleactiontarget-base">
|
||||
<content>
|
||||
<xul:menulist class="ruleactionitem">
|
||||
<xul:menupopup>
|
||||
<xul:menuitem value="6" label="&highestPriorityCmd.label;"/>
|
||||
<xul:menuitem value="5" label="&highPriorityCmd.label;"/>
|
||||
<xul:menuitem value="4" label="&normalPriorityCmd.label;"/>
|
||||
<xul:menuitem value="3" label="&lowPriorityCmd.label;"/>
|
||||
<xul:menuitem value="2" label="&lowestPriorityCmd.label;"/>
|
||||
</xul:menupopup>
|
||||
</xul:menulist>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="ruleactiontarget-junkscore" extends="chrome://messenger/content/searchWidgets.xml#ruleactiontarget-base">
|
||||
<content>
|
||||
<xul:menulist class="ruleactionitem">
|
||||
<xul:menupopup>
|
||||
<xul:menuitem value="100" label="&junk.label;"/>
|
||||
<xul:menuitem value="0" label="¬Junk.label;"/>
|
||||
</xul:menupopup>
|
||||
</xul:menulist>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="ruleactiontarget-replyto" extends="chrome://messenger/content/searchWidgets.xml#ruleactiontarget-base">
|
||||
<content>
|
||||
<xul:menulist class="ruleactionitem">
|
||||
<xul:menupopup>
|
||||
</xul:menupopup>
|
||||
</xul:menulist>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager);
|
||||
var identity = accountManager.getFirstIdentityForServer(gFilterList.folder.server);
|
||||
var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
var resource = rdfService.GetResource(identity.stationeryFolder);
|
||||
var msgFolder = resource.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
var msgWindow = GetFilterEditorMsgWindow();
|
||||
var msgDatabase = msgFolder.getMsgDatabase(msgWindow);
|
||||
var enumerator = msgDatabase.EnumerateMessages();
|
||||
var templateListPopup = document.getAnonymousNodes(this)[0].menupopup;
|
||||
|
||||
if ( enumerator )
|
||||
{
|
||||
while (enumerator.hasMoreElements())
|
||||
{
|
||||
var header = enumerator.getNext();
|
||||
if (header instanceof Components.interfaces.nsIMsgDBHdr)
|
||||
{
|
||||
var msgTemplateUri = msgFolder.URI + "?messageId=" + header.messageId + '&subject=' + header.subject;
|
||||
var newItem = document.getAnonymousNodes(this)[0].appendItem(header.subject, msgTemplateUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="ruleactiontarget-forwardto" extends="chrome://messenger/content/searchWidgets.xml#ruleactiontarget-base">
|
||||
<content>
|
||||
<xul:textbox class="ruleactionitem"/>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="ruleactiontarget-folder" extends="chrome://messenger/content/searchWidgets.xml#ruleactiontarget-base">
|
||||
<content>
|
||||
<xul:menulist class="ruleactionitem">
|
||||
<xul:menupopup class="folderTargetPopup" oncommand="SetFolderPickerElement(this.getAttribute('uri'), this.parentNode);"/>
|
||||
</xul:menulist>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
if (!this.uri)
|
||||
SetFolderPickerElement(this.menulist.firstChild.tree.builderView.getResourceAtIndex(0).Value, this.menulist);
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
<property name="uri" readonly="true" onget="return document.getAnonymousNodes(this)[0].getAttribute('uri');"/>
|
||||
<field name="menulist">document.getAnonymousNodes(this)[0]</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
@ -16,21 +16,6 @@
|
||||
<!ENTITY body.label "body">
|
||||
<!ENTITY contains.label "contains">
|
||||
<!ENTITY nocontains.label "doesn't contain">
|
||||
<!ENTITY moveToFolder.label "Move to folder:">
|
||||
<!ENTITY copyToFolder.label "Copy to folder:">
|
||||
|
||||
<!ENTITY changePriority.label "Change the priority to:">
|
||||
<!ENTITY delete.label "Delete the message">
|
||||
<!ENTITY markRead.label "Mark the message as read">
|
||||
<!ENTITY markFlagged.label "Flag the message">
|
||||
<!ENTITY label.label "Label the message:">
|
||||
<!ENTITY killThread.label "Ignore thread">
|
||||
<!ENTITY watchThread.label "Watch thread">
|
||||
<!ENTITY deleteFromServer.label "Delete from POP server">
|
||||
<!ENTITY fetchBodyFromServer.label "Fetch body from POP server">
|
||||
<!ENTITY setJunkScore.label "Set Junk Status to:">
|
||||
<!ENTITY forwardTo.label "Forward to:">
|
||||
<!ENTITY replyWithTemplate.label "Reply with template:">
|
||||
<!ENTITY filterName.label "Filter name:">
|
||||
<!ENTITY filterName.accesskey "i">
|
||||
|
||||
@ -50,3 +35,18 @@
|
||||
<!ENTITY newFolderButton.label "New Folder...">
|
||||
<!ENTITY newFolderButton.accesskey "N">
|
||||
|
||||
<!-- New Style Filter Rule Actions -->
|
||||
<!ENTITY moveMessage.label "Move Message to">
|
||||
<!ENTITY copyMessage.label "Copy Message to">
|
||||
<!ENTITY forwardTo.label "Forward Message to">
|
||||
<!ENTITY replyWithTemplate.label "Reply with Template">
|
||||
<!ENTITY markMessageRead.label "Mark As Read">
|
||||
<!ENTITY markMessageFlagged.label "Mark As Flagged">
|
||||
<!ENTITY labelMessage.label "Label Message As">
|
||||
<!ENTITY setPriority.label "Set Priority to">
|
||||
<!ENTITY setJunkScore.label "Set Junk Status to">
|
||||
<!ENTITY deleteMessage.label "Delete Message">
|
||||
<!ENTITY deleteFromPOP.label "Delete From POP Server">
|
||||
<!ENTITY fetchFromPOP.label "Fetch From POP Server">
|
||||
<!ENTITY ignoreThread.label "Ignore Thread">
|
||||
<!ENTITY watchThread.label "Watch Thread">
|
||||
|
@ -155,6 +155,7 @@ messenger.jar:
|
||||
content/messenger/CustomHeaders.js (base/search/resources/content/CustomHeaders.js)
|
||||
content/messenger/FilterEditor.xul (base/search/resources/content/FilterEditor.xul)
|
||||
content/messenger/FilterEditor.js (base/search/resources/content/FilterEditor.js)
|
||||
content/messenger/searchWidgets.xml (base/search/resources/content/searchWidgets.xml)
|
||||
content/messenger/mail-offline.js (base/resources/content/mail-offline.js)
|
||||
content/messenger/viewLog.xul (base/search/resources/content/viewLog.xul)
|
||||
content/messenger/viewLog.js (base/search/resources/content/viewLog.js)
|
||||
|
@ -80,3 +80,10 @@ textbox {
|
||||
min-height:1px;
|
||||
}
|
||||
|
||||
.filler {
|
||||
padding-right: 22px;
|
||||
}
|
||||
|
||||
.ruleactionitem {
|
||||
min-width: 15em;
|
||||
}
|
||||
|
@ -79,3 +79,11 @@ textbox {
|
||||
width: 560px;
|
||||
min-height:1px;
|
||||
}
|
||||
|
||||
.filler {
|
||||
padding-right: 22px;
|
||||
}
|
||||
|
||||
.ruleactionitem {
|
||||
min-width: 15em;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user