CRM-12994, js cleanup
authorkurund <kurund@civicrm.org>
Sat, 27 Jul 2013 20:00:22 +0000 (01:30 +0530)
committerkurund <kurund@civicrm.org>
Sat, 27 Jul 2013 20:00:22 +0000 (01:30 +0530)
----------------------------------------
* CRM-12994: Premiums Section disabled, yet asking for No Thank You Title
  http://issues.civicrm.org/jira/browse/CRM-12994

templates/CRM/Contribute/Form/ContributionPage/Premium.tpl

index 8eb2c2855d3bea5dc8bc7a42f65b7763a313c325..4e5df540e02e986bfa49e2cb6abc0a95c066919f 100644 (file)
     </tr>
   </table>
 
-  <div id="premiumSettings" class="crm-accordion-wrapper crm-plain_text_email-accordion collapsed">
-    <div class="crm-accordion-header">
-      {ts}Premiums Settings{/ts}
-    </div>
-    <div class="crm-accordion-body">
-
-      <table class="form-layout-compressed">
-        <tr class="crm-contribution-contributionpage-premium-form-block-premiums_intro_title">
-          <td class="label">
-            {$form.premiums_intro_title.label}
-            {if $action == 2}
-              {include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_premiums'
-              field='premiums_intro_title' id=$contributionPageID}
-            {/if}
-          </td>
-          <td class="html-adjust">{$form.premiums_intro_title.html}<br/>
-            <span class="description">{ts}Title to appear at the top of the Premiums section.{/ts}</span>
-          </td>
-        </tr>
-        <tr class="crm-contribution-contributionpage-premium-form-block-premiums_intro_text">
-          <td class="label">
-            {$form.premiums_intro_text.label}
-            {if $action == 2}
-              {include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_premiums'
-              field='premiums_intro_text' id=$contributionPageID}
-            {/if}
-          </td>
-          <td class="html-adjust">{$form.premiums_intro_text.html}<br/>
+  <div id="premiumSettings">
+    <div class="crm-accordion-wrapper crm-premium-settings-accordion collapsed">
+      <div class="crm-accordion-header">
+        {ts}Premiums Settings{/ts}
+      </div>
+      <div class="crm-accordion-body">
+        <table class="form-layout-compressed">
+          <tr class="crm-contribution-contributionpage-premium-form-block-premiums_intro_title">
+            <td class="label">
+              {$form.premiums_intro_title.label}
+              {if $action == 2}
+                {include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_premiums'
+                field='premiums_intro_title' id=$contributionPageID}
+              {/if}
+            </td>
+            <td class="html-adjust">{$form.premiums_intro_title.html}<br/>
+              <span class="description">{ts}Title to appear at the top of the Premiums section.{/ts}</span>
+            </td>
+          </tr>
+          <tr class="crm-contribution-contributionpage-premium-form-block-premiums_intro_text">
+            <td class="label">
+              {$form.premiums_intro_text.label}
+              {if $action == 2}
+                {include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_premiums'
+                field='premiums_intro_text' id=$contributionPageID}
+              {/if}
+            </td>
+            <td class="html-adjust">{$form.premiums_intro_text.html}<br/>
             <span class="description">
               {ts}Enter content for the introductory message. This will be displayed below the Premiums section title.
                 You may include HTML formatting tags. You can also include images, as long as they are already
                 uploaded to a server - reference them using complete URLs.{/ts}
             </span>
-          </td>
-        </tr>
-        <tr class="crm-contribution-contributionpage-premium-form-block-premiums_contact_email">
-          <td class="label">
-            {$form.premiums_contact_email.label}
-          </td>
-          <td class="html-adjust">{$form.premiums_contact_email.html}<br/>
+            </td>
+          </tr>
+          <tr class="crm-contribution-contributionpage-premium-form-block-premiums_contact_email">
+            <td class="label">
+              {$form.premiums_contact_email.label}
+            </td>
+            <td class="html-adjust">{$form.premiums_contact_email.html}<br/>
             <span class="description">
               {ts}This email address is included in automated contribution receipts if the contributor has selected
                 a premium. It should be an appropriate contact mailbox for inquiries about premium
                 fulfillment/shipping.{/ts}
             </span>
-          </td>
-        </tr>
-        <tr class="crm-contribution-contributionpage-premium-form-block-premiums_contact_phone">
-          <td class="label">
-            {$form.premiums_contact_phone.label}
-          </td>
-          <td class="html-adjust">{$form.premiums_contact_phone.html}<br/>
+            </td>
+          </tr>
+          <tr class="crm-contribution-contributionpage-premium-form-block-premiums_contact_phone">
+            <td class="label">
+              {$form.premiums_contact_phone.label}
+            </td>
+            <td class="html-adjust">{$form.premiums_contact_phone.html}<br/>
             <span class="description">
               {ts}This phone number is included in automated contribution receipts if the contributor has selected
                 a premium. It should be an appropriate phone number for inquiries about premium
                 fulfillment/shipping.{/ts}
             </span>
