/********************************************************************************* * SugarCRM Community Edition is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero 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 Affero General Public License for more * details. * * You should have received a copy of the GNU Affero 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 Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero 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". ********************************************************************************/ var focus_obj = false; var label = SUGAR.language.get('app_strings', 'LBL_DEFAULT_LINK_TEXT'); function remember_place(obj) { focus_obj = obj; } function showVariable() { document.EditView.variable_text.value = document.EditView.variable_name.options[document.EditView.variable_name.selectedIndex].value; } function addVariables(the_select,the_module) { the_select.options.length = 0; for(var i=0;i]+>/gi, ''); } } /* * this function will insert variables into text area */ function insert_variable_text(myField, myValue) { //IE support if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } /* * This function inserts variables into a TinyMCE instance */ function insert_variable_html(text) { var inst = tinyMCE.getInstanceById("body_text"); if (inst) inst.getWin().focus(); //var html = inst.getContent(true); //inst.setContent(html + text); inst.execCommand('mceInsertRawHTML', false, text); } function insert_variable_html_link(text) { the_label = document.getElementById('url_text').value; if(typeof(the_label) =='undefined'){ the_label = label; } //remove surounding parenthesis around the label if(the_label[0] == '{' && the_label[the_label.length-1] == '}'){ the_label = the_label.substring(1,the_label.length-1); } var thelink = " "+the_label+" "; insert_variable_html(thelink); } /* * this function will check to see if text only flag has been checked. * If so, the it will call the text insert function, if not, then it * will call the html (tinyMCE eidtor) insert function */ function insert_variable(text) { //if text only flag is checked, then insert into text field if(document.getElementById('toggle_textonly').checked == true){ //use text version insert insert_variable_text(document.getElementById('body_text_plain'), text) ; }else{ //use html version insert insert_variable_html(text) ; } }