From e73ea57b9f5057e45a15cdc4f6ceb8ceccc761ad Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 19 Feb 2017 09:57:07 +1100 Subject: [PATCH] CRM-20052 get Billing Block js working as expeected on Drupal 8 as it does elsewhere --- CRM/Financial/Form/Payment.php | 4 ++-- templates/CRM/Core/BillingBlock.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Financial/Form/Payment.php b/CRM/Financial/Form/Payment.php index dbb50070eb..8d4969ee4f 100644 --- a/CRM/Financial/Form/Payment.php +++ b/CRM/Financial/Form/Payment.php @@ -104,10 +104,10 @@ class CRM_Financial_Form_Payment extends CRM_Core_Form { $creditCards = CRM_Financial_BAO_PaymentProcessor::getCreditCards($paymentProcessorID); $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames($creditCards); CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10) + ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10, 'html-header', FALSE) // workaround for CRM-13634 // ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes))); - ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';'); + ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';', '-9999', 'html-header'); } } diff --git a/templates/CRM/Core/BillingBlock.js b/templates/CRM/Core/BillingBlock.js index 4d75202f6e..5a61311184 100644 --- a/templates/CRM/Core/BillingBlock.js +++ b/templates/CRM/Core/BillingBlock.js @@ -7,7 +7,7 @@ * Changes the icon depending on the credit card number. * Removes spaces and dashes from credit card numbers. */ - function civicrm_billingblock_creditcard_helper() { + $(function civicrm_billingblock_creditcard_helper() { $.each(CRM.config.creditCardTypes, function(key, val) { var html = '' + val + ''; $('.crm-credit_card_type-icons').append(html); @@ -37,7 +37,7 @@ civicrm_billingblock_set_card_type(ccnumber); }); - } + }); function civicrm_billingblock_set_card_type(ccnumber) { // Based on http://davidwalsh.name/validate-credit-cards -- 2.25.1