[ 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 Settings_Vtiger_Index_Js("Settings_PBXManager_Index_Js", {},{ 11 12 /* 13 * function to Save the PBXManager Server Details 14 */ 15 saveAsteriskServerDetails : 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 = 'SaveAjax'; 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 progressIndicatorElement.progressIndicator({'mode':'hide'}); 40 thisInstance.registerDetailViewEvents(); 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 register the events in editView 58 */ 59 registerEditViewEvents : function() { 60 var thisInstance = this; 61 var form = jQuery('#MyModal'); 62 var cancelLink = jQuery('.cancelLink', form); 63 64 //To Auto-Generate Vtiger Secret Key 65 var url = 'index.php?module=PBXManager&parent=Settings&action=Gateway&mode=getSecretKey'; 66 AppConnector.request(url).then( 67 function(data) { 68 jQuery("input[name='vtigersecretkey']").attr("value",data.result); 69 } 70 ); 71 //END 72 73 //register validation engine 74 var params = app.validationEngineOptions; 75 params.onValidationComplete = function(form, valid){ 76 if(valid) { 77 thisInstance.saveAsteriskServerDetails(form); 78 return valid; 79 } 80 } 81 form.validationEngine(params); 82 //END 83 84 form.submit(function(e) { 85 e.preventDefault(); 86 }); 87 88 //register click event for cancelLink 89 cancelLink.click(function(e) { 90 var OutgoingServerDetailUrl = form.data('detailUrl'); 91 var progressIndicatorElement = jQuery.progressIndicator({ 92 'position' : 'html', 93 'blockInfo' : { 94 'enabled' : true 95 } 96 }); 97 98 thisInstance.loadContents(OutgoingServerDetailUrl).then( 99 function(data) { 100 progressIndicatorElement.progressIndicator({'mode':'hide'}); 101 //after loading contents, register the events 102 thisInstance.registerDetailViewEvents(); 103 }, 104 function(error, err) { 105 progressIndicatorElement.progressIndicator({'mode':'hide'}); 106 } 107 ); 108 }); 109 //END 110 }, 111 112 /* 113 * function to register the events in DetailView 114 */ 115 registerDetailViewEvents : function() { 116 var thisInstance = this; 117 //Detail view container 118 var container = jQuery('#AsteriskServerDetails'); 119 var editButton = jQuery('.editButton', container); 120 121 editButton.click(function(e){ 122 var url = jQuery(e.currentTarget).data('url'); 123 var progressIndicatorElement = jQuery.progressIndicator({ 124 'position' : 'html', 125 'blockInfo' : { 126 'enabled' : true 127 } 128 }); 129 130 thisInstance.loadContents(url).then( 131 function(data) { 132 //after load the contents register the edit view events 133 thisInstance.registerEditViewEvents(); 134 progressIndicatorElement.progressIndicator({'mode':'hide'}); 135 }, 136 function(error, err) { 137 progressIndicatorElement.progressIndicator({'mode':'hide'}); 138 } 139 ); 140 }); 141 }, 142 143 /* 144 * function to load the contents from the url through pjax 145 */ 146 loadContents : function(url) { 147 var aDeferred = jQuery.Deferred(); 148 AppConnector.requestPjax(url).then( 149 function(data){ 150 jQuery('.contentsDiv').html(data); 151 aDeferred.resolve(data); 152 }, 153 function(error, err){ 154 aDeferred.reject(); 155 } 156 ); 157 return aDeferred.promise(); 158 }, 159 160 // to Registering required Events on list view page load 161 registerEvents: function() { 162 var thisInstance = this; 163 thisInstance.registerDetailViewEvents(); 164 } 165 }); 166 167 jQuery(document).ready(function(e){ 168 var instance = new Settings_Vtiger_Index_Js(); 169 instance.registerEvents(); 170 }); 171
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 |