MediaWiki:Common.js: Difference between revisions

From Rebellious Projects Wiki
Created page with "Any JavaScript here will be loaded for all users on every page load.: $('.pi-image-collection').each(function() { var $tabs = $(this).find('.pi-image-collection-tab'); var $images = $(this).find('.pi-image-collection-image'); $tabs.on('click', function() { var index = $(this).index(); $tabs.removeClass('active'); $images.removeClass('active'); $(this).addClass('active'); $images.eq(index).addClass('active');..."
 
No edit summary
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
$('.pi-image-collection').each(function() {
    $(document).on('click', '.pi-tab-link', function() {
    var $tabs = $(this).find('.pi-image-collection-tab');
        var $collection = $(this).closest('.pi-media-collection');
    var $images = $(this).find('.pi-image-collection-image');
        var tabId = $(this).data('pi-tab');
   
 
    $tabs.on('click', function() {
        $collection.find('.pi-tab-link').removeClass('current');
        var index = $(this).index();
         $collection.find('.pi-media-collection-tab-content').removeClass('current');
         $tabs.removeClass('active');
 
        $images.removeClass('active');
         $(this).addClass('current');
         $(this).addClass('active');
         $collection.find('#' + tabId).addClass('current');
         $images.eq(index).addClass('active');
     });
     });
});
});

Revision as of 07:28, 15 March 2026

$(document).ready(function() {
    $(document).on('click', '.pi-tab-link', function() {
        var $collection = $(this).closest('.pi-media-collection');
        var tabId = $(this).data('pi-tab');

        $collection.find('.pi-tab-link').removeClass('current');
        $collection.find('.pi-media-collection-tab-content').removeClass('current');

        $(this).addClass('current');
        $collection.find('#' + tabId).addClass('current');
    });
});