MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
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) {
        // Hide all communityFeatured elements initially
    // Only proceed if filters are not active
        $('[id^="community-featured-"]').hide();
    if (!areFiltersActive) {
   
        // Hide all communityFeatured elements initially
        // Determine the appropriate communityFeatured element based on the current view and section
        $('[id^="community-featured-"]').hide();
        var communityFeatured;
   
        if (view === 'block') {
        // Determine the appropriate communityFeatured element based on the current view and section
            communityFeatured = $('#community-featured-block-' + section);
        var communityFeatured;
        } else if (view === 'list') {
        if (view === 'block') {
            communityFeatured = $('#community-featured-list-' + section);
            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');
        // Position the appropriate communityFeatured element after the second card if it exists
            if (filteredCards.length >= 2) {
        if (communityFeatured.length) {
                communityFeatured.detach();
            var filteredCards = communityFeatured.closest('.list-container').find('.filtered-list-item');
                filteredCards.eq(1).after(communityFeatured);
            if (filteredCards.length >= 2) {
                communityFeatured.show();
                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);
     });
     });


Navigation menu