Ian province abbreviation patch - issue 724
[civicrm-core.git] / templates / CRM / common / paymentBlock.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.7 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
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
29 CRM.$(function($) {
30 function buildPaymentBlock(type) {
31 var $form = $('#billing-payment-block').closest('form');
32
33 {/literal}{if !$isBillingAddressRequiredForPayLater}{literal}
34 if (type == 0) {
35 $("#billing-payment-block").html('');
36 return;
37 }
38 {/literal}{/if}
39
40 {if $contributionPageID}
41 {capture assign='contributionPageID'}id={$contributionPageID}&{/capture}
42 {else}
43 {capture assign='contributionPageID'}{/capture}
44 {/if}
45 {if $urlPathVar}
46 {capture assign='urlPathVar'}{$urlPathVar}&{/capture}
47 {else}
48 {capture assign='urlPathVar'}{/capture}
49 {/if}
50
51 var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="`$urlPathVar``$contributionPageID`processor_id="}" + type;
52 {literal}
53 if (typeof(CRM.vars) != "undefined") {
54 if (typeof(CRM.vars.coreForm) != "undefined") {
55 if (typeof(CRM.vars.coreForm.contact_id) != "undefined") {
56 dataUrl = dataUrl + "&cid=" + CRM.vars.coreForm.contact_id;
57 }
58
59 if (typeof(CRM.vars.coreForm.checksum) != "undefined" ) {
60 dataUrl = dataUrl + "&cs=" + CRM.vars.coreForm.checksum;
61 }
62 }
63 }
64
65 // Processors like pp-express will hide the form submit buttons, so re-show them when switching
66 $('.crm-submit-buttons', $form).show().find('input').prop('disabled', true);
67 CRM.loadPage(dataUrl, {target: '#billing-payment-block'});
68 }
69
70 $('.crm-group.payment_options-group').show();
71 $('[name=payment_processor_id]').on('change.paymentBlock', function() {
72 buildPaymentBlock($(this).val());
73 });
74 $('#billing-payment-block').on('crmLoad', function() {
75 $('.crm-submit-buttons input').prop('disabled', false);
76 })
77 });
78
79 </script>
80 {/literal}