Template changes for Williams-Sonoma, Artera, and Instacart.
This commit is contained in:
@ -37,19 +37,19 @@
|
||||
function updateFilter(filterId) {
|
||||
const filterContainer = document.querySelector('#filter-dropdown-' + filterId);
|
||||
const label = document.querySelector('#filter-dropdown-' + filterId + ' .filter-value-label');
|
||||
|
||||
|
||||
if (filterContainer && label) {
|
||||
// Get category filter values
|
||||
const categorySelect = filterContainer.querySelector('select[name="category-filter"]');
|
||||
const categoryValues = categorySelect ? Array.from(categorySelect.selectedOptions).map(option => option.value) : [];
|
||||
|
||||
|
||||
// Get progress filter values
|
||||
const progressSelect = filterContainer.querySelector('select[name="progress-filter"]');
|
||||
const progressValues = progressSelect ? Array.from(progressSelect.selectedOptions).map(option => option.value) : [];
|
||||
|
||||
|
||||
// Calculate total selected count
|
||||
const totalSelected = categoryValues.length + progressValues.length;
|
||||
|
||||
|
||||
if (totalSelected === 0) {
|
||||
// Set language-specific "All" text
|
||||
const allTextEn = label.querySelector('.lang-en');
|
||||
@ -65,7 +65,7 @@
|
||||
const selectedText = lang === 'es' ? `${totalSelected} seleccionados` : `${totalSelected} selected`;
|
||||
label.textContent = selectedText;
|
||||
}
|
||||
|
||||
|
||||
// Fire custom event with both filter types
|
||||
const filterUpdateEvent = new CustomEvent('filterUpdate', {
|
||||
detail: {
|
||||
@ -74,14 +74,14 @@
|
||||
progressValues: progressValues
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
document.dispatchEvent(filterUpdateEvent);
|
||||
}
|
||||
}
|
||||
|
||||
function resetFilter(filterId) {
|
||||
const filterContainer = document.querySelector('#filter-dropdown-' + filterId);
|
||||
|
||||
|
||||
if (filterContainer) {
|
||||
// Reset category filter
|
||||
const categorySelect = filterContainer.querySelector('select[name="category-filter"]');
|
||||
@ -95,7 +95,7 @@
|
||||
Array.from(categoryDisplay).forEach(child => {
|
||||
child.remove();
|
||||
});
|
||||
|
||||
|
||||
// Reset progress filter
|
||||
const progressSelect = filterContainer.querySelector('select[name="progress-filter"]');
|
||||
if (progressSelect) {
|
||||
@ -108,7 +108,7 @@
|
||||
Array.from(progressDisplay).forEach(child => {
|
||||
child.remove();
|
||||
});
|
||||
|
||||
|
||||
// Update the filter to apply the reset
|
||||
updateFilter(filterId);
|
||||
}
|
||||
@ -162,4 +162,4 @@
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user