MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus Stadtsprachen
Nöth (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Nöth (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| (5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 3: | Zeile 3: | ||
mw.loader.load( '/index.php?title=MediaWiki:ListNav.js&action=raw&ctype=text/javascript' ); | mw.loader.load( '/index.php?title=MediaWiki:ListNav.js&action=raw&ctype=text/javascript' ); | ||
function scrollToAnchor(anchorId) { | |||
const element = document.getElementById(anchorId); | |||
const navbarHeight = 50; | |||
if (element) { | |||
// Calculate the adjusted scroll position | |||
const elementPosition = element.getBoundingClientRect().top + window.pageYOffset; | |||
const offsetPosition = elementPosition - navbarHeight; | |||
// Scroll to the adjusted position | |||
window.scrollTo({ | |||
top: offsetPosition, | |||
behavior: 'smooth' | |||
}); | |||
} | |||
} | |||
$( function () { | $( function () { | ||
$( '#mw-content-text' ).on( 'click', '.newwin > a', function () { | $( '#mw-content-text' ).on( 'click', '.newwin > a', function () { | ||
| Zeile 15: | Zeile 32: | ||
var random= Math.floor(Math.random()*3)+0; | var random= Math.floor(Math.random()*3)+0; | ||
var bigSize=[ | var bigSize=[ | ||
"url( | "url(https://stadtsprachen.kallimachos.de/images/2/25/Vorschlag_Banner_2.jpg)", | ||
"url( | "url(https://stadtsprachen.kallimachos.de/images/a/a0/Vorschlag_Banner.jpg)", | ||
"url( | "url(https://stadtsprachen.kallimachos.de/images/8/81/Vorschlag_Banner_3.jpg)" | ||
]; | ]; | ||
var element = document.getElementById("random"); | var element = document.getElementById("random"); | ||
| Zeile 77: | Zeile 94: | ||
/* Workaround for broken ListNav sorting */ | /* Workaround for broken ListNav sorting */ | ||
(function waitForElement() { | (function waitForElement() { | ||
var element = document.getElementById('sprachhandlungen'); | if (window.jQuery && $.fn.listnav) { // Ensure jQuery and listnav plugin are loaded | ||
var element = document.getElementById('sprachhandlungen'); | |||
if (element) { | |||
$('#sprachhandlungen').listnav({includeAll: false}); | |||
} else { | |||
setTimeout(waitForElement, 500); // Retry in 500ms | |||
} | |||
} else { | } else { | ||
setTimeout(waitForElement, 500); // | setTimeout(waitForElement, 500); // Retry in 500ms | ||
} | } | ||
})(); | })(); | ||
Aktuelle Version vom 27. Februar 2025, 11:05 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
mw.loader.load( '/index.php?title=MediaWiki:Spotlight.js&action=raw&ctype=text/javascript' );
mw.loader.load( '/index.php?title=MediaWiki:ListNav.js&action=raw&ctype=text/javascript' );
function scrollToAnchor(anchorId) {
const element = document.getElementById(anchorId);
const navbarHeight = 50;
if (element) {
// Calculate the adjusted scroll position
const elementPosition = element.getBoundingClientRect().top + window.pageYOffset;
const offsetPosition = elementPosition - navbarHeight;
// Scroll to the adjusted position
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
}
}
$( function () {
$( '#mw-content-text' ).on( 'click', '.newwin > a', function () {
var otherWindow = window.open();
otherWindow.opener = null;
otherWindow.location = this;
return false;
} );
} );
$( function randombg(){
var random= Math.floor(Math.random()*3)+0;
var bigSize=[
"url(https://stadtsprachen.kallimachos.de/images/2/25/Vorschlag_Banner_2.jpg)",
"url(https://stadtsprachen.kallimachos.de/images/a/a0/Vorschlag_Banner.jpg)",
"url(https://stadtsprachen.kallimachos.de/images/8/81/Vorschlag_Banner_3.jpg)"
];
var element = document.getElementById("random");
if(typeof(element) !== 'undefined' && element !== null){
element.style.backgroundImage=bigSize[random];
};
});
$(document).ready(function () {
if(mw.config.get("wgUserName") == null){
var hide = document.getElementById("hidden");
var hide2 = document.getElementById("hidden2");
hide.style.display = "none";
hide2.style.display = "none";
}
});
$(document).ready(function(){
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var mapList = window.maps.leafletList;
for (var i = 0; i < mapList.length; i++) {
var map = mapList[i].map;
map.setZoom(5);
map.panTo(new L.LatLng(50.918, 10.274));
map.invalidateSize(true);
}
});
});
mw.hook('wikipage.content').add(function ($content) {
function initializeAccordions() {
var accordionButtons = document.getElementsByClassName("bs-accordion-button");
// Set up click handlers for all buttons
for (var i = 0; i < accordionButtons.length; i++) {
accordionButtons[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight) {
content.style.maxHeight = null;
} else {
content.style.maxHeight = content.scrollHeight + "px";
}
});
}
// Open the first panel by default
if (accordionButtons.length > 0) {
accordionButtons[0].classList.add("active");
var firstContent = accordionButtons[0].nextElementSibling;
firstContent.style.maxHeight = firstContent.scrollHeight + "px";
}
}
initializeAccordions();
});
/* Workaround for broken ListNav sorting */
(function waitForElement() {
if (window.jQuery && $.fn.listnav) { // Ensure jQuery and listnav plugin are loaded
var element = document.getElementById('sprachhandlungen');
if (element) {
$('#sprachhandlungen').listnav({includeAll: false});
} else {
setTimeout(waitForElement, 500); // Retry in 500ms
}
} else {
setTimeout(waitForElement, 500); // Retry in 500ms
}
})();