MediaWiki:Common.js: Difference between revisions
Appearance
Created page with "→Any JavaScript here will be loaded for all users on every page load.: // Tab functionality $(document).ready(function() { // Initialize tabs - show first tab by default $('.wiki-tabs-container').each(function() { var $container = $(this); var $firstButton = $container.find('.wiki-tab-button').first(); var firstTabId = $firstButton.data('tab'); $firstButton.addClass('active'); $container.find('#' + firstTabId)..." |
Sonja says (talk | contribs) No edit summary |
||
| Line 27: | Line 27: | ||
$container.find('#' + tabId).addClass('active').show(); | $container.find('#' + tabId).addClass('active').show(); | ||
}); | }); | ||
}); | |||
// =============================== | |||
// Add Custom Sticky Header Link | |||
// =============================== | |||
mw.hook('wikipage.content').add(function () { | |||
const icons = document.querySelector('.vector-sticky-header-icons'); | |||
if (!icons) return; | |||
// Prevent duplicate button on navigation | |||
if (document.getElementById('custom-sticky-link')) return; | |||
const link = document.createElement('a'); | |||
link.id = 'custom-sticky-link'; | |||
link.href = 'https://discord.gg/t2Rp2dRvze'; // CHANGE THIS | |||
link.target = '_blank'; | |||
link.className = 'cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet'; | |||
link.textContent = 'Join Us on Discord!'; // CHANGE TEXT | |||
link.style.marginLeft = '10px'; | |||
link.style.fontWeight = 'bold'; | |||
icons.prepend(link); // use appendChild() if you want it at the end | |||
}); | }); | ||
Revision as of 13:13, 13 February 2026
/* Any JavaScript here will be loaded for all users on every page load. */
// Tab functionality
$(document).ready(function() {
// Initialize tabs - show first tab by default
$('.wiki-tabs-container').each(function() {
var $container = $(this);
var $firstButton = $container.find('.wiki-tab-button').first();
var firstTabId = $firstButton.data('tab');
$firstButton.addClass('active');
$container.find('#' + firstTabId).addClass('active').show();
});
// Tab click handler
$('.wiki-tab-button').on('click', function() {
var $button = $(this);
var tabId = $button.data('tab');
var $container = $button.closest('.wiki-tabs-container');
// Remove active class from all buttons and panes in this container
$container.find('.wiki-tab-button').removeClass('active');
$container.find('.wiki-tab-pane').removeClass('active').hide();
// Add active class to clicked button and corresponding pane
$button.addClass('active');
$container.find('#' + tabId).addClass('active').show();
});
});
// ===============================
// Add Custom Sticky Header Link
// ===============================
mw.hook('wikipage.content').add(function () {
const icons = document.querySelector('.vector-sticky-header-icons');
if (!icons) return;
// Prevent duplicate button on navigation
if (document.getElementById('custom-sticky-link')) return;
const link = document.createElement('a');
link.id = 'custom-sticky-link';
link.href = 'https://discord.gg/t2Rp2dRvze'; // CHANGE THIS
link.target = '_blank';
link.className = 'cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet';
link.textContent = 'Join Us on Discord!'; // CHANGE TEXT
link.style.marginLeft = '10px';
link.style.fontWeight = 'bold';
icons.prepend(link); // use appendChild() if you want it at the end
});