CRM-14737 - Search js - add comments and cleanup
authorColeman Watts <coleman@civicrm.org>
Wed, 4 Jun 2014 07:57:35 +0000 (08:57 +0100)
committerColeman Watts <coleman@civicrm.org>
Wed, 4 Jun 2014 07:57:35 +0000 (08:57 +0100)
js/crm.searchForm.js
templates/CRM/Contact/Form/Selector.tpl

index a89f8f6a6e39e73816b8fa75a77de1d4c5d10fec..d94ea93aa236c62d8812720cba7848a7e0b9eccc 100644 (file)
@@ -26,6 +26,7 @@
     return $(form).hasClass('crm-ajax-selection-form');
   }
 
+  // Use ajax to store selection server-side
   function phoneHome(single, $el, event) {
     var url = CRM.url('civicrm/ajax/markSelection');
     var params = {qfKey: 'civicrm search ' + $('input[name=qfKey]', form).val()};
       params.name = $el.attr('id');
     } else {
       params.variableType = 'multiple';
+      // "Reset all" button
       if ($el.is('a')) {
         event.preventDefault();
         $("input.select-row, input.select-rows", form).prop('checked', false).closest('tr').removeClass('crm-row-selected');
-      } else {
+      }
+      // Master checkbox
+      else {
         params.name = $('input.select-row').map(function() {return $(this).attr('id')}).get().join('-');
       }
     }
     .on('crmLoad', function(e) {
       if ($(e.target).is('#crm-container') || $(e.target).is('#crm-main-content-wrapper')) {
         clearTaskMenu();
-        selected = usesAjax() ? parseInt($('label[for*=ts_sel] span', form).text(), 10) : countCheckboxes();
+        if (usesAjax()) {
+          selected = parseInt($('label[for*=ts_sel] span', form).text(), 10);
+        } else {
+          selected = countCheckboxes();
+          displayCount();
+        }
         enableTaskMenu();
       }
     })
index 40cce12d2d86922faf65be0fc98990a5e2033e3f..4d5b3b3628fa94ed298e4691232a3718accda528 100644 (file)
 <script type="text/javascript">
   {literal}
   CRM.$(function($) {
+    // Clear any old selection that may be lingering in quickform
     $("input.select-row, input.select-rows", 'form.crm-search-form').prop('checked', false);
+    // Retrieve stored checkboxes
     var cids = {/literal}{$selectedContactIds|@json_encode}{literal};
     if (cids.length > 0) {
-      $('#mark_x_' + cids.join(',#mark_x_')).prop('checked', true).closest('tr').addClass('crm-row-selected');
-      $('input[name=radio_ts][value=ts_sel]').prop('checked', true);
+      $('#mark_x_' + cids.join(',#mark_x_') + ',input[name=radio_ts][value=ts_sel]').prop('checked', true);
     }
   });
 {/literal}