From 1cb61235ddfc46474537c9a567962f1747ebe71e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 4 Jun 2014 08:57:35 +0100 Subject: [PATCH] CRM-14737 - Search js - add comments and cleanup --- js/crm.searchForm.js | 13 +++++++++++-- templates/CRM/Contact/Form/Selector.tpl | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/js/crm.searchForm.js b/js/crm.searchForm.js index a89f8f6a6e..d94ea93aa2 100644 --- a/js/crm.searchForm.js +++ b/js/crm.searchForm.js @@ -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()}; @@ -37,10 +38,13 @@ 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('-'); } } @@ -59,7 +63,12 @@ .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(); } }) diff --git a/templates/CRM/Contact/Form/Selector.tpl b/templates/CRM/Contact/Form/Selector.tpl index 40cce12d2d..4d5b3b3628 100644 --- a/templates/CRM/Contact/Form/Selector.tpl +++ b/templates/CRM/Contact/Form/Selector.tpl @@ -147,11 +147,12 @@