CRM-18424 better amount label for repeat transactions
authoreileenmcnaugton <eileen@fuzion.co.nz>
Sun, 17 Apr 2016 12:49:43 +0000 (00:49 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Sun, 24 Apr 2016 20:33:43 +0000 (08:33 +1200)
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

templates/CRM/Contribute/Form/Contribution/Main.tpl
templates/CRM/Price/Form/Calculate.tpl

index b10db3f9ff2b715ad205c7b8db88c1de99f9c24b..50d1f356d03a79557c5ce0f1c9beec7c08daa2c8 100644 (file)
   {/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();
   }
 
   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 );
+      }
     }
     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( );
+      }
     }
   }
 
 
   CRM.$(function($) {
     enableHonorType();
-    showRecurHelp();
+    toggleRecur();
     skipPaymentMethod();
   });
 
index 2bb381f5968adfb02feb2e81b933606f6b6d9b08..e5a6b55c5ae26b435b3af79092ae2e702df0a6ef 100644 (file)
 
 {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>