Merge remote branch 'canonical/master' into merge-forward
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution / Main.tpl
index ea79486c8ee2737c1300c928961b47ea0ccc7e78..8317871f15c05e538639417c1b7b9f0baef2e8cd 100644 (file)
   CRM.$(function($) {
     // highlight price sets
     function updatePriceSetHighlight() {
-      cj('#priceset .price-set-row').removeClass('highlight');
-      cj('#priceset .price-set-row input:checked').parent().parent().addClass('highlight');
+      cj('#priceset .price-set-row span').removeClass('highlight');
+      cj('#priceset .price-set-row input:checked').parent().addClass('highlight');
     }
     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(); 
+      }
+    }
+
+    $('#pricevalue').each(toggleBillingBlockIfFree).on('change', toggleBillingBlockIfFree);
   });
   {/literal}
 </script>