MediaWiki:Common.js: Difference between revisions
MediaWiki interface page
More actions
Created page with "→Any JavaScript here will be loaded for all users on every page load.: mw.loader.load('mediawiki.page.gallery.slideshow');" |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
/* | /* Custom Slider Logic (Supports multiple sliders & custom timing) */ | ||
$(function() { | |||
$('.jule-slider').each(function() { | |||
var $slider = $(this); | |||
// Read the time from the data-interval attribute (default to 4000ms) | |||
var intervalTime = parseInt($slider.attr('data-interval')) || 4000; | |||
setInterval(function() { | |||
var $active = $slider.find('.jule-slide.active'); | |||
var $next = $active.next('.jule-slide'); | |||
// Loop back to start if at the end | |||
if ($next.length === 0) { | |||
$next = $slider.find('.jule-slide').first(); | |||
} | |||
// Swap classes to trigger CSS transitions | |||
$active.removeClass('active').css('opacity', '0'); | |||
$next.addClass('active').css('opacity', '1'); | |||
}, intervalTime); | |||
}); | |||
}); | |||
/* Infobox Tab Logic */ | |||
$(function() { | |||
// When a tab button is clicked... | |||
$('.infobox-tab-btn').on('click', function() { | |||
var $btn = $(this); | |||
var targetId = $btn.attr('data-target'); | |||
var $container = $btn.closest('.infobox-image-area'); | |||
// 1. Remove 'active' from all buttons in this infobox | |||
$container.find('.infobox-tab-btn').removeClass('active'); | |||
// 2. Hide all images in this infobox | |||
$container.find('.infobox-img-content').removeClass('active'); | |||
// 3. Make the clicked button active | |||
$btn.addClass('active'); | |||
// 4. Show the target image | |||
$container.find('#' + targetId).addClass('active'); | |||
}); | |||
}); | |||
Latest revision as of 19:26, 27 January 2026
/* Custom Slider Logic (Supports multiple sliders & custom timing) */
$(function() {
$('.jule-slider').each(function() {
var $slider = $(this);
// Read the time from the data-interval attribute (default to 4000ms)
var intervalTime = parseInt($slider.attr('data-interval')) || 4000;
setInterval(function() {
var $active = $slider.find('.jule-slide.active');
var $next = $active.next('.jule-slide');
// Loop back to start if at the end
if ($next.length === 0) {
$next = $slider.find('.jule-slide').first();
}
// Swap classes to trigger CSS transitions
$active.removeClass('active').css('opacity', '0');
$next.addClass('active').css('opacity', '1');
}, intervalTime);
});
});
/* Infobox Tab Logic */
$(function() {
// When a tab button is clicked...
$('.infobox-tab-btn').on('click', function() {
var $btn = $(this);
var targetId = $btn.attr('data-target');
var $container = $btn.closest('.infobox-image-area');
// 1. Remove 'active' from all buttons in this infobox
$container.find('.infobox-tab-btn').removeClass('active');
// 2. Hide all images in this infobox
$container.find('.infobox-img-content').removeClass('active');
// 3. Make the clicked button active
$btn.addClass('active');
// 4. Show the target image
$container.find('#' + targetId).addClass('active');
});
});