4,554
edits
No edit summary |
No edit summary Tag: Reverted |
||
Line 108: | Line 108: | ||
} | } | ||
// Function to check if filters are cleared | // Function to check if filters are cleared | ||
function checkFiltersCleared(selector, communityElement) { | function checkFiltersCleared(selector, communityElement, positionSelector, positionIndex) { | ||
var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | var checkedFilters = $(selector + ' .filtered-value-option input[type="checkbox"]:checked'); | ||
if (checkedFilters.length === 0) { | if (checkedFilters.length === 0) { | ||
positionAndShowCommunityElement(communityElement, positionSelector, positionIndex); | |||
} else { | } else { | ||
communityElement.hide(); | |||
communityElement.hide(); | |||
} | } | ||
} | |||
function positionAndShowCommunityElement(communityElement, positionSelector, positionIndex) { | |||
// Detach the element first | |||
communityElement.detach(); | |||
// Find the target position and insert the community element | |||
var targetPosition = $(positionSelector + ' .card').eq(positionIndex); | |||
communityElement.insertAfter(targetPosition); | |||
// Use fadeIn for a smooth appearance | |||
communityElement.hide().fadeIn(); | |||
} | } | ||
Line 125: | Line 134: | ||
// 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, '#list', 1); // Position after 2nd card | ||
}); | }); | ||
// 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, '#list-list', 3); // Position after 4th card | ||
}); | }); | ||