4,554
edits
No edit summary |
No edit summary |
||
Line 100: | Line 100: | ||
} | } | ||
// Function to check if all filters are cleared | |||
function | function checkFiltersCleared(selector, communityElement) { | ||
var checkedFilters = $(' | var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | ||
console.log("Checked filters count:", checkedFilters.length); | console.log("Checked filters count in " + selector + ":", checkedFilters.length); | ||
if (checkedFilters.length === 0) { | if (checkedFilters.length === 0) { | ||
console.log("All filters are cleared"); | console.log("All filters are cleared in " + selector); | ||
communityElement.show(); | |||
} else { | } else { | ||
console.log("Some filters are still active"); | console.log("Some filters are still active in " + selector); | ||
} | } | ||
} | } | ||
// Event delegation for filter changes | // 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() { | ||
setTimeout( | setTimeout(function() { checkFiltersCleared('#list', communityFeatured); }, 100); // Delay to allow for filter processing | ||
console.log("Filter change detected"); | console.log("Filter change detected in #list"); | ||
}); | }); | ||
// Initial | // Event delegation for filter changes in list view | ||
$('#list-list').on('change', '.filtered-value-option input[type="checkbox"]', function() { | |||
setTimeout(function() { checkFiltersCleared('#list-list', communityListFeatured); }, 100); // Delay to allow for filter processing | |||
console.log("Filter change detected in #list-list"); | |||
}); | |||
// Initial checks | |||
checkFiltersCleared('#list', communityFeatured); | |||
checkFiltersCleared('#list-list', communityListFeatured); | |||
// Function to open the modal and adjust the list | // Function to open the modal and adjust the list | ||
Line 157: | Line 143: | ||
// Hide communityFeatured | // Hide communityFeatured | ||
communityFeatured.hide(); | //communityFeatured.hide(); | ||
communityListFeatured.hide(); | //communityListFeatured.hide(); | ||
// Extract and handle the information from the cardElement | // Extract and handle the information from the cardElement | ||
Line 276: | Line 262: | ||
// Check if any filters are active | // Check if any filters are active | ||
// var areFiltersActive = $('#list-list .filtered-value-option input[type="checkbox"]:checked').length > 0; | |||
// Show communityFeatured only if no filters are active | // Show communityFeatured only if no filters are active | ||
if (!areFiltersActive) { | //if (!areFiltersActive) { | ||
communityFeatured.show(); | //communityFeatured.show(); | ||
communityListFeatured.show(); | //communityListFeatured.show(); | ||
} | //} | ||
} | } | ||