1CRM.$(function($) { 2 if ($('#discountcode').length > 0) { 3 skipPaymentMethod(); 4 function showHidePayment(flag) { 5 $('.payment_options-group, div.payment_processor-section, #payment_information').toggle(!flag); 6 if (flag) { 7 // also unset selected payment methods 8 $('input[name="payment_processor"]').prop('checked', false); 9 } 10 } 11 12 /** 13 * Function copied from templates/CRM/Price/Form/Calculate.tpl - calculateTotalFee() (in case it gets changed somewhere along the way) 14 * This Calculates the total fee on CiviCRM 15 */ 16 function discountCalculateTotalFee() { 17 var totalFee = 0; 18 $('#priceset [price]').each(function () { 19 totalFee = totalFee + $(this).data('line_raw_total'); 20 }); 21 22 return totalFee; 23 } 24 25 function skipPaymentMethod() { 26 var flag = false; 27 $('.price-set-option-content input').each( function(){ 28 if (!$(this)[0].hasAttribute("data-amount")) return; 29 currentTotal = $(this).attr('data-amount').replace(/[^\/\d]/g,''); 30 if ($(this).is(':checked')) { 31 if (currentTotal == 0 ) { 32 flag = true; 33 } 34 else { 35 flag = false; 36 return false; 37 } 38 } 39 }); 40 $('.price-set-option-content input').change( function () { 41 if (discountCalculateTotalFee() == 0) { 42 flag = true; 43 } else { 44 flag = false; 45 } 46 showHidePayment(flag); 47 }); 48 showHidePayment(flag); 49 } 50 } 51});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.