4,114
edits
No edit summary |
No edit summary |
||
Line 172: | Line 172: | ||
}); | }); | ||
} | } | ||
// Function to check if filters are cleared for given selectors and update visibility of corresponding community elements | |||
function updateCommunityElementsVisibility(selectors, communityElements) { | |||
selectors.forEach((selector, index) => { | |||
var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | |||
console.log(`Checked filters count in ${selector}:`, checkedFilters.length); | |||
// If no filters are checked, show the community element associated with this selector | |||
if (checkedFilters.length === 0) { | |||
console.log(`All filters are cleared in ${selector}`); | |||
communityElements[index].show(); | |||
} else { | |||
console.log(`Some filters are still active in ${selector}`); | |||
communityElements[index].hide(); // Hide the community element if any filters are active | |||
} | |||
}); | |||
} | |||
// 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') | |||
]; | |||
// Call the function to initially set the visibility based on filters | |||
updateCommunityElementsVisibility(selectors, communityElements); | |||
// | // You can also call this function in response to filter changes or page events where filters might be modified | ||
$('#list, #list-block-1, #list-block-2, #list-block-3, #list-list-1, #list-list-2, #list-list-3').on('change', '.filtered-value-option input[type="checkbox"]', function() { | |||
updateCommunityElementsVisibility(selectors, communityElements); | |||
}); | |||
// 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) { | ||
Line 414: | Line 420: | ||
} | } | ||
// Function to check if all filters are cleared in block view | // Function to check if all filters are cleared in block view and its variations | ||
function checkBlockFiltersCleared() { | |||
var selectors = ['#list', '#list-block-1', '#list-block-2', '#list-block-3']; | |||
selectors.forEach(selector => { | |||
var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | |||
console.log(`Checked filters count in ${selector}:`, checkedFilters.length); | |||
if (checkedFilters.length === 0) { | |||
console.log(`All filters are cleared in ${selector}`); | |||
// Show all community elements related to block views | |||
$('#community-featured, #community-featured-block-1, #community-featured-block-2, #community-featured-block-3').show(); | |||
} else { | |||
console.log(`Some filters are still active in ${selector}`); | |||
// Hide all community elements related to block views | |||
$('#community-featured, #community-featured-block-1, #community-featured-block-2, #community-featured-block-3').hide(); | |||
} | |||
}); | |||
} | |||
// Function to check if all filters are cleared in list view and its variations | |||
function checkListFiltersCleared() { | |||
var selectors = ['#list-list', '#list-list-1', '#list-list-2', '#list-list-3']; | |||
selectors.forEach(selector => { | |||
var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | |||
console.log(`Checked filters count in ${selector}:`, checkedFilters.length); | |||
if (checkedFilters.length === 0) { | |||
console.log(`All filters are cleared in ${selector}`); | |||
// Show all community elements related to list views | |||
$('#community-featured, #community-featured-list-1, #community-featured-list-2, #community-featured-list-3').show(); | |||
} else { | |||
console.log(`Some filters are still active in ${selector}`); | |||
// Hide all community elements related to list views | |||
$('#community-featured, #community-featured-list-1, #community-featured-list-2, #community-featured-list-3').hide(); | |||
} | |||
}); | |||
} | |||
// closeModal function | // closeModal function |