📄 emailui.js
字号:
var bcc = document.getElementById("addressBCC" + idx); switch(type) { case "to": cc.style.visibility = 'hidden'; case "cc": bcc.style.visibility = 'hidden'; break; } } }, /** * Redisplays the textareas after an address is commited */ toggleTextareaShow : function(sType, aArgs) { var textBoxId = aArgs[0]._oTextbox.id; // "addressTo0" var type = ""; var idx = -1; if(textBoxId.indexOf("addressTo") > -1) { type = "to"; } else if(textBoxId.indexOf("addressCC") > -1) { type = "cc"; } idx = textBoxId.substr(9); // follow through if not BCC if(type != "") { document.getElementById("addressCC" + idx).style.visibility = 'visible'; document.getElementById("addressBCC" + idx).style.visibility = 'visible'; } }};//// END AUTOCOMPLETE////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// COMPOSE & SEND/** * expands the options sidebar */SUGAR.email2.composeLayout = { currentInstanceId : 0, tinyConfig : "code,bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull," + "separator,bullist,numlist,outdent,indent,separator,forecolor,backcolor,fontselect,fontsizeselect", /////////////////////////////////////////////////////////////////////////// //// COMPOSE FLOW /** * Prepare bucket DIV and yui-ext tab panels */ _0_yui_ext : function() { var idx = this.currentInstanceId; // render div and tab // create bucket DIV Ext.DomHelper.append(document.body, { tag:'div', name:'htmleditordiv' + idx, id:'htmleditordiv' + idx, cls:'x-layout-inactive-content' }); // get template engine with template var editorTarget = new Ext.DomHelper.Template(SUGAR.email2.templates['compose']); // apply template variables editorTarget.append('htmleditordiv' + idx, { 'app_strings':app_strings, 'mod_strings':mod_strings, 'theme': theme, 'idx' : SUGAR.email2.composeLayout.currentInstanceId }); e2Layout.getComposeLayout(); // create Tab panel var composePanel = new Ext.NestedLayoutPanel(SUGAR.email2.composeLayout[idx], {isCompose : true}); composePanel.title = app_strings.LBL_EMAIL_COMPOSE; composePanel.closable = true; composePanel.on('activate', function () {SUGAR.email2.tinyInstances.currentHtmleditor = "htmleditor" + idx}); SUGAR.email2.innerLayout.add('center', composePanel); // work-around to hide sliding panels in IE //SUGAR.email2.composeLayout[idx].regions.east.expand(); //SUGAR.email2.composeLayout[idx].regions.east.collapse(); }, /** * Prepare TinyMCE */ _1_tiny : function() { var idx = SUGAR.email2.composeLayout.currentInstanceId; SUGAR.email2.tinyInstances.currentHtmleditor = 'htmleditor' + idx; SUGAR.email2.tinyInstances[SUGAR.email2.tinyInstances.currentHtmleditor] = new Object(); SUGAR.email2.tinyInstances[SUGAR.email2.tinyInstances.currentHtmleditor].ready = false; var t = tinyMCE.getInstanceById('htmleditor' + idx); if(typeof(t) == 'undefined') { var nav = new String(navigator.appVersion); var cof = document.getElementById('composeOverFrame' + idx); var head = document.getElementById('composeHeaderTable' + idx); var targetHeight = cof.clientHeight - head.clientHeight; tinyMCE.execCommand('mceAddControl', false, SUGAR.email2.tinyInstances.currentHtmleditor); var instance = tinyMCE.getInstanceById(SUGAR.email2.tinyInstances.currentHtmleditor); var tableEl = document.getElementById(instance.editorId + '_parent').firstChild; var toolbar = document.getElementById(instance.editorId + '_toolbar'); if (SUGAR.email2.util.isIe()) { instance.iframeElement.style.height = "100%"; instance.iframeElement.height = "100%"; } else { instance.iframeElement.style.height = targetHeight - toolbar.clientHeight; } tableEl.style.height = targetHeight; setTimeout("SUGAR.email2.composeLayout.setSignature('" + idx + "');", 1000); } }, /** * Initializes d&d, auto-complete, email templates */ _2_final : function() { var idx = SUGAR.email2.composeLayout.currentInstanceId; if(this.emailTemplates) { this.setComposeOptions(idx); } else { //populate email template cache AjaxObject.target = ''; AjaxObject.startRequest(callbackComposeCache, urlStandard + "&emailUIAction=fillComposeCache"); } // handle drop targets for addressBook var to = new Ext.dd.DropTarget('addressTo'+idx, {ddGroup: 'addressBookDD', notifyDrop:this.handleDrop}); var cc = new Ext.dd.DropTarget('addressCC' + idx, {ddGroup: 'addressBookDD', notifyDrop:this.handleDrop}); var bcc = new Ext.dd.DropTarget('addressBCC' + idx, {ddGroup: 'addressBookDD', notifyDrop:this.handleDrop}); // auto-complete setup SUGAR.email2.autoComplete.init(idx); // set focus on to: document.getElementById("addressTo" + idx).focus(); }, c1_composeEmail : function(isReplyForward, retry) { if (Ext.isEmpty(retry)) { this._0_yui_ext(); } if (typeof(tinyMCE) == 'undefined' || typeof(tinyMCE.settings) == 'undefined' || typeof(tinyMCE.themes.advanced) == 'undefined'){ setTimeout("SUGAR.email2.composeLayout.c1_composeEmail(" + isReplyForward + ", true);", 500); } else { this._1_tiny(); this._2_final(); if(isReplyForward) { this.replyForwardEmailStage2(); } } }, /** * takes draft info and prepopulates */ c0_composeDraft : function() { this.getNewInstanceId(); inCompose = true; document.getElementById('_blank').innerHTML = ''; var idx = SUGAR.email2.composeLayout.currentInstanceId; SUGAR.email2.composeLayout.currentInstanceId = idx; SUGAR.email2.tinyInstances.currentHtmleditor = 'htmleditor' + SUGAR.email2.composeLayout.currentInstanceId; SUGAR.email2.tinyInstances[SUGAR.email2.tinyInstances.currentHtmleditor] = new Object(); SUGAR.email2.tinyInstances[SUGAR.email2.tinyInstances.currentHtmleditor].ready = false; SUGAR.email2.composeLayout._0_yui_ext(); SUGAR.email2.composeLayout._1_tiny(); // hack to hide "hidden" option/attach panel content in both IE and FF SUGAR.email2.composeLayout[idx].regions.east.expand(); SUGAR.email2.composeLayout[idx].regions.east.collapse(); // final touches SUGAR.email2.composeLayout._2_final(); /* Draft-specific final processing. Need a delay to allow Tiny to render before calling setText() */ setTimeout("AjaxObject.handleReplyForwardForDraft(SUGAR.email2.o);", 1000); }, /** * Strip & Prep editor hidden fields */ c0_composeNewEmail : function() { this.getNewInstanceId(); this.c1_composeEmail(false); }, /** * Sends async request to get the compose view. * Requests come from "reply" or "forwards" */ c0_replyForwardEmail : function(ieId, uid, mbox, type) { SUGAR.email2.composeLayout.replyForwardObj = new Object(); SUGAR.email2.composeLayout.replyForwardObj.ieId = ieId; SUGAR.email2.composeLayout.replyForwardObj.uid = uid; SUGAR.email2.composeLayout.replyForwardObj.mbox = mbox; SUGAR.email2.composeLayout.replyForwardObj.type = type; if(mbox == 'sugar::Emails') { SUGAR.email2.composeLayout.replyForwardObj.sugarEmail = true; } SUGAR.email2.composeLayout.getNewInstanceId(); SUGAR.email2.composeLayout.c1_composeEmail(true); }, //// END COMPOSE FLOW /////////////////////////////////////////////////////////////////////////// /** * Called when a contact, email, or mailinglist is dropped * into one of the compose fields. */ handleDrop : function (source, event, data, target) { var nodes; if (!target) { target = event.getTarget(); if (data.single) { data.nodes = [data.nodes]; } nodes = data.nodes; } else { target = document.getElementById(target); nodes = data; } //If a mailing list was dropped if (source.id == 'lists') { } else if (target.id.indexOf('address') > -1) { // dropped onto email to/cc/bcc field for(var i in nodes) { if (nodes[i].id) { var node = nodes[i]; var email = ""; if (node.className.indexOf('contact') > -1) { email = SUGAR.email2.addressBook.getFormattedAddress(node.id); } else if (node.className.indexOf('address-email') > -1){ email = node.innerHTML.replace(/ /gi, ''); email = email.replace('<', '<').replace('>', '>'); var o = SUGAR.email2.addressBook._contactCache[node.parentNode.firstChild['id']]; var name = new String(o.name); var finalName = name.replace(/(<([^>]+)>)/ig, ""); email = finalName + email; } target.value = SUGAR.email2.addressBook.smartAddEmailAddressToComposeField(target.value, email); } } } }, /*///////////////////////////////////////////////////////////////////////////// /// EMAIL TEMPLATE CODE */ applyEmailTemplate : function (idx, id) { // id is selected index of email template drop-down if(id == '' || id == "0") { return; } call_json_method('EmailTemplates','retrieve','record='+id,'email_template_object', this.appendEmailTemplateJSON); // get attachments if any AjaxObject.target = ''; AjaxObject.startRequest(callbackLoadAttachments, urlStandard + "&emailUIAction=getTemplateAttachments&parent_id=" + id); }, appendEmailTemplateJSON : function() { var idx = SUGAR.email2.composeLayout.currentInstanceId; // post increment // query based on template, contact_id0,related_to if(document.getElementById('emailSubject' + idx).value == '') { // cn: bug 7743, don't stomp populated Subject Line document.getElementById('emailSubject' + idx).value = decodeURI(encodeURI(json_objects['email_template_object']['fields']['subject'])); } var text = decodeURI(encodeURI(json_objects['email_template_object']['fields']['body_html'])).replace(/<BR>/ig, '\n').replace(/<br>/gi, "\n").replace(/&/gi,'&').replace(/</gi,'<').replace(/>/gi,'>').replace(/'/gi,'\'').replace(/"/gi,'"'); // cn: bug 14361 - text-only templates don't fill compose screen if(text == '') { text = decodeURI(encodeURI(json_objects['email_template_object']['fields']['body'])).replace(/<BR>/ig, '\n').replace(/<br>/gi, "\n").replace(/&/gi,'&').replace(/</gi,'<').replace(/>/gi,'>').replace(/'/gi,'\'').replace(/"/gi,'"'); } var tiny = SUGAR.email2.util.getTiny('htmleditor' + idx); var tinyHTML = tiny.getHTML('htmleditor' + idx); var openTag = '<div><span><span>'; var closeTag = '</span></span></div>'; var htmllow = tinyHTML.toLowerCase(); var start = htmllow.indexOf(openTag); if (start > -1) { var htmlPart1 = tinyHTML.substr(0, start); var htmlPart2 = tinyHTML.substr(start); tinyHTML = htmlPart1 + text + htmlPart2; tiny.setHTML(tinyHTML); } else { tinyHTML = tinyHTML + text; tiny.setHTML(tinyHTML); } }, /** * Writes out the signature in the email editor */ setSignature : function(idx) { if (!tinyMCE) return false; //wait for signatures to load before trying to set them if (!SUGAR.email2.composeLayout.signatures) { setTimeout("SUGAR.email2.composeLayout.setSignature(" + idx + ");", 1000); } if(idx) { var sel = document.getElementById('signatures' + idx); } else { var sel = document.getElementById('signature_id'); idx = SUGAR.email2.tinyInstances.currentHtmleditor; } var signature = ''; try { signature = sel.options[sel.selectedIndex].value; } catch(e) { } var openTag = '<div><span><span>'; var closeTag = '</span></span></div>'; var t = SUGAR.email2.util.getTiny('htmleditor' + idx); //IE 6 Hack t.contentDocument = t.contentWindow.document; var html = t.getHTML('htmleditor' + idx); var htmllow = html.toLowerCase(); var start = htmllow.indexOf(openTag); var end = htmllow.indexOf(closeTag) + closeTag.length; // selected "none" - remove signature from email if(signature == '') { if (start > -1) { var htmlPart1 = html.substr(0, start); var htmlPa
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -