From: Laury GvR Date: Thu, 27 Dec 2018 15:36:09 +0000 (-0500) Subject: Improve efficiency of area map dropdown category selection X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=6ed7da01ae7ac6f9100c137496d2e574d191d32e;p=WP-Plugins%2Fglm-member-db.git Improve efficiency of area map dropdown category selection --- 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 (){