Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
2c4c49ca | 3 | | CiviCRM version 4.7 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
e7112fa7 | 5 | | Copyright CiviCRM LLC (c) 2004-2015 | |
6a488035 TO |
6 | +--------------------------------------------------------------------+ |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
9 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
10 | | under the terms of the GNU Affero General Public License | | |
11 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
12 | | | | |
13 | | CiviCRM is distributed in the hope that it will be useful, but | | |
14 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
16 | | See the GNU Affero General Public License for more details. | | |
17 | | | | |
18 | | You should have received a copy of the GNU Affero General Public | | |
19 | | License and the CiviCRM Licensing Exception along | | |
20 | | with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | *} | |
26 | {literal} | |
27 | <script type="text/javascript"> | |
28 | ||
bc44463a CW |
29 | CRM.$(function($) { |
30 | function buildPaymentBlock(type) { | |
79b237f9 | 31 | var $form = $('#billing-payment-block').closest('form'); |
1d1fee72 | 32 | {/literal} |
bc44463a CW |
33 | {if $contributionPageID} |
34 | {capture assign='contributionPageID'}id={$contributionPageID}&{/capture} | |
35 | {else} | |
36 | {capture assign='contributionPageID'}{/capture} | |
37 | {/if} | |
38 | {if $urlPathVar} | |
39 | {capture assign='urlPathVar'}{$urlPathVar}&{/capture} | |
40 | {else} | |
41 | {capture assign='urlPathVar'}{/capture} | |
42 | {/if} | |
1d1fee72 | 43 | {if $billing_profile_id} |
44 | {capture assign='profilePathVar'}billing_profile_id={$billing_profile_id}&{/capture} | |
45 | {else} | |
46 | {capture assign='profilePathVar'}{/capture} | |
47 | {/if} | |
bc44463a | 48 | |
1d1fee72 | 49 | var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="`$urlPathVar``$profilePathVar``$contributionPageID`processor_id="}" + type; |
bc44463a | 50 | {literal} |
064af727 | 51 | if (typeof(CRM.vars) != "undefined") { |
52 | if (typeof(CRM.vars.coreForm) != "undefined") { | |
53 | if (typeof(CRM.vars.coreForm.contact_id) != "undefined") { | |
54 | dataUrl = dataUrl + "&cid=" + CRM.vars.coreForm.contact_id; | |
55 | } | |
56 | ||
57 | if (typeof(CRM.vars.coreForm.checksum) != "undefined" ) { | |
58 | dataUrl = dataUrl + "&cs=" + CRM.vars.coreForm.checksum; | |
59 | } | |
60 | } | |
61 | } | |
62 | ||
79b237f9 CW |
63 | // Processors like pp-express will hide the form submit buttons, so re-show them when switching |
64 | $('.crm-submit-buttons', $form).show().find('input').prop('disabled', true); | |
bc44463a | 65 | CRM.loadPage(dataUrl, {target: '#billing-payment-block'}); |
6a488035 | 66 | } |
064af727 | 67 | |
ae8f569f | 68 | $('.crm-group.payment_options-group').show(); |
bc44463a CW |
69 | $('[name=payment_processor_id]').on('change.paymentBlock', function() { |
70 | buildPaymentBlock($(this).val()); | |
6a488035 | 71 | }); |
79b237f9 CW |
72 | $('#billing-payment-block').on('crmLoad', function() { |
73 | $('.crm-submit-buttons input').prop('disabled', false); | |
74 | }) | |
bc44463a | 75 | }); |
6a488035 TO |
76 | |
77 | </script> | |
78 | {/literal} |