From 7d3c3387dc8c27af73efbba826fee70e81cd6e84 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 19 Feb 2017 10:01:22 +1100 Subject: [PATCH] Minor Fix following testing on d7 --- templates/CRM/Core/BillingBlock.js | 48 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/templates/CRM/Core/BillingBlock.js b/templates/CRM/Core/BillingBlock.js index 5a61311184..e170975ac8 100644 --- a/templates/CRM/Core/BillingBlock.js +++ b/templates/CRM/Core/BillingBlock.js @@ -7,37 +7,39 @@ * Changes the icon depending on the credit card number. * Removes spaces and dashes from credit card numbers. */ - $(function civicrm_billingblock_creditcard_helper() { - $.each(CRM.config.creditCardTypes, function(key, val) { - var html = '' + val + ''; - $('.crm-credit_card_type-icons').append(html); + function civicrm_billingblock_creditcard_helper() { + $(function() { + $.each(CRM.config.creditCardTypes, function(key, val) { + var html = '' + val + ''; + $('.crm-credit_card_type-icons').append(html); - $('.crm-credit_card_type-icon-' + key).click(function() { - $('#credit_card_type').val(val); - $('.crm-container .credit_card_type-section a').css('opacity', 0.25); - $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 1); - return false; + $('.crm-credit_card_type-icon-' + key).click(function() { + $('#credit_card_type').val(val); + $('.crm-container .credit_card_type-section a').css('opacity', 0.25); + $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 1); + return false; + }); }); - }); - // Hide the CC type field (redundant) - $('#credit_card_type, .label', '.crm-container .credit_card_type-section').hide(); + // Hide the CC type field (redundant) + $('#credit_card_type, .label', '.crm-container .credit_card_type-section').hide(); - // Select according to the number entered - $('.crm-container input#credit_card_number').change(function() { - var ccnumber = cj(this).val(); + // Select according to the number entered + $('.crm-container input#credit_card_number').change(function() { + var ccnumber = cj(this).val(); - // Remove spaces and dashes - ccnumber = ccnumber.replace(/[- ]/g, ''); - cj(this).val(ccnumber); + // Remove spaces and dashes + ccnumber = ccnumber.replace(/[- ]/g, ''); + cj(this).val(ccnumber); - // Semi-hide all images, we will un-hide the right one afterwards - $('.crm-container .credit_card_type-section a').css('opacity', 0.25); - $('#credit_card_type').val(''); + // Semi-hide all images, we will un-hide the right one afterwards + $('.crm-container .credit_card_type-section a').css('opacity', 0.25); + $('#credit_card_type').val(''); - civicrm_billingblock_set_card_type(ccnumber); + civicrm_billingblock_set_card_type(ccnumber); + }); }); - }); + } function civicrm_billingblock_set_card_type(ccnumber) { // Based on http://davidwalsh.name/validate-credit-cards -- 2.25.1