MediaWiki:Common.js
Aus Lost Dreams Of Tomorrow Wiki
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
$(document).ready(function(){
// Username replacement
$.each($('.username'), function(){
var username = mw.config.get('wgUserName');
if (!username) {
username = "Pro Gamer";
}
$(this).text(username);
});
// Assign custom sidebar collapsible classes
$("#mw-site-navigation .sidebar-chunk").each(function() {
var $chunk = $(this);
var $header = $chunk.find('h3, label').first();
var $content = $chunk.find('.sidebar-inner, ul, .mw-portlet-body').first();
if ($header.length && $content.length) {
$header.addClass("sidebar-collapsible");
$content.addClass("sidebar-collapsible-content");
// Store reference to content in header's data
$header.data('content', $content);
}
});
$("#mw-site-navigation").prepend("<div id=\"sidebar-collapsible-toggle\">Expand All</div>");
// Hide content except for the ones specified as expanded
var expandedContentTitles = ['Players', 'World'];
$(".sidebar-collapsible").each(function() {
var headerText = $(this).text().trim();
var $content = $(this).data('content');
if (!expandedContentTitles.includes(headerText)) {
$(this).addClass('closed');
$content.hide();
} else {
$(this).addClass('open');
$content.show();
}
});
// On section title click
$(".sidebar-collapsible").click(function() {
$(this).toggleClass('open closed');
var $content = $(this).data('content');
$content.slideToggle(200);
});
// Expand/Close All
$("#sidebar-collapsible-toggle").click(function() {
if($(this).text() == "Expand All") {
$(".sidebar-collapsible-content").slideDown(200);
$(".sidebar-collapsible").addClass('open').removeClass('closed');
$(this).text("Close All");
} else {
$(".sidebar-collapsible-content").slideUp(200);
$(".sidebar-collapsible").addClass('closed').removeClass('open');
$(this).text("Expand All");
}
});
});
mw.loader.using('mobile.site.styles');
/* Sets the top property for stickyHeader tables */
function setStickyHeaderTop() {
const stickyTables = document.getElementsByClassName('stickyHeader');
const headHeight = document.getElementById('mw-header-container').offsetHeight;
for (i = 0; i < stickyTables.length; i++) {
const firstRow = stickyTables[i].getElementsByClassName('headerRow-0');
const secondRow = stickyTables[i].getElementsByClassName('headerRow-1');
var firstHeight = 0;
if (firstRow.length > 0) {
firstHeight = firstRow[0].offsetHeight;
const firstHeaders = firstRow[0].getElementsByTagName('th');
for (j = 0; j < firstHeaders.length; j++) {
firstHeaders[j].style.top = headHeight + 'px';
}
if (secondRow.length > 0) {
const secondHeaders = secondRow[0].getElementsByTagName('th');
var secondHeight = headHeight + firstHeight;
for (j = 0; j < secondHeaders.length; j++) {
secondHeaders[j].style.top = secondHeight + 'px';
}
}
}
}
}
$(document).ready(function () {
if (document.getElementsByClassName('stickyHeader').length > 0) {
setStickyHeaderTop();
$(window).resize(setStickyHeaderTop);
}
});