Skip to content

Commit

Permalink
CRM-18424 better amount label for repeat transactions
Browse files Browse the repository at this point in the history
Note that this patch also does some minor consolidation, bringing actions that relate to the is_recur checkbox into the same function.

I made the total_amount label always present, but sometimes hidden. this saves us having to check for it and also gives is a place to store data
consistently. We have been moving towards greater DOM consistency on payment pages
  • Loading branch information
eileenmcnaughton committed Apr 17, 2016
1 parent bf15c19 commit 308bcf1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 36 deletions.
50 changes: 19 additions & 31 deletions templates/CRM/Contribute/Form/Contribution/Main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -300,32 +300,6 @@
{/if}

{literal}
if ({/literal}"{$form.is_recur}"{literal}) {
if (document.getElementsByName("is_recur")[0].checked == true) {
window.onload = function() {
enablePeriod();
}
}
}

function enablePeriod ( ) {
var frqInt = {/literal}"{$form.frequency_interval}"{literal};
if ( document.getElementsByName("is_recur")[0].checked == true ) {
//get back to auto renew settings.
var allowAutoRenew = {/literal}'{$allowAutoRenewMembership}'{literal};
if ( allowAutoRenew && cj("#auto_renew") ) {
showHideAutoRenew( null );
}
}
else {
//disabled auto renew settings.
var allowAutoRenew = {/literal}'{$allowAutoRenewMembership}'{literal};
if ( allowAutoRenew && cj("#auto_renew") ) {
cj("#auto_renew").prop('checked', false );
cj('#allow_auto_renew').hide( );
}
}
}

cj('input[name="soft_credit_type_id"]').on('change', function() {
enableHonorType();
Expand All @@ -342,16 +316,30 @@
}

cj('input[id="is_recur"]').on('change', function() {
showRecurHelp();
toggleRecur();
});

function showRecurHelp( ) {
var showHelp = cj('input[id="is_recur"]:checked');
if ( showHelp.val() > 0) {
function toggleRecur( ) {
var isRecur = cj('input[id="is_recur"]:checked');
var allowAutoRenew = {/literal}'{$allowAutoRenewMembership}'{literal};
if (isRecur.val() > 0) {
cj('#recurHelp').show();
cj('#amount_sum_label').text(ts('Regular amount'));
//get back to auto renew settings.
if ( allowAutoRenew && cj("#auto_renew") ) {
showHideAutoRenew( null );
}
cj('amount_sum_label').data('is_repeat', TRUE);
}
else {
cj('#recurHelp').hide();
cj('#amount_sum_label').text(ts('Total amount'));
//disabled auto renew settings.
if ( allowAutoRenew && cj("#auto_renew") ) {
cj("#auto_renew").prop('checked', false );
cj('#allow_auto_renew').hide( );
}
cj('amount_sum_label').data('is_repeat', FALSE);
}
}

Expand Down Expand Up @@ -381,7 +369,7 @@

CRM.$(function($) {
enableHonorType();
showRecurHelp();
toggleRecur();
skipPaymentMethod();
});

Expand Down
9 changes: 4 additions & 5 deletions templates/CRM/Price/Form/Calculate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@

{assign var='hideTotal' value=$quickConfig+$noCalcValueDisplay}
<div id="pricesetTotal" class="crm-section section-pricesetTotal">
{if !$hideTotal}
<div class="label" id="pricelabel">
<div class="label
{if $hideTotal}, hiddenElement{/if}" id="pricelabel">
<label>
{if ( $extends eq 'Contribution' ) || ( $extends eq 'Membership' )}
{ts}Total Amount{/ts}{else}{ts}Total Fee(s){/ts}
{if $isAdditionalParticipants} {ts}for this participant{/ts}{/if}
<span id='amount_sum_label'>{ts}Total Amount{/ts}{else}{ts}Total Fee(s){/ts}</span>
{if $isAdditionalParticipants} {ts}for this participant{/ts}{/if}
{/if}
</label>
</div>
{/if}
<div class="content calc-value" {if $hideTotal}style="display:none;"{/if} id="pricevalue" ></div>
</div>

Expand Down

0 comments on commit 308bcf1

Please sign in to comment.