[ 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("Settings_Vtiger_OutgoingServer_Js",{},{ 11 12 /* 13 * function to Save the Outgoing Server Details 14 */ 15 saveOutgoingDetails : function(form) { 16 var thisInstance = this; 17 var data = form.serializeFormData(); 18 var progressIndicatorElement = jQuery.progressIndicator({ 19 'position' : 'html', 20 'blockInfo' : { 21 'enabled' : true 22 } 23 }); 24 25 if(typeof data == 'undefined' ) { 26 data = {}; 27 } 28 data.module = app.getModuleName(); 29 data.parent = app.getParentModuleName(); 30 data.action = 'OutgoingServerSaveAjax'; 31 32 AppConnector.request(data).then( 33 function(data) { 34 if(data['success']) { 35 var OutgoingServerDetailUrl = form.data('detailUrl'); 36 //after save, load detail view contents and register events 37 thisInstance.loadContents(OutgoingServerDetailUrl).then( 38 function(data) { 39 thisInstance.registerDetailViewEvents(); 40 progressIndicatorElement.progressIndicator({'mode':'hide'}); 41 }, 42 function(error, err) { 43 progressIndicatorElement.progressIndicator({'mode':'hide'}); 44 } 45 ); 46 } else { 47 progressIndicatorElement.progressIndicator({'mode':'hide'}); 48 jQuery('.errorMessage', form).removeClass('hide'); 49 } 50 }, 51 function(error, errorThrown){ 52 } 53 ); 54 }, 55 56 /* 57 * function to load the contents from the url through pjax 58 */ 59 loadContents : function(url) { 60 var aDeferred = jQuery.Deferred(); 61 AppConnector.requestPjax(url).then( 62 function(data){ 63 jQuery('.contentsDiv').html(data); 64 aDeferred.resolve(data); 65 }, 66 function(error, err){ 67 aDeferred.reject(); 68 } 69 ); 70 return aDeferred.promise(); 71 }, 72 73 /* 74 * function to register the events in editView 75 */ 76 registerEditViewEvents : function() { 77 var thisInstance = this; 78 var form = jQuery('#OutgoingServerForm'); 79 var cancelLink = jQuery('.cancelLink', form); 80 81 //register validation engine 82 var params = app.validationEngineOptions; 83 params.onValidationComplete = function(form, valid){ 84 if(valid) { 85 thisInstance.saveOutgoingDetails(form); 86 return valid; 87 } 88 } 89 form.validationEngine(params); 90 91 form.submit(function(e) { 92 e.preventDefault(); 93 }) 94 95 //register click event for cancelLink 96 cancelLink.click(function(e) { 97 var OutgoingServerDetailUrl = form.data('detailUrl'); 98 var progressIndicatorElement = jQuery.progressIndicator({ 99 'position' : 'html', 100 'blockInfo' : { 101 'enabled' : true 102 } 103 }); 104 105 thisInstance.loadContents(OutgoingServerDetailUrl).then( 106 function(data) { 107 progressIndicatorElement.progressIndicator({'mode':'hide'}); 108 //after loading contents, register the events 109 thisInstance.registerDetailViewEvents(); 110 }, 111 function(error, err) { 112 progressIndicatorElement.progressIndicator({'mode':'hide'}); 113 } 114 ); 115 }) 116 }, 117 118 /* 119 * function to register the events in DetailView 120 */ 121 registerDetailViewEvents : function() { 122 var thisInstance = this; 123 //Detail view container 124 var container = jQuery('#OutgoingServerDetails'); 125 var editButton = jQuery('.editButton', container); 126 127 //register click event for edit button 128 editButton.click(function(e) { 129 var progressIndicatorElement = jQuery.progressIndicator({ 130 'position' : 'html', 131 'blockInfo' : { 132 'enabled' : true 133 } 134 }); 135 136 var url = editButton.data('url'); 137 thisInstance.loadContents(url).then( 138 function(data) { 139 //after load the contents register the edit view events 140 thisInstance.registerEditViewEvents(); 141 progressIndicatorElement.progressIndicator({'mode':'hide'}); 142 }, 143 function(error, err) { 144 progressIndicatorElement.progressIndicator({'mode':'hide'}); 145 } 146 ); 147 }); 148 }, 149 150 registerEvents: function() { 151 var thisInstance = this; 152 153 if(jQuery('#OutgoingServerForm').length > 0) { 154 thisInstance.registerEditViewEvents(); 155 } else { 156 thisInstance.registerDetailViewEvents(); 157 } 158 159 } 160 161 }); 162 163 jQuery(document).ready(function(e){ 164 var instance = new Settings_Vtiger_OutgoingServer_Js(); 165 instance.registerEvents(); 166 })
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 |