⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emailui.js

📁 SugarCRM5.1 开源PHP客户关系管理系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
/********************************************************************************* * SugarCRM is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc. *  * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation with the addition of the following permission added * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. *  * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more * details. *  * You should have received a copy of the GNU General Public License along with * this program; if not, see http://www.gnu.org/licenses or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. *  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. *  * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. *  * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/SUGAR.email2 = {    cache : new Object(),    o : null, // holder for reference to AjaxObject's return object (used in composeDraft())    reGUID : new RegExp(/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/i),    templates : {},    tinyInstances : {        currentHtmleditor : ''    },    /**     * preserves hits from email server     */    _setDetailCache : function(ret) {        if(ret.meta) {            var compKey = ret.meta.mbox + ret.meta.uid;            if(!SUGAR.email2.cache[compKey]) {                SUGAR.email2.cache[compKey] = ret;            }        }    },    autoSetLayout : function() {        var c = document.getElementById('container');        var nav = new String(navigator.appVersion);        var cH = c.offsetTop;        var h = (nav.match(/MSIE/i)) ? document.body.clientHeight - 10 : document.body.scrollHeight - 10;        h -= 13;        c.style.height = h - cH;        SUGAR.email2.complexLayout.layout();        if(SUGAR.email2.grid) {            SUGAR.email2.grid.autoSize();        }    }};///////////////////////////////////////////////////////////////////////////////////    EMAIL ACCOUNTSSUGAR.email2.accounts = {    outboundDialog : null,    errorStyle : 'input-error',    normalStyle : '',    /**     * makes async call to retrieve an outbound instance for editting     */     //EXT111    editOutbound : function() {        var sel = document.getElementById("outbound_email");        var obi = sel.options[sel.selectedIndex].value;        if(obi.match(/^(add|line|sendmail)+/)) {            alert('oops');        } else {            AjaxObject.startRequest(AjaxObject.accounts.callbackEditOutbound, urlStandard + "&emailUIAction=editOutbound&outbound_email=" + obi);        }    },    //EXT111    getReplyAddress : function() {        var primary = '';        for(var i=0; i<SUGAR.email2.userPrefs.current_user.emailAddresses.length; i++) {            var addy = SUGAR.email2.userPrefs.current_user.emailAddresses[i];            if(addy.primary_address == "1") {                primary = addy.email_address;            }            if(addy.reply_to == "1") {                return addy.email_address;            }        }        return primary;    },    /**     * Handles change to 'add'     *///EXT111    handleOutboundSelectChange : function() {        var select = document.getElementById("outbound_email");        document.getElementById("outbound_email_edit_button").style.display = 'none';        if(select.value == 'add') {            this.showAddSmtp();        } else if(select.value != 'sendmail' && select.value != 'none' && select.value != 'line' &&         	select.options[select.selectedIndex].text.search(/system - /) == -1) {            document.getElementById("outbound_email_edit_button").style.display = '';        }    },    /**     * Called on "Accounts" tab activation event     */    lazyLoad : function() {        // below called with FQ names, wrapped by event handler        SUGAR.email2.accounts.rebuildAccountList();        //SUGAR.email2.accounts.rebuildShowAccountList();        SUGAR.email2.accounts.rebuildMailerOptions();        SUGAR.email2.accounts.addNewAccount();    },    /**     * Displays a modal diaglogue to add a SMTP server     */    showAddSmtp : function() {        // lazy load dialogue        if(!this.outboundDialog) {            this.outboundDialog = new Ext.LayoutDialog("outboundDialog", {                title: app_strings.LBL_EMAIL_ACCOUNTS_OUTBOUND,                modal:true,                width:600,                height:350,                shadow:true,                minWidth:300,                minHeight:300,                center: {                    autoScroll:true,                    alwaysShowTabs: false                }            });            var layout = this.outboundDialog.getLayout();            this.outboundDialog.beginUpdate();            layout.add('center', new Ext.ContentPanel('outboundServers'));            this.outboundDialog.endUpdate();            layout.showPanel('outboundServers');        } // end lazy load                // clear out form        var form = document.getElementById('outboundEmailForm');        for(i=0; i<form.elements.length; i++) {            if(form.elements[i].name == 'mail_smtpport') {                form.elements[i].value = 25;            } else if(form.elements[i].type != 'button') {                form.elements[i].value = '';            } else if(form.elements[i].type == 'checkbox') {                form.elements[i].checked = false;            }        }        this.outboundDialog.show();    },    /**     * Accounts' Advanced Settings view toggle     */    toggleAdv : function() {        var adv = document.getElementById("ie_adv");        if(adv.style.display == 'none') {            adv.style.display = "";        } else {            adv.style.display = 'none';        }    },    /**     * Presets default values for Gmail     */    fillGmailDefaults : function() {        document.getElementById("mail_smtpserver").value = 'smtp.gmail.com';        document.getElementById("mail_smtpport").value = '465';        document.getElementById("mail_smtpauth_req").checked = true;        document.getElementById("mail_smtpssl").checked = true;    },    /**     * Sets Port field to selected protocol and SSL settings defaults     */    setPortDefault : function() {        var prot    = document.getElementById('protocol');        var ssl        = document.getElementById('ssl');        var port    = document.getElementById('port');        var stdPorts= new Array("110", "143", "993", "995");        var stdBool    = new Boolean(false);        var mailboxdiv = document.getElementById("mailboxdiv");		var monitoredFolder = document.getElementById("subscribeFolderButton");        if(port.value == '') {            stdBool.value = true;        } else {            for(i=0; i<stdPorts.length; i++) {                if(stdPorts[i] == port.value) {                    stdBool.value = true;                }            }        }        if(stdBool.value == true) {            if(prot.value == 'imap' && ssl.checked == false) { // IMAP                port.value = "143";            } else if(prot.value == 'imap' && ssl.checked == true) { // IMAP-SSL                port.value = '993';            } else if(prot.value == 'pop3' && ssl.checked == false) { // POP3                port.value = '110';            } else if(prot.value == 'pop3' && ssl.checked == true) { // POP3-SSL                port.value = '995';            }        }                if (prot.value == 'imap') {        	mailboxdiv.style.display = "";        	monitoredFolder.style.display = "";        	if (document.getElementById('mailbox').value == "") {        		document.getElementById('mailbox').value = "INBOX";        	}        } else {        	mailboxdiv.style.display = "none";			monitoredFolder.style.display = "none";        	document.getElementById('mailbox').value = "";        } // else    },    /**     * Draws/removes red boxes around required fields.     */    ieAccountError : function(style) {        document.getElementById('server_url').className = style;        document.getElementById('email_user').className = style;        document.getElementById('email_password').className = style;        document.getElementById('protocol').className = style;        document.getElementById('port').className = style;    },    /**     * Empties all the fields in the accounts edit view     */    addNewAccount:function() {        document.getElementById('ie_id').value = '';        document.getElementById('ie_name').value = '';        document.getElementById('from_name').value = SUGAR.email2.userPrefs.current_user.full_name;        document.getElementById('from_addr').value = this.getReplyAddress();        document.getElementById('server_url').value = '';        document.getElementById('email_user').value = '';        document.getElementById('email_password').value = '';        document.getElementById('port').value = '';        document.getElementById('deleteButton').style.display = 'none';        document.getElementById('protocol').options[0].selected = true;        // handle SSL        document.getElementById('ssl').checked = false;    },    /**     * Populates an account's fields in Settings->Accounts     */    fillIeAccount:function(jsonstr) {        var o = JSON.parse(jsonstr);        document.getElementById('ie_id').value = o.id;        document.getElementById('ie_name').value = o.name;        if (o.stored_options != null) {        	document.getElementById('from_name').value = o.stored_options.from_name;        	document.getElementById('from_addr').value = o.stored_options.from_addr;        }        document.getElementById('server_url').value = o.server_url;        document.getElementById('email_user').value = o.email_user;        document.getElementById('email_password').value = o.email_password;        document.getElementById('port').value = o.port;        document.getElementById('group_id').value = o.group_id;        document.getElementById('mailbox').value = o.mailbox;        document.getElementById('deleteButton').style.display = 'inline';        var i = 0;        // handle protocol        if(document.getElementById('protocol').value != o.protocol) {            var prot = document.getElementById('protocol');            for(i=0; i<prot.options.length; i++) {                if(prot.options[i].value == o.service[3]) {                    prot.options[i].selected = true;                    this.setPortDefault();                }            }        }        // handle SSL        if(typeof(o.service[2]) != 'undefined') {            document.getElementById('ssl').checked = true;        }        // handle SMTP selection        if(o.stored_options != null && typeof(o.stored_options.outbound_email) != 'undefined') {            var opts = document.getElementById('outbound_email').options;            for(i=0; i<opts.length; i++) {                if(opts[i].value == o.stored_options.outbound_email) {                    opts[i].selected = true;                }            }        }        SUGAR.email2.accounts.handleOutboundSelectChange();    },    deleteIeAccount : function() {        if(confirm(app_strings.LBL_EMAIL_IE_DELETE_CONFIRM)) {            overlay(app_strings.LBL_EMAIL_IE_DELETE, app_strings.LBL_EMAIL_ONE_MOMENT);            var formObject = document.getElementById('ieAccount');            YAHOO.util.Connect.setForm(formObject);            AjaxObject.target = 'frameFlex';            AjaxObject.startRequest(callbackAccountDelete, urlStandard + '&emailUIAction=deleteIeAccount');        }    },    /**     * Saves Outbound email settings     */    saveOutboundSettings : function() {        YAHOO.util.Connect.setForm(document.getElementById("outboundEmailForm"));        AjaxObject.startRequest(callbackOutboundSave, urlStandard + "&emailUIAction=saveOutbound");    },    saveIeAccount : function() {        if(SUGAR.email2.accounts.checkIeCreds()) {            document.getElementById('saveButton').disabled = true;            overlay(app_strings.LBL_EMAIL_IE_SAVE, app_strings.LBL_EMAIL_ONE_MOMENT);            var formObject = document.getElementById('ieAccount');            YAHOO.util.Connect.setForm(formObject);            AjaxObject._reset();            AjaxObject.target = 'frameFlex';            AjaxObject.startRequest(callbackAccount, urlStandard + '&emailUIAction=saveIeAccount');        }    },    testSettings : function() {        form = document.getElementById('ieAccount');        if(SUGAR.email2.accounts.checkIeCreds()) {            ie_test_open_popup_with_submit("InboundEmail", "Popup", "Popup", 400, 300, form.server_url.value, form.protocol.value, form.port.value, form.email_user.value, Rot13.write(form.email_password.value), form.mailbox.value, form.ssl.checked, true);        }    },    getFoldersListForInboundAccountForEmail2 : function() {        form = document.getElementById('ieAccount');        if(SUGAR.email2.accounts.checkIeCreds()) {            getFoldersListForInboundAccount("InboundEmail", "ShowInboundFoldersList", "Popup", 400, 300, form.server_url.value, form.protocol.value, form.port.value, form.email_user.value, Rot13.write(form.email_password.value), form.mailbox.value, form.ssl.checked, true);        } // if    	    },        checkIeCreds : function() {        var errors = new Array();        var out = new String();        var ie_name = document.getElementById('ie_name').value;        var fromAddress = document.getElementById('from_addr').value;        var server_url = document.getElementById('server_url').value;        var email_user = document.getElementById('email_user').value;        var email_password = document.getElementById('email_password').value;        var protocol = document.getElementById('protocol').value;        var port = document.getElementById('port').value;        if(trim(ie_name) == "") {            errors.push(app_strings.LBL_EMAIL_ERROR_NAME);        }        if(trim(fromAddress) == "") {            errors.push(app_strings.LBL_EMAIL_ERROR_FROM_ADDRESS);        }        if(trim(server_url) == "") {            errors.push(app_strings.LBL_EMAIL_ERROR_SERVER);        }        if(trim(email_user) == "") {            errors.push(app_strings.LBL_EMAIL_ERROR_USER);        }        if(trim(email_password) == "") {            errors.push(app_strings.LBL_EMAIL_ERROR_PASSWORD);        }        if(protocol == "") {            errors.push(app_strings.LBL_EMAIL_ERROR_PROTOCOL);        }        if (protocol == 'imap') {        	var mailbox = document.getElementById('mailbox').value;        	if (trim(mailbox) == "") {        		errors.push(app_strings.LBL_EMAIL_ERROR_MONITORED_FOLDER);        	} // if        }        if(port == "") {            errors.push(app_strings.LBL_EMAIL_ERROR_PORT);        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -