4,554
edits
No edit summary Tag: Reverted |
No edit summary Tag: Manual revert |
||
Line 108: | Line 108: | ||
} | } | ||
// Function to check if filters are cleared and update visibility of community elements | |||
function checkFiltersCleared(selector, communityElement) { | |||
var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | ||
console.log("Checked filters count in " + selector + ":", checkedFilters.length); | |||
if (checkedFilters.length === 0) { | if (checkedFilters.length === 0) { | ||
console.log("All filters are cleared in " + selector); | |||
communityElement.show(); | |||
} else { | } else { | ||
communityElement.hide(); | console.log("Some filters are still active in " + selector); | ||
communityElement.hide(); // Hide the element if any filters are active | |||
} | } | ||
} | } | ||
// Event delegation for filter changes in block view | // Event delegation for filter changes in block view | ||
$('#list').on('change', '.filtered-value-option input[type="checkbox"]', function() { | $('#list').on('change', '.filtered-value-option input[type="checkbox"]', function() { | ||
checkFiltersCleared('#list', communityFeatured | checkFiltersCleared('#list', communityFeatured); // Call the function directly without delay | ||
}); | }); | ||
// Event delegation for filter changes in list view | // Event delegation for filter changes in list view | ||
$('#list-list').on('change', '.filtered-value-option input[type="checkbox"]', function() { | $('#list-list').on('change', '.filtered-value-option input[type="checkbox"]', function() { | ||
checkFiltersCleared('#list-list', communityListFeatured | checkFiltersCleared('#list-list', communityListFeatured); // Call the function directly without delay | ||
}); | }); | ||