Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2014-10-14-11-24-52
[civicrm-core.git] / templates / CRM / Contribute / Form / Contribution / Main.tpl
index f7a4add18fe19b399309aa3a0d2fc5596b1ca1d7..4a64c72409368facb2a4cd1b364391f75a87a54d 100644 (file)
         {$form.frequency_unit.html}
       {/if}
       {if $is_recur_installments}
+        <span id="recur_installments_num">
         {ts}for{/ts} {$form.installments.html} {$form.installments.label}
+        </span>
       {/if}
+      <div id="recurHelp" class="description">
+                               {ts}Your recurring contribution will be processed automatically.{/ts}
+                               {if $is_recur_installments}
+                                       {ts}You can specify the number of installments, or you can leave the number of installments blank if you want to make an open-ended commitment. In either case, you can choose to cancel at any time.{/ts}
+                               {/if}
+        {if $is_email_receipt}
+          {ts}You will receive an email receipt for each recurring contribution.{/ts}
+        {/if}
+      </div>
     </div>
     <div class="clear"></div>
   </div>
 
   <div id="billing-payment-block">
     {* If we have a payment processor, load it - otherwise it happens via ajax *}
-    {if $ppType}
+    {if $ppType or $isBillingAddressRequiredForPayLater}
       {include file="CRM/Contribute/Form/Contribution/Main.tpl" snippet=4}
     {/if}
   </div>
   {elseif $onBehalfRequired}
     showOnBehalf(true);
   {/if}
-
-  {if $honor_block_is_active AND $form.soft_credit_type_id.html}
-    enableHonorType();
-  {/if}
   {literal}
 
+       cj('input[name="soft_credit_type_id"]').on('change', function() {
+               enableHonorType();
+       });
+       
   function enableHonorType( ) {
-    var element = document.getElementsByName("soft_credit_type_id");
-    for (var i = 0; i < element.length; i++ ) {
-      var isHonor = false;
-      if ( element[i].checked == true ) {
-        var isHonor = true;
-        break;
-      }
-    }
-    if ( isHonor ) {
+    var selectedValue = cj('input[name="soft_credit_type_id"]:checked'); 
+    if ( selectedValue.val() > 0) {
       cj('#honorType').show();
-      cj('#honorTypeEmail').show();
     }
     else {
       cj('#honorType').hide();
-      cj('#honorTypeEmail').hide();
     }
   }
 
+       cj('input[id="is_recur"]').on('change', function() {
+               showRecurHelp();
+       });
+
+  function showRecurHelp( ) {
+    var showHelp = cj('input[id="is_recur"]:checked'); 
+    if ( showHelp.val() > 0) {
+      cj('#recurHelp').show();
+    }
+    else {
+      cj('#recurHelp').hide();
+    }
+  }
+       
   function pcpAnonymous( ) {
     // clear nickname field if anonymous is true
     if (document.getElementsByName("pcp_is_anonymous")[1].checked) {
 
   CRM.$(function($) {
     toggleConfirmButton();
+               enableHonorType();
+               showRecurHelp();
   });
 
   function showHidePayPalExpressOption() {
   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();
+        cj(".payment_options-group").hide();  
+      } 
+      else {
+        cj("#billing-payment-block").show();
+        cj(".payment_options-group").show(); 
+      }
+    }
+
+    $('#pricevalue').each(toggleBillingBlockIfFree).on('change', toggleBillingBlockIfFree);
   });
   {/literal}
 </script>