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:
bugzilla%standard8.demon.co.uk 2005-08-31 17:44:26 +00:00
Родитель 49f8f0912e
Коммит b62d5b649e
2 изменённых файлов: 257 добавлений и 264 удалений

Просмотреть файл

@ -74,6 +74,7 @@ var sNameProperty = null;
var msgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"].createInstance(); var msgWindow = Components.classes["@mozilla.org/messenger/msgwindow;1"].createInstance();
msgWindow = msgWindow.QueryInterface(Components.interfaces.nsIMsgWindow); 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 * 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); gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
//This migrates the LDAPServer Preferences from 4.x to mozilla format. //This migrates the LDAPServer Preferences from 4.x to mozilla format.
try { gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"];
gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"].getService(); if (gLDAPPrefsService) {
gLDAPPrefsService = gLDAPPrefsService.QueryInterface( Components.interfaces.nsILDAPPrefsService); try {
} catch (ex) {dump ("ERROR: Cannot get the LDAP service\n" + ex + "\n");} gLDAPPrefsService = gLDAPPrefsService
.getService(Components.interfaces.nsILDAPPrefsService);
} catch (ex) {dump ("ERROR: Cannot get the LDAP prefs service\n" + ex + "\n");}
}
gMsgCompose = null; gMsgCompose = null;
gWindowLocked = false; gWindowLocked = false;
@ -184,7 +188,9 @@ function disableEditableFields()
gMsgCompose.editor.flags |= nsIPlaintextEditorMail.eEditorReadonlyMask; gMsgCompose.editor.flags |= nsIPlaintextEditorMail.eEditorReadonlyMask;
var disableElements = document.getElementsByAttribute("disableonsend", "true"); var disableElements = document.getElementsByAttribute("disableonsend", "true");
for (i=0;i<disableElements.length;i++) for (i=0;i<disableElements.length;i++)
{
disableElements[i].setAttribute('disabled', 'true'); disableElements[i].setAttribute('disabled', 'true');
}
} }
function enableEditableFields() function enableEditableFields()
@ -251,13 +257,13 @@ var gComposeRecyclingListener = {
}, },
onReopen: function(params) { 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"); var identityElement = document.getElementById("msgIdentity");
if (identityElement) if (identityElement)
identityElement.focus(); identityElement.focus();
InitializeGlobalVariables(); InitializeGlobalVariables();
ComposeStartup(true, params); ComposeStartup(true, params);
var event = document.createEvent('Events'); var event = document.createEvent('Events');
event.initEvent('compose-window-reopen', false, true); event.initEvent('compose-window-reopen', false, true);
@ -355,7 +361,7 @@ var progressListener = {
statusText = document.getElementById("statusText"); statusText = document.getElementById("statusText");
if (statusText) if (statusText)
statusText.setAttribute("label", aMessage); statusText.setAttribute("label", aMessage);
} catch (ex) {}; } catch (ex) {}
}, },
onSecurityChange: function(aWebProgress, aRequest, state) onSecurityChange: function(aWebProgress, aRequest, state)
@ -589,14 +595,13 @@ function CommandUpdate_MsgCompose()
updateComposeItems(); updateComposeItems();
} }
function updateComposeItems() function updateComposeItems()
{ {
try try {
{ // Edit Menu
//Edit Menu
goUpdateCommand("cmd_rewrap"); goUpdateCommand("cmd_rewrap");
//Insert Menu // Insert Menu
if (gMsgCompose && gMsgCompose.composeHTML) if (gMsgCompose && gMsgCompose.composeHTML)
{ {
goUpdateCommand("cmd_renderedHTMLEnabler"); goUpdateCommand("cmd_renderedHTMLEnabler");
@ -613,14 +618,13 @@ function updateComposeItems()
goUpdateCommand("cmd_smiley"); goUpdateCommand("cmd_smiley");
} }
//Options Menu // Options Menu
goUpdateCommand("cmd_spelling"); goUpdateCommand("cmd_spelling");
goUpdateCommand("cmd_quoteMessage"); goUpdateCommand("cmd_quoteMessage");
} catch(e) {} } catch(e) {}
} }
function openEditorContextMenu() function openEditorContextMenu()
{ {
// if we have a mispelled word, do one thing, otherwise show the usual context menu // if we have a mispelled word, do one thing, otherwise show the usual context menu
var spellCheckNoSuggestionsItem = document.getElementById('spellCheckNoSuggestions'); var spellCheckNoSuggestionsItem = document.getElementById('spellCheckNoSuggestions');
@ -638,7 +642,7 @@ function openEditorContextMenu()
updateEditItems(); updateEditItems();
} }
function updateEditItems() function updateEditItems()
{ {
goUpdateCommand("cmd_pasteNoFormatting"); goUpdateCommand("cmd_pasteNoFormatting");
goUpdateCommand("cmd_pasteQuote"); goUpdateCommand("cmd_pasteQuote");
@ -650,10 +654,8 @@ function updateEditItems()
goUpdateCommand("cmd_findPrev"); goUpdateCommand("cmd_findPrev");
} }
var messageComposeOfflineObserver = var messageComposeOfflineObserver = {
{ observe: function(subject, topic, state) {
observe: function(subject, topic, state)
{
// sanity checks // sanity checks
if (topic != "network:offline-status-changed") return; if (topic != "network:offline-status-changed") return;
if (state == "offline") if (state == "offline")
@ -795,9 +797,14 @@ function setupLdapAutocompleteSession()
if (gLDAPSession) { if (gLDAPSession) {
LDAPSession = gLDAPSession; LDAPSession = gLDAPSession;
} else { } else {
LDAPSession = Components.classes[ LDAPSession = Components
"@mozilla.org/autocompleteSession;1?type=ldap"].createInstance() .classes["@mozilla.org/autocompleteSession;1?type=ldap"];
.QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession); 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) { if (autocompleteDirectory && !gIsOffline) {
@ -1172,6 +1179,7 @@ function ComposeFieldsReady(msgType)
CompFields2Recipients(gMsgCompose.compFields, gMsgCompose.type); CompFields2Recipients(gMsgCompose.compFields, gMsgCompose.type);
SetComposeWindowTitle(); SetComposeWindowTitle();
// need timeout for reply to work
if (gMsgCompose.composeHTML) if (gMsgCompose.composeHTML)
setTimeout("loadHTMLMsgPrefs();", 0); setTimeout("loadHTMLMsgPrefs();", 0);
@ -1203,23 +1211,22 @@ function ComposeStartup(recycled, aParams)
if (aParams) if (aParams)
params = aParams; params = aParams;
else if (window.arguments && window.arguments[0]) else if (window.arguments && window.arguments[0]) {
{ try {
try
{
if (window.arguments[0] instanceof Components.interfaces.nsIMsgComposeParams) if (window.arguments[0] instanceof Components.interfaces.nsIMsgComposeParams)
params = window.arguments[0]; params = window.arguments[0];
else else
params = handleMailtoArgs(window.arguments[0]); 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 // 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) if (!params)
{
args = GetArgs(window.arguments[0]); args = GetArgs(window.arguments[0]);
} }
}
var identityList = document.getElementById("msgIdentity"); var identityList = document.getElementById("msgIdentity");
var identityListPopup = document.getElementById("msgIdentityPopup"); var identityListPopup = document.getElementById("msgIdentityPopup");
@ -1319,7 +1326,11 @@ function ComposeStartup(recycled, aParams)
} catch (e) { dump(" FAILED TO START EDITOR: "+e+"\n"); } } catch (e) { dump(" FAILED TO START EDITOR: "+e+"\n"); }
// setEditorType MUST be call before setContentWindow // 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 //Remove HTML toolbar, format and insert menus as we are editing in plain text mode
document.getElementById("outputFormatMenu").setAttribute("hidden", true); document.getElementById("outputFormatMenu").setAttribute("hidden", true);
@ -1328,11 +1339,7 @@ function ComposeStartup(recycled, aParams)
document.getElementById("insertMenu").setAttribute("hidden", true); document.getElementById("insertMenu").setAttribute("hidden", true);
document.getElementById("menu_showFormatToolbar").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 // Do setup common to Message Composer and Web Composer
EditorSharedStartup(); EditorSharedStartup();
initLanguageMenu(); initLanguageMenu();
@ -1351,7 +1358,7 @@ function ComposeStartup(recycled, aParams)
cleanBody = decodeURI(body); cleanBody = decodeURI(body);
} catch(e) { cleanBody = 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>"; msgCompFields.body = "<BR><A HREF=\"" + body + "\">" + cleanBody + "</A><BR>";
} }
else else
@ -1690,10 +1697,10 @@ function GenericSendMessage( msgType )
if (msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later) if (msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later)
{ {
//Do we need to check the spelling? //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 // 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. // therefore we need to explicitly focus on the mail body when we have to do a spellcheck.
window.content.focus(); window.content.focus();
window.cancelSendMessage = false; window.cancelSendMessage = false;
try { try {
@ -1703,112 +1710,113 @@ function GenericSendMessage( msgType )
catch(ex){} catch(ex){}
if(window.cancelSendMessage) if(window.cancelSendMessage)
return; 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 (subject == "")
{ {
if (gPromptService) 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)
{ {
throw "UNEXPECTED: currentAccountKey '" + currentAccountKey + var result = {value:sComposeMsgsBundle.getString("defaultSubject")};
"' has no matching account!"; if (gPromptService.prompt(
} window,
var servertype = account.incomingServer.type; sComposeMsgsBundle.getString("sendMsgTitle"),
sComposeMsgsBundle.getString("subjectDlogMessage"),
if (servertype != "nntp" && msgCompFields.newsgroups != "") result,
{ null,
// default to ask user if the pref is not set {value:0}))
var dontAskAgain = sPrefs.getBoolPref("mail.compose.dontWarnMail2Newsgroup");
if (!dontAskAgain)
{ {
var checkbox = {value:false}; msgCompFields.subject = result.value;
var okToProceed = gPromptService.confirmCheck(window, var subjectInputElem = document.getElementById("msgSubject");
sComposeMsgsBundle.getString("sendMsgTitle"), subjectInputElem.value = result.value;
sComposeMsgsBundle.getString("recipientDlogMessage"),
sComposeMsgsBundle.getString("CheckMsg"), checkbox);
if (!okToProceed)
return;
if (checkbox.value)
sPrefs.setBoolPref(kDontAskAgainPref, true);
} }
else
return;
}
}
// remove newsgroups to prevent news_p to be set // check if the user tries to send a message to a newsgroup through a mail account
// in nsMsgComposeAndSend::DeliverMessage() var currentAccountKey = getCurrentAccountKey();
msgCompFields.newsgroups = ""; 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. // remove newsgroups to prevent news_p to be set
var convert = DetermineConvertibility(); // in nsMsgComposeAndSend::DeliverMessage()
var action = DetermineHTMLAction(convert); msgCompFields.newsgroups = "";
// 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)) // 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; return;
if (action == nsIMsgCompSendFormat.AskUser) if (action == nsIMsgCompSendFormat.AskUser)
{ {
var recommAction = convert == nsIMsgCompConvertible.No var recommAction = (convert == nsIMsgCompConvertible.No)
? nsIMsgCompSendFormat.AskUser ? nsIMsgCompSendFormat.AskUser
: nsIMsgCompSendFormat.PlainText; : nsIMsgCompSendFormat.PlainText;
var result2 = {action:recommAction, var result2 = {action:recommAction,
convertible:convert, convertible:convert,
abort:false}; abort:false};
window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul", window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul",
"askSendFormatDialog", "chrome,modal,titlebar,centerscreen", "askSendFormatDialog", "chrome,modal,titlebar,centerscreen",
result2); result2);
if (result2.abort) if (result2.abort)
return; return;
action = result2.action; 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.
switch (action) // we will remember the users "send format" decision
{ // in the address collector code (see nsAbAddressCollecter::CollectAddress())
case nsIMsgCompSendFormat.PlainText: // by using msgCompFields.forcePlainText and msgCompFields.useMultipartAlternative
msgCompFields.forcePlainText = true; // to determine the nsIAbPreferMailFormat (unknown, plaintext, or html)
msgCompFields.useMultipartAlternative = false; // if the user sends both, we remember html.
break; switch (action)
case nsIMsgCompSendFormat.HTML: {
msgCompFields.forcePlainText = false; case nsIMsgCompSendFormat.PlainText:
msgCompFields.useMultipartAlternative = false; msgCompFields.forcePlainText = true;
break; msgCompFields.useMultipartAlternative = false;
case nsIMsgCompSendFormat.Both: break;
msgCompFields.forcePlainText = false; case nsIMsgCompSendFormat.HTML:
msgCompFields.useMultipartAlternative = true; msgCompFields.forcePlainText = false;
break; msgCompFields.useMultipartAlternative = false;
default: dump("\###SendMessage Error: invalid action value\n"); return; 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 // hook for extra compose pre-processing
@ -1961,8 +1969,8 @@ function Save()
function SaveAsFile(saveAs) function SaveAsFile(saveAs)
{ {
dump("SaveAsFile from XUL\n"); dump("SaveAsFile from XUL\n");
var subject = document.getElementById('msgSubject').value; var subject = document.getElementById('msgSubject').value;
GetCurrentEditor().setDocumentTitle(subject); GetCurrentEditor().setDocumentTitle(subject);
if (gMsgCompose.bodyConvertible() == nsIMsgCompConvertible.Plain) if (gMsgCompose.bodyConvertible() == nsIMsgCompConvertible.Plain)
SaveDocument(saveAs, false, "text/plain"); SaveDocument(saveAs, false, "text/plain");
@ -1987,7 +1995,6 @@ function SaveAsTemplate()
defaultSaveOperation = "template"; defaultSaveOperation = "template";
} }
function MessageFcc(menuItem) function MessageFcc(menuItem)
{ {
// Get the id for the folder we're FCC into // 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 // walk through the recipients list and add them to the inline spell checker ignore list
function addRecipientsToIgnoreList(aAddressesToAdd) function addRecipientsToIgnoreList(aAddressesToAdd)
{ {
if (InlineSpellChecker.inlineSpellChecker && InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell) if (InlineSpellChecker.inlineSpellChecker && InlineSpellChecker.inlineSpellChecker.enableRealTimeSpell)
{ {
// break the list of potentially many recipients back into individual names // 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 fileHandler = ioService.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
var currentAttachment = fileHandler.getURLSpecFromFile(currentFile); var currentAttachment = fileHandler.getURLSpecFromFile(currentFile);
if (!DuplicateFileCheck(currentAttachment)) { if (!DuplicateFileCheck(currentAttachment)) {
var attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance(Components.interfaces.nsIMsgAttachment); var attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance(Components.interfaces.nsIMsgAttachment);
attachment.url = currentAttachment; attachment.url = currentAttachment;
@ -2676,6 +2682,7 @@ function AttachPage()
} }
} }
} }
function DuplicateFileCheck(FileUrl) function DuplicateFileCheck(FileUrl)
{ {
var bucket = document.getElementById('attachmentBucket'); var bucket = document.getElementById('attachmentBucket');
@ -3068,8 +3075,8 @@ function setupAutocomplete()
if (sPrefs.getBoolPref("mail.autoComplete.highlightNonMatches")) if (sPrefs.getBoolPref("mail.autoComplete.highlightNonMatches"))
document.getElementById('addressCol2#1').highlightNonMatches = true; document.getElementById('addressCol2#1').highlightNonMatches = true;
if (sPrefs.getIntPref("mail.autoComplete.commentColumn")) { if (sPrefs.getIntPref("mail.autoComplete.commentColumn")) {
document.getElementById('addressCol2#1').showCommentColumn = true; document.getElementById('addressCol2#1').showCommentColumn = true;
} }
} catch (ex) { } catch (ex) {
// if we can't get this pref, then don't show the columns (which is // if we can't get this pref, then don't show the columns (which is
@ -3236,7 +3243,6 @@ var envelopeDragObserver = {
} }
}; };
function DisplaySaveFolderDlg(folderURI) function DisplaySaveFolderDlg(folderURI)
{ {
try{ try{
@ -3272,8 +3278,6 @@ function DisplaySaveFolderDlg(folderURI)
return; return;
} }
function SetMsgAddressingWidgetTreeElementFocus() function SetMsgAddressingWidgetTreeElementFocus()
{ {
var element = document.getElementById("msgRecipient#" + awGetNumberOfRecipients()); var element = document.getElementById("msgRecipient#" + awGetNumberOfRecipients());
@ -3461,7 +3465,6 @@ function toggleAddressPicker()
sidebarBox.setAttribute("sidebarVisible", "false"); sidebarBox.setAttribute("sidebarVisible", "false");
elt.removeAttribute("checked"); elt.removeAttribute("checked");
} }
} }
// public method called by the address picker sidebar // public method called by the address picker sidebar
@ -3470,7 +3473,7 @@ function AddRecipient(recipientType, address)
awAddRecipient(recipientType, address); awAddRecipient(recipientType, address);
} }
function loadHTMLMsgPrefs() function loadHTMLMsgPrefs()
{ {
var pref = GetPrefs(); var pref = GetPrefs();
var fontFace; var fontFace;
@ -3482,13 +3485,14 @@ function loadHTMLMsgPrefs()
fontFace = pref.getCharPref("msgcompose.font_face"); fontFace = pref.getCharPref("msgcompose.font_face");
doStatefulCommand('cmd_fontFace', fontFace); doStatefulCommand('cmd_fontFace', fontFace);
} catch (e) {} } catch (e) {}
try { try {
fontSize = pref.getCharPref("msgcompose.font_size"); fontSize = pref.getCharPref("msgcompose.font_size");
EditorSetFontSize(fontSize); EditorSetFontSize(fontSize);
} catch (e) {} } catch (e) {}
var bodyElement = GetBodyElement(); var bodyElement = GetBodyElement();
try { try {
textColor = pref.getCharPref("msgcompose.text_color"); textColor = pref.getCharPref("msgcompose.text_color");
if (!bodyElement.getAttribute("text")) if (!bodyElement.getAttribute("text"))
@ -3499,7 +3503,7 @@ function loadHTMLMsgPrefs()
onFontColorChange(); onFontColorChange();
} }
} catch (e) {} } catch (e) {}
try { try {
bgColor = pref.getCharPref("msgcompose.background_color"); bgColor = pref.getCharPref("msgcompose.background_color");
if (!bodyElement.getAttribute("bgcolor")) if (!bodyElement.getAttribute("bgcolor"))
@ -3527,4 +3531,3 @@ function InitEditor()
InlineSpellChecker.Init(editor, sPrefs.getBoolPref("mail.spellcheck.inline")); InlineSpellChecker.Init(editor, sPrefs.getBoolPref("mail.spellcheck.inline"));
InlineSpellChecker.checkDocument(window.content.document); InlineSpellChecker.checkDocument(window.content.document);
} }

Просмотреть файл

@ -132,10 +132,10 @@ function InitializeGlobalVariables()
//This migrates the LDAPServer Preferences from 4.x to mozilla format. //This migrates the LDAPServer Preferences from 4.x to mozilla format.
gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"]; gLDAPPrefsService = Components.classes["@mozilla.org/ldapprefs-service;1"];
if (gLDAPPrefsService) { if (gLDAPPrefsService) {
try { try {
gLDAPPrefsService = gLDAPPrefsService.getService().gLDAPPrefsService gLDAPPrefsService = gLDAPPrefsService
.QueryInterface( Components.interfaces.nsILDAPPrefsService); .getService(Components.interfaces.nsILDAPPrefsService);
} catch (ex) {dump ("ERROR: Cannot get the LDAP prefs service\n" + ex + "\n");} } catch (ex) {dump ("ERROR: Cannot get the LDAP prefs service\n" + ex + "\n");}
} }
gMsgCompose = null; gMsgCompose = null;
@ -166,8 +166,6 @@ function InitializeGlobalVariables()
gLastWindowToHaveFocus = null; gLastWindowToHaveFocus = null;
gReceiptOptionChanged = false; gReceiptOptionChanged = false;
gAttachVCardOptionChanged = false; gAttachVCardOptionChanged = false;
} }
InitializeGlobalVariables(); InitializeGlobalVariables();
@ -263,7 +261,7 @@ var gComposeRecyclingListener = {
}, },
onReopen: function(params) { 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"); var identityElement = document.getElementById("msgIdentity");
if (identityElement) if (identityElement)
identityElement.focus(); identityElement.focus();
@ -369,7 +367,7 @@ var progressListener = {
statusText = document.getElementById("statusText"); statusText = document.getElementById("statusText");
if (statusText) if (statusText)
statusText.setAttribute("label", aMessage); statusText.setAttribute("label", aMessage);
} catch (ex) {}; } catch (ex) {}
}, },
onSecurityChange: function(aWebProgress, aRequest, state) onSecurityChange: function(aWebProgress, aRequest, state)
@ -564,7 +562,6 @@ function GetSelectedMessages()
function SetupCommandUpdateHandlers() function SetupCommandUpdateHandlers()
{ {
// dump("SetupCommandUpdateHandlers\n");
top.controllers.insertControllerAt(0, defaultController); top.controllers.insertControllerAt(0, defaultController);
} }
@ -585,33 +582,31 @@ function CommandUpdate_MsgCompose()
updateComposeItems(); updateComposeItems();
} }
function updateComposeItems() { function updateComposeItems()
{
try { try {
// Edit Menu
goUpdateCommand("cmd_rewrap");
//Edit Menu // Insert Menu
goUpdateCommand("cmd_rewrap"); if (gMsgCompose && gMsgCompose.composeHTML)
{
//Insert Menu goUpdateCommand("cmd_renderedHTMLEnabler");
if (gMsgCompose && gMsgCompose.composeHTML) goUpdateCommand("cmd_decreaseFont");
{ goUpdateCommand("cmd_increaseFont");
goUpdateCommand("cmd_renderedHTMLEnabler"); goUpdateCommand("cmd_bold");
goUpdateCommand("cmd_decreaseFont"); goUpdateCommand("cmd_italic");
goUpdateCommand("cmd_increaseFont"); goUpdateCommand("cmd_underline");
goUpdateCommand("cmd_bold"); goUpdateCommand("cmd_ul");
goUpdateCommand("cmd_italic"); goUpdateCommand("cmd_ol");
goUpdateCommand("cmd_underline"); goUpdateCommand("cmd_indent");
goUpdateCommand("cmd_ul"); goUpdateCommand("cmd_outdent");
goUpdateCommand("cmd_ol"); goUpdateCommand("cmd_align");
goUpdateCommand("cmd_indent"); goUpdateCommand("cmd_smiley");
goUpdateCommand("cmd_outdent"); }
goUpdateCommand("cmd_align");
goUpdateCommand("cmd_smiley");
}
//Options Menu
goUpdateCommand("cmd_spelling");
// Options Menu
goUpdateCommand("cmd_spelling");
} catch(e) {} } catch(e) {}
} }
@ -634,7 +629,8 @@ function openEditorContextMenu()
updateEditItems(); updateEditItems();
} }
function updateEditItems() { function updateEditItems()
{
goUpdateCommand("cmd_pasteNoFormatting"); goUpdateCommand("cmd_pasteNoFormatting");
goUpdateCommand("cmd_pasteQuote"); goUpdateCommand("cmd_pasteQuote");
goUpdateCommand("cmd_delete"); goUpdateCommand("cmd_delete");
@ -792,13 +788,13 @@ function setupLdapAutocompleteSession()
if (gLDAPSession) { if (gLDAPSession) {
LDAPSession = gLDAPSession; LDAPSession = gLDAPSession;
} else { } else {
LDAPSession = Components.classes[ LDAPSession = Components
"@mozilla.org/autocompleteSession;1?type=ldap"]; .classes["@mozilla.org/autocompleteSession;1?type=ldap"];
if (LDAPSession) { if (LDAPSession) {
try { try {
LDAPSession = LDAPSession.createInstance() LDAPSession = LDAPSession.createInstance()
.QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession); .QueryInterface(Components.interfaces.nsILDAPAutoCompleteSession);
} catch (ex) {dump ("ERROR: Cannot get the LDAP autocomplete session\n" + ex + "\n");} } catch (ex) {dump ("ERROR: Cannot get the LDAP autocomplete session\n" + ex + "\n");}
} }
} }
@ -1214,21 +1210,20 @@ function ComposeStartup(recycled, aParams)
if (aParams) if (aParams)
params = aParams; params = aParams;
else else if (window.arguments && window.arguments[0]) {
if (window.arguments && window.arguments[0]) { try {
try {
if (window.arguments[0] instanceof Components.interfaces.nsIMsgComposeParams) if (window.arguments[0] instanceof Components.interfaces.nsIMsgComposeParams)
params = window.arguments[0]; params = window.arguments[0];
else else
params = handleMailtoArgs(window.arguments[0]); 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 // 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) 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"); dump("Failed to get editor element!\n");
return; return;
} }
document.getElementById("returnReceiptMenu").setAttribute('checked', document.getElementById("returnReceiptMenu").setAttribute('checked',
gMsgCompose.compFields.returnReceipt); gMsgCompose.compFields.returnReceipt);
document.getElementById("cmd_attachVCard").setAttribute('checked', document.getElementById("cmd_attachVCard").setAttribute('checked',
@ -1330,7 +1326,11 @@ function ComposeStartup(recycled, aParams)
} catch (e) { dump(" FAILED TO START EDITOR: "+e+"\n"); } } catch (e) { dump(" FAILED TO START EDITOR: "+e+"\n"); }
// setEditorType MUST be call before setContentWindow // 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 //Remove HTML toolbar, format and insert menus as we are editing in plain text mode
document.getElementById("outputFormatMenu").setAttribute("hidden", true); document.getElementById("outputFormatMenu").setAttribute("hidden", true);
@ -1339,11 +1339,6 @@ function ComposeStartup(recycled, aParams)
document.getElementById("insertMenu").setAttribute("hidden", true); document.getElementById("insertMenu").setAttribute("hidden", true);
document.getElementById("menu_showFormatToolbar").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 // Do setup common to Message Composer and Web Composer
EditorSharedStartup(); EditorSharedStartup();
@ -1654,9 +1649,9 @@ function GenericSendMessage( msgType )
if (gMsgCompose != null) if (gMsgCompose != null)
{ {
var msgCompFields = gMsgCompose.compFields; var msgCompFields = gMsgCompose.compFields;
if (msgCompFields) if (msgCompFields)
{ {
Recipients2CompFields(msgCompFields); Recipients2CompFields(msgCompFields);
var subject = document.getElementById("msgSubject").value; var subject = document.getElementById("msgSubject").value;
msgCompFields.subject = subject; msgCompFields.subject = subject;
@ -1669,9 +1664,10 @@ function GenericSendMessage( msgType )
if (msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later) if (msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later)
{ {
//Do we need to check the spelling? //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.content.focus();
window.cancelSendMessage = false; window.cancelSendMessage = false;
try { try {
@ -1683,27 +1679,26 @@ function GenericSendMessage( msgType )
return; 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 (subject == "")
{ {
if (gPromptService) if (gPromptService)
{ {
var result = {value:sComposeMsgsBundle.getString("defaultSubject")}; var result = {value:sComposeMsgsBundle.getString("defaultSubject")};
if (gPromptService.prompt( if (gPromptService.prompt(
window, window,
sComposeMsgsBundle.getString("sendMsgTitle"), sComposeMsgsBundle.getString("sendMsgTitle"),
sComposeMsgsBundle.getString("subjectDlogMessage"), sComposeMsgsBundle.getString("subjectDlogMessage"),
result, result,
null, null,
{value:0} {value:0}))
)) {
{ msgCompFields.subject = result.value;
msgCompFields.subject = result.value; var subjectInputElem = document.getElementById("msgSubject");
var subjectInputElem = document.getElementById("msgSubject"); subjectInputElem.value = result.value;
subjectInputElem.value = result.value; }
} else
else return;
return;
} }
} }
@ -1732,11 +1727,11 @@ function GenericSendMessage( msgType )
{ {
var checkbox = {value:false}; var checkbox = {value:false};
var okToProceed = gPromptService.confirmCheck( var okToProceed = gPromptService.confirmCheck(
window, window,
sComposeMsgsBundle.getString("subjectDlogTitle"), sComposeMsgsBundle.getString("subjectDlogTitle"),
sComposeMsgsBundle.getString("recipientDlogMessage"), sComposeMsgsBundle.getString("recipientDlogMessage"),
sComposeMsgsBundle.getString("CheckMsg"), sComposeMsgsBundle.getString("CheckMsg"),
checkbox); checkbox);
if (!okToProceed) if (!okToProceed)
return; return;
@ -1747,7 +1742,7 @@ function GenericSendMessage( msgType )
} catch (ex) {} } catch (ex) {}
} }
// remove newsgroups to prevent news_p to be set // remove newsgroups to prevent news_p to be set
// in nsMsgComposeAndSend::DeliverMessage() // in nsMsgComposeAndSend::DeliverMessage()
msgCompFields.newsgroups = ""; msgCompFields.newsgroups = "";
} }
@ -1762,15 +1757,15 @@ function GenericSendMessage( msgType )
if (action == nsIMsgCompSendFormat.AskUser) if (action == nsIMsgCompSendFormat.AskUser)
{ {
var recommAction = convert == nsIMsgCompConvertible.No var recommAction = (convert == nsIMsgCompConvertible.No)
? nsIMsgCompSendFormat.AskUser ? nsIMsgCompSendFormat.AskUser
: nsIMsgCompSendFormat.PlainText; : nsIMsgCompSendFormat.PlainText;
var result2 = {action:recommAction, var result2 = {action:recommAction,
convertible:convert, convertible:convert,
abort:false}; abort:false};
window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul", window.openDialog("chrome://messenger/content/messengercompose/askSendFormat.xul",
"askSendFormatDialog", "chrome,modal,titlebar,centerscreen", "askSendFormatDialog", "chrome,modal,titlebar,centerscreen",
result2); result2);
if (result2.abort) if (result2.abort)
return; return;
action = result2.action; action = result2.action;
@ -1832,7 +1827,7 @@ function GenericSendMessage( msgType )
case 1: // send anyway case 1: // send anyway
msgCompFields.needToCheckCharset = false; msgCompFields.needToCheckCharset = false;
break; break;
case 2: // cancel case 2: // cancel
return; return;
} }
} }
@ -1853,7 +1848,6 @@ function GenericSendMessage( msgType )
} }
msgWindow.SetDOMWindow(window); msgWindow.SetDOMWindow(window);
msgWindow.rootDocShell.allowAuth = true; msgWindow.rootDocShell.allowAuth = true;
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), currentAccountKey, msgWindow, progress); gMsgCompose.SendMsg(msgType, getCurrentIdentity(), currentAccountKey, msgWindow, progress);
} }
catch (ex) { catch (ex) {
@ -1945,6 +1939,7 @@ function SaveAsFile(saveAs)
dump("SaveAsFile from XUL\n"); dump("SaveAsFile from XUL\n");
var subject = document.getElementById('msgSubject').value; var subject = document.getElementById('msgSubject').value;
GetCurrentEditor().setDocumentTitle(subject); GetCurrentEditor().setDocumentTitle(subject);
if (gMsgCompose.bodyConvertible() == nsIMsgCompConvertible.Plain) if (gMsgCompose.bodyConvertible() == nsIMsgCompConvertible.Plain)
SaveDocument(saveAs, false, "text/plain"); SaveDocument(saveAs, false, "text/plain");
else else
@ -1968,7 +1963,6 @@ function SaveAsTemplate()
defaultSaveOperation = "template"; defaultSaveOperation = "template";
} }
function MessageFcc(menuItem) function MessageFcc(menuItem)
{ {
// Get the id for the folder we're FCC into // Get the id for the folder we're FCC into
@ -2118,13 +2112,13 @@ function ToggleReturnReceipt(target)
function ToggleAttachVCard(target) function ToggleAttachVCard(target)
{ {
var msgCompFields = gMsgCompose.compFields; var msgCompFields = gMsgCompose.compFields;
if (msgCompFields) if (msgCompFields)
{ {
msgCompFields.attachVCard = ! msgCompFields.attachVCard; msgCompFields.attachVCard = ! msgCompFields.attachVCard;
target.setAttribute('checked', msgCompFields.attachVCard); target.setAttribute('checked', msgCompFields.attachVCard);
gAttachVCardOptionChanged = true; gAttachVCardOptionChanged = true;
} }
} }
function queryISupportsArray(supportsArray, iid) { function queryISupportsArray(supportsArray, iid) {
@ -2567,7 +2561,6 @@ function FocusOnFirstAttachment()
function AttachmentElementHasItems() function AttachmentElementHasItems()
{ {
var element = document.getElementById("attachmentBucket"); var element = document.getElementById("attachmentBucket");
return element ? element.childNodes.length : 0; return element ? element.childNodes.length : 0;
} }
@ -2607,7 +2600,7 @@ function DetermineHTMLAction(convertible)
//Check newsgroups now... //Check newsgroups now...
noHtmlnewsgroups = gMsgCompose.compFields.newsgroups; noHtmlnewsgroups = gMsgCompose.compFields.newsgroups;
if (noHtmlRecipients != "" || noHtmlnewsgroups != "") if (noHtmlRecipients != "" || noHtmlnewsgroups != "")
{ {
if (convertible == nsIMsgCompConvertible.Plain) if (convertible == nsIMsgCompConvertible.Plain)
@ -2979,8 +2972,6 @@ function DisplaySaveFolderDlg(folderURI)
return; return;
} }
function SetMsgAddressingWidgetElementFocus() function SetMsgAddressingWidgetElementFocus()
{ {
var element = awGetInputElement(awGetNumberOfRecipients()); var element = awGetInputElement(awGetNumberOfRecipients());
@ -3141,9 +3132,9 @@ function SwitchElementFocus(event)
} }
} }
function loadHTMLMsgPrefs() { function loadHTMLMsgPrefs()
{
var pref = GetPrefs(); var pref = GetPrefs();
var fontFace; var fontFace;
var fontSize; var fontSize;
var textColor; var textColor;
@ -3157,7 +3148,7 @@ function loadHTMLMsgPrefs() {
try { try {
fontSize = pref.getCharPref("msgcompose.font_size"); fontSize = pref.getCharPref("msgcompose.font_size");
EditorSetFontSize(fontSize); EditorSetFontSize(fontSize);
} catch (e) {} } catch (e) {}
var bodyElement = GetBodyElement(); var bodyElement = GetBodyElement();
@ -3176,7 +3167,6 @@ function loadHTMLMsgPrefs() {
document.getElementById("cmd_backgroundColor").setAttribute("state", bgColor); document.getElementById("cmd_backgroundColor").setAttribute("state", bgColor);
onBackgroundColorChange(); onBackgroundColorChange();
} catch (e) {} } catch (e) {}
} }
function AutoSave() function AutoSave()