MediaWiki:Common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Gerard (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Gerard (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
/* Das folgende JavaScript wird für alle Benutzer geladen. */ | /* Das folgende JavaScript wird für alle Benutzer geladen. */ | ||
document.addEventListener('DOMContentLoaded', function () { | document.addEventListener('DOMContentLoaded', function () { | ||
// | |||
// TEST: 5 Sekunden Anzeige | |||
// | |||
const box = document.createElement('div'); | const box = document.createElement('div'); | ||
box.textContent = "Common.js läuft!"; | box.textContent = "Common.js läuft!"; | ||
| Zeile 13: | Zeile 16: | ||
box.style.border = "2px solid black"; | box.style.border = "2px solid black"; | ||
box.style.zIndex = "99999"; | box.style.zIndex = "99999"; | ||
document.body.appendChild(box); | |||
setTimeout(() => box.remove(), 5000); | |||
// | |||
// TerranianStar – Sidebar-Portale einklappbar machen | |||
// | |||
const portals = document.querySelectorAll('.vector-menu.mw-portlet'); | |||
portals.forEach(portal => { | |||
const heading = portal.querySelector('.vector-menu-heading'); | |||
const content = portal.querySelector('.vector-menu-content'); | |||
if (!heading || !content) return; | |||
if (heading.textContent.trim() === 'Navigation') return; | |||
heading.style.cursor = 'pointer'; | |||
heading.addEventListener('click', () => { | |||
} | content.classList.toggle('ts-collapsed'); | ||
}); | |||
}); | |||
}); | }); | ||
// | // | ||
// Icons für Bearbeiten / Quelltext bearbeiten (Vector‑2022) | // Icons für Bearbeiten / Quelltext bearbeiten (Vector‑2022) | ||
// (Dieser Hook MUSS außerhalb von DOMContentLoaded bleiben!) | |||
// | // | ||
mw.hook('wikipage.content').add(function($content) { | mw.hook('wikipage.content').add(function($content) { | ||
| Zeile 30: | Zeile 50: | ||
var text = $a.text().trim(); | var text = $a.text().trim(); | ||
$a.css({ | $a.css({ | ||
'font-size': '0', | 'font-size': '0', | ||
| Zeile 43: | Zeile 62: | ||
}); | }); | ||
if (text === 'Bearbeiten') { | if (text === 'Bearbeiten') { | ||
$a.css('background-image', 'url("/Wiki_BlueX/images/e/e6/EditIcon.png")'); | $a.css('background-image', 'url("/Wiki_BlueX/images/e/e6/EditIcon.png")'); | ||
} | } | ||
if (text === 'Quelltext bearbeiten') { | if (text === 'Quelltext bearbeiten') { | ||
$a.css('background-image', 'url("/Wiki_BlueX/images/f/f6/QEditIcon.png")'); | $a.css('background-image', 'url("/Wiki_BlueX/images/f/f6/QEditIcon.png")'); | ||
| Zeile 54: | Zeile 71: | ||
}); | }); | ||
$content.find('.mw-editsection').css('font-size', '0'); | $content.find('.mw-editsection').css('font-size', '0'); | ||
}); | }); | ||
Version vom 24. Mai 2026, 14:42 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
document.addEventListener('DOMContentLoaded', function () {
//
// TEST: 5 Sekunden Anzeige
//
const box = document.createElement('div');
box.textContent = "Common.js läuft!";
box.style.position = "fixed";
box.style.top = "10px";
box.style.left = "10px";
box.style.background = "lime";
box.style.color = "black";
box.style.padding = "10px";
box.style.border = "2px solid black";
box.style.zIndex = "99999";
document.body.appendChild(box);
setTimeout(() => box.remove(), 5000);
//
// TerranianStar – Sidebar-Portale einklappbar machen
//
const portals = document.querySelectorAll('.vector-menu.mw-portlet');
portals.forEach(portal => {
const heading = portal.querySelector('.vector-menu-heading');
const content = portal.querySelector('.vector-menu-content');
if (!heading || !content) return;
if (heading.textContent.trim() === 'Navigation') return;
heading.style.cursor = 'pointer';
heading.addEventListener('click', () => {
content.classList.toggle('ts-collapsed');
});
});
});
//
// Icons für Bearbeiten / Quelltext bearbeiten (Vector‑2022)
// (Dieser Hook MUSS außerhalb von DOMContentLoaded bleiben!)
//
mw.hook('wikipage.content').add(function($content) {
$content.find('.mw-editsection a').each(function() {
var $a = $(this);
var text = $a.text().trim();
$a.css({
'font-size': '0',
'display': 'inline-block',
'width': '22px',
'height': '22px',
'background-size': 'contain',
'background-repeat': 'no-repeat',
'background-position': 'center',
'vertical-align': 'middle',
'margin-left': '4px'
});
if (text === 'Bearbeiten') {
$a.css('background-image', 'url("/Wiki_BlueX/images/e/e6/EditIcon.png")');
}
if (text === 'Quelltext bearbeiten') {
$a.css('background-image', 'url("/Wiki_BlueX/images/f/f6/QEditIcon.png")');
}
});
$content.find('.mw-editsection').css('font-size', '0');
});