From: Seamus Lee Date: Sat, 18 Feb 2017 22:57:07 +0000 (+1100) Subject: CRM-20052 get Billing Block js working as expeected on Drupal 8 as it does elsewhere X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e73ea57b9f5057e45a15cdc4f6ceb8ceccc761ad;p=civicrm-core.git CRM-20052 get Billing Block js working as expeected on Drupal 8 as it does elsewhere --- 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