4,114
edits
No edit summary |
No edit summary Tag: Reverted |
||
Line 160: | Line 160: | ||
} | } | ||
// Function to check if filters are cleared and update visibility of community elements | |||
function checkFiltersCleared(selectors, communityElements) { | |||
selectors.forEach((selector, index) => { | |||
var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | |||
if (checkedFilters.length === 0) { | |||
console.log("All filters are cleared"); | |||
communityElements[index].show(); | |||
} else { | |||
console.log("Some filters are still active"); | |||
communityElements[index].hide(); | |||
} | |||
}); | |||
} | |||
// Event delegation for filter changes in block, list views, and their variations | // Event delegation for filter changes in block, list views, and their variations | ||
Line 186: | Line 185: | ||
}); | }); | ||
// Initial checks | |||
var selectors = ['#list', '#list-list', '#list-block-1', '#list-block-2', '#list-block-3', '#list-list-1', '#list-list-2', '#list-list-3']; | |||
var communityElements = [ | |||
$('#community-featured'), | |||
$('#community-featured-block-1'), | |||
$('#community-featured-block-2'), | |||
$('#community-featured-block-3'), | |||
$('#community-featured-list-1'), | |||
$('#community-featured-list-2'), | |||
$('#community-featured-list-3') | |||
]; | |||
// Initial | // Initial check on page load | ||
checkFiltersCleared(selectors, communityElements); | |||
// | // Check whenever a filter changes | ||
selectors.forEach(function( | selectors.forEach(selector => { | ||
$(selector).on('change', '.filtered-value-option input[type="checkbox"]', function() { | |||
checkFiltersCleared(selectors, communityElements); | |||
}); | |||
}); | }); | ||
// Function to check if all filters are cleared and return boolean | // Function to check if all filters are cleared and return boolean | ||
function areFiltersCleared(selector | function areFiltersCleared(selectors) { | ||
return selectors.every(selector => { | |||
var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | |||
return checkedFilters.length === 0; | |||
}); | |||
} | |||
// Function to open the modal and adjust the list | // Function to open the modal and adjust the list | ||
function openModal(cardElement, event) { | function openModal(cardElement, event) { |