MediaWiki:Common.js: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| (16 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
/* === PREPRINT START === */ | /* === PREPRINT START === */ | ||
/* ============================================ | /* ============================================ | ||
PREPRINT v7.17 - JS | PREPRINT v7.17 - JS v260225r1 | ||
============================================ */ | ============================================ */ | ||
| Zeile 14: | Zeile 9: | ||
// Prevent repeated initialization | // Prevent repeated initialization | ||
if (window.preprintInitialized) { | if (window.preprintInitialized) { | ||
return; | return; | ||
} | } | ||
| Zeile 35: | Zeile 29: | ||
var imagesStabilized = false; | var imagesStabilized = false; | ||
// Debug logging with source tracking | // Debug logging with source tracking (silent in production) | ||
function log(adapter, message) { | function log(adapter, message) { | ||
} | } | ||
| Zeile 663: | Zeile 656: | ||
}); | }); | ||
} | } | ||
| Zeile 756: | Zeile 748: | ||
} | } | ||
}); | }); | ||
// Helper functions (closure) | // Helper functions (closure) | ||
function ensureColumns() { | function ensureColumns() { | ||
| Zeile 856: | Zeile 846: | ||
scrollToHash(); | scrollToHash(); | ||
} | } | ||
| Zeile 887: | Zeile 876: | ||
scrollToHash(); | scrollToHash(); | ||
} | } | ||
function reconcileLayout( | function reconcileLayout() { | ||
if (!document.body.classList.contains('preprint-landscape')) return; | if (!document.body.classList.contains('preprint-landscape')) return; | ||
if (reconcileLayout._running) return; | if (reconcileLayout._running) return; | ||
reconcileLayout._running = true; | reconcileLayout._running = true; | ||
// Disconnect observer to prevent re-entry from our writes | // Disconnect observer to prevent re-entry from our writes | ||
| Zeile 906: | Zeile 893: | ||
// === PHASE 1: CLEAN + READ === | // === PHASE 1: CLEAN + READ === | ||
// Remove all previous-cycle artifacts | |||
// Remove all previous | |||
$('.preprint-oc-spacer').remove(); | $('.preprint-oc-spacer').remove(); | ||
if (layout && layout[0]) layout[0].style.paddingBottom = ''; | if (layout && layout[0]) layout[0].style.paddingBottom = ''; | ||
linkage.forEach(function(link) { | linkage.forEach(function(link) { | ||
link.element[0].style.top = '0px'; | if (link.element[0].style.position !== 'absolute') { | ||
link.element[0].style.position = 'absolute'; | |||
link.element[0].style.top = '0px'; | |||
} | |||
}); | }); | ||
// Force reflow | // Force reflow after cleanup | ||
void document.body.offsetHeight; | void document.body.offsetHeight; | ||
| Zeile 1.104: | Zeile 1.090: | ||
subtree: true, attributes: true, attributeFilter: ['class'] | subtree: true, attributes: true, attributeFilter: ['class'] | ||
}); | }); | ||
// ResizeObserver: catches container width changes not visible to | |||
// window resize (TOC pin/unpin, tool menu toggle, DevTools panel). | |||
// Created once, never disconnected — only fires on actual size change. | |||
if (!layout._resizeObserver && typeof ResizeObserver !== 'undefined') { | |||
layout._resizeObserver = new ResizeObserver(function() { | |||
clearTimeout(layout._resizeDebounce); | |||
layout._resizeDebounce = setTimeout(function() { | |||
if (PAL.isOrientationLocked()) return; | |||
if (document.body.classList.contains('preprint-landscape')) { | |||
reconcileLayout(); | |||
} | |||
}, 200); | |||
}); | |||
layout._resizeObserver.observe(layout[0]); | |||
} | |||
} | } | ||
| Zeile 1.133: | Zeile 1.135: | ||
el.scrollIntoView({ block: 'start' }); | el.scrollIntoView({ block: 'start' }); | ||
window.scrollBy(0, -60); | window.scrollBy(0, -60); | ||
} | } | ||
returnTarget = null; | returnTarget = null; | ||
| Zeile 1.145: | Zeile 1.146: | ||
target.scrollIntoView({ block: 'start' }); | target.scrollIntoView({ block: 'start' }); | ||
window.scrollBy(0, -60); | window.scrollBy(0, -60); | ||
} | } | ||
} | } | ||
| Zeile 1.263: | Zeile 1.263: | ||
getPositionAnchor: getPositionAnchor, | getPositionAnchor: getPositionAnchor, | ||
getLayout: function() { return layout; }, | getLayout: function() { return layout; }, | ||
set returnTarget(id) { returnTarget = id; } | set returnTarget(id) { returnTarget = id; }, | ||
pauseObserver: function() { | |||
if (layout && layout._ocObserver) layout._ocObserver.disconnect(); | |||
}, | |||
resumeObserver: function() { | |||
if (layout && layout[0] && layout._ocObserver) { | |||
layout._ocObserver.observe(layout[0], { | |||
subtree: true, attributes: true, attributeFilter: ['class'] | |||
}); | |||
} | |||
} | |||
}; | }; | ||
})(); | })(); | ||
| Zeile 1.328: | Zeile 1.338: | ||
var $icon = $('<a class="book-nav-icon"></a>'); | var $icon = $('<a class="book-nav-icon"></a>'); | ||
if (isBookRoot) { | if (isBookRoot) { | ||
$icon.attr('href', '/'); | var saved = sessionStorage.getItem('preprint-position'); | ||
if (saved) { | |||
var pos = JSON.parse(saved); | |||
$icon.attr('href', '/wiki/' + pos.article); | |||
} else { | |||
$icon.attr('href', '#'); | |||
$icon.addClass('book-nav-icon-disabled'); | |||
} | |||
} else { | } else { | ||
$icon.attr('href', '/wiki/' + book + (rootAnchor ? '#' + rootAnchor : '')); | $icon.attr('href', '/wiki/' + book + (rootAnchor ? '#' + rootAnchor : '')); | ||
| Zeile 1.343: | Zeile 1.360: | ||
var pos = JSON.parse(saved); | var pos = JSON.parse(saved); | ||
window.location.href = '/wiki/' + pos.article; | window.location.href = '/wiki/' + pos.article; | ||
} | } | ||
// No action when disabled — no homepage fallback | |||
}); | }); | ||
} else { | } else { | ||
| Zeile 1.374: | Zeile 1.390: | ||
} | } | ||
} | } | ||
} | } | ||
| Zeile 1.441: | Zeile 1.455: | ||
$landmark.before($link); | $landmark.before($link); | ||
if (mw.config.get('wgUserName')) { | |||
var style = document.createElement('style'); | |||
style.textContent = '@media(max-width:790px){.book-nav-sidebar{display:none!important}}'; | |||
document.head.appendChild(style); | |||
} | |||
} | } | ||
| Zeile 1.583: | Zeile 1.601: | ||
// Mobile: root page IS the TOC, hide MW-generated one | // Mobile: root page IS the TOC, hide MW-generated one | ||
$('.toc, #toc').hide(); | $('.toc, #toc').hide(); | ||
} else if (isPreprintLayout && bookNavData.length && PAL.isMinerva()) { | } else if (isPreprintLayout && bookNavData.length && PAL.isMinerva()) { | ||
// Mobile book chapters: linear reading, no TOC | // Mobile book chapters: linear reading, no TOC | ||
$('.toc, #toc').hide(); | $('.toc, #toc').hide(); | ||
} | } | ||
// Desktop: TOC always visible (sticky sidebar navigation) | // Desktop: TOC always visible (sticky sidebar navigation) | ||
| Zeile 1.632: | Zeile 1.648: | ||
return; | return; | ||
} | } | ||
// Build structure (Model) | // Build structure (Model) | ||
Model.buildStructure(); | Model.buildStructure(); | ||
| Zeile 1.642: | Zeile 1.656: | ||
setTimeout(function() { | setTimeout(function() { | ||
Model.applyProjection(initialMode); | Model.applyProjection(initialMode); | ||
Model.pauseObserver(); | |||
$('.preprint-layout').addClass('preprint-ready'); | $('.preprint-layout').addClass('preprint-ready'); | ||
Model.resumeObserver(); | |||
window.preprintReadyAt = performance.now(); | window.preprintReadyAt = performance.now(); | ||
}, 50); | }, 50); | ||
| Zeile 1.686: | Zeile 1.702: | ||
PAL.onProjectionChange(function(event) { | PAL.onProjectionChange(function(event) { | ||
// Icon already hidden by onPreProjectionChange | // Icon already hidden by onPreProjectionChange | ||
| Zeile 1.733: | Zeile 1.748: | ||
}); | }); | ||
mw.loader.load('/wiki/MediaWiki:Common.js/debug.js?action=raw&ctype=text/javascript'); | // mw.loader.load('/wiki/MediaWiki:Common.js/debug.js?action=raw&ctype=text/javascript'); | ||
}); | }); | ||
})(); | })(); | ||
/* === PREPRINT END === */ | |||
/* Unified Consent System JavaScript | /* === CONSENT START === */ | ||
/* Unified Consent System JavaScript v260224r1 | |||
* Single file for both EN and DE versions | * Single file for both EN and DE versions | ||
* Automatically detects language based on domain | * Automatically detects language based on domain | ||
| Zeile 1.782: | Zeile 1.797: | ||
} | } | ||
// Handle consent acquisition box - 90-day reminder for | // Handle consent acquisition box - 90-day reminder for visitors (spec §8.9) | ||
$(document).ready(function() { | $(document).ready(function() { | ||
var consentBox = document.getElementById('consent-acquisition-box'); | var consentBox = document.getElementById('consent-acquisition-box'); | ||
| Zeile 1.804: | Zeile 1.819: | ||
// ADD THIS LINE: | // ADD THIS LINE: | ||
localStorage.setItem('consent-acquisition-dismissed-until', Date.now() + (90 * 24 * 60 * 60 * 1000)); | localStorage.setItem('consent-acquisition-dismissed-until', Date.now() + (90 * 24 * 60 * 60 * 1000)); | ||
var targetPage = getCurrentLanguage() === 'de' ? | if (mw.config.get('wgUserName')) { | ||
window.location.href = '/wiki/Special:Preferences#mw-prefsection-legal'; | |||
} else { | |||
var targetPage = getCurrentLanguage() === 'de' ? | |||
'/wiki/Transformal_GmbH:Einstellungen' : | |||
'/wiki/Transformal_GmbH:Settings'; | |||
window.location.href = targetPage; | |||
} | |||
}); | }); | ||
}); | }); | ||
| Zeile 1.905: | Zeile 1.924: | ||
} | } | ||
} | } | ||
/* === CONSENT END === */ | |||
/* === CONDITIONAL START === */ | |||
/* Template 'ConditionalContent' - v250925r8 */ | /* Template 'ConditionalContent' - v250925r8 */ | ||
| Zeile 1.965: | Zeile 1.988: | ||
} | } | ||
}); | }); | ||
/* === CONDITIONAL END === */ | |||