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 communityFeatured = $('#community-featured');
     var communityFeatured = $('#community-featured');
    var communityFeaturedBlock1 = $('#community-featured-block-1');
    var communityFeaturedBlock2 = $('#community-featured-block-2');
    var communityFeaturedBlock3 = $('#community-featured-block-3');
    var communityFeaturedList1 = $('#community-featured-list-1');
    var communityFeaturedList2 = $('#community-featured-list-2');
    var communityFeaturedList3 = $('#community-featured-list-3');
     var filteredCards = $('.filtered-list-item');
     var filteredCards = $('.filtered-list-item');
     var showArticleWrapper = $('#show-article-wrapper');
     var showArticleWrapper = $('#show-article-wrapper');
Line 26: Line 32:
    }
    }
}
}
    function updateCommunityFeaturedPosition(view, section) {
        // 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();
            }
        }
    }


     // Check if the specific element exists on the page
     // Check if the specific element exists on the page
Line 572: Line 601:
// NEW TEST
// NEW TEST
// Handle Block View Button in home
// Handle Block View Button in home
$(".home-block-view-button").click(function() {
    $(".home-block-view-button").click(function() {
    // Show block view and block sorting buttons, hide list view and list sorting buttons
        $(".home-block-view").show();
    $(".home-block-view").show();
        $(".home-list-view").hide();
    $(".home-list-view").hide();
        $(".home-block-sorting-buttons").css('display', 'flex');
    $(".home-block-sorting-buttons").css('display', 'flex');
        $(".home-list-sorting-buttons").hide();
    $(".home-list-sorting-buttons").hide();
        $(".home-block-view > div").hide();
    $(".home-block-view > div").hide();
        $(".home-chronicle-block").show();
    $(".home-chronicle-block").show();
   
});
        // Update the position of the communityFeatured elements for the chronicle block view
        updateCommunityFeaturedPosition('block', '1'); // '1' corresponds to chronicle
    });
// Handle List View Button in home
    // Handle List View Button in home
$(".home-list-view-button").click(function() {
    $(".home-list-view-button").click(function() {
    // Show list view and list sorting buttons, hide block view and block sorting buttons
        $(".home-list-view").show();
    $(".home-list-view").show();
        $(".home-block-view").hide();
    $(".home-block-view").hide();
        $(".home-list-sorting-buttons").css('display', 'flex');
    $(".home-list-sorting-buttons").css('display', 'flex');
        $(".home-block-sorting-buttons").hide();
    $(".home-block-sorting-buttons").hide();
        $(".home-list-view > div").hide();
    $(".home-list-view > div").hide();
        $(".home-chronicle-list").show();
    $(".home-chronicle-list").show();
 
});
        // Update the position of the communityFeatured elements for the chronicle list view
        updateCommunityFeaturedPosition('list', '1'); // '1' corresponds to chronicle
    });
// Handle List Sorting Buttons in home
// Handle List Sorting Buttons in home for the chronicle list
$(".home-chronicle-list-button").click(function() {
    $(".home-chronicle-list-button").click(function() {
    // Show only the chronicle list
        // Show only the chronicle list
    $(".home-list-view > div").hide();
        $(".home-list-view > div").hide();
    $(".home-chronicle-list").show();
        $(".home-chronicle-list").show();
});
 
        // Update the position of the communityFeatured element for the chronicle list view
$(".home-random-list-button").click(function() {
        updateCommunityFeaturedPosition('list', '1'); // '1' corresponds to chronicle
    // Show only the random list
    });
    $(".home-list-view > div").hide();
 
    $(".home-random-list").show();
    // Similarly, you would update the handlers for the random list button and alphabetical list button:
});
    $(".home-random-list-button").click(function() {
        // Show only the random list
$(".home-alphabetical-list-button").click(function() {
        $(".home-list-view > div").hide();
    // Show only the alphabetical list
        $(".home-random-list").show();
    $(".home-list-view > div").hide();
 
    $(".home-alphabetical-list").show();
        // Update the position of the communityFeatured element for the random list view
});
        updateCommunityFeaturedPosition('list', '2'); // '2' corresponds to random
    });
 
    $(".home-alphabetical-list-button").click(function() {
        // Show only the alphabetical list
        $(".home-list-view > div").hide();
        $(".home-alphabetical-list").show();
 
        // Update the position of the communityFeatured element for the alphabetical list view
        updateCommunityFeaturedPosition('list', '3'); // '3' corresponds to alphabetical
    });
 
// Handle Block Sorting Buttons
// Handle Block Sorting Buttons
Line 617: Line 661:
    $(".home-block-view > div").hide();
    $(".home-block-view > div").hide();
    $(".home-chronicle-block").show();
    $(".home-chronicle-block").show();
        // Update the position of the communityFeatured element for the alphabetical list view
        updateCommunityFeaturedPosition('block', '1'); // '1' corresponds to chronicle
});
});
Line 623: Line 670:
    $(".home-block-view > div").hide();
    $(".home-block-view > div").hide();
    $(".home-random-block").show();
    $(".home-random-block").show();
        // Update the position of the communityFeatured element for the random list view
        updateCommunityFeaturedPosition('block', '2'); // '2' corresponds to random
});
});
Line 629: Line 679:
    $(".home-block-view > div").hide();
    $(".home-block-view > div").hide();
    $(".home-alphabetical-block").show();
    $(".home-alphabetical-block").show();
        // Update the position of the communityFeatured element for the alphabetical list view
        updateCommunityFeaturedPosition('block', '3'); // '3' corresponds to alphabetical
});
});
});
});

Navigation menu