Revert "Updated imprint and legal documents"
Sonarqube Scanner / Build and analyze (push) Canceled after 0s
Sonarqube Scanner / Build and analyze (push) Canceled after 0s
This reverts commit fd16c66142.
This commit is contained in:
+34
-143
@@ -1,21 +1,17 @@
|
||||
(function (ns) {
|
||||
'use strict';
|
||||
|
||||
const DROPDOWN_ANIMATION_MS = 180;
|
||||
const dialog = document.getElementById('info-dialog');
|
||||
const title = document.getElementById('info-dialog-title');
|
||||
const menu = document.getElementById('info-menu');
|
||||
const backButton = document.getElementById('info-back');
|
||||
const closeButton = document.getElementById('info-close');
|
||||
const infoButton = document.getElementById('info-button');
|
||||
const pageTitles = Object.freeze({
|
||||
privacy: 'Datenschutzerklärung',
|
||||
imprint: 'Impressum',
|
||||
technology: 'Cookies und Technik'
|
||||
});
|
||||
const menuEntries = Object.freeze([
|
||||
['privacy', 'Datenschutzerklärung'],
|
||||
['imprint', 'Impressum'],
|
||||
['technology', 'Cookies und verwendete JavaScripts']
|
||||
]);
|
||||
|
||||
let elements = null;
|
||||
let dropdownOpen = false;
|
||||
let dropdownCloseTimer = null;
|
||||
|
||||
function ready(callback) {
|
||||
if (document.readyState === 'loading') {
|
||||
@@ -234,9 +230,6 @@
|
||||
}
|
||||
|
||||
function activate(element, handler) {
|
||||
if (!element || typeof element.addEventListener !== 'function') return;
|
||||
if (element.dataset.wegwichtelLegalUiBound === 'true') return;
|
||||
element.dataset.wegwichtelLegalUiBound = 'true';
|
||||
element.addEventListener('pointerup', event => {
|
||||
if (!isActivation(event)) return;
|
||||
event.preventDefault();
|
||||
@@ -251,75 +244,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
function setClass(element, className, enabled) {
|
||||
if (!element || !element.classList) return;
|
||||
element.classList.toggle(className, enabled);
|
||||
}
|
||||
|
||||
function runNextFrame(callback) {
|
||||
if (typeof globalThis.requestAnimationFrame === 'function') {
|
||||
globalThis.requestAnimationFrame(callback);
|
||||
return;
|
||||
}
|
||||
callback();
|
||||
}
|
||||
|
||||
function schedule(callback, timeout) {
|
||||
if (typeof globalThis.setTimeout === 'function') return globalThis.setTimeout(callback, timeout);
|
||||
callback();
|
||||
return null;
|
||||
}
|
||||
|
||||
function cancelSchedule(timer) {
|
||||
if (timer === null || typeof globalThis.clearTimeout !== 'function') return;
|
||||
globalThis.clearTimeout(timer);
|
||||
}
|
||||
|
||||
function setDropdownOpen(open) {
|
||||
if (!elements?.dropdown || !elements?.infoButton) return;
|
||||
dropdownOpen = open;
|
||||
elements.infoButton.setAttribute('aria-expanded', open ? 'true' : 'false');
|
||||
elements.infoButton.setAttribute('aria-label', open ? 'Informationsmenü schließen' : 'Informationsmenü öffnen');
|
||||
cancelSchedule(dropdownCloseTimer);
|
||||
dropdownCloseTimer = null;
|
||||
|
||||
if (open) {
|
||||
elements.dropdown.hidden = false;
|
||||
runNextFrame(() => setClass(elements.dropdown, 'is-open', true));
|
||||
return;
|
||||
}
|
||||
|
||||
setClass(elements.dropdown, 'is-open', false);
|
||||
dropdownCloseTimer = schedule(() => {
|
||||
if (dropdownOpen || !elements?.dropdown) return;
|
||||
elements.dropdown.hidden = true;
|
||||
}, DROPDOWN_ANIMATION_MS);
|
||||
}
|
||||
|
||||
function toggleDropdown() {
|
||||
setDropdownOpen(!dropdownOpen);
|
||||
}
|
||||
|
||||
function elementContains(element, target) {
|
||||
if (!element || !target) return false;
|
||||
if (element === target) return true;
|
||||
return typeof element.contains === 'function' && element.contains(target);
|
||||
}
|
||||
|
||||
function isInsideInfoControl(target) {
|
||||
return elementContains(elements?.infoButton, target) || elementContains(elements?.dropdown, target);
|
||||
}
|
||||
|
||||
function isProgressStorageEnabled() {
|
||||
if (!ns.PrivacyStorage || typeof ns.PrivacyStorage.isProgressStorageEnabled !== 'function') return false;
|
||||
return ns.PrivacyStorage.isProgressStorageEnabled();
|
||||
}
|
||||
|
||||
function setProgressStorageEnabled(enabled) {
|
||||
if (!ns.PrivacyStorage || typeof ns.PrivacyStorage.setProgressStorageEnabled !== 'function') return false;
|
||||
return ns.PrivacyStorage.setProgressStorageEnabled(enabled);
|
||||
}
|
||||
|
||||
function syncStorageToggles() {
|
||||
const enabled = isProgressStorageEnabled();
|
||||
document.querySelectorAll('.progress-storage-toggle').forEach(toggle => {
|
||||
@@ -330,13 +254,24 @@
|
||||
});
|
||||
}
|
||||
|
||||
function showMenu() {
|
||||
title.textContent = 'Informationen';
|
||||
menu.hidden = false;
|
||||
backButton.hidden = true;
|
||||
document.querySelectorAll('[data-info-page]').forEach(page => {
|
||||
page.hidden = true;
|
||||
});
|
||||
}
|
||||
|
||||
function showPage(name) {
|
||||
const pageName = Object.prototype.hasOwnProperty.call(pageTitles, name) ? name : 'privacy';
|
||||
const page = elements?.content?.querySelector(`[data-info-page="${pageName}"]`)
|
||||
?? document.querySelector(`[data-info-page="${pageName}"]`);
|
||||
if (!page) return;
|
||||
|
||||
if (elements?.title) elements.title.textContent = pageTitles[pageName] ?? 'Informationen';
|
||||
title.textContent = pageTitles[name] ?? 'Informationen';
|
||||
menu.hidden = true;
|
||||
backButton.hidden = false;
|
||||
document.querySelectorAll('[data-info-page]').forEach(item => {
|
||||
item.hidden = item !== page;
|
||||
});
|
||||
@@ -352,26 +287,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
function openDialog(name = 'privacy') {
|
||||
if (!elements?.dialog) return;
|
||||
const pageName = Object.prototype.hasOwnProperty.call(pageTitles, name) ? name : 'privacy';
|
||||
setDropdownOpen(false);
|
||||
showPage(pageName);
|
||||
function openDialog() {
|
||||
if (dialog.open) return;
|
||||
showMenu();
|
||||
syncStorageToggles();
|
||||
if (!elements.dialog.open) {
|
||||
if (typeof elements.dialog.showModal === 'function') elements.dialog.showModal();
|
||||
else elements.dialog.setAttribute('open', '');
|
||||
}
|
||||
focusSafely(elements.closeButton ?? elements.dialog);
|
||||
if (typeof dialog.showModal === 'function') dialog.showModal();
|
||||
else dialog.setAttribute('open', '');
|
||||
closeButton.focus();
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
if (elements?.dialog) {
|
||||
if (typeof elements.dialog.close === 'function') elements.dialog.close();
|
||||
else elements.dialog.removeAttribute('open');
|
||||
}
|
||||
setDropdownOpen(false);
|
||||
focusSafely(elements?.infoButton);
|
||||
if (typeof dialog.close === 'function') dialog.close();
|
||||
else dialog.removeAttribute('open');
|
||||
infoButton.focus();
|
||||
}
|
||||
|
||||
function bindStorageToggles() {
|
||||
@@ -388,26 +316,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
function bindDialog() {
|
||||
activate(elements.infoButton, toggleDropdown);
|
||||
activate(elements.closeButton, closeDialog);
|
||||
elements.dropdown.querySelectorAll('[data-info-target]').forEach(button => {
|
||||
activate(button, () => openDialog(button.dataset.infoTarget));
|
||||
});
|
||||
|
||||
if (!document.documentElement.dataset.wegwichtelLegalUiDocumentBound) {
|
||||
document.documentElement.dataset.wegwichtelLegalUiDocumentBound = 'true';
|
||||
document.addEventListener('pointerup', event => {
|
||||
if (!dropdownOpen || isInsideInfoControl(event.target)) return;
|
||||
setDropdownOpen(false);
|
||||
});
|
||||
document.addEventListener('keydown', event => {
|
||||
if (!dropdownOpen || event.key !== 'Escape' || elements?.dialog?.open) return;
|
||||
event.preventDefault();
|
||||
setDropdownOpen(false);
|
||||
focusSafely(elements?.infoButton);
|
||||
});
|
||||
}
|
||||
activate(infoButton, openDialog);
|
||||
activate(closeButton, closeDialog);
|
||||
activate(backButton, showMenu);
|
||||
document.querySelectorAll('[data-info-target]').forEach(button => {
|
||||
activate(button, () => showPage(button.dataset.infoTarget));
|
||||
});
|
||||
|
||||
if (elements.dialog.dataset.wegwichtelLegalUiDialogBound !== 'true') {
|
||||
elements.dialog.dataset.wegwichtelLegalUiDialogBound = 'true';
|
||||
@@ -439,28 +353,5 @@
|
||||
});
|
||||
}
|
||||
|
||||
ns.LegalUi = Object.freeze({
|
||||
open: name => ready(() => {
|
||||
if (!elements) init();
|
||||
openDialog(name);
|
||||
}),
|
||||
close: () => ready(() => {
|
||||
if (!elements) init();
|
||||
closeDialog();
|
||||
}),
|
||||
toggleMenu: () => ready(() => {
|
||||
if (!elements) init();
|
||||
toggleDropdown();
|
||||
}),
|
||||
closeMenu: () => ready(() => {
|
||||
if (!elements) init();
|
||||
setDropdownOpen(false);
|
||||
}),
|
||||
syncStorageToggles: () => ready(() => {
|
||||
if (!elements) init();
|
||||
syncStorageToggles();
|
||||
})
|
||||
});
|
||||
|
||||
ready(init);
|
||||
ns.LegalUi = Object.freeze({ open: openDialog, close: closeDialog, syncStorageToggles });
|
||||
}(globalThis.Wegwichtel ??= {}));
|
||||
|
||||
Reference in New Issue
Block a user