MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus Lost Dreams Of Tomorrow Wiki
Keine Bearbeitungszusammenfassung Markierung: Zurückgesetzt |
Keine Bearbeitungszusammenfassung Markierung: Zurückgesetzt |
||
| Zeile 1: | Zeile 1: | ||
// MediaWiki Sidebar Toggle Script - | // MediaWiki Sidebar Toggle Script - SICHERE VERSION | ||
/*------------------------Sidebar Toggle Script ------------------------------------------*/ | /*------------------------Sidebar Toggle Script ------------------------------------------*/ | ||
(function() { | (function() { | ||
'use strict'; | 'use strict'; | ||
var initialized = false; | |||
function initSidebar() { | function initSidebar() { | ||
if (initialized) return; | |||
var portlets = document.querySelectorAll('#p-Players, #p-World, #p-Items_and_Gear, #p-Guides, #p-Community'); | var portlets = document.querySelectorAll('#p-Players, #p-World, #p-Items_and_Gear, #p-Guides, #p-Community'); | ||
if (portlets.length === 0) return; | |||
initialized = true; | |||
console.log('Gefundene Portlets:', portlets.length); | console.log('Gefundene Portlets:', portlets.length); | ||
| Zeile 14: | Zeile 21: | ||
var portletBody = portlet.querySelector('.mw-portlet-body'); | var portletBody = portlet.querySelector('.mw-portlet-body'); | ||
if (!header || !portletBody) | if (!header || !portletBody) return; | ||
if (header.hasAttribute('data-toggle-init')) return; | |||
header.setAttribute('data-toggle-init', 'true'); | |||
console.log('Initialisiere:', header.textContent); | console.log('Initialisiere:', header.textContent); | ||
var oldIcon = header.querySelector('.toggle-icon'); | var oldIcon = header.querySelector('.toggle-icon'); | ||
if (oldIcon) | if (oldIcon) oldIcon.remove(); | ||
var icon = document.createElement('span'); | var icon = document.createElement('span'); | ||
icon.className = 'toggle-icon'; | icon.className = 'toggle-icon'; | ||
icon.style. | icon.style.cssText = 'margin-left: auto; padding-left: 10px; display: inline-flex; align-items: center; justify-content: center; transition: transform 0.2s ease; flex-shrink: 0;'; | ||
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>'; | icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>'; | ||
header.appendChild(icon); | header.appendChild(icon); | ||
header.style.cssText = 'cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; width: 100%;'; | |||
var isOpen = !header.classList.contains('closed'); | var isOpen = !header.classList.contains('closed'); | ||
if (!isOpen) { | if (!isOpen) { | ||
| Zeile 60: | Zeile 47: | ||
} | } | ||
var toggleMenu = function(e) { | var toggleMenu = function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
| Zeile 69: | Zeile 55: | ||
if (body.style.display === 'none') { | if (body.style.display === 'none') { | ||
body.style.display = 'block'; | body.style.display = 'block'; | ||
icon.style.transform = 'rotate(0deg)'; | icon.style.transform = 'rotate(0deg)'; | ||
header.classList.remove('closed'); | header.classList.remove('closed'); | ||
header.classList.add('open'); | header.classList.add('open'); | ||
} else { | } else { | ||
body.style.display = 'none'; | body.style.display = 'none'; | ||
icon.style.transform = 'rotate(-90deg)'; | icon.style.transform = 'rotate(-90deg)'; | ||
header.classList.add('closed'); | header.classList.add('closed'); | ||
header.classList.remove('open'); | header.classList.remove('open'); | ||
} | } | ||
}; | }; | ||
header.addEventListener('click', toggleMenu); | header.addEventListener('click', toggleMenu); | ||
}); | }); | ||
} | } | ||
if (document.readyState === 'loading') { | if (document.readyState === 'loading') { | ||
document.addEventListener('DOMContentLoaded', initSidebar); | document.addEventListener('DOMContentLoaded', initSidebar); | ||
} else { | } else { | ||
initSidebar(); | initSidebar(); | ||
} | } | ||
})(); | })(); | ||
Version vom 12. Januar 2026, 00:18 Uhr
// MediaWiki Sidebar Toggle Script - SICHERE VERSION
/*------------------------Sidebar Toggle Script ------------------------------------------*/
(function() {
'use strict';
var initialized = false;
function initSidebar() {
if (initialized) return;
var portlets = document.querySelectorAll('#p-Players, #p-World, #p-Items_and_Gear, #p-Guides, #p-Community');
if (portlets.length === 0) return;
initialized = true;
console.log('Gefundene Portlets:', portlets.length);
portlets.forEach(function(portlet) {
var header = portlet.querySelector('h3');
var portletBody = portlet.querySelector('.mw-portlet-body');
if (!header || !portletBody) return;
if (header.hasAttribute('data-toggle-init')) return;
header.setAttribute('data-toggle-init', 'true');
console.log('Initialisiere:', header.textContent);
var oldIcon = header.querySelector('.toggle-icon');
if (oldIcon) oldIcon.remove();
var icon = document.createElement('span');
icon.className = 'toggle-icon';
icon.style.cssText = 'margin-left: auto; padding-left: 10px; display: inline-flex; align-items: center; justify-content: center; transition: transform 0.2s ease; flex-shrink: 0;';
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
header.appendChild(icon);
header.style.cssText = 'cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; width: 100%;';
var isOpen = !header.classList.contains('closed');
if (!isOpen) {
portletBody.style.display = 'none';
icon.style.transform = 'rotate(-90deg)';
} else {
portletBody.style.display = 'block';
icon.style.transform = 'rotate(0deg)';
}
var toggleMenu = function(e) {
e.preventDefault();
e.stopPropagation();
var icon = header.querySelector('.toggle-icon');
var body = portlet.querySelector('.mw-portlet-body');
if (body.style.display === 'none') {
body.style.display = 'block';
icon.style.transform = 'rotate(0deg)';
header.classList.remove('closed');
header.classList.add('open');
} else {
body.style.display = 'none';
icon.style.transform = 'rotate(-90deg)';
header.classList.add('closed');
header.classList.remove('open');
}
};
header.addEventListener('click', toggleMenu);
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initSidebar);
} else {
initSidebar();
}
})();
/*------------------------Landing Features------------------------------------------*/
(function() {
'use strict';
function initLandingTabs() {
const tabs = document.querySelectorAll('.tab-button');
const grids = document.querySelectorAll('.landing-grid');
console.log('Tabs gefunden:', tabs.length); // Debug
console.log('Grids gefunden:', grids.length); // Debug
if (tabs.length === 0 || grids.length === 0) {
console.log('Landing Features nicht gefunden - warte...');
return;
}
tabs.forEach(tab => {
tab.addEventListener('click', function() {
console.log('Tab geklickt:', this.dataset.tab); // Debug
// Remove active from all tabs
tabs.forEach(t => t.classList.remove('active'));
this.classList.add('active');
// Hide all grids
grids.forEach(g => g.classList.remove('active'));
// Show selected grid
const targetGrid = document.getElementById(this.dataset.tab);
if (targetGrid) {
targetGrid.classList.add('active');
console.log('Grid aktiviert:', this.dataset.tab);
} else {
console.log('Grid nicht gefunden:', this.dataset.tab);
}
});
});
console.log('Landing Tabs initialisiert!');
}
// Mehrfache Versuche, den Code zu laden
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initLandingTabs);
} else {
initLandingTabs();
}
// Zusätzlicher Versuch nach 500ms (falls MediaWiki später lädt)
setTimeout(initLandingTabs, 500);
})();
// Collapsible Sidebar Sections - Mobile
$(document).ready(function() {
// Toggle für collapsible sections
$('.sidebar-collapsible, h3[style*="cursor: pointer"]').click(function(e) {
e.preventDefault();
$(this).toggleClass('closed');
$(this).next('.mw-portlet-body, ul').slideToggle(200);
});
// Schließe Sidebar beim Klick außerhalb (Mobile)
if (window.innerWidth <= 850) {
$('#mw-sidebar-checkbox:checked ~ .mw-sidebar').on('click', function(e) {
if (e.target === this) {
$('#mw-sidebar-checkbox').prop('checked', false);
}
});
}
});