?? msgcomposecommands.js
字號:
else { if (gMsgCompose) gMsgCompose.CloseWindow(false); //Don't try to recyle a bogus window else window.close();// window.tryToClose=ComposeCanClose; }}function ComposeLoad(){ // First get the preferences service try { var prefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); sPrefs = prefService.getBranch(null); sPrefBranchInternal = sPrefs.QueryInterface(Components.interfaces.nsIPrefBranch2); } catch (ex) { dump("failed to preferences services\n"); } try { sOther_headers = sPrefs.getCharPref("mail.compose.other.header"); } catch (ex) { dump("failed to get the mail.compose.other.header pref\n"); } try { sAccountManagerDataSource = Components.classes["@mozilla.org/rdf/datasource;1?name=msgaccountmanager"].getService(Components.interfaces.nsIRDFDataSource); sRDF = Components.classes['@mozilla.org/rdf/rdf-service;1'].getService(Components.interfaces.nsIRDFService); sNameProperty = sRDF.GetResource("http://home.netscape.com/NC-rdf#Name?sort=true"); } catch (ex) { dump("failed to get RDF\n"); } AddMessageComposeOfflineObserver(); AddDirectoryServerObserver(true); try { // XXX: We used to set commentColumn on the initial auto complete column after the document has loaded // inside of setupAutocomplete. But this happens too late for the first widget and it was never showing // the comment field. Try to set it before the document finishes loading: if (sPrefs.getIntPref("mail.autoComplete.commentColumn")) document.getElementById('addressCol2#1').showCommentColumn = true; } catch (ex) { // do nothing... } if (gLogComposePerformance) sMsgComposeService.TimeStamp("Start initializing the compose window (ComposeLoad)", false); try { SetupCommandUpdateHandlers(); var wizardcallback = true; var state = verifyAccounts(wizardcallback); // this will do migration, or create a new account if we need to. if (sOther_headers) { var selectNode = document.getElementById('addressCol1#1'); var sOther_headers_Array = sOther_headers.split(","); for (var i = 0; i < sOther_headers_Array.length; i++) selectNode.appendItem(sOther_headers_Array[i] + ":", "addr_other"); } if (state) ComposeStartup(false, null); } catch (ex) { dump("EX: = " + ex + "\n"); var errorTitle = sComposeMsgsBundle.getString("initErrorDlogTitle"); var errorMsg = sComposeMsgsBundle.getFormattedString("initErrorDlogMessage", [""]); if (gPromptService) gPromptService.alert(window, errorTitle, errorMsg); else window.alert(errorMsg); if (gMsgCompose) gMsgCompose.CloseWindow(false); //Don't try to recycle a bogus window else window.close(); return; } window.tryToClose=ComposeCanClose; if (gLogComposePerformance) sMsgComposeService.TimeStamp("Done with the initialization (ComposeLoad). Waiting on editor to load about:blank", false); // initialize the customizeDone method on the customizeable toolbar var toolbox = document.getElementById("compose-toolbox"); toolbox.customizeDone = MailToolboxCustomizeDone; var toolbarset = document.getElementById('customToolbars'); toolbox.toolbarset = toolbarset;}function ComposeUnload(){ dump("\nComposeUnload from XUL\n"); EditorCleanup(); RemoveMessageComposeOfflineObserver(); RemoveDirectoryServerObserver(null); if (gCurrentIdentity) RemoveDirectoryServerObserver("mail.identity." + gCurrentIdentity.key); if (gCurrentAutocompleteDirectory) RemoveDirectorySettingsObserver(gCurrentAutocompleteDirectory); if (gMsgCompose) gMsgCompose.UnregisterStateListener(stateListener); if (gAutoSaveTimeout) clearTimeout(gAutoSaveTimeout);}function SetDocumentCharacterSet(aCharset){ dump("SetDocumentCharacterSet Callback!\n"); dump(aCharset + "\n"); if (gMsgCompose) { gMsgCompose.SetDocumentCharset(aCharset); gCurrentMailSendCharset = aCharset; gCharsetTitle = null; SetComposeWindowTitle(); } else dump("Compose has not been created!\n");}function UpdateMailEditCharset(){ var send_default_charset = gMsgCompose.compFields.defaultCharacterSet;// dump("send_default_charset is " + send_default_charset + "\n"); var compFieldsCharset = gMsgCompose.compFields.characterSet;// dump("gMsgCompose.compFields is " + compFieldsCharset + "\n"); if (gCharsetConvertManager) { var charsetAlias = gCharsetConvertManager.getCharsetAlias(compFieldsCharset); if (charsetAlias == "us-ascii") compFieldsCharset = "ISO-8859-1"; // no menu item for "us-ascii" } // charset may have been set implicitly in case of reply/forward // or use pref default otherwise var menuitem = document.getElementById(send_default_charset == compFieldsCharset ? send_default_charset : compFieldsCharset); if (menuitem) menuitem.setAttribute('checked', 'true'); // Set a document charset to a default mail send charset. if (send_default_charset == compFieldsCharset) SetDocumentCharacterSet(send_default_charset);}function InitCharsetMenuCheckMark(){ // return if the charset is already set explitily if (gCurrentMailSendCharset != null) { dump("already set to " + gCurrentMailSendCharset + "\n"); return; } // Check the menu UpdateMailEditCharset(); // use setTimeout workaround to delay checkmark the menu // when onmenucomplete is ready then use it instead of oncreate // see bug #78290 for the details setTimeout("UpdateMailEditCharset()", 0);}function GetCharsetUIString(){ var charset = gMsgCompose.compFields.characterSet; if (gSendDefaultCharset == null) { gSendDefaultCharset = gMsgCompose.compFields.defaultCharacterSet; } charset = charset.toUpperCase(); if (charset == "US-ASCII") charset = "ISO-8859-1"; if (charset != gSendDefaultCharset) { if (gCharsetTitle == null) { try { // check if we have a converter for this charset var charsetAlias = gCharsetConvertManager.getCharsetAlias(charset); var encoderList = gCharsetConvertManager.getEncoderList(); var found = false; while (encoderList.hasMore()) { if (charsetAlias == encoderList.getNext()) { found = true; break; } } if (!found) { dump("no charset converter available for " + charset + " default charset is used instead\n"); // set to default charset, no need to show it in the window title gMsgCompose.compFields.characterSet = gSendDefaultCharset; return ""; } // get a localized string gCharsetTitle = gCharsetConvertManager.getCharsetTitle(charsetAlias); } catch (ex) { dump("failed to get a charset title of " + charset + "!\n"); dump("Exception: " + ex + "\n"); gCharsetTitle = charset; // just show the charset itself } } return " - " + gCharsetTitle; } return "";}function GenericSendMessage( msgType ){ dump("GenericSendMessage from XUL\n"); dump("Identity = " + getCurrentIdentity() + "\n"); if (gMsgCompose != null) { var msgCompFields = gMsgCompose.compFields; if (msgCompFields) { Recipients2CompFields(msgCompFields); var subject = GetMsgSubjectElement().value; msgCompFields.subject = subject; Attachments2CompFields(msgCompFields); 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. SetMsgBodyFrameFocus(); window.cancelSendMessage = false; try { window.openDialog("chrome://editor/content/EdSpellCheck.xul", "_blank", "chrome,close,titlebar,modal", true, true); } 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 = GetMsgSubjectElement(); 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 + "' 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); } // 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. 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 var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); observerService.notifyObservers(window, "mail:composeOnSend", null); // Check if the headers of composing mail can be converted to a mail charset. if (msgType == nsIMsgCompDeliverMode.Now || msgType == nsIMsgCompDeliverMode.Later || msgType == nsIMsgCompDeliverMode.Save || msgType == nsIMsg
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -