CRM-20052 get Billing Block js working as expeected on Drupal 8 as it does elsewhere
authorSeamus Lee <seamuslee001@gmail.com>
Sat, 18 Feb 2017 22:57:07 +0000 (09:57 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Sat, 18 Feb 2017 22:57:07 +0000 (09:57 +1100)
CRM/Financial/Form/Payment.php
templates/CRM/Core/BillingBlock.js

index dbb50070eb6292e665f479855cb288ec521d062b..8d4969ee4f8ac159be2e0af55dbb4e4871b23e83 100644 (file)
@@ -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');
   }
 
 }
index 4d75202f6eace2bd4af6bcfa75c20a0aabd789b8..5a6131118408f3f31dc56721a299bc104eb0f29d 100644 (file)
@@ -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 = '<a href="#" title="' + val + '" class="crm-credit_card_type-icon-' + key + '"><span>' + val + '</span></a>';
       $('.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