From 6ed7da01ae7ac6f9100c137496d2e574d191d32e Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Thu, 27 Dec 2018 10:36:09 -0500 Subject: [PATCH] Improve efficiency of area map dropdown category selection --- js/leaflet-area-map.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/js/leaflet-area-map.js b/js/leaflet-area-map.js index 32e11279..90c2a144 100644 --- a/js/leaflet-area-map.js +++ b/js/leaflet-area-map.js @@ -47,14 +47,9 @@ var GlmMap = { jQuery("#cat-main-close-" + category_id).click(function(){ jQuery("#cat-main-" + category_id).slideUp(GlmMap._catDivSpeed).parent().toggleClass("open"); }); - jQuery("#cat-main-" + category_id + " .catLabel input[type='checkbox']").click(function() { - var anySubCatSelected = false; - jQuery("#cat-main-" + category_id + " .catLabel input[type='checkbox']").each(function() { - if ($(this)[0].checked) { - anySubCatSelected = true; - } - }); - jQuery("#cat-" + category_id).toggleClass("selected", anySubCatSelected); + // While any checkbox of a given category is selected, preserve 'selected' class on that category's tab + $("#cat-main-" + category_id + " .catLabel input[type='checkbox']").on("click", function() { + $("#cat-" + category_id).toggleClass("selected", $("#cat-main-" + category_id + " input:checkbox:checked").length > 0); }); }); jQuery("#memLocHdr").click(function (){ -- 2.17.1