/*+******************************************************************************** * The contents of this file are subject to the vtiger CRM Public License Version 1.0 * ("License"); You may not use this file except in compliance with the License * The Original Code is: vtiger CRM Open Source * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. ********************************************************************************/ function VTEmailTask($){ var vtinst = new VtigerWebservices("webservice.php"); var desc = null; var accessibleModulesInfo = null; //Display an error message. function errorDialog(message){ alert(message); } //This is a wrapper to handle webservice errors. function handleError(fn){ return function(status, result){ if(status){ fn(result); }else{ console.log('Failure:', result); } }; } //Insert text at the cursor function insertAtCursor(element, value){ //http://alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript if (document.selection) { element.focus(); var sel = document.selection.createRange(); sel.text = value; element.focus(); }else if (element.selectionStart || element.selectionStart == '0') { var startPos = element.selectionStart; var endPos = element.selectionEnd; var scrollTop = element.scrollTop; element.value = element.value.substring(0, startPos) + value + element.value.substring(endPos, element.value.length); element.focus(); element.selectionStart = startPos + value.length; element.selectionEnd = startPos + value.length; element.scrollTop = scrollTop; } else { element.value += value; element.focus(); } } //Convert user type into reference for consistency in describe objects //This is done inplace function referencify(desc){ var fields = desc['fields']; for(var i=0; i' + v + ''); }); select.chosen(); } $(document).ready(function(){ $('#btn_insert_variable').on('click',function(e) { insertTemplateField('templateVarContainer','([source]: ([module]) [destination])', true, true, { callback: function(text, param) { var textarea = CKEDITOR.instances.save_content; textarea.insertHtml(text); } } ); }); //Setup the validator validator.mandatoryFields.push('recepient'); validator.mandatoryFields.push('subject'); }); } /*function addPDFTemplate() { if(attachmentFiles == null) { attachmentFiles = {}; } var templateID = jQuery("#task-template").val(); if(templateID == "") return; attachmentFiles[templateID] = ["dummy", false]; repaintAttachments(); }*/ /* var Attachments = { addAttachment: function(id, title, filename, options) { if(typeof options == 'undefined') { options = {}; } if(typeof filename == 'undefined') { filename = title; } attachmentFiles[id] = [title, filename, options]; repaintAttachments(); } }*/ /*function removeAttachment(index) { attachmentFiles[index] = false; repaintAttachments(); }*/ /* function repaintAttachments() { var html = ""; var result = {}; jQuery.each(attachmentFiles, function(index, value) { if(value == false) return; if(typeof(value) == 'string') { value = [value, false]; } result[index] = value; if(typeof available_attachments[index] != 'undefined') { fileTitle = available_attachments[index]; } else { fileTitle = value[0]; } html += "
 " + fileTitle + "
"; }); jQuery("#mail_files").html(html); jQuery("#task-attachments").val(JSON.stringify(result)); } function selectDocumentsAttachment() { var popupInstance = Vtiger_Popup_Js.getInstance(); var params={}; params['module'] = 'Documents'; params['src_module'] = 'Workflow2'; popupInstance.show(params, function(responseString) { var file = jQuery.parseJSON(responseString); jQuery.each(file, function(index, value) { addDocumentAttachment(index, value.info.filename); }); console.log(responseString); }); } jQuery(function() { if(attachmentFiles != null) { repaintAttachments(); } });*/ vtEmailTask = VTEmailTask(jQuery); jQuery(function() { jQuery('#use_mailserver_from').on('change', function() { console.log(jQuery(this).prop('checked')); if(jQuery(this).prop('checked')) { jQuery('#from_row').hide(); } else { jQuery('#from_row').show(); } }); if(jQuery('#use_mailserver_from').prop('checked')) { jQuery('#use_mailserver_from').trigger('change'); } });