[ 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_Popup_Js("Product_PriceBooks_Popup_Js",{ 10 11 },{ 12 /** 13 * Function to register event for enabling list price 14 */ 15 checkBoxChangeHandler : function(e){ 16 this._super(e); 17 var elem = jQuery(e.currentTarget); 18 var parentRow = elem.closest('tr'); 19 if(elem.is(':checked')) { 20 jQuery('input[name=listPrice]',parentRow).removeClass('invisible'); 21 }else{ 22 jQuery('input[name=listPrice]',parentRow).addClass('invisible'); 23 } 24 }, 25 26 /** 27 * Function to register event for add to pricebook button in the popup 28 */ 29 30 registerSelectButton : function(){ 31 var popupPageContentsContainer = jQuery('#popupPage'); 32 var thisInstance = this; 33 popupPageContentsContainer.on('jqv.form.result', function(e){ 34 e.preventDefault(); 35 var tableEntriesElement = popupPageContentsContainer.find('table.listViewEntriesTable'); 36 var selectedRecords = jQuery('input.entryCheckBox', tableEntriesElement).filter(':checked'); 37 if((selectedRecords.length) == 0){ 38 var message = app.vtranslate("JS_PLEASE_SELECT_ONE_RECORD"); 39 bootbox.alert(message); 40 return; 41 } 42 var invalidFields = popupPageContentsContainer.data('jqv').InvalidFields; 43 if((invalidFields.length) == 0){ 44 var selectedRecordDetails = new Array(); 45 selectedRecords.each(function(index, checkBoxElement){ 46 var checkBoxJqueryObject = jQuery(checkBoxElement) 47 var row = checkBoxJqueryObject.closest('tr'); 48 var rowListPrice = row.find('input[name=listPrice]'); 49 var listPrice = rowListPrice.val(); 50 var id = row.data('id'); 51 selectedRecordDetails.push({'id' : id,'price' : listPrice}); 52 }); 53 thisInstance.done(selectedRecordDetails, thisInstance.getEventName()); 54 } 55 56 }); 57 }, 58 /** 59 * Function to handle select all in the popup 60 */ 61 62 selectAllHandler : function(e){ 63 this._super(e); 64 var currentElement = jQuery(e.currentTarget); 65 var isMainCheckBoxChecked = currentElement.is(':checked'); 66 var tableElement = currentElement.closest('table'); 67 if(isMainCheckBoxChecked) { 68 jQuery('input.entryCheckBox', tableElement).closest('tr').find('input[name="listPrice"]').removeClass('invisible'); 69 }else { 70 jQuery('input.entryCheckBox', tableElement).closest('tr').find('input[name="listPrice"]').addClass('invisible'); 71 } 72 }, 73 74 /** 75 * Function to register event for actions buttons 76 */ 77 registerEventForActionsButtons : function(){ 78 var thisInstance = this; 79 var popupPageContentsContainer = this.getPopupPageContainer(); 80 popupPageContentsContainer.on('click','a.cancelLink',function(e){ 81 thisInstance.done(); 82 }) 83 }, 84 85 /** 86 * Function to get Page Records 87 */ 88 getPageRecords : function(params){ 89 var thisInstance = this; 90 var aDeferred = jQuery.Deferred(); 91 this._super(params).then( 92 function(data){ 93 thisInstance.popupSlimScroll(); 94 var form = jQuery('#popupPage'); 95 form.validationEngine('detach'); 96 form.validationEngine('attach'); 97 aDeferred.resolve(data); 98 }, 99 100 function(textStatus, errorThrown){ 101 aDeferred.reject(textStatus, errorThrown); 102 } 103 ); 104 return aDeferred.promise(); 105 }, 106 107 /** 108 * Function to handle sort 109 */ 110 sortHandler : function(headerElement){ 111 var thisInstance = this; 112 //Listprice column should not be sorted so checking for class noSorting 113 if(headerElement.hasClass('noSorting')){ 114 return; 115 } 116 this._super(headerElement).then( 117 function(data){ 118 thisInstance.popupSlimScroll(); 119 var form = jQuery('#popupPage'); 120 form.validationEngine('detach'); 121 form.validationEngine('attach'); 122 }, 123 124 function(textStatus, errorThrown){ 125 126 } 127 ); 128 }, 129 130 /** 131 * Function to handle slim scroll for popup 132 */ 133 popupSlimScroll : function(){ 134 var popupPageContentsContainer = this.getPopupPageContainer(); 135 var element = popupPageContentsContainer.find('.popupEntriesDiv'); 136 app.showScrollBar(element, {"height" : '400px'}); 137 }, 138 139 /** 140 * Function which will register event when user clicks on the row 141 */ 142 registerEventForListViewEntries : function() { 143 //To Make sure we will not close the window once he clicks on the row, 144 //which is default behaviour in normal popup 145 return true; 146 }, 147 148 registerEventForListViewEntries : function(){ 149 var popupPageContentsContainer = this.getPopupPageContainer(); 150 popupPageContentsContainer.on('click','.listViewEntries',function(e){ 151 return; 152 }); 153 }, 154 155 /** 156 * Function to register events 157 */ 158 registerEvents : function(){ 159 this._super(); 160 this.registerEventForActionsButtons(); 161 this.popupSlimScroll(); 162 jQuery('#popupPage').validationEngine({promptPosition : "topRight"}); 163 } 164 });
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 |