MediaWiki:Common.js
MediaWiki interface page
More actions
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* 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');
});
});