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

📄 email.js

📁 SugarCRM5.1 开源PHP客户关系管理系统
💻 JS
📖 第 1 页 / 共 3 页
字号:
		// put the focus on the popup if the browser supports the focus() method		win.focus();	}}///////////////////////////////////////////////////////////////////////////////////	HTML/PLAIN EDITOR FUNCTIONSfunction setEditor() {	if(document.getElementById('setEditor').checked == false) {		toggle_textonly();	}}// cn: bug 9690 - unchecked "Send HTML" - we hose the html_div contentsfunction prepSave() {	if(document.getElementById('setEditor').checked == false) {		document.getElementById('html_div').innerHTML = '';	}}function toggle_textonly() {	var altText = document.getElementById('alt_text_div');	var plain = document.getElementById('text_div');	var html = document.getElementById('html_div');	var desc = document.getElementById('description');	var tiny = tinyMCE.getInstanceById('description_html');	// toggling INTO HTML editting	if(html.style.display == 'none') {		html.style.display = 'block';		if(document.getElementById('toggle_textarea_elem').checked == false) {			plain.style.display = 'none';		}		altText.style.display = 'block';		var plainText = new String(desc.value);		plainText = plainText.replace(/\n/gi, '<br />');		tiny.setHTML(plainText);	} else {		// toggling into Plain Text ONLY		html.style.display = 'none';		plain.style.display = 'block';		altText.style.display = 'none';		if(tiny.getHTML()) {			var htmlText = new String(tiny.getHTML());			htmlText = htmlText.replace(/<br \/>/gi, "\n");			htmlText = htmlText.replace(/&gt;/gi, ">");			htmlText = htmlText.replace(/&lt;/gi, "<");			htmlText = htmlText.replace(/&nbsp;/gi, " ");			desc.value = stripTags(htmlText);		}	}}function stripTags(str) {	var theText = new String(str);	if(theText != 'undefined') {		return theText.replace(/<\/?[^>]+>/gi, '');	}}function toggle_textarea() {	var checkbox = document.getElementById('toggle_textarea_elem');	var plain = document.getElementById('text_div');	if (checkbox.checked == false) {		plain.style.display = 'none';	} else {		plain.style.display = 'block';	}}////	END HTML/PLAIN EDITOR FUNCTIONS//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	EMAIL TEMPLATE CODEfunction fill_email(id) {	var where = "parent_id='" + id + "'";	var order = '';	if(id == '') {		// query based on template, contact_id0,related_to		if(! append) {			document.EditView.name.value  = '';			document.EditView.description.value = '';			document.EditView.description_html.value = '';		}		return;	}	call_json_method('EmailTemplates','retrieve','record='+id,'email_template_object', appendEmailTemplateJSON);	args = {"module":"Notes","where":where, "order":order};	if(typeof(global_rpcClient) == 'undefined') {		global_rpcClient = new SugarRPCClient();	}	req_id = global_rpcClient.call_method('get_full_list', args);	global_request_registry[req_id] = [ejo, 'display'];}function appendEmailTemplateJSON() {	// query based on template, contact_id0,related_to	if(document.EditView.name.value == '') { // cn: bug 7743, don't stomp populated Subject Line		document.EditView.name.value = decodeURI(encodeURI(json_objects['email_template_object']['fields']['subject']));	}	document.EditView.description.value += decodeURI(encodeURI(json_objects['email_template_object']['fields']['body'])).replace(/<BR>/ig, '\n');	var tiny = tinyMCE.getInstanceById("description_html");	var tinyHtml = tiny.getHTML(true);	// cn: bug 10985 - IE6/7 will show inline image at top of screen if we set this with no valid target	if(document.getElementById('setEditor').checked == true) {		var descHtml = decodeURI(encodeURI(json_objects['email_template_object']['fields']['body_html'])).replace(/&lt;/gi,'<').replace(/&gt;/gi,'>').replace(/<BR>/ig, '\n').replace(/&#039;/gi,'\'').replace(/&quot;/gi,'"');		// cn: bug 13376 - leave &amp; to last to preserve certain HTML-entities for TinyMCE editor		descHtml = descHtml.replace(/&amp;/gi,'&');		tiny.setHTML(tinyHtml + descHtml);	}	var htmlDiv = document.getElementById('html_div');	// hide the HTML editor if this is Plain-text only	if((tinyHtml == '' || tinyHtml == '<br>') && htmlDiv.style.display == '') {		var desc = document.getElementById('description');		var plainText = new String(desc.value);		plainText = plainText.replace(/\n/gi, '<br />');		tiny.setHTML(plainText);		// cn: bug 6212		// if the template is plain-text, then uncheck "Send HTML Email"		document.getElementById('setEditor').checked = false;		setEditor();	}}if(typeof SugarClass == "object") {	SugarClass.inherit("EmailJsonObj","SugarClass");}function EmailJsonObj() {}EmailJsonObj.prototype.display = function(result) {	var bean;	var block = document.getElementById('template_attachments');	var target = block.innerHTML;	var full_file_path;	for(i in result) {		if(typeof result[i] == 'object') {			bean = result[i];			full_file_path = file_path + bean['id']+bean['filename'];			target += '\n<input type="hidden" name="template_attachment[]" value="' + bean['id'] + '">';			target += '\n<input type="checkbox" name="temp_remove_attachment[]" value="' + bean['id'] + '"> '+ lnk_remove + '&nbsp;&nbsp;';			target += '<a href="' + full_file_path + '"target="_blank">' + bean['filename'] + '</a><br>';		}	}	block.innerHTML = target;}ejo = new EmailJsonObj();////	END EMAIL TEMPLATE CODE///////////////////////////////////////////////////////////////////////////////function fill_form(type, error_text) {	if(document.getElementById('subjectfield').value == '') {		var sendAnyways = confirm(lbl_send_anyways);		if(sendAnyways == false) { return false; }	}	if(type == 'out' && document.EditView.to_addrs.value  == '' &&		document.EditView.cc_addrs.value  == '' &&		document.EditView.bcc_addrs.value  == '') {		alert(error_text);		return false;	}	var the_form = document.EditView;	var inputs = the_form.getElementsByTagName('input');	//  this detects if browser needs the following hack or not..	if(inputs.length > 0) {		// no need to appendChild to EditView to get file uploads to work		return check_form('EditView');	}	if(! check_form('EditView')) {		return false;	}	return true;}function setLabels(uploads_arr) {}//this function appends the selected email address to the aggregated email address fields.function set_current_parent(id,email,name,value) {	current_contact_id.value += id+";";	current_contact_email.value += email+";";	current_contact_name.value += name+";";	if(current_contact.value != '') {		current_contact.value += "; ";	}	current_contact.value += name + " <" + email + ">";//	current_contact.value += value;}function set_email_return(popup_reply_data) {	var form_name = popup_reply_data.form_name;	var name_to_value_array = popup_reply_data.name_to_value_array;	if (typeof name_to_value_array == "object" ) {		update_email_addresses(form_name,name_to_value_array);	} else {		for(var i in name_to_value_array) {			update_email_addresses(form_name,name_to_value_array[i]);		}	}}function update_email_addresses(form_name,name_to_value) {	for(var the_key in name_to_value) {		if(the_key == 'toJSON') {			/* just ignore */		} else {			var displayValue = name_to_value[the_key];			displayValue=displayValue.replace('&#039;',"'");  //restore escaped single quote.			displayValue=displayValue.replace('&amp;',"&");  //restore escaped &.			displayValue=displayValue.replace('&gt;',">");  //restore escaped >.			displayValue=displayValue.replace('&lt;',"<");  //restore escaped <.			displayValue=displayValue.replace('&quot; ',"\"");  //restore escaped ".			window.document.forms[form_name].elements[the_key].value += displayValue + '; ';		}	}}//create references to input fields associated with the select email address button.//Clicked button is passed as the parameter to the function.function button_change_onclick(obj) {	var prefix = 'to_';	if(obj.name.match(/^cc_/i)) {	    prefix = 'cc_';	} else if(obj.name.match(/^bcc_/i)) {		prefix = 'bcc_';	}	for(var i = 0; i < obj.form.length;i++) {		child = obj.form[i];		if(child.name.indexOf(prefix) != 0) {			continue;		}		if(child.name.match(/addrs_emails$/i)) {			current_contact_email = child;		} else if(child.name.match(/addrs_ids$/i)) {			current_contact_id = child;		} else if(child.name.match(/addrs_names$/i)) {			current_contact_name = child;		} else if(child.name.match(/addrs$/i)) {			current_contact = child;		}	}	var filter = '';	var acct_name = '';	if(document.EditView.parent_type.value  == 'Accounts' && typeof(document.EditView.parent_name.value) != 'undefined' && document.EditView.parent_name.value != '') {		filter = "&form_submit=false&query=true&html=Email_picker&account_name=" + escape(document.EditView.parent_name.value);		acct_name = document.EditView.parent_name.value;	}	var popup_request_data =	{		"call_back_function" : "set_email_return",		"form_name" : "EditView",		"field_to_name_array" :		{			"id" : prefix + "addrs_ids",			"email1" : prefix + "addrs_emails",			"name" : prefix + "addrs_names",			"email_and_name1" : prefix + "addrs_field"		}	};	return open_popup("Contacts", 600, 400, filter, true, false, popup_request_data, 'MultiSelect', false, 'popupdefsEmail');}//this function clear the value stored in the aggregated email address fields(nodes).//it relies on the references set by the button_change_onclick methodfunction clear_email_addresses() {	if(current_contact != '') {		current_contact.value = '';	}	if(current_contact_id != '') {		current_contact_id.value = '';	}	if(current_contact_email != '') {		current_contact_email.value = '';	}	if(current_contact_name != '') {		current_contact_name.value = '';	}}function quick_create_overlib(id, theme) {    return overlib('<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,"yes");\' onmouseout=\'unhiliteItem(this);\' href=\'index.php?module=Cases&action=EditView&inbound_email_id=' + id + '\'>' +            "<img border='0' src='themes/default/images/Cases.gif' style='margin-right:5px'>" + SUGAR.language.get('Emails', 'LBL_LIST_CASE') + '</a>' +            "<a style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' href='index.php?module=Leads&action=EditView&inbound_email_id=" + id + "'>" +                    "<img border='0' src='themes/default/images/Leads.gif' style='margin-right:5px'>"                    + SUGAR.language.get('Emails', 'LBL_LIST_LEAD') + "</a>" +             "<a style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' href='index.php?module=Contacts&action=EditView&inbound_email_id=" + id + "'>" +                    "<img border='0' src='themes/default/images/Contacts.gif' style='margin-right:5px'>"                    + SUGAR.language.get('Emails', 'LBL_LIST_CONTACT') + "</a>" +             "<a style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' href='index.php?module=Bugs&action=EditView&inbound_email_id=" + id + "'>"+                    "<img border='0' src='themes/default/images/Bugs.gif' style='margin-right:5px'>"                    + SUGAR.language.get('Emails', 'LBL_LIST_BUG') + "</a>" +             "<a style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' href='index.php?module=Tasks&action=EditView&inbound_email_id=" + id + "'>" +                    "<img border='0' src='themes/default/images/Tasks.gif' style='margin-right:5px'>"                   + SUGAR.language.get('Emails', 'LBL_LIST_TASK') + "</a>"            , CAPTION, SUGAR.language.get('Emails', 'LBL_QUICK_CREATE')            , STICKY, MOUSEOFF, 3000, CLOSETEXT, '<img border=0  style="margin-left:2px; margin-right: 2px;" src="themes/' + theme + '/images/close.gif">', WIDTH, 150, CLOSETITLE, SUGAR.language.get('app_strings', 'LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'), CLOSECLICK, FGCLASS, 'olOptionsFgClass',            CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass');}

⌨️ 快捷键说明

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