Add admin menu drawer and poll cloning, drop participant screen tools
- Remove fullscreen and wake lock buttons from the participant view. - Turn the admin sidebar into a drawer below 900px, opened from a header menu button next to the theme switch (progressive enhancement). - Add "Umfrage kopieren": clone a poll with all slides, options and images but without responses, with its own join code and admin link. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0f91377de3
commit
bd57f23be6
15 files changed
+374
-138
No files matched your search
+46
-81
@@ -1704,88 +1704,7 @@
|
||||
|
||||
// ------------------------------------------------------------------ participant
|
||||
|
||||
// Fullscreen and screen wake lock for the participant view (both optional, buttons stay hidden if unsupported).
|
||||
function initScreenTools(root) {
|
||||
function setPressed(button, on) {
|
||||
var text = button.getAttribute(on ? 'data-label-on' : 'data-label-off');
|
||||
button.setAttribute('aria-pressed', on ? 'true' : 'false');
|
||||
button.setAttribute('aria-label', text);
|
||||
button.title = text;
|
||||
}
|
||||
|
||||
// The buttons live in the layout header, outside the participant root.
|
||||
var fsButton = document.querySelector('[data-fullscreen-toggle]');
|
||||
if (fsButton && document.fullscreenEnabled) {
|
||||
fsButton.hidden = false;
|
||||
fsButton.addEventListener('click', function () {
|
||||
if (document.fullscreenElement) {
|
||||
document.exitFullscreen();
|
||||
} else {
|
||||
document.documentElement.requestFullscreen().catch(function () {});
|
||||
}
|
||||
});
|
||||
// Also fires when leaving with Esc/back gesture.
|
||||
document.addEventListener('fullscreenchange', function () {
|
||||
setPressed(fsButton, !!document.fullscreenElement);
|
||||
});
|
||||
}
|
||||
|
||||
var wlButton = document.querySelector('[data-wakelock-toggle]');
|
||||
if (wlButton && 'wakeLock' in navigator) {
|
||||
// The page reloads on every slide change, so the choice is kept per tab and re-applied on load.
|
||||
var STORE = 'plenario-wakelock';
|
||||
// On by default; only an explicit "off" is remembered.
|
||||
var wanted = true;
|
||||
var sentinel = null;
|
||||
try {
|
||||
wanted = sessionStorage.getItem(STORE) !== '0';
|
||||
} catch (e) {
|
||||
// storage blocked: choice only lasts until the next slide
|
||||
}
|
||||
var remember = function () {
|
||||
try {
|
||||
sessionStorage.setItem(STORE, wanted ? '1' : '0');
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
};
|
||||
|
||||
var acquire = function () {
|
||||
if (!wanted || sentinel || document.visibilityState !== 'visible') {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return navigator.wakeLock.request('screen').then(function (lock) {
|
||||
sentinel = lock;
|
||||
// The browser releases the lock when the tab is hidden; re-acquired on return.
|
||||
lock.addEventListener('release', function () {
|
||||
sentinel = null;
|
||||
});
|
||||
}).catch(function () {
|
||||
wanted = false; // denied (e.g. battery saver)
|
||||
remember();
|
||||
setPressed(wlButton, false);
|
||||
});
|
||||
};
|
||||
|
||||
wlButton.hidden = false;
|
||||
setPressed(wlButton, wanted);
|
||||
acquire();
|
||||
wlButton.addEventListener('click', function () {
|
||||
wanted = !wanted;
|
||||
remember();
|
||||
setPressed(wlButton, wanted);
|
||||
if (wanted) {
|
||||
acquire();
|
||||
} else if (sentinel) {
|
||||
sentinel.release();
|
||||
}
|
||||
});
|
||||
document.addEventListener('visibilitychange', acquire);
|
||||
}
|
||||
}
|
||||
|
||||
function initParticipant(root) {
|
||||
initScreenTools(root);
|
||||
var stateUrl = root.getAttribute('data-state-url');
|
||||
var voteUrl = root.getAttribute('data-vote-url');
|
||||
var version = root.getAttribute('data-version');
|
||||
@@ -3161,10 +3080,56 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Admin menu drawer: below 900px the sidebar slides in from the right (CSS), opened by the header button.
|
||||
// Without JS the button stays hidden and the sidebar remains a normal block below the slides.
|
||||
function initDrawer() {
|
||||
var toggle = document.querySelector('[data-drawer-toggle]');
|
||||
var drawer = toggle ? document.getElementById(toggle.getAttribute('aria-controls')) : null;
|
||||
if (!toggle || !drawer) {
|
||||
return;
|
||||
}
|
||||
var root = document.body;
|
||||
drawer.classList.add('sidebar--drawer');
|
||||
toggle.hidden = false;
|
||||
|
||||
function setOpen(open) {
|
||||
root.classList.toggle('drawer-open', open);
|
||||
toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
|
||||
if (open) {
|
||||
var close = drawer.querySelector('[data-drawer-close]');
|
||||
if (close) {
|
||||
close.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
toggle.addEventListener('click', function () {
|
||||
setOpen(!root.classList.contains('drawer-open'));
|
||||
});
|
||||
document.addEventListener('click', function (event) {
|
||||
var target = event.target.closest ? event.target.closest('[data-drawer-close], a[href^="#"]') : null;
|
||||
if (target && root.classList.contains('drawer-open') && (target.hasAttribute('data-drawer-close') || drawer.contains(target))) {
|
||||
setOpen(false);
|
||||
}
|
||||
});
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Escape' && root.classList.contains('drawer-open') && !document.querySelector('dialog[open]')) {
|
||||
setOpen(false);
|
||||
toggle.focus();
|
||||
}
|
||||
});
|
||||
// Back to a wide screen: the sidebar is a normal column again.
|
||||
window.addEventListener('resize', function () {
|
||||
if (window.innerWidth > 900 && root.classList.contains('drawer-open')) {
|
||||
setOpen(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.querySelectorAll('[data-theme-switch]').forEach(initThemeSwitch);
|
||||
initWidgets(document);
|
||||
initShare();
|
||||
initDrawer();
|
||||
initQrDownload();
|
||||
initAdminDashboard();
|
||||
document.querySelectorAll('[data-presenter]').forEach(initPresenter);
|
||||
|
||||
Reference in new issue
Block a user