[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 /*+*********************************************************************************** 2 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 3 * ("License"); You may not use this file except in compliance with the License 4 * The Original Code is: vtiger CRM Open Source 5 * The Initial Developer of the Original Code is vtiger. 6 * Portions created by vtiger are Copyright (C) vtiger. 7 * All Rights Reserved. 8 *************************************************************************************/ 9 10 jQuery.Class("Vtiger_Helper_Js",{ 11 12 checkServerConfigResponseCache : '', 13 /* 14 * Function to get the instance of Mass edit of Email 15 */ 16 getEmailMassEditInstance : function(){ 17 18 var className = 'Emails_MassEdit_Js'; 19 var emailMassEditInstance = new window[className](); 20 return emailMassEditInstance 21 }, 22 /* 23 * function to check server Configuration 24 * returns boolean true or false 25 */ 26 27 checkServerConfig : function(module){ 28 var aDeferred = jQuery.Deferred(); 29 var actionParams = { 30 "action": 'CheckServerInfo', 31 'module' : module 32 }; 33 AppConnector.request(actionParams).then( 34 function(data) { 35 var state = false; 36 if(data.result){ 37 state = true; 38 } else { 39 state = false; 40 } 41 aDeferred.resolve(state); 42 } 43 ); 44 return aDeferred.promise(); 45 }, 46 /* 47 * Function to get Date Instance 48 * @params date---this is the field value 49 * @params dateFormat---user date format 50 * @return date object 51 */ 52 53 getDateInstance : function(dateTime,dateFormat){ 54 var dateTimeComponents = dateTime.split(" "); 55 var dateComponent = dateTimeComponents[0]; 56 var timeComponent = dateTimeComponents[1]; 57 var seconds = '00'; 58 59 var splittedDate = dateComponent.split("-"); 60 var splittedDateFormat = dateFormat.split("-"); 61 var year = splittedDate[splittedDateFormat.indexOf("yyyy")]; 62 var month = splittedDate[splittedDateFormat.indexOf("mm")]; 63 var date = splittedDate[splittedDateFormat.indexOf("dd")]; 64 var dateInstance = Date.parse(year+"-"+month+"-"+date); 65 if((year.length > 4) || (month.length > 2) || (date.length > 2) || (dateInstance == null)){ 66 var errorMsg = app.vtranslate("JS_INVALID_DATE"); 67 throw errorMsg; 68 } 69 70 //Before creating date object time is set to 00 71 //because as while calculating date object it depends system timezone 72 if(typeof timeComponent == "undefined"){ 73 timeComponent = '00:00:00'; 74 } 75 76 var timeSections = timeComponent.split(':'); 77 if(typeof timeSections[2] != 'undefined'){ 78 seconds = timeSections[2]; 79 } 80 81 //Am/Pm component exits 82 if(typeof dateTimeComponents[2] != 'undefined') { 83 timeComponent += ' ' + dateTimeComponents[2]; 84 if(dateTimeComponents[2].toLowerCase() == 'pm' && timeSections[0] != '12') { 85 timeSections[0] = parseInt(timeSections[0], 10) + 12; 86 } 87 88 if(dateTimeComponents[2].toLowerCase() == 'am' && timeSections[0] == '12') { 89 timeSections[0] = '00'; 90 } 91 } 92 93 month = month-1; 94 var dateInstance = new Date(year,month,date,timeSections[0],timeSections[1],seconds); 95 return dateInstance; 96 }, 97 requestToShowComposeEmailForm : function(selectedId,fieldname,fieldmodule){ 98 var selectedFields = new Array(); 99 selectedFields.push(fieldname); 100 var selectedIds = new Array(); 101 selectedIds.push(selectedId); 102 var params = { 103 'module' : 'Emails', 104 'fieldModule' : fieldmodule, 105 'selectedFields' : selectedFields, 106 'selected_ids' : selectedIds, 107 'view' : 'ComposeEmail' 108 } 109 var emailsMassEditInstance = Vtiger_Helper_Js.getEmailMassEditInstance(); 110 emailsMassEditInstance.showComposeEmailForm(params); 111 }, 112 113 /* 114 * Function to get the compose email popup 115 */ 116 getInternalMailer : function(selectedId,fieldname,fieldmodule){ 117 var module = 'Emails'; 118 var cacheResponse = Vtiger_Helper_Js.checkServerConfigResponseCache; 119 var checkServerConfigPostOperations = function (data) { 120 if(data == true){ 121 Vtiger_Helper_Js.requestToShowComposeEmailForm(selectedId,fieldname,fieldmodule); 122 } else { 123 alert(app.vtranslate('JS_EMAIL_SERVER_CONFIGURATION')); 124 } 125 } 126 if(cacheResponse === ''){ 127 var checkServerConfig = Vtiger_Helper_Js.checkServerConfig(module); 128 checkServerConfig.then(function(data){ 129 Vtiger_Helper_Js.checkServerConfigResponseCache = data; 130 checkServerConfigPostOperations(Vtiger_Helper_Js.checkServerConfigResponseCache); 131 }); 132 } else { 133 checkServerConfigPostOperations(Vtiger_Helper_Js.checkServerConfigResponseCache); 134 } 135 }, 136 137 /* 138 * Function to show the confirmation messagebox 139 */ 140 showConfirmationBox : function(data){ 141 var aDeferred = jQuery.Deferred(); 142 var bootBoxModal = bootbox.confirm(data['message'],app.vtranslate('LBL_NO'),app.vtranslate('LBL_YES'), function(result) { 143 if(result){ 144 aDeferred.resolve(); 145 } else{ 146 aDeferred.reject(); 147 } 148 }); 149 150 bootBoxModal.on('hidden',function(e){ 151 //In Case of multiple modal. like mass edit and quick create, if bootbox is shown and hidden , it will remove 152 // modal open 153 if(jQuery('#globalmodal').length > 0) { 154 // Mimic bootstrap modal action body state change 155 jQuery('body').addClass('modal-open'); 156 } 157 }) 158 return aDeferred.promise(); 159 }, 160 161 /* 162 * Function to check Duplication of Account Name 163 * returns boolean true or false 164 */ 165 166 checkDuplicateName : function(details) { 167 var accountName = details.accountName; 168 var recordId = details.recordId; 169 var aDeferred = jQuery.Deferred(); 170 var moduleName = details.moduleName; 171 if(typeof moduleName == "undefined"){ 172 moduleName = app.getModuleName(); 173 } 174 var params = { 175 'module' : moduleName, 176 'action' : "CheckDuplicate", 177 'accountname' : accountName, 178 'record' : recordId 179 } 180 AppConnector.request(params).then( 181 function(data) { 182 var response = data['result']; 183 var result = response['success']; 184 if(result == true) { 185 aDeferred.reject(response); 186 } else { 187 aDeferred.resolve(response); 188 } 189 }, 190 function(error,err){ 191 aDeferred.reject(); 192 } 193 ); 194 return aDeferred.promise(); 195 }, 196 197 showMessage : function(params){ 198 if(typeof params.type == "undefined"){ 199 params.type = 'info'; 200 } 201 params.animation = "show"; 202 params.title = app.vtranslate('JS_MESSAGE'), 203 Vtiger_Helper_Js.showPnotify(params); 204 }, 205 206 /* 207 * Function to show pnotify message 208 */ 209 showPnotify : function(customParams) { 210 211 var userParams = customParams; 212 if(typeof customParams == 'string') { 213 var userParams = {}; 214 userParams.text = customParams; 215 } 216 217 var params = { 218 sticker: false, 219 delay: '3000', 220 type: 'error', 221 pnotify_history: false 222 } 223 224 if(typeof userParams != 'undefined'){ 225 var params = jQuery.extend(params,userParams); 226 } 227 return jQuery.pnotify(params); 228 }, 229 230 /* 231 * Function to add clickoutside event on the element - By using outside events plugin 232 * @params element---On which element you want to apply the click outside event 233 * @params callbackFunction---This function will contain the actions triggered after clickoutside event 234 */ 235 addClickOutSideEvent : function(element, callbackFunction) { 236 element.one('clickoutside',callbackFunction); 237 }, 238 239 /* 240 * Function to show horizontal top scroll bar 241 */ 242 showHorizontalTopScrollBar : function() { 243 var container = jQuery('.contentsDiv'); 244 var topScroll = jQuery('.contents-topscroll',container); 245 var bottomScroll = jQuery('.contents-bottomscroll', container); 246 247 jQuery('.topscroll-div', container).css('width', jQuery('.bottomscroll-div', container).outerWidth()); 248 jQuery('.bottomscroll-div', container).css('width', jQuery('.topscroll-div', container).outerWidth()); 249 250 topScroll.scroll(function(){ 251 bottomScroll.scrollLeft(topScroll.scrollLeft()); 252 }); 253 254 bottomScroll.scroll(function(){ 255 topScroll.scrollLeft(bottomScroll.scrollLeft()); 256 }); 257 } 258 259 },{});
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |