Changes

MediaWiki:Common.js

546 bytes added, 02:38, 14 December 2024
m
Changing scrollIntoView to be centered instead
/* Any JavaScript here will be loaded for all users on every page load. */
/* Allows for navigation from one tab to another within the same tabber */
function tabberGoTo(thisElement, tabName, id) {
var tabbertab = thisElement
}
const tabberParent tabber = tabbertab.parentElement const tabberChildren = Array.from(tabberParenttabber.children)
// Switch tabs
tabbertab.style.display = 'none'
tabberChildren.find(function (child => ) { return child.title === tabName}).style.display = 'block'
// Handle tabbernav CSS
const nav = tabberChildren.find(function (child => ) { return child.classList.contains('tabbernav')}) for (const child of Array.from(nav.children).forEach(function (child) {
if (child.firstElementChild.title === tabbertab.title) { child.classList = '' }
if (child.firstElementChild.title === tabName) { child.classList = 'tabberactive' }
})
 
if (id) {
document.getElementById(id).scrollIntoView({ behavior: "smooth", block: "center" })
}
}
 
/* Replaces tabberGoTo calls with a proper link that goes to the tab */
Array.from(document.getElementsByClassName('tabberGoTo')).forEach(function (element) {
const newElement = document.createElement('a')
newElement.setAttribute('onclick', "tabberGoTo(this, '" + element.classList[1] + "', '" + element.id + "')")
newElement.textContent = element.textContent
documentelement.getElementByIdreplaceWith(idnewElement).scrollIntoView({ behavior: "smooth", block: "end" })}
/* Replaces currency keywords (Gold, Gems, Defender Medals) with their icon in elements which include currency costs */
WikiDefender, bureaucrat, administrator
736
edits