CRM-14882 - hide billing block for online contrib forms when total is zero. This...
authorDave Greenberg <dave@civicrm.org>
Wed, 18 Jun 2014 22:13:02 +0000 (15:13 -0700)
committerDave Greenberg <dave@civicrm.org>
Wed, 18 Jun 2014 22:13:02 +0000 (15:13 -0700)
----------------------------------------
* CRM-14882:
  https://issues.civicrm.org/jira/browse/CRM-14882

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

index f628a06837e4e9315ed2ea418e9d18e108af0a4f..4bd752e2aa35643bf2365cfce5a5054e34d8b089 100644 (file)
     }
     cj('#priceset input[type="radio"]').change(updatePriceSetHighlight);
     updatePriceSetHighlight();
+
+    function toggleBillingBlockIfFree(){
+       var total_amount_tmp =  $(this).data('raw-total'); 
+    // Hide billing questions if this is free
+           if(  total_amount_tmp == 0 ){
+               cj("#billing-payment-block").hide(); 
+           }else{
+               cj("#billing-payment-block").show(); 
+           }
+         }
+     CRM.$('#pricevalue').each( toggleBillingBlockIfFree);
+
+    $('#priceset input').on('change', function() {
+      CRM.$('#pricevalue').each( toggleBillingBlockIfFree);
+    });
   });
   {/literal}
 </script>
index 8f1d4fcf707ed517aa19347ae6bb87ec47590fec..f4273f4e8b85edf7b5adc5a13d71b4e4f5c4a2ba 100644 (file)
@@ -200,6 +200,7 @@ function display( totalfee ) {
     scriptfee   = totalfee;
     scriptarray = price;
     cj('#total_amount').val( totalfee );
+               cj('#pricevalue').data('raw-total', totalfee );
 
     ( totalfee < 0 ) ? cj('table#pricelabel').addClass('disabled') : cj('table#pricelabel').removeClass('disabled');
     if (typeof skipPaymentMethod == 'function') {