From: Coleman Watts Date: Thu, 4 Jun 2015 02:56:57 +0000 (-0400) Subject: CRM-16555 - Cleanup billing block js X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bc44463aeecb9c04a4c5627c8ef98923125443e5;p=civicrm-core.git CRM-16555 - Cleanup billing block js --- diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index e6fea0842e..18e11131a8 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -312,6 +312,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP // Set title if ($this->_mode) { + CRM_Financial_Form_Payment::addCreditCardJs(); $this->setPageTitle($this->_ppID ? ts('Credit Card Pledge Payment') : ts('Credit Card Contribution')); } else { diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 52dc3f6adc..2350155c52 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -1419,15 +1419,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu break; } } - if (!$form->_snippet) { - // Add JS to show icons for the accepted credit cards - $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames(); - CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10) - // workaround for CRM-13634 - // ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes))); - ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';'); - } + CRM_Financial_Form_Payment::addCreditCardJs(); } $form->assign('paymentProcessorID', $form->_paymentProcessorID); } diff --git a/CRM/Financial/Form/Payment.php b/CRM/Financial/Form/Payment.php index 9d8ad34e6a..56ad9e158a 100644 --- a/CRM/Financial/Form/Payment.php +++ b/CRM/Financial/Form/Payment.php @@ -54,20 +54,25 @@ class CRM_Financial_Form_Payment extends CRM_Core_Form { //$payPalExpressId = ($values['payment_processor_type'] == 'PayPal_Express') ? $values['id'] : 0; // $this->assign('payPalExpressId', $payPalExpressId); - // Add JS to show icons for the accepted credit cards + self::addCreditCardJs(); + $this->assign('paymentProcessorID', $this->_paymentProcessorID); + } + + public function buildQuickForm() { + CRM_Core_Payment_ProcessorForm::buildQuickForm($this); + } + + /** + * Add JS to show icons for the accepted credit cards + */ + public static function addCreditCardJs() { $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames(); CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10) // workaround for CRM-13634 // ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes))); ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';'); - - $this->assign('paymentProcessorID', $this->_paymentProcessorID); - } - - public function buildQuickForm() { - CRM_Core_Payment_ProcessorForm::buildQuickForm($this); } } diff --git a/templates/CRM/Core/BillingBlock.js b/templates/CRM/Core/BillingBlock.js index dec4b6581f..bc06b0a457 100644 --- a/templates/CRM/Core/BillingBlock.js +++ b/templates/CRM/Core/BillingBlock.js @@ -76,7 +76,4 @@ civicrm_billingblock_creditcard_helper(); - $(function() { - $('#billing-payment-block').on('crmFormLoad', civicrm_billingblock_creditcard_helper); - }); })(CRM.$); diff --git a/templates/CRM/common/paymentBlock.tpl b/templates/CRM/common/paymentBlock.tpl index 54016083e4..7ee0301ed3 100644 --- a/templates/CRM/common/paymentBlock.tpl +++ b/templates/CRM/common/paymentBlock.tpl @@ -26,44 +26,37 @@ {literal} {/literal}