From 885fe21a4135cebdf4a5b7e9a6fd66aca6d3a34a Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sat, 21 Jun 2014 13:05:43 +1000 Subject: [PATCH] Fix select all checkbox behavior --- assets/js/admin/sportspress-admin.js | 34 +++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js index 5297a8ca..6a0a8858 100644 --- a/assets/js/admin/sportspress-admin.js +++ b/assets/js/admin/sportspress-admin.js @@ -49,22 +49,24 @@ jQuery(document).ready(function($){ filter += ".sp-filter-"+filterval; }); } - $panel = $(this).closest(".sp-tab-select").siblings(".sp-tab-panel") - $panel.find(".sp-post").hide(0, function() { - $(this).find("input").prop("disabled", true); - $(this).filter(filter).show(0, function() { - $(this).find("input").prop("disabled", false); + $panel = $(this).closest(".sp-tab-select").siblings(".sp-tab-panel"); + $panel.each(function() { + $(this).find(".sp-post").hide(0, function() { + $(this).find("input").prop("disabled", true); + $(this).filter(filter).show(0, function() { + $(this).find("input").prop("disabled", false); + }); }); + if($(this).find(".sp-post:visible").length > 0) { + $(this).find(".sp-select-all-container").show(); + $(this).find(".sp-show-all-container").show(); + $(this).find(".sp-not-found-container").hide(); + } else { + $(this).find(".sp-select-all-container").hide(); + $(this).find(".sp-show-all-container").hide(); + $(this).find(".sp-not-found-container").show(); + } }); - if($panel.find(".sp-post:visible").length > 0) { - $panel.find(".sp-select-all-container").show(); - $panel.find(".sp-show-all-container").show(); - $panel.find(".sp-not-found-container").hide(); - } else { - $panel.find(".sp-select-all-container").hide(); - $panel.find(".sp-show-all-container").hide(); - $panel.find(".sp-not-found-container").show(); - } }); // Trigger tab filter @@ -77,7 +79,7 @@ jQuery(document).ready(function($){ // Show all filter $(".sp-tab-panel").on("click", ".sp-show-all", function() { - $(this).closest("li").hide().siblings(".sp-post").show().find("input").prop("disabled", false); + $(this).closest("li").hide().siblings(".sp-post, .sp-select-all-container").show().find("input").prop("disabled", false); }); // Self-cloning @@ -231,7 +233,7 @@ jQuery(document).ready(function($){ // Check if all checkboxes are checked already $(".sp-select-all-range").on("checkCheck", function() { $(this).each(function() { - $(this).find(".sp-select-all").prop("checked", $(this).find("input[type=checkbox]:checked:not(.sp-select-all)").length == $(this).find("input[type=checkbox]:visible:not(.sp-select-all)").length); + $(this).find(".sp-select-all").prop("checked", $(this).find("input[type=checkbox]:checked:not(.sp-select-all)").length != 0 && $(this).find("input[type=checkbox]:checked:not(.sp-select-all)").length == $(this).find("input[type=checkbox]:visible:not(.sp-select-all)").length); }); });