4,114
edits
No edit summary Tag: Manual revert |
No edit summary |
||
Line 1: | Line 1: | ||
$(document).ready(function () { | $(document).ready(function () { | ||
var areFiltersActive = false; | |||
var communityFeatured = $('#community-featured'); | var communityFeatured = $('#community-featured'); | ||
var communityFeaturedBlock1 = $('#community-featured-block-1'); | var communityFeaturedBlock1 = $('#community-featured-block-1'); | ||
Line 36: | Line 37: | ||
function updateCommunityFeaturedPosition(view, section) { | function updateCommunityFeaturedPosition(view, section) { | ||
// Only proceed if filters are not active | |||
if (!areFiltersActive) { | |||
// Hide all communityFeatured elements initially | |||
$('[id^="community-featured-"]').hide(); | |||
// Determine the appropriate communityFeatured element based on the current view and section | |||
var communityFeatured; | |||
if (view === 'block') { | |||
communityFeatured = $('#community-featured-block-' + section); | |||
} else if (view === 'list') { | |||
communityFeatured = $('#community-featured-list-' + section); | |||
} | |||
// Position the appropriate communityFeatured element after the second card if it exists | |||
if (communityFeatured.length) { | |||
var filteredCards = communityFeatured.closest('.list-container').find('.filtered-list-item'); | |||
if (filteredCards.length >= 2) { | |||
communityFeatured.detach(); | |||
filteredCards.eq(1).after(communityFeatured); | |||
communityFeatured.show(); | |||
} | |||
} | |||
} | |||
} | } | ||
Line 220: | Line 224: | ||
// You can also call this function in response to filter changes or page events where filters might be modified | // 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() { | $('#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); | areFiltersActive = $('.filtered-value-option input[type="checkbox"]:checked').length > 0; | ||
updateCommunityElementsVisibility(selectors, communityElements); | |||
}); | }); | ||