Follow up patch to bug 300338 - tidy MsgComposeCommands.js. Patch by Serge GAUTHERIE <gautheri@noos.fr>. r=dmose,sr=bienvenu
This commit is contained in:
Родитель
49f8f0912e
Коммит
b62d5b649e
|
@ -74,6 +74,7 @@ var sNameProperty = null;
|
|||
var msgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"].createInstance();
|
||||
msgWindow = msgWindow.QueryInterface(Components.interfaces.nsIMsgWindow);
|
||||
|
||||
|
||||
/**
|
||||
* Global variables, need to be re-initialized every time mostly because we need to release them when the window close
|
||||
*/
|
||||
|
@ -128,10 +129,13 @@ function InitializeGlobalVariables()
|
|||
gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
//This migrates the LDAPServer Preferences from 4.x to mozilla format.
|
||||
try {
|
||||
gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"].getService();
|
||||
gLDAPPrefsService = gLDAPPrefsService.QueryInterface( Components.interfaces.nsILDAPPrefsService);
|
||||
} catch (ex) {dump ("ERROR: Cannot get the LDAP service\n" + ex + "\n");}
|
||||
gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"];
|
||||
if (gLDAPPrefsService) {
|
||||
try {
|
||||
gLDAPPrefsService = gLDAPPrefsService
|
||||
.getService(Components.interfaces.nsILDAPPrefsService);
|
||||
} catch (ex) {dump ("ERROR: Cannot get the LDAP prefs service\n" + ex + "\n");}
|
||||
}
|
||||
|
||||
gMsgCompose = null;
|
||||
gWindowLocked = false;
|
||||
|
@ -184,7 +188,9 @@ function disableEditableFields()
|
|||
gMsgCompose.editor.flags |= nsIPlaintextEditorMail.eEditorReadonlyMask;
|
||||
var disableElements = document.getElementsByAttribute("disableonsend", "true");
|
||||
for (i=0;i<disableElements.length;i++)
|
||||
{
|
||||
disableElements[i].setAttribute('disabled', 'true');
|
||||
}
|
||||
}
|
||||
|
||||
function enableEditableFields()
|
||||
|
@ -251,13 +257,13 @@ var gComposeRecyclingListener = {
|
|||
},
|
||||
|
||||
onReopen: function(params) {
|
||||
//Reset focus to avoid undesirable visual effect when reopening the winodw
|
||||
// Reset focus to avoid undesirable visual effect when reopening the window
|
||||
var identityElement = document.getElementById("msgIdentity");
|
||||
if (identityElement)
|
||||
identityElement.focus();
|
||||
|
||||
InitializeGlobalVariables();
|
||||
ComposeStartup(true, params);
|
||||
ComposeStartup(true, params);
|
||||
|
||||
var event = document.createEvent('Events');
|
||||
event.initEvent('compose-window-reopen', false, true);
|
||||
|
@ -355,7 +361,7 @@ var progressListener = {
|
|||
statusText = document.getElementById("statusText");
|
||||
if (statusText)
|
||||
statusText.setAttribute("label", aMessage);
|
||||
} catch (ex) {};
|
||||
} catch (ex) {}
|
||||
},
|
||||
|
||||
onSecurityChange: function(aWebProgress, aRequest, state)
|
||||
|
@ -589,14 +595,13 @@ function CommandUpdate_MsgCompose()
|
|||
updateComposeItems();
|
||||
}
|
||||
|
||||
function updateComposeItems()
|
||||
function updateComposeItems()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Edit Menu
|
||||
try {
|
||||
// Edit Menu
|
||||
goUpdateCommand("cmd_rewrap");
|
||||
|
||||
//Insert Menu
|
||||
// Insert Menu
|
||||
if (gMsgCompose && gMsgCompose.composeHTML)
|
||||
{
|
||||
goUpdateCommand("cmd_renderedHTMLEnabler");
|
||||
|
@ -613,14 +618,13 @@ function updateComposeItems()
|
|||
goUpdateCommand("cmd_smiley");
|
||||
}
|
||||
|
||||
//Options Menu
|
||||
// Options Menu
|
||||
goUpdateCommand("cmd_spelling");
|
||||
goUpdateCommand("cmd_quoteMessage");
|
||||
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function openEditorContextMenu()
|
||||
function openEditorContextMenu()
|
||||
{
|
||||
// if we have a mispelled word, do one thing, otherwise show the usual context menu
|
||||
var spellCheckNoSuggestionsItem = document.getElementById('spellCheckNoSuggestions');
|
||||
|
@ -638,7 +642,7 @@ function openEditorContextMenu()
|
|||
updateEditItems();
|
||||
}
|
||||
|
||||
function updateEditItems()
|
||||
function updateEditItems()
|
||||
{
|
||||
goUpdateCommand("cmd_pasteNoFormatting");
|
||||
goUpdateCommand("cmd_pasteQuote");
|
||||
|
@ -650,10 +654,8 @@ function updateEditItems()
|
|||
goUpdateCommand("cmd_findPrev");
|
||||
}
|
||||
|
||||
var messageComposeOfflineObserver =
|
||||
{
|
||||
observe: function(subject, topic, state)
|
||||
{
|
||||
var messageComposeOfflineObserver = {
|
||||
observe: function(subject, topic, state) {
|
||||
// sanity checks
|
||||
if (topic != "network:offline-status-changed") return;
|
||||
if (state == "offline")
|
||||
|
@ -795,9 +797,14 @@ function setupLdapAutocompleteSession()
|
|||
if (gLDAPSession) {
|
||||
LDAPSession = gLDAPSession;
|
||||
} else {
|
||||
LDAPSession = Components.classes[
|
||||
"@mozilla.org/autocompleteSession;1?type=ldap"].createInstance()
|
||||
.QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession);
|
||||
LDAPSession = Components
|
||||
.classes["@mozilla.org/autocompleteSession;1?type=ldap"];
|
||||
if (LDAPSession) {
|
||||
try {
|
||||
LDAPSession = LDAPSession.createInstance()
|
||||
.QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession);
|
||||
} catch (ex) {dump ("ERROR: Cannot get the LDAP autocomplete session\n" + ex + "\n");}
|
||||
}
|
||||
}
|
||||
|
||||
if (autocompleteDirectory && !gIsOffline) {
|
||||
|
@ -1172,6 +1179,7 @@ function ComposeFieldsReady(msgType)
|
|||
CompFields2Recipients(gMsgCompose.compFields, gMsgCompose.type);
|
||||
SetComposeWindowTitle();
|
||||
|
||||
// need timeout for reply to work
|
||||
if (gMsgCompose.composeHTML)
|
||||
setTimeout("loadHTMLMsgPrefs();", 0);
|
||||
|
||||
|
@ -1203,23 +1211,22 @@ function ComposeStartup(recycled, aParams)
|
|||
|
||||
if (aParams)
|
||||
params = aParams;
|
||||
else if (window.arguments && window.arguments[0])
|
||||
{
|
||||
try
|
||||
{
|
||||
else if (window.arguments && window.arguments[0]) {
|
||||
try {
|
||||
if (window.arguments[0] instanceof Components.interfaces.nsIMsgComposeParams)
|
||||
params = window.arguments[0];
|
||||
else
|
||||
params = handleMailtoArgs(window.arguments[0]);
|
||||
}
|
||||
|
||||
catch(ex) { dump("ERROR with parameters: " + ex + "\n"); }
|
||||
|
||||
|
||||
// if still no dice, try and see if the params is an old fashioned list of string attributes
|
||||
// XXX can we get rid of this yet?
|
||||
// XXX can we get rid of this yet?
|
||||
if (!params)
|
||||
{
|
||||
args = GetArgs(window.arguments[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var identityList = document.getElementById("msgIdentity");
|
||||
var identityListPopup = document.getElementById("msgIdentityPopup");
|
||||
|
@ -1319,7 +1326,11 @@ function ComposeStartup(recycled, aParams)
|
|||
} catch (e) { dump(" FAILED TO START EDITOR: "+e+"\n"); }
|
||||
|
||||
// setEditorType MUST be call before setContentWindow
|
||||
if (!gMsgCompose.composeHTML)
|
||||
if (gMsgCompose.composeHTML)
|
||||
{
|
||||
initLocalFontFaceMenu(document.getElementById("FontFacePopup"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Remove HTML toolbar, format and insert menus as we are editing in plain text mode
|
||||
document.getElementById("outputFormatMenu").setAttribute("hidden", true);
|
||||
|
@ -1328,11 +1339,7 @@ function ComposeStartup(recycled, aParams)
|
|||
document.getElementById("insertMenu").setAttribute("hidden", true);
|
||||
document.getElementById("menu_showFormatToolbar").setAttribute("hidden", true);
|
||||
}
|
||||
else //if (gMsgCompose.composeHTML)
|
||||
{
|
||||
var fontsList = document.getElementById("FontFacePopup");
|
||||
initLocalFontFaceMenu(fontsList);
|
||||
}
|
||||
|
||||
// Do setup common to Message Composer and Web Composer
|
||||
EditorSharedStartup();
|
||||
initLanguageMenu();
|
||||
|
@ -1351,7 +1358,7 @@ function ComposeStartup(recycled, aParams)
|
|||
cleanBody = decodeURI(body);
|
||||
} catch(e) { cleanBody = body;}
|
||||
|
||||
// XXX : need html-escaping here
|
||||
// XXX : need to do html-escaping here !
|
||||
msgCompFields.body = "<BR><A HREF=\"" + body + "\">" + cleanBody + "</A><BR>";
|
||||
}
|
||||
else
|
||||
|
@ -1690,10 +1697,10 @@ function GenericSendMessage( msgType )
|
|||
if (msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later)
|
||||
{
|
||||
//Do we need to check the spelling?
|
||||
if (sPrefs.getBoolPref("mail.SpellCheckBeforeSend"))
|
||||
if (sPrefs.getBoolPref("mail.SpellCheckBeforeSend"))
|
||||
{
|
||||
//We disable spellcheck for the following -subject line, attachment pane, identity and addressing widget
|
||||
//therefore we need to explicitly focus on the mail body when we have to do a spellcheck.
|
||||
// We disable spellcheck for the following -subject line, attachment pane, identity and addressing widget
|
||||
// therefore we need to explicitly focus on the mail body when we have to do a spellcheck.
|
||||
window.content.focus();
|
||||
window.cancelSendMessage = false;
|
||||
try {
|
||||
|
@ -1703,112 +1710,113 @@ function GenericSendMessage( msgType )
|
|||
catch(ex){}
|
||||
if(window.cancelSendMessage)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Check if we have a subject, else ask user for confirmation
|
||||
if (subject == "")
|
||||
{
|
||||
if (gPromptService)
|
||||
{
|
||||
var result = {value:sComposeMsgsBundle.getString("defaultSubject")};
|
||||
if (gPromptService.prompt(
|
||||
window,
|
||||
sComposeMsgsBundle.getString("sendMsgTitle"),
|
||||
sComposeMsgsBundle.getString("subjectDlogMessage"),
|
||||
result,
|
||||
null,
|
||||
{value:0}))
|
||||
{
|
||||
msgCompFields.subject = result.value;
|
||||
var subjectInputElem = document.getElementById("msgSubject");
|
||||
subjectInputElem.value = result.value;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the user tries to send a message to a newsgroup through a mail account
|
||||
var currentAccountKey = getCurrentAccountKey();
|
||||
var account = gAccountManager.getAccount(currentAccountKey);
|
||||
if (!account)
|
||||
// Check if we have a subject, else ask user for confirmation
|
||||
if (subject == "")
|
||||
{
|
||||
if (gPromptService)
|
||||
{
|
||||
throw "UNEXPECTED: currentAccountKey '" + currentAccountKey +
|
||||
"' has no matching account!";
|
||||
}
|
||||
var servertype = account.incomingServer.type;
|
||||
|
||||
if (servertype != "nntp" && msgCompFields.newsgroups != "")
|
||||
{
|
||||
// default to ask user if the pref is not set
|
||||
var dontAskAgain = sPrefs.getBoolPref("mail.compose.dontWarnMail2Newsgroup");
|
||||
|
||||
if (!dontAskAgain)
|
||||
var result = {value:sComposeMsgsBundle.getString("defaultSubject")};
|
||||
if (gPromptService.prompt(
|
||||
window,
|
||||
sComposeMsgsBundle.getString("sendMsgTitle"),
|
||||
sComposeMsgsBundle.getString("subjectDlogMessage"),
|
||||
result,
|
||||
null,
|
||||
{value:0}))
|
||||
{
|
||||
var checkbox = {value:false};
|
||||
var okToProceed = gPromptService.confirmCheck(window,
|
||||
sComposeMsgsBundle.getString("sendMsgTitle"),
|
||||
sComposeMsgsBundle.getString("recipientDlogMessage"),
|
||||
sComposeMsgsBundle.getString("CheckMsg"), checkbox);
|
||||
|
||||
if (!okToProceed)
|
||||
return;
|
||||
|
||||
if (checkbox.value)
|
||||
sPrefs.setBoolPref(kDontAskAgainPref, true);
|
||||
msgCompFields.subject = result.value;
|
||||
var subjectInputElem = document.getElementById("msgSubject");
|
||||
subjectInputElem.value = result.value;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// remove newsgroups to prevent news_p to be set
|
||||
// in nsMsgComposeAndSend::DeliverMessage()
|
||||
msgCompFields.newsgroups = "";
|
||||
// check if the user tries to send a message to a newsgroup through a mail account
|
||||
var currentAccountKey = getCurrentAccountKey();
|
||||
var account = gAccountManager.getAccount(currentAccountKey);
|
||||
if (!account)
|
||||
{
|
||||
throw "UNEXPECTED: currentAccountKey '" + currentAccountKey +
|
||||
"' has no matching account!";
|
||||
}
|
||||
var servertype = account.incomingServer.type;
|
||||
|
||||
if (servertype != "nntp" && msgCompFields.newsgroups != "")
|
||||
{
|
||||
// default to ask user if the pref is not set
|
||||
var dontAskAgain = sPrefs.getBoolPref("mail.compose.dontWarnMail2Newsgroup");
|
||||
|
||||
if (!dontAskAgain)
|
||||
{
|
||||
var checkbox = {value:false};
|
||||
var okToProceed = gPromptService.confirmCheck(
|
||||
window,
|
||||
sComposeMsgsBundle.getString("sendMsgTitle"),
|
||||
sComposeMsgsBundle.getString("recipientDlogMessage"),
|
||||
sComposeMsgsBundle.getString("CheckMsg"),
|
||||
checkbox);
|
||||
|
||||
if (!okToProceed)
|
||||
return;
|
||||
|
||||
if (checkbox.value)
|
||||
sPrefs.setBoolPref(kDontAskAgainPref, true);
|
||||
}
|
||||
|
||||
// Before sending the message, check what to do with HTML message, eventually abort.
|
||||
var convert = DetermineConvertibility();
|
||||
var action = DetermineHTMLAction(convert);
|
||||
// check if e-mail addresses are complete, in case user
|
||||
// has turned off autocomplete to local domain.
|
||||
if (!CheckValidEmailAddress(msgCompFields.to, msgCompFields.cc, msgCompFields.bcc))
|
||||
// remove newsgroups to prevent news_p to be set
|
||||
// in nsMsgComposeAndSend::DeliverMessage()
|
||||
msgCompFields.newsgroups = "";
|
||||
}
|
||||
|
||||
// Before sending the message, check what to do with HTML message, eventually abort.
|
||||
var convert = DetermineConvertibility();
|
||||
var action = DetermineHTMLAction(convert);
|
||||
// check if e-mail addresses are complete, in case user
|
||||
// has turned off autocomplete to local domain.
|
||||
if (!CheckValidEmailAddress(msgCompFields.to, msgCompFields.cc, msgCompFields.bcc))
|
||||
return;
|
||||
|
||||
if (action == nsIMsgCompSendFormat.AskUser)
|
||||
{
|
||||
var recommAction = convert == nsIMsgCompConvertible.No
|
||||
? nsIMsgCompSendFormat.AskUser
|
||||
: nsIMsgCompSendFormat.PlainText;
|
||||
var result2 = {action:recommAction,
|
||||
convertible:convert,
|
||||
abort:false};
|
||||
window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul",
|
||||
"askSendFormatDialog", "chrome,modal,titlebar,centerscreen",
|
||||
result2);
|
||||
if (result2.abort)
|
||||
return;
|
||||
action = result2.action;
|
||||
}
|
||||
|
||||
// we will remember the users "send format" decision
|
||||
// in the address collector code (see nsAbAddressCollecter::CollectAddress())
|
||||
// by using msgCompFields.forcePlainText and msgCompFields.useMultipartAlternative
|
||||
// to determine the nsIAbPreferMailFormat (unknown, plaintext, or html)
|
||||
// if the user sends both, we remember html.
|
||||
if (action == nsIMsgCompSendFormat.AskUser)
|
||||
{
|
||||
var recommAction = (convert == nsIMsgCompConvertible.No)
|
||||
? nsIMsgCompSendFormat.AskUser
|
||||
: nsIMsgCompSendFormat.PlainText;
|
||||
var result2 = {action:recommAction,
|
||||
convertible:convert,
|
||||
abort:false};
|
||||
window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul",
|
||||
"askSendFormatDialog", "chrome,modal,titlebar,centerscreen",
|
||||
result2);
|
||||
if (result2.abort)
|
||||
return;
|
||||
action = result2.action;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case nsIMsgCompSendFormat.PlainText:
|
||||
msgCompFields.forcePlainText = true;
|
||||
msgCompFields.useMultipartAlternative = false;
|
||||
break;
|
||||
case nsIMsgCompSendFormat.HTML:
|
||||
msgCompFields.forcePlainText = false;
|
||||
msgCompFields.useMultipartAlternative = false;
|
||||
break;
|
||||
case nsIMsgCompSendFormat.Both:
|
||||
msgCompFields.forcePlainText = false;
|
||||
msgCompFields.useMultipartAlternative = true;
|
||||
break;
|
||||
default: dump("\###SendMessage Error: invalid action value\n"); return;
|
||||
}
|
||||
// we will remember the users "send format" decision
|
||||
// in the address collector code (see nsAbAddressCollecter::CollectAddress())
|
||||
// by using msgCompFields.forcePlainText and msgCompFields.useMultipartAlternative
|
||||
// to determine the nsIAbPreferMailFormat (unknown, plaintext, or html)
|
||||
// if the user sends both, we remember html.
|
||||
switch (action)
|
||||
{
|
||||
case nsIMsgCompSendFormat.PlainText:
|
||||
msgCompFields.forcePlainText = true;
|
||||
msgCompFields.useMultipartAlternative = false;
|
||||
break;
|
||||
case nsIMsgCompSendFormat.HTML:
|
||||
msgCompFields.forcePlainText = false;
|
||||
msgCompFields.useMultipartAlternative = false;
|
||||
break;
|
||||
case nsIMsgCompSendFormat.Both:
|
||||
msgCompFields.forcePlainText = false;
|
||||
msgCompFields.useMultipartAlternative = true;
|
||||
break;
|
||||
default: dump("\###SendMessage Error: invalid action value\n"); return;
|
||||
}
|
||||
}
|
||||
|
||||
// hook for extra compose pre-processing
|
||||
|
@ -1961,8 +1969,8 @@ function Save()
|
|||
function SaveAsFile(saveAs)
|
||||
{
|
||||
dump("SaveAsFile from XUL\n");
|
||||
var subject = document.getElementById('msgSubject').value;
|
||||
GetCurrentEditor().setDocumentTitle(subject);
|
||||
var subject = document.getElementById('msgSubject').value;
|
||||
GetCurrentEditor().setDocumentTitle(subject);
|
||||
|
||||
if (gMsgCompose.bodyConvertible() == nsIMsgCompConvertible.Plain)
|
||||
SaveDocument(saveAs, false, "text/plain");
|
||||
|
@ -1987,7 +1995,6 @@ function SaveAsTemplate()
|
|||
defaultSaveOperation = "template";
|
||||
}
|
||||
|
||||
|
||||
function MessageFcc(menuItem)
|
||||
{
|
||||
// Get the id for the folder we're FCC into
|
||||
|
@ -2100,7 +2107,7 @@ function SelectAddress()
|
|||
|
||||
// walk through the recipients list and add them to the inline spell checker ignore list
|
||||
function addRecipientsToIgnoreList(aAddressesToAdd)
|
||||
{
|
||||
{
|
||||
if (InlineSpellChecker.inlineSpellChecker && InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell)
|
||||
{
|
||||
// break the list of potentially many recipients back into individual names
|
||||
|
@ -2564,7 +2571,6 @@ function AttachFile()
|
|||
var fileHandler = ioService.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
|
||||
var currentAttachment = fileHandler.getURLSpecFromFile(currentFile);
|
||||
|
||||
|
||||
if (!DuplicateFileCheck(currentAttachment)) {
|
||||
var attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance(Components.interfaces.nsIMsgAttachment);
|
||||
attachment.url = currentAttachment;
|
||||
|
@ -2676,6 +2682,7 @@ function AttachPage()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function DuplicateFileCheck(FileUrl)
|
||||
{
|
||||
var bucket = document.getElementById('attachmentBucket');
|
||||
|
@ -3068,8 +3075,8 @@ function setupAutocomplete()
|
|||
if (sPrefs.getBoolPref("mail.autoComplete.highlightNonMatches"))
|
||||
document.getElementById('addressCol2#1').highlightNonMatches = true;
|
||||
|
||||
if (sPrefs.getIntPref("mail.autoComplete.commentColumn")) {
|
||||
document.getElementById('addressCol2#1').showCommentColumn = true;
|
||||
if (sPrefs.getIntPref("mail.autoComplete.commentColumn")) {
|
||||
document.getElementById('addressCol2#1').showCommentColumn = true;
|
||||
}
|
||||
} catch (ex) {
|
||||
// if we can't get this pref, then don't show the columns (which is
|
||||
|
@ -3236,7 +3243,6 @@ var envelopeDragObserver = {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
function DisplaySaveFolderDlg(folderURI)
|
||||
{
|
||||
try{
|
||||
|
@ -3272,8 +3278,6 @@ function DisplaySaveFolderDlg(folderURI)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function SetMsgAddressingWidgetTreeElementFocus()
|
||||
{
|
||||
var element = document.getElementById("msgRecipient#" + awGetNumberOfRecipients());
|
||||
|
@ -3461,7 +3465,6 @@ function toggleAddressPicker()
|
|||
sidebarBox.setAttribute("sidebarVisible", "false");
|
||||
elt.removeAttribute("checked");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// public method called by the address picker sidebar
|
||||
|
@ -3470,7 +3473,7 @@ function AddRecipient(recipientType, address)
|
|||
awAddRecipient(recipientType, address);
|
||||
}
|
||||
|
||||
function loadHTMLMsgPrefs()
|
||||
function loadHTMLMsgPrefs()
|
||||
{
|
||||
var pref = GetPrefs();
|
||||
var fontFace;
|
||||
|
@ -3482,13 +3485,14 @@ function loadHTMLMsgPrefs()
|
|||
fontFace = pref.getCharPref("msgcompose.font_face");
|
||||
doStatefulCommand('cmd_fontFace', fontFace);
|
||||
} catch (e) {}
|
||||
|
||||
|
||||
try {
|
||||
fontSize = pref.getCharPref("msgcompose.font_size");
|
||||
EditorSetFontSize(fontSize);
|
||||
} catch (e) {}
|
||||
|
||||
var bodyElement = GetBodyElement();
|
||||
} catch (e) {}
|
||||
|
||||
var bodyElement = GetBodyElement();
|
||||
|
||||
try {
|
||||
textColor = pref.getCharPref("msgcompose.text_color");
|
||||
if (!bodyElement.getAttribute("text"))
|
||||
|
@ -3499,7 +3503,7 @@ function loadHTMLMsgPrefs()
|
|||
onFontColorChange();
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
|
||||
try {
|
||||
bgColor = pref.getCharPref("msgcompose.background_color");
|
||||
if (!bodyElement.getAttribute("bgcolor"))
|
||||
|
@ -3527,4 +3531,3 @@ function InitEditor()
|
|||
InlineSpellChecker.Init(editor, sPrefs.getBoolPref("mail.spellcheck.inline"));
|
||||
InlineSpellChecker.checkDocument(window.content.document);
|
||||
}
|
||||
|
||||
|
|
|
@ -132,10 +132,10 @@ function InitializeGlobalVariables()
|
|||
//This migrates the LDAPServer Preferences from 4.x to mozilla format.
|
||||
gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"];
|
||||
if (gLDAPPrefsService) {
|
||||
try {
|
||||
gLDAPPrefsService = gLDAPPrefsService.getService().gLDAPPrefsService
|
||||
.QueryInterface( Components.interfaces.nsILDAPPrefsService);
|
||||
} catch (ex) {dump ("ERROR: Cannot get the LDAP prefs service\n" + ex + "\n");}
|
||||
try {
|
||||
gLDAPPrefsService = gLDAPPrefsService
|
||||
.getService(Components.interfaces.nsILDAPPrefsService);
|
||||
} catch (ex) {dump ("ERROR: Cannot get the LDAP prefs service\n" + ex + "\n");}
|
||||
}
|
||||
|
||||
gMsgCompose = null;
|
||||
|
@ -166,8 +166,6 @@ function InitializeGlobalVariables()
|
|||
gLastWindowToHaveFocus = null;
|
||||
gReceiptOptionChanged = false;
|
||||
gAttachVCardOptionChanged = false;
|
||||
|
||||
|
||||
}
|
||||
InitializeGlobalVariables();
|
||||
|
||||
|
@ -263,7 +261,7 @@ var gComposeRecyclingListener = {
|
|||
},
|
||||
|
||||
onReopen: function(params) {
|
||||
//Reset focus to avoid undesirable visual effect when reopening the winodw
|
||||
// Reset focus to avoid undesirable visual effect when reopening the window
|
||||
var identityElement = document.getElementById("msgIdentity");
|
||||
if (identityElement)
|
||||
identityElement.focus();
|
||||
|
@ -369,7 +367,7 @@ var progressListener = {
|
|||
statusText = document.getElementById("statusText");
|
||||
if (statusText)
|
||||
statusText.setAttribute("label", aMessage);
|
||||
} catch (ex) {};
|
||||
} catch (ex) {}
|
||||
},
|
||||
|
||||
onSecurityChange: function(aWebProgress, aRequest, state)
|
||||
|
@ -564,7 +562,6 @@ function GetSelectedMessages()
|
|||
|
||||
function SetupCommandUpdateHandlers()
|
||||
{
|
||||
// dump("SetupCommandUpdateHandlers\n");
|
||||
top.controllers.insertControllerAt(0, defaultController);
|
||||
}
|
||||
|
||||
|
@ -585,33 +582,31 @@ function CommandUpdate_MsgCompose()
|
|||
updateComposeItems();
|
||||
}
|
||||
|
||||
function updateComposeItems() {
|
||||
function updateComposeItems()
|
||||
{
|
||||
try {
|
||||
// Edit Menu
|
||||
goUpdateCommand("cmd_rewrap");
|
||||
|
||||
//Edit Menu
|
||||
goUpdateCommand("cmd_rewrap");
|
||||
|
||||
//Insert Menu
|
||||
if (gMsgCompose && gMsgCompose.composeHTML)
|
||||
{
|
||||
goUpdateCommand("cmd_renderedHTMLEnabler");
|
||||
goUpdateCommand("cmd_decreaseFont");
|
||||
goUpdateCommand("cmd_increaseFont");
|
||||
goUpdateCommand("cmd_bold");
|
||||
goUpdateCommand("cmd_italic");
|
||||
goUpdateCommand("cmd_underline");
|
||||
goUpdateCommand("cmd_ul");
|
||||
goUpdateCommand("cmd_ol");
|
||||
goUpdateCommand("cmd_indent");
|
||||
goUpdateCommand("cmd_outdent");
|
||||
goUpdateCommand("cmd_align");
|
||||
goUpdateCommand("cmd_smiley");
|
||||
}
|
||||
|
||||
//Options Menu
|
||||
goUpdateCommand("cmd_spelling");
|
||||
|
||||
// Insert Menu
|
||||
if (gMsgCompose && gMsgCompose.composeHTML)
|
||||
{
|
||||
goUpdateCommand("cmd_renderedHTMLEnabler");
|
||||
goUpdateCommand("cmd_decreaseFont");
|
||||
goUpdateCommand("cmd_increaseFont");
|
||||
goUpdateCommand("cmd_bold");
|
||||
goUpdateCommand("cmd_italic");
|
||||
goUpdateCommand("cmd_underline");
|
||||
goUpdateCommand("cmd_ul");
|
||||
goUpdateCommand("cmd_ol");
|
||||
goUpdateCommand("cmd_indent");
|
||||
goUpdateCommand("cmd_outdent");
|
||||
goUpdateCommand("cmd_align");
|
||||
goUpdateCommand("cmd_smiley");
|
||||
}
|
||||
|
||||
// Options Menu
|
||||
goUpdateCommand("cmd_spelling");
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
|
@ -634,7 +629,8 @@ function openEditorContextMenu()
|
|||
updateEditItems();
|
||||
}
|
||||
|
||||
function updateEditItems() {
|
||||
function updateEditItems()
|
||||
{
|
||||
goUpdateCommand("cmd_pasteNoFormatting");
|
||||
goUpdateCommand("cmd_pasteQuote");
|
||||
goUpdateCommand("cmd_delete");
|
||||
|
@ -792,13 +788,13 @@ function setupLdapAutocompleteSession()
|
|||
if (gLDAPSession) {
|
||||
LDAPSession = gLDAPSession;
|
||||
} else {
|
||||
LDAPSession = Components.classes[
|
||||
"@mozilla.org/autocompleteSession;1?type=ldap"];
|
||||
LDAPSession = Components
|
||||
.classes["@mozilla.org/autocompleteSession;1?type=ldap"];
|
||||
if (LDAPSession) {
|
||||
try {
|
||||
LDAPSession = LDAPSession.createInstance()
|
||||
.QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession);
|
||||
} catch (ex) {dump ("ERROR: Cannot get the LDAP autocomplete session\n" + ex + "\n");}
|
||||
try {
|
||||
LDAPSession = LDAPSession.createInstance()
|
||||
.QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession);
|
||||
} catch (ex) {dump ("ERROR: Cannot get the LDAP autocomplete session\n" + ex + "\n");}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1214,21 +1210,20 @@ function ComposeStartup(recycled, aParams)
|
|||
|
||||
if (aParams)
|
||||
params = aParams;
|
||||
else
|
||||
if (window.arguments && window.arguments[0]) {
|
||||
try {
|
||||
else if (window.arguments && window.arguments[0]) {
|
||||
try {
|
||||
if (window.arguments[0] instanceof Components.interfaces.nsIMsgComposeParams)
|
||||
params = window.arguments[0];
|
||||
else
|
||||
params = handleMailtoArgs(window.arguments[0]);
|
||||
}
|
||||
catch(ex) { dump("ERROR with parameters: " + ex + "\n"); }
|
||||
|
||||
}
|
||||
catch(ex) { dump("ERROR with parameters: " + ex + "\n"); }
|
||||
|
||||
// if still no dice, try and see if the params is an old fashioned list of string attributes
|
||||
// XXX can we get rid of this yet?
|
||||
if (!params)
|
||||
// XXX can we get rid of this yet?
|
||||
if (!params)
|
||||
{
|
||||
args = GetArgs(window.arguments[0]);
|
||||
args = GetArgs(window.arguments[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1314,6 +1309,7 @@ function ComposeStartup(recycled, aParams)
|
|||
dump("Failed to get editor element!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById("returnReceiptMenu").setAttribute('checked',
|
||||
gMsgCompose.compFields.returnReceipt);
|
||||
document.getElementById("cmd_attachVCard").setAttribute('checked',
|
||||
|
@ -1330,7 +1326,11 @@ function ComposeStartup(recycled, aParams)
|
|||
} catch (e) { dump(" FAILED TO START EDITOR: "+e+"\n"); }
|
||||
|
||||
// setEditorType MUST be call before setContentWindow
|
||||
if (!gMsgCompose.composeHTML)
|
||||
if (gMsgCompose.composeHTML)
|
||||
{
|
||||
initLocalFontFaceMenu(document.getElementById("FontFacePopup"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Remove HTML toolbar, format and insert menus as we are editing in plain text mode
|
||||
document.getElementById("outputFormatMenu").setAttribute("hidden", true);
|
||||
|
@ -1339,11 +1339,6 @@ function ComposeStartup(recycled, aParams)
|
|||
document.getElementById("insertMenu").setAttribute("hidden", true);
|
||||
document.getElementById("menu_showFormatToolbar").setAttribute("hidden", true);
|
||||
}
|
||||
|
||||
if (gMsgCompose.composeHTML) {
|
||||
var fontsList = document.getElementById("FontFacePopup");
|
||||
initLocalFontFaceMenu(fontsList);
|
||||
}
|
||||
|
||||
// Do setup common to Message Composer and Web Composer
|
||||
EditorSharedStartup();
|
||||
|
@ -1654,9 +1649,9 @@ function GenericSendMessage( msgType )
|
|||
|
||||
if (gMsgCompose != null)
|
||||
{
|
||||
var msgCompFields = gMsgCompose.compFields;
|
||||
if (msgCompFields)
|
||||
{
|
||||
var msgCompFields = gMsgCompose.compFields;
|
||||
if (msgCompFields)
|
||||
{
|
||||
Recipients2CompFields(msgCompFields);
|
||||
var subject = document.getElementById("msgSubject").value;
|
||||
msgCompFields.subject = subject;
|
||||
|
@ -1669,9 +1664,10 @@ function GenericSendMessage( msgType )
|
|||
if (msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later)
|
||||
{
|
||||
//Do we need to check the spelling?
|
||||
if (sPrefs.getBoolPref("mail.SpellCheckBeforeSend")){
|
||||
//We disable spellcheck for the following -subject line, attachment pane, identity and addressing widget
|
||||
//therefore we need to explicitly focus on the mail body when we have to do a spellcheck.
|
||||
if (sPrefs.getBoolPref("mail.SpellCheckBeforeSend"))
|
||||
{
|
||||
// We disable spellcheck for the following -subject line, attachment pane, identity and addressing widget
|
||||
// therefore we need to explicitly focus on the mail body when we have to do a spellcheck.
|
||||
window.content.focus();
|
||||
window.cancelSendMessage = false;
|
||||
try {
|
||||
|
@ -1683,27 +1679,26 @@ function GenericSendMessage( msgType )
|
|||
return;
|
||||
}
|
||||
|
||||
//Check if we have a subject, else ask user for confirmation
|
||||
// Check if we have a subject, else ask user for confirmation
|
||||
if (subject == "")
|
||||
{
|
||||
if (gPromptService)
|
||||
{
|
||||
var result = {value:sComposeMsgsBundle.getString("defaultSubject")};
|
||||
if (gPromptService.prompt(
|
||||
window,
|
||||
sComposeMsgsBundle.getString("sendMsgTitle"),
|
||||
sComposeMsgsBundle.getString("subjectDlogMessage"),
|
||||
result,
|
||||
null,
|
||||
{value:0}
|
||||
))
|
||||
{
|
||||
msgCompFields.subject = result.value;
|
||||
var subjectInputElem = document.getElementById("msgSubject");
|
||||
subjectInputElem.value = result.value;
|
||||
}
|
||||
else
|
||||
return;
|
||||
window,
|
||||
sComposeMsgsBundle.getString("sendMsgTitle"),
|
||||
sComposeMsgsBundle.getString("subjectDlogMessage"),
|
||||
result,
|
||||
null,
|
||||
{value:0}))
|
||||
{
|
||||
msgCompFields.subject = result.value;
|
||||
var subjectInputElem = document.getElementById("msgSubject");
|
||||
subjectInputElem.value = result.value;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1732,11 +1727,11 @@ function GenericSendMessage( msgType )
|
|||
{
|
||||
var checkbox = {value:false};
|
||||
var okToProceed = gPromptService.confirmCheck(
|
||||
window,
|
||||
sComposeMsgsBundle.getString("subjectDlogTitle"),
|
||||
sComposeMsgsBundle.getString("recipientDlogMessage"),
|
||||
sComposeMsgsBundle.getString("CheckMsg"),
|
||||
checkbox);
|
||||
window,
|
||||
sComposeMsgsBundle.getString("subjectDlogTitle"),
|
||||
sComposeMsgsBundle.getString("recipientDlogMessage"),
|
||||
sComposeMsgsBundle.getString("CheckMsg"),
|
||||
checkbox);
|
||||
|
||||
if (!okToProceed)
|
||||
return;
|
||||
|
@ -1747,7 +1742,7 @@ function GenericSendMessage( msgType )
|
|||
} catch (ex) {}
|
||||
}
|
||||
|
||||
// remove newsgroups to prevent news_p to be set
|
||||
// remove newsgroups to prevent news_p to be set
|
||||
// in nsMsgComposeAndSend::DeliverMessage()
|
||||
msgCompFields.newsgroups = "";
|
||||
}
|
||||
|
@ -1762,15 +1757,15 @@ function GenericSendMessage( msgType )
|
|||
|
||||
if (action == nsIMsgCompSendFormat.AskUser)
|
||||
{
|
||||
var recommAction = convert == nsIMsgCompConvertible.No
|
||||
? nsIMsgCompSendFormat.AskUser
|
||||
: nsIMsgCompSendFormat.PlainText;
|
||||
var result2 = {action:recommAction,
|
||||
convertible:convert,
|
||||
abort:false};
|
||||
window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul",
|
||||
"askSendFormatDialog", "chrome,modal,titlebar,centerscreen",
|
||||
result2);
|
||||
var recommAction = (convert == nsIMsgCompConvertible.No)
|
||||
? nsIMsgCompSendFormat.AskUser
|
||||
: nsIMsgCompSendFormat.PlainText;
|
||||
var result2 = {action:recommAction,
|
||||
convertible:convert,
|
||||
abort:false};
|
||||
window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul",
|
||||
"askSendFormatDialog", "chrome,modal,titlebar,centerscreen",
|
||||
result2);
|
||||
if (result2.abort)
|
||||
return;
|
||||
action = result2.action;
|
||||
|
@ -1832,7 +1827,7 @@ function GenericSendMessage( msgType )
|
|||
case 1: // send anyway
|
||||
msgCompFields.needToCheckCharset = false;
|
||||
break;
|
||||
case 2: // cancel
|
||||
case 2: // cancel
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1853,7 +1848,6 @@ function GenericSendMessage( msgType )
|
|||
}
|
||||
msgWindow.SetDOMWindow(window);
|
||||
msgWindow.rootDocShell.allowAuth = true;
|
||||
|
||||
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), currentAccountKey, msgWindow, progress);
|
||||
}
|
||||
catch (ex) {
|
||||
|
@ -1945,6 +1939,7 @@ function SaveAsFile(saveAs)
|
|||
dump("SaveAsFile from XUL\n");
|
||||
var subject = document.getElementById('msgSubject').value;
|
||||
GetCurrentEditor().setDocumentTitle(subject);
|
||||
|
||||
if (gMsgCompose.bodyConvertible() == nsIMsgCompConvertible.Plain)
|
||||
SaveDocument(saveAs, false, "text/plain");
|
||||
else
|
||||
|
@ -1968,7 +1963,6 @@ function SaveAsTemplate()
|
|||
defaultSaveOperation = "template";
|
||||
}
|
||||
|
||||
|
||||
function MessageFcc(menuItem)
|
||||
{
|
||||
// Get the id for the folder we're FCC into
|
||||
|
@ -2118,13 +2112,13 @@ function ToggleReturnReceipt(target)
|
|||
|
||||
function ToggleAttachVCard(target)
|
||||
{
|
||||
var msgCompFields = gMsgCompose.compFields;
|
||||
if (msgCompFields)
|
||||
{
|
||||
msgCompFields.attachVCard = ! msgCompFields.attachVCard;
|
||||
target.setAttribute('checked', msgCompFields.attachVCard);
|
||||
gAttachVCardOptionChanged = true;
|
||||
}
|
||||
var msgCompFields = gMsgCompose.compFields;
|
||||
if (msgCompFields)
|
||||
{
|
||||
msgCompFields.attachVCard = ! msgCompFields.attachVCard;
|
||||
target.setAttribute('checked', msgCompFields.attachVCard);
|
||||
gAttachVCardOptionChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
function queryISupportsArray(supportsArray, iid) {
|
||||
|
@ -2567,7 +2561,6 @@ function FocusOnFirstAttachment()
|
|||
function AttachmentElementHasItems()
|
||||
{
|
||||
var element = document.getElementById("attachmentBucket");
|
||||
|
||||
return element ? element.childNodes.length : 0;
|
||||
}
|
||||
|
||||
|
@ -2607,7 +2600,7 @@ function DetermineHTMLAction(convertible)
|
|||
|
||||
//Check newsgroups now...
|
||||
noHtmlnewsgroups = gMsgCompose.compFields.newsgroups;
|
||||
|
||||
|
||||
if (noHtmlRecipients != "" || noHtmlnewsgroups != "")
|
||||
{
|
||||
if (convertible == nsIMsgCompConvertible.Plain)
|
||||
|
@ -2979,8 +2972,6 @@ function DisplaySaveFolderDlg(folderURI)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function SetMsgAddressingWidgetElementFocus()
|
||||
{
|
||||
var element = awGetInputElement(awGetNumberOfRecipients());
|
||||
|
@ -3141,9 +3132,9 @@ function SwitchElementFocus(event)
|
|||
}
|
||||
}
|
||||
|
||||
function loadHTMLMsgPrefs() {
|
||||
function loadHTMLMsgPrefs()
|
||||
{
|
||||
var pref = GetPrefs();
|
||||
|
||||
var fontFace;
|
||||
var fontSize;
|
||||
var textColor;
|
||||
|
@ -3157,7 +3148,7 @@ function loadHTMLMsgPrefs() {
|
|||
try {
|
||||
fontSize = pref.getCharPref("msgcompose.font_size");
|
||||
EditorSetFontSize(fontSize);
|
||||
} catch (e) {}
|
||||
} catch (e) {}
|
||||
|
||||
var bodyElement = GetBodyElement();
|
||||
|
||||
|
@ -3176,7 +3167,6 @@ function loadHTMLMsgPrefs() {
|
|||
document.getElementById("cmd_backgroundColor").setAttribute("state", bgColor);
|
||||
onBackgroundColorChange();
|
||||
} catch (e) {}
|
||||
|
||||
}
|
||||
|
||||
function AutoSave()
|
||||
|
|
Загрузка…
Ссылка в новой задаче