-          </td>
-        </tr>
-        <tr class="crm-contribution-contributionpage-premium-form-block-premiums_display_min_contribution">
-          <td class="label">
-            {$form.premiums_display_min_contribution.label}
-          </td>
-          <td class="html-adjust">{$form.premiums_display_min_contribution.html}<br/>
+            </td>
+          </tr>
+          <tr class="crm-contribution-contributionpage-premium-form-block-premiums_display_min_contribution">
+            <td class="label">
+              {$form.premiums_display_min_contribution.label}
+            </td>
+            <td class="html-adjust">{$form.premiums_display_min_contribution.html}<br/>
             <span class="description">
               {ts}Should the minimum contribution amount be automatically displayed after each premium description?{/ts}
             </span>
-          </td>
-        </tr>
-        <tr class="crm-contribution-contributionpage-premium-form-block-premiums_nothankyou_label">
-          <td class="label">
-            {$form.premiums_nothankyou_label.label}<span class="marker"> *</span>
-          </td>
-          <td class="html-adjust">{$form.premiums_nothankyou_label.html}<br/>
-            <span class="description">{ts}You can change the text for the 'No thank-you' radio button.{/ts}</span>
-          </td>
-        </tr>
-        <tr class="crm-contribution-contributionpage-premium-form-block-premiums_nothankyou_position">
-          <td class="label">
-            {$form.premiums_nothankyou_position.label}
-          </td>
-          <td class="html-adjust">{$form.premiums_nothankyou_position.html}<br/>
+            </td>
+          </tr>
+          <tr class="crm-contribution-contributionpage-premium-form-block-premiums_nothankyou_label">
+            <td class="label">
+              {$form.premiums_nothankyou_label.label}<span class="marker"> *</span>
+            </td>
+            <td class="html-adjust">{$form.premiums_nothankyou_label.html}<br/>
+              <span class="description">{ts}You can change the text for the 'No thank-you' radio button.{/ts}</span>
+            </td>
+          </tr>
+          <tr class="crm-contribution-contributionpage-premium-form-block-premiums_nothankyou_position">
+            <td class="label">
+              {$form.premiums_nothankyou_position.label}
+            </td>
+            <td class="html-adjust">{$form.premiums_nothankyou_position.html}<br/>
             <span class="description">
               {ts}Place the 'No thank-you' radio button before OR after the list of premiums offered on this page.{/ts}
             </span>
-          </td>
-        </tr>
-      </table>
+            </td>
+          </tr>
+        </table>
+      </div>
+      <!-- /.crm-accordion-body -->
     </div>
-    <!-- /.crm-accordion-body -->
-    {* Call Premiums tpl inside premiumSettings div to hide it on unchecking premiums_active checkbox*}
+    <!-- /.crm-accordion-wrapper -->
+
+    {* include premium product templates *}
     {include file="CRM/Contribute/Page/Premium.tpl"}
   </div>
-  <!-- /.crm-accordion-wrapper -->
 
   <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
 
     // bind click event to premiums_active checkbox
     cj('#premiums_active').click(function () {
-      // call function to show/hide Premium Settings div
-      premiumBlock(cj(this).prop('checked'));
+      premiumBlock();
     });
 
-    // show/hide Premium Settings div on page load
-    // depending on "Premiums Section Enabled?" checkbox's value
-    if (!cj('#premiums_active').is(':checked')) {
-      cj("#premiumSettings:not(.collapsed)").crmAccordionToggle();
+    // hide premium setting if premium block is not enabled
+    if (!cj('#premiums_active').prop('checked')) {
       cj('#premiumSettings').hide();
     }
-    else {
-      cj("#premiumSettings").crmAccordionToggle();
+  });
+
+  // function to show/hide premium settings
+  function premiumBlock() {
+    if (cj('#premiums_active').prop('checked')) {
       cj('#premiumSettings').show();
     }
-
-    // function to show/hide Premium Settings
-    function premiumBlock(checked) {
-      if (checked) {
-        cj("#premiumSettings").crmAccordionToggle();
-        cj('#premiumSettings').show();
-        return;
-      }
-      else {
-        cj("#premiumSettings:not(.collapsed)").crmAccordionToggle();
-        cj('#premiumSettings').hide();
-        return;
-      }
+    else {
+      cj('#premiumSettings').hide();
     }
-  });
+    return false;
+  }
+
   {/literal}
 </script>