MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 16: Line 16:
    return list.width();
    return list.width();
});
});
   
    updateCommunityFeaturedPosition('block', '1');
      
      
     // Insert the community featured element after the second card
     // Insert the community featured element after the second card
Line 33: Line 35:
}
}


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

Navigation menu