[ 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 Vtiger_List_Js("Portal_List_Js",{ 10 11 getDefaultParams : function() { 12 var params = { 13 'module': app.getModuleName(), 14 'view' : 'List', 15 'page' : jQuery('#pageNumber').val(), 16 'orderby' : jQuery('#orderBy').val(), 17 'sortorder' : jQuery('#sortOrder').val(), 18 'search_value' : jQuery('#alphabetValue').val() 19 } 20 return params; 21 }, 22 23 editBookmark : function(params) { 24 AppConnector.request(params).then(function(data) { 25 var callBackFunction = function(data) { 26 Portal_List_Js.saveBookmark(); 27 }; 28 app.showModalWindow(data,function(data){ 29 if(typeof callBackFunction == 'function'){ 30 callBackFunction(data); 31 } 32 }); 33 }); 34 }, 35 36 saveBookmark : function() { 37 jQuery('#saveBookmark').on('submit',function(e){ 38 e.preventDefault(); 39 var form = jQuery(e.currentTarget); 40 var params = form.serializeFormData(); 41 if(params.bookmarkName == '' || params.bookmarkUrl == '') { 42 var data = { 43 title : app.vtranslate('JS_MESSAGE'), 44 text: 'Please enter all mandatory field', 45 animation: 'show', 46 type: 'error' 47 }; 48 Vtiger_Helper_Js.showPnotify(data); 49 return false; 50 } 51 AppConnector.request(params).then(function(data) { 52 if(data.success) { 53 var params = { 54 title : app.vtranslate('JS_MESSAGE'), 55 text: data.result.message, 56 animation: 'show', 57 type: 'success' 58 }; 59 Vtiger_Helper_Js.showPnotify(params); 60 var url = Portal_List_Js.getDefaultParams(); 61 Portal_List_Js.loadListViewContent(url); 62 } 63 }); 64 }); 65 }, 66 67 massDeleteRecords : function() { 68 var listInstance = Vtiger_List_Js.getInstance(); 69 var validationResult = listInstance.checkListRecordSelected(); 70 if(validationResult != true) { 71 var selectedIds = listInstance.readSelectedIds(true); 72 var excludedIds = listInstance.readExcludedIds(true); 73 var message = app.vtranslate('LBL_MASS_DELETE_CONFIRMATION'); 74 Vtiger_Helper_Js.showConfirmationBox({'message' : message}).then( 75 function(e) { 76 var deleteURL = 'index.php?module='+app.getModuleName()+'&action=MassDelete'; 77 deleteURL += '&selected_ids='+selectedIds+'&excluded_ids='+excludedIds; 78 var searchValue = listInstance.getAlphabetSearchValue(); 79 80 if((typeof searchValue != "undefined") && (searchValue.length > 0)) { 81 deleteURL += '&search_value='+searchValue; 82 } 83 AppConnector.request(deleteURL).then(function(data) { 84 if(data.success) { 85 var params = { 86 title : app.vtranslate('JS_MESSAGE'), 87 text: data.result.message, 88 animation: 'show', 89 type: 'error' 90 }; 91 Vtiger_Helper_Js.showPnotify(params); 92 var url = Portal_List_Js.getDefaultParams(); 93 Portal_List_Js.loadListViewContent(url); 94 } 95 }); 96 }); 97 } else { 98 listInstance.noRecordSelectedAlert(); 99 } 100 }, 101 102 loadListViewContent : function(url) { 103 var progressIndicatorElement = jQuery.progressIndicator({ 104 'position' : 'html', 105 'blockInfo' : { 106 'enabled' : true 107 } 108 }); 109 AppConnector.requestPjax(url).then(function(data) { 110 progressIndicatorElement.progressIndicator({ 111 'mode' : 'hide' 112 }); 113 jQuery('#listViewContents').html(data); 114 Portal_List_Js.updatePagination(); 115 }); 116 }, 117 118 updatePagination : function(){ 119 var previousPageExist = jQuery('#previousPageExist').val(); 120 var nextPageExist = jQuery('#nextPageExist').val(); 121 var previousPageButton = jQuery('#previousPageButton'); 122 var nextPageButton = jQuery('#nextPageButton'); 123 var listViewEntriesCount = parseInt(jQuery('#noOfEntries').val()); 124 var pageStartRange = parseInt(jQuery('#pageStartRange').val()); 125 var pageEndRange = parseInt(jQuery('#pageEndRange').val()); 126 var pages = jQuery('#totalPageCount').text(); 127 var totalNumberOfRecords = jQuery('.totalNumberOfRecords'); 128 var pageNumbersTextElem = jQuery('.pageNumbersText'); 129 var currentPage = parseInt(jQuery('#pageNumber').val()); 130 131 jQuery('#pageToJump').val(currentPage); 132 if(previousPageExist != ""){ 133 previousPageButton.removeAttr('disabled'); 134 } else if(previousPageExist == "") { 135 previousPageButton.attr("disabled","disabled"); 136 } 137 if((nextPageExist != "") && (pages >1)){ 138 nextPageButton.removeAttr('disabled'); 139 } else if((nextPageExist == "") || (pages == 1)) { 140 nextPageButton.attr("disabled","disabled"); 141 } 142 if(listViewEntriesCount != 0){ 143 var pageNumberText = pageStartRange+" "+app.vtranslate('to')+" "+pageEndRange; 144 pageNumbersTextElem.html(pageNumberText); 145 totalNumberOfRecords.removeClass('hide'); 146 } else { 147 pageNumbersTextElem.html("<span> </span>"); 148 if(!totalNumberOfRecords.hasClass('hide')){ 149 totalNumberOfRecords.addClass('hide'); 150 } 151 } 152 } 153 },{ 154 155 registerAddBookmark : function() { 156 jQuery('.addBookmark').on('click', function() { 157 var params = { 158 'module' : app.getModuleName(), 159 'parent' : app.getParentModuleName(), 160 'view' : 'EditAjax' 161 }; 162 Portal_List_Js.editBookmark(params); 163 }); 164 }, 165 166 registerEditBookmark : function() { 167 jQuery('.editRecord').live('click', function(e) { 168 e.stopPropagation(); 169 var currentTarget = jQuery(e.currentTarget); 170 var id = currentTarget.closest('.listViewEntries').data('id'); 171 var params = { 172 'module' : app.getModuleName(), 173 'parent' : app.getParentModuleName(), 174 'view' : 'EditAjax', 175 'record' : id 176 }; 177 Portal_List_Js.editBookmark(params); 178 }); 179 }, 180 181 registerDeleteBookmark : function() { 182 jQuery('.deleteRecord').live('click', function(e) { 183 e.stopPropagation(); 184 e.preventDefault(); 185 var currentTarget = jQuery(e.currentTarget); 186 var id = currentTarget.closest('.listViewEntries').data('id'); 187 var message = app.vtranslate('LBL_DELETE_CONFIRMATION'); 188 Vtiger_Helper_Js.showConfirmationBox({ 189 'message' : message 190 }).then(function(e) { 191 var params = { 192 'module' : app.getModuleName(), 193 'parent' : app.getParentModuleName(), 194 'action' : 'DeleteAjax', 195 'record' : id 196 }; 197 AppConnector.request(params).then(function(data) { 198 if(data.success) { 199 var params = { 200 title : app.vtranslate('JS_MESSAGE'), 201 text: data.result.message, 202 animation: 'show', 203 type: 'error' 204 }; 205 Vtiger_Helper_Js.showPnotify(params); 206 var url = Portal_List_Js.getDefaultParams(); 207 Portal_List_Js.loadListViewContent(url); 208 } 209 }); 210 }); 211 }); 212 }, 213 214 registerAlphabetSearch : function() { 215 jQuery('.portalAlphabetSearch').live('click', function(e) { 216 var currentTarget = jQuery(e.currentTarget); 217 var searchValue = currentTarget.find('a').attr('id'); 218 var url = Portal_List_Js.getDefaultParams(); 219 url['search_value'] = searchValue; 220 Portal_List_Js.loadListViewContent(url); 221 }) 222 }, 223 224 registerSortingEvent : function() { 225 jQuery('.portalListViewHeader').live('click', function(e) { 226 var currentTarget = jQuery(e.currentTarget); 227 var orderBy = currentTarget.attr('id'); 228 var sortOrder = currentTarget.data('nextsortorderval'); 229 var url = Portal_List_Js.getDefaultParams(); 230 url['orderby'] = orderBy; 231 url['sortorder'] = sortOrder; 232 Portal_List_Js.loadListViewContent(url); 233 }); 234 }, 235 236 registerPreviousPageEvent : function() { 237 jQuery('#previousPageButton').on('click', function(e) { 238 var currentPage = jQuery('#pageNumber').val(); 239 var previousPage = parseInt(currentPage) - 1; 240 if(previousPage < 1) 241 return false; 242 var url = Portal_List_Js.getDefaultParams(); 243 url['page'] = previousPage; 244 Portal_List_Js.loadListViewContent(url); 245 }); 246 }, 247 248 registerNextPageEvent : function() { 249 jQuery('#nextPageButton').on('click', function(e) { 250 var currentPage = jQuery('#pageNumber').val(); 251 var nextPage = parseInt(currentPage) + 1; 252 var totalPages = parseInt(jQuery('#totalPageCount').text()); 253 if(nextPage > totalPages) 254 return false; 255 var url = Portal_List_Js.getDefaultParams(); 256 url['page'] = nextPage; 257 Portal_List_Js.loadListViewContent(url); 258 }); 259 }, 260 261 registerRowClickEvent: function(){ 262 jQuery('.listViewEntries').live('click', function(e){ 263 if(jQuery(e.target, jQuery(e.currentTarget)).is('td:first-child')) return; 264 if(jQuery(e.target).is('input[type="checkbox"]')) return; 265 var elem = jQuery(e.currentTarget); 266 var recordUrl = elem.data('recordurl'); 267 if(typeof recordUrl == 'undefined') { 268 return; 269 } 270 window.location.href = recordUrl; 271 }); 272 }, 273 274 registerEvents : function(){ 275 this._super(); 276 this.registerAddBookmark(); 277 this.registerEditBookmark(); 278 this.registerDeleteBookmark(); 279 this.registerAlphabetSearch(); 280 this.registerSortingEvent(); 281 this.registerPreviousPageEvent(); 282 this.registerNextPageEvent(); 283 this.registerRowClickEvent(); 284 } 285 });
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 |