?? msgcomposecommands.js
字號:
/* This function will go away soon as now arguments are passed to the window using a object of type nsMsgComposeParams instead of a string */function GetArgs(originalData){ var args = new Object(); if (originalData == "") return null; var data = ""; var separator = String.fromCharCode(1); var quoteChar = ""; var prevChar = ""; var nextChar = ""; for (var i = 0; i < originalData.length; i ++, prevChar = aChar) { var aChar = originalData.charAt(i) var aCharCode = originalData.charCodeAt(i) if ( i < originalData.length - 1) nextChar = originalData.charAt(i + 1); else nextChar = ""; if (aChar == quoteChar && (nextChar == "," || nextChar == "")) { quoteChar = ""; data += aChar; } else if ((aCharCode == 39 || aCharCode == 34) && prevChar == "=") //quote or double quote { if (quoteChar == "") quoteChar = aChar; data += aChar; } else if (aChar == ",") { if (quoteChar == "") data += separator; else data += aChar } else data += aChar } var pairs = data.split(separator);// dump("Compose: argument: {" + data + "}\n"); for (i = pairs.length - 1; i >= 0; i--) { var pos = pairs[i].indexOf('='); if (pos == -1) continue; var argname = pairs[i].substring(0, pos); var argvalue = pairs[i].substring(pos + 1); if (argvalue.charAt(0) == "'" && argvalue.charAt(argvalue.length - 1) == "'") args[argname] = argvalue.substring(1, argvalue.length - 1); else try { args[argname] = decodeURIComponent(argvalue); } catch (e) {args[argname] = argvalue;} dump("[" + argname + "=" + args[argname] + "]\n"); } return args;}function ComposeFieldsReady(msgType){ //If we are in plain text, we need to set the wrap column if (! gMsgCompose.composeHTML) { try { gMsgCompose.editor.QueryInterface(nsIPlaintextEditorMail).wrapWidth = gMsgCompose.wrapLength; } catch (e) { dump("### textEditor.wrapWidth exception text: " + e + " - failed\n"); } } CompFields2Recipients(gMsgCompose.compFields, gMsgCompose.type); SetComposeWindowTitle(); // need timeout for reply to work if (gMsgCompose.composeHTML) setTimeout("loadHTMLMsgPrefs();", 0); enableEditableFields(); AdjustFocus();}// checks if the passed in string is a mailto url, if it is, generates nsIMsgComposeParams// for the url and returns them.function handleMailtoArgs(mailtoUrl){ // see if the string is a mailto url....do this by checking the first 7 characters of the string if (/^mailto:/i.test(mailtoUrl)) { // if it is a mailto url, turn the mailto url into a MsgComposeParams object.... var uri = gIOService.newURI(mailtoUrl, null, null); if (uri) return sMsgComposeService.getParamsForMailto(uri); } return null;}function ComposeStartup(recycled, aParams){ var params = null; // New way to pass parameters to the compose window as a nsIMsgComposeParameters object var args = null; // old way, parameters are passed as a string if (aParams) params = aParams; 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? if (!params) { args = GetArgs(window.arguments[0]); } } var identityList = document.getElementById("msgIdentity"); var identityListPopup = document.getElementById("msgIdentityPopup"); document.addEventListener("keypress", awDocumentKeyPress, true); if (identityListPopup) FillIdentityListPopup(identityListPopup); if (!params) { // This code will go away soon as now arguments are passed to the window using a object of type nsMsgComposeParams instead of a string params = Components.classes["@mozilla.org/messengercompose/composeparams;1"].createInstance(Components.interfaces.nsIMsgComposeParams); params.composeFields = Components.classes["@mozilla.org/messengercompose/composefields;1"].createInstance(Components.interfaces.nsIMsgCompFields); if (args) { //Convert old fashion arguments into params var composeFields = params.composeFields; if (args.bodyislink == "true") params.bodyIsLink = true; if (args.type) params.type = args.type; if (args.format) params.format = args.format; if (args.originalMsg) params.originalMsgURI = args.originalMsg; if (args.preselectid) params.identity = getIdentityForKey(args.preselectid); if (args.to) composeFields.to = args.to; if (args.cc) composeFields.cc = args.cc; if (args.bcc) composeFields.bcc = args.bcc; if (args.newsgroups) composeFields.newsgroups = args.newsgroups; if (args.subject) composeFields.subject = args.subject; if (args.attachment) { var attachmentList = args.attachment.split(","); var attachment; for (var i = 0; i < attachmentList.length; i ++) { attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance(Components.interfaces.nsIMsgAttachment); attachment.url = attachmentList[i]; composeFields.addAttachment(attachment); } } if (args.newshost) composeFields.newshost = args.newshost; if (args.body) composeFields.body = args.body; } } // " <>" is an empty identity, and most likely not valid if (!params.identity || params.identity.identityName == " <>") { // no pre selected identity, so use the default account var identities = gAccountManager.defaultAccount.identities; if (identities.Count() == 0) identities = gAccountManager.allIdentities; params.identity = identities.QueryElementAt(0, Components.interfaces.nsIMsgIdentity); } identityList.value = params.identity.key; LoadIdentity(true); if (sMsgComposeService) { gMsgCompose = sMsgComposeService.InitCompose(window, params); if (gMsgCompose) { // set the close listener gMsgCompose.recyclingListener = gComposeRecyclingListener; //Lets the compose object knows that we are dealing with a recycled window gMsgCompose.recycledWindow = recycled; // Get the <editor> element to startup an editor var editorElement = GetCurrentEditorElement(); if (!editorElement) { dump("Failed to get editor element!\n"); return; } document.getElementById("returnReceiptMenu").setAttribute('checked', gMsgCompose.compFields.returnReceipt); document.getElementById("cmd_attachVCard").setAttribute('checked', gMsgCompose.compFields.attachVCard); document.getElementById("menu_inlineSpellCheck").setAttribute('checked', sPrefs.getBoolPref("mail.spellcheck.inline")); // If recycle, editor is already created if (!recycled) { try { var editortype = gMsgCompose.composeHTML ? "htmlmail" : "textmail"; editorElement.makeEditable(editortype, true); } catch (e) { dump(" FAILED TO START EDITOR: "+e+"\n"); } // setEditorType MUST be call before setContentWindow 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); document.getElementById("FormatToolbar").setAttribute("hidden", true); document.getElementById("formatMenu").setAttribute("hidden", true); document.getElementById("insertMenu").setAttribute("hidden", true); document.getElementById("menu_showFormatToolbar").setAttribute("hidden", true); } // Do setup common to Message Composer and Web Composer EditorSharedStartup(); } var msgCompFields = gMsgCompose.compFields; if (msgCompFields) { if (params.bodyIsLink) { var body = msgCompFields.body; if (gMsgCompose.composeHTML) { var cleanBody; try { cleanBody = decodeURI(body); } catch(e) { cleanBody = body;} // XXX : need to do html-escaping here ! msgCompFields.body = "<BR><A HREF=\"" + body + "\">" + cleanBody + "</A><BR>"; } else msgCompFields.body = "\n<" + body + ">\n"; } var subjectValue = msgCompFields.subject; GetMsgSubjectElement().value = subjectValue; var attachments = msgCompFields.attachmentsArray; if (attachments) for (i = 0; i < attachments.Count(); i ++) AddAttachment(attachments.QueryElementAt(i, Components.interfaces.nsIMsgAttachment)); if (attachments.Count()) { ChangeAttachmentBucketVisibility(false); } } var event = document.createEvent('Events'); event.initEvent('compose-window-init', false, true); document.getElementById("msgcomposeWindow").dispatchEvent(event); gMsgCompose.RegisterStateListener(stateListener); if (recycled) { InitEditor(); if (gMsgCompose.composeHTML) { // Force color picker on toolbar to show document colors onFontColorChange(); onBackgroundColorChange(); } // reset the priorty field for recycled windows updatePriorityToolbarButton('Normal'); } else { // Add an observer to be called when document is done loading, // which creates the editor try { GetCurrentCommandManager(). addCommandObserver(gMsgEditorCreationObserver, "obs_documentCreated"); // Load empty page to create the editor editorElement.webNavigation.loadURI("about:blank", // uri string 0, // load flags null, // referrer null, // post-data stream null); } catch (e) { dump(" Failed to startup editor: "+e+"\n"); } } } } gEditingDraft = gMsgCompose.compFields.draftId; // finally, see if we need to auto open the address sidebar. var sideBarBox = document.getElementById('sidebar-box'); if (sideBarBox.getAttribute("sidebarVisible") == "true") { // if we aren't supposed to have the side bar hidden, make sure it is visible if (document.getElementById("sidebar").getAttribute("src") == "") setTimeout(toggleAddressPicker, 0); // do this on a delay so we don't hurt perf. on bringing up a new compose window } gAutoSaveInterval = sPrefs.getBoolPref("mail.compose.autosave") ? sPrefs.getIntPref("mail.compose.autosaveinterval") * 60000 : 0; if (gAutoSaveInterval) gAutoSaveTimeout = setTimeout(AutoSave, gAutoSaveInterval); gExplicitSave = false;}// The new, nice, simple way of getting notified when a new editor has been createdvar gMsgEditorCreationObserver ={ observe: function(aSubject, aTopic, aData) { if (aTopic == "obs_documentCreated") { var editor = GetCurrentEditor(); if (editor && GetCurrentCommandManager() == aSubject) { var editorStyle = editor.QueryInterface(Components.interfaces.nsIEditorStyleSheets); editorStyle.addStyleSheet("chrome://messenger/skin/messageQuotes.css"); InitEditor(); } // Now that we know this document is an editor, update commands now if // the document has focus, or next time it receives focus via // CommandUpdate_MsgCompose() if (gLastWindowToHaveFocus == document.commandDispatcher.focusedWindow) updateComposeItems(); else gLastWindowToHaveFocus = null; } }}function WizCallback(state){ if (state){ ComposeStartup(false, null); }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -