MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 33: Line 33:
}
}


    updateCommunityFeaturedPosition('block', '1');
   
    // Update the positioning and visibility of community featured elements based on view and section
     function updateCommunityFeaturedPosition(view, section) {
     function updateCommunityFeaturedPosition(view, section) {
         // Hide all communityFeatured elements initially
         // Initially hide all community featured elements
         $('[id^="community-featured-"]').hide();
         $('#community-featured-block-1, #community-featured-block-2, #community-featured-block-3, #community-featured-list-1, #community-featured-list-2, #community-featured-list-3').hide();
   
 
         // Determine the appropriate communityFeatured element based on the current view and section
         // Determine which community featured element to show based on the current view and section
         var communityFeatured;
         var communityFeaturedElement;
         if (view === 'block') {
         if (view === 'block') {
             communityFeatured = $('#community-featured-block-' + section);
             communityFeaturedElement = $('#community-featured-block-' + section);
         } else if (view === 'list') {
         } else if (view === 'list') {
             communityFeatured = $('#community-featured-list-' + section);
             communityFeaturedElement = $('#community-featured-list-' + section);
         }
         }
   
 
         // Position the appropriate communityFeatured element after the second card if it exists
         // Show and position the appropriate community featured element if it exists
         if (communityFeatured.length) {
         if (communityFeaturedElement.length && filteredCards.length >= 2) {
            var filteredCards = communityFeatured.closest('.list-container').find('.filtered-list-item');
            communityFeaturedElement.detach();
            if (filteredCards.length >= 2) {
            filteredCards.eq(1).after(communityFeaturedElement);
                communityFeatured.detach();
            communityFeaturedElement.show();
                filteredCards.eq(1).after(communityFeatured);
                communityFeatured.show();
            }
         }
         }
     }
     }

Navigation menu