Merge origin/main into feature/participant-screen-tools
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
30 files changed
+1161
-91
No files matched your search
@@ -228,12 +228,14 @@ textarea { resize: vertical; }
|
||||
|
||||
.slide-list { list-style: none; padding: 0; margin: 0 0 16px; }
|
||||
.slide-item {
|
||||
display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center;
|
||||
display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 16px; align-items: center;
|
||||
background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
|
||||
padding: 14px 16px; margin-bottom: 10px;
|
||||
}
|
||||
.slide-item--current { border-color: var(--c1); box-shadow: 0 0 0 2px rgba(224, 69, 123, .15); }
|
||||
.slide-item__pos { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; }
|
||||
.slide-item--hidden { border-style: dashed; background: var(--surface-2); }
|
||||
.slide-item--hidden .slide-item__body { opacity: .75; }
|
||||
.slide-item__pos {width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; }
|
||||
.slide-item__lead { display: flex; align-items: center; gap: 4px; }
|
||||
.slide-list__hint { font-size: .85rem; margin: 0 0 8px; }
|
||||
.drag-handle {
|
||||
@@ -257,11 +259,8 @@ textarea { resize: vertical; }
|
||||
.slide-embed summary:hover { color: var(--text); }
|
||||
.slide-embed .copy-field { margin-top: 6px; }
|
||||
.slide-embed input { min-width: 0; flex: 1; }
|
||||
.slide-item__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
|
||||
@media (max-width: 700px) {
|
||||
.slide-item { grid-template-columns: auto minmax(0, 1fr); }
|
||||
.slide-item__actions { grid-column: 1 / -1; justify-content: flex-start; }
|
||||
}
|
||||
.slide-item__actions { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-start; }
|
||||
.button--icon { min-width: 40px; min-height: 36px; padding: 6px 8px; font-size: 1.05rem; }
|
||||
|
||||
.type-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
|
||||
.type-card { display: block; padding: 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); border-top: 4px solid var(--c0); }
|
||||
@@ -542,7 +541,9 @@ textarea { resize: vertical; }
|
||||
.qa-item.is-current { box-shadow: inset 0 0 0 2px var(--c1); }
|
||||
.qa-votes { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--qa); position: relative; }
|
||||
.qa-own { font-size: .85rem; color: var(--muted); white-space: nowrap; }
|
||||
.qa-item:has(.qa-own-actions) { flex-wrap: wrap; }
|
||||
/* Own questions: text on its own row, label and edit/delete below it (otherwise the text gets squeezed on phones). */
|
||||
.qa-item:has(.qa-own-actions) { flex-wrap: wrap; row-gap: 6px; }
|
||||
.qa-item:has(.qa-own-actions) .qa-item__text { flex-basis: 100%; }
|
||||
.qa-own-actions { flex: none; display: inline-flex; gap: 4px; margin-left: auto; }
|
||||
.qa-own-actions .button { min-height: 36px; }
|
||||
.qa-item.is-editing { display: block; }
|
||||
@@ -551,6 +552,12 @@ textarea { resize: vertical; }
|
||||
.qa-stepper { flex: none; display: inline-flex; align-items: center; gap: 6px; }
|
||||
.qa-stepper__count { min-width: 3.2em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
|
||||
.qa-stepper.is-active .qa-stepper__count { color: var(--qa); }
|
||||
/* Phones: voting controls below the question, so the text keeps the full width. */
|
||||
@media (max-width: 700px) {
|
||||
.qa-item:has(.qa-stepper) { flex-wrap: wrap; row-gap: 8px; }
|
||||
.qa-item:has(.qa-stepper) .qa-item__text { flex-basis: 100%; }
|
||||
.qa-item:has(.qa-stepper) { justify-content: center; }
|
||||
}
|
||||
.qa-upvote { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 2px solid var(--qa); background: var(--surface); color: var(--qa); font: inherit; font-size: 1.3rem; font-weight: 700; line-height: 1; cursor: pointer; }
|
||||
.qa-upvote--up { background: var(--qa); color: var(--surface); }
|
||||
.qa-upvote:disabled { opacity: .45; cursor: not-allowed; }
|
||||
@@ -735,3 +742,27 @@ body.present {
|
||||
.theme-switch { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; height: 40px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
|
||||
.theme-switch:hover { border-color: var(--primary); }
|
||||
.theme-switch__icon { font-size: 1.3em; line-height: 1; }
|
||||
|
||||
/* Slide form in a dialog (admin dashboard) */
|
||||
/* The dialog itself does not scroll (overflow visible), so the close button can sit on its outer corner;
|
||||
the inner panel carries border, background and scrolling. */
|
||||
.modal { width: min(720px, calc(100vw - 24px)); padding: 0; border: 0; background: transparent; color: var(--text); overflow: visible; }
|
||||
.modal::backdrop { background: rgba(10, 12, 30, .55); }
|
||||
.modal__panel {
|
||||
max-height: calc(100dvh - 24px); overflow: auto;
|
||||
border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
|
||||
}
|
||||
.modal .card--form { max-width: none; margin: 0; border: 0; box-shadow: none; background: transparent; }
|
||||
.modal__close {
|
||||
position: absolute; top: -14px; right: -14px; z-index: 1; width: 36px; height: 36px; padding: 0;
|
||||
display: grid; place-items: center; border: 1px solid var(--border); border-radius: 50%;
|
||||
background: var(--surface); color: var(--text); font-size: 1rem; line-height: 1; cursor: pointer;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
.modal__close:hover { background: var(--surface-2); }
|
||||
.modal__close:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
|
||||
.modal .message { margin: 16px 16px 0; cursor: default; }
|
||||
body:has(dialog[open]) { overflow: hidden; }
|
||||
.slide-item__actions form { display: contents; }
|
||||
.slide-item__actions button:disabled, .admin-head__actions button:disabled { opacity: .6; cursor: progress; }
|
||||
+236
-17
@@ -13,6 +13,10 @@
|
||||
* - [data-sortable] admin slide list: drag & drop / arrow keys via [data-drag-handle], POSTs ids[] to the URL
|
||||
* - [data-order-options] slide form of ordering slides: sortable rows (correct order), "add entry"
|
||||
* - [data-order-form] participant answer of ordering slides: sortable items posting order[]
|
||||
* - [data-live] admin dashboard: forms inside (hide, delete, duplicate, …) run via fetch and refresh
|
||||
* the [data-refresh] regions instead of reloading the page (header X-Fragment)
|
||||
* - [data-modal] link whose target page (slide form) opens in the <dialog data-modal-dialog>
|
||||
* - [data-confirm] on a submit button: window.confirm() before the form is sent (replaces inline onclick, CSP)
|
||||
* - [data-theme-switch] cycles the colour scheme (data-theme on <html>, stored in localStorage),
|
||||
* see templates/element/theme_init.php for the pre-paint part
|
||||
*
|
||||
@@ -1000,7 +1004,6 @@
|
||||
var onStage = options && options.onStage;
|
||||
var onQuestion = options && options.onQuestion;
|
||||
var questions = results.questions;
|
||||
var maxVotes = Math.max.apply(null, questions.map(function (q) { return q.votes; }).concat([1]));
|
||||
var children = [Qa.steps(results.stage, onStage, results.stages)];
|
||||
var withVotes = results.maxUpvotes > 0;
|
||||
|
||||
@@ -1027,11 +1030,10 @@
|
||||
+ results.maxUpvotes + (results.maxUpvotes === 1 ? ' Stimme' : ' Stimmen')
|
||||
+ (results.maxPerQuestion < results.maxUpvotes ? ' (höchstens ' + results.maxPerQuestion + ' pro Frage)' : '')
|
||||
+ ' · bisher ' + results.upvotes + ' vergeben' }));
|
||||
children.push(el('ol', { class: 'qa-list' }, questions.map(function (question) {
|
||||
// No counts or ranking while voting is open (the server sends none), so the stage does not sway the vote.
|
||||
children.push(el('ul', { class: 'qa-list' }, questions.map(function (question) {
|
||||
return el('li', { class: 'qa-item' }, [
|
||||
el('span', { class: 'qa-item__text', text: question.text }),
|
||||
votes(question),
|
||||
el('span', { class: 'qa-item__bar', style: 'width:' + (question.votes / maxVotes * 100) + '%' })
|
||||
el('span', { class: 'qa-item__text', text: question.text })
|
||||
]);
|
||||
})));
|
||||
} else if (questions.length === 0) {
|
||||
@@ -1127,8 +1129,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
function initCopy() {
|
||||
document.querySelectorAll('[data-copy]').forEach(function (button) {
|
||||
function initCopy(root) {
|
||||
(root || document).querySelectorAll('[data-copy]').forEach(function (button) {
|
||||
button.addEventListener('click', function () { copyFrom(button); });
|
||||
});
|
||||
}
|
||||
@@ -1314,11 +1316,12 @@
|
||||
|
||||
if (!slide) {
|
||||
q('[data-status]').textContent = state.poll.isPaused ? 'Pause' : '';
|
||||
var allHidden = state.count === 0 && state.hiddenCount > 0;
|
||||
q('[data-question]').textContent = state.count === 0
|
||||
? 'Noch keine Folien angelegt'
|
||||
? (allHidden ? 'Alle Folien sind ausgeblendet' : 'Noch keine Folien angelegt')
|
||||
: state.poll.title;
|
||||
q('[data-description]').textContent = state.count === 0
|
||||
? 'Lege in der Verwaltung Fragen an.'
|
||||
? (allHidden ? 'Blende in der Verwaltung mindestens eine Folie ein.' : 'Lege in der Verwaltung Fragen an.')
|
||||
: (state.poll.isPaused
|
||||
? 'Teilnehmende sehen gerade eine Pause-Seite. Drücke P oder → zum Fortsetzen.'
|
||||
: 'Drücke → um zu starten.');
|
||||
@@ -1437,9 +1440,9 @@
|
||||
var indicator = q('[data-live]');
|
||||
indicator.textContent = !state.poll.isActive
|
||||
? 'Umfrage geschlossen'
|
||||
: (isLive ? '● live' : 'nicht live');
|
||||
: (state.isHidden ? 'ausgeblendet' : (isLive ? '● live' : 'nicht live'));
|
||||
indicator.classList.toggle('is-live', isLive);
|
||||
q('[data-go-live]').hidden = isLive || !state.poll.isActive;
|
||||
q('[data-go-live]').hidden = isLive || !state.poll.isActive || !!state.isHidden;
|
||||
}
|
||||
function goLive() {
|
||||
live = true;
|
||||
@@ -2562,8 +2565,228 @@
|
||||
button.hidden = false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ admin dashboard without reloads
|
||||
|
||||
/**
|
||||
* Loads server-rendered admin pages as fragments (layout "fragment": content + flash only)
|
||||
* and merges them into the open page. The HTML comes from our own templates (escaped there);
|
||||
* it is adopted as DOM nodes, never written with innerHTML.
|
||||
*/
|
||||
var Fragments = {
|
||||
request: function (url, options) {
|
||||
options = options || {};
|
||||
return fetch(url, {
|
||||
method: options.method || 'GET',
|
||||
body: options.body,
|
||||
credentials: 'same-origin',
|
||||
cache: 'no-store',
|
||||
headers: { Accept: 'text/html', 'X-Fragment': '1', 'X-CSRF-Token': csrfToken() }
|
||||
}).then(function (response) {
|
||||
if (!response.ok) {
|
||||
throw new Error('HTTP ' + response.status);
|
||||
}
|
||||
return response.text();
|
||||
}).then(function (html) {
|
||||
return new DOMParser().parseFromString(html, 'text/html');
|
||||
});
|
||||
},
|
||||
|
||||
/** Replaces the [data-refresh] regions (all, or only `names`) with those of `doc`. */
|
||||
apply: function (doc, names) {
|
||||
doc.querySelectorAll('[data-refresh]').forEach(function (fresh) {
|
||||
var name = fresh.getAttribute('data-refresh');
|
||||
var old = document.querySelector('[data-refresh="' + name + '"]');
|
||||
if (!old || (names && names.indexOf(name) < 0)) {
|
||||
return;
|
||||
}
|
||||
var node = document.importNode(fresh, true);
|
||||
old.replaceWith(node);
|
||||
initWidgets(node);
|
||||
});
|
||||
},
|
||||
|
||||
/** Shows an error where the user is looking (dialog or flash area). */
|
||||
fail: function (container, text) {
|
||||
var message = el('div', { class: 'message error', role: 'alert', 'data-dismiss': '', text: text });
|
||||
container.insertBefore(message, container.firstChild);
|
||||
}
|
||||
};
|
||||
|
||||
function initAdminDashboard() {
|
||||
var dialog = document.querySelector('[data-modal-dialog]');
|
||||
var body = dialog ? dialog.querySelector('[data-modal-body]') : null;
|
||||
var dirty = false;
|
||||
var focusId = null;
|
||||
|
||||
function flashArea() {
|
||||
return document.querySelector('[data-refresh="flash"]') || document.body;
|
||||
}
|
||||
|
||||
/** Keeps the keyboard position after a list refresh: same button, else the slide, else the next slide. */
|
||||
function restoreFocus(target) {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
var item = target.id ? document.querySelector('[data-slide-id="' + target.id + '"]') : null;
|
||||
var node = null;
|
||||
if (item) {
|
||||
node = (target.action && item.querySelector('form[action="' + target.action + '"] button'))
|
||||
|| item.querySelector('.slide-item__title');
|
||||
} else if (target.nextId) {
|
||||
node = document.querySelector('[data-slide-id="' + target.nextId + '"] .slide-item__title');
|
||||
}
|
||||
if (node) {
|
||||
node.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function refreshList() {
|
||||
return Fragments.request(window.location.href).then(function (doc) {
|
||||
Fragments.apply(doc, ['head', 'slides']);
|
||||
});
|
||||
}
|
||||
|
||||
function openModal(doc) {
|
||||
var content = doc.querySelector('[data-modal-content]');
|
||||
var flash = doc.querySelector('[data-refresh="flash"]');
|
||||
body.replaceChildren();
|
||||
if (flash && flash.childNodes.length) {
|
||||
// Shown inside the dialog (validation errors), not as flash of the page behind it.
|
||||
var notes = document.importNode(flash, true);
|
||||
notes.removeAttribute('data-refresh');
|
||||
body.appendChild(notes);
|
||||
}
|
||||
body.appendChild(document.importNode(content, true));
|
||||
initWidgets(body);
|
||||
dirty = false;
|
||||
if (!dialog.open) {
|
||||
dialog.showModal();
|
||||
}
|
||||
dialog.querySelector('[data-modal-panel]').scrollTop = 0;
|
||||
}
|
||||
|
||||
function requestClose() {
|
||||
if (dirty && !window.confirm('Änderungen verwerfen?')) {
|
||||
return;
|
||||
}
|
||||
dialog.close();
|
||||
}
|
||||
|
||||
/** Result of a POST: either the dashboard (done) or a form (open in the dialog). */
|
||||
function handle(doc, source) {
|
||||
if (doc.querySelector('[data-modal-content]')) {
|
||||
// A form: validation errors (dialog stays open) or the copy of a duplicated slide.
|
||||
var wasOpen = dialog.open;
|
||||
openModal(doc);
|
||||
|
||||
return wasOpen ? null : refreshList();
|
||||
}
|
||||
Fragments.apply(doc);
|
||||
if (dialog && dialog.open) {
|
||||
dirty = false;
|
||||
dialog.close();
|
||||
}
|
||||
restoreFocus(source);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
document.addEventListener('submit', function (event) {
|
||||
var form = event.target;
|
||||
var submitter = event.submitter || form.querySelector('button[type=submit], button:not([type])');
|
||||
var confirmText = submitter && submitter.getAttribute('data-confirm');
|
||||
if (confirmText && !window.confirm(confirmText)) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
var inDialog = dialog !== null && dialog.contains(form);
|
||||
if (!inDialog && !form.closest('[data-live]')) {
|
||||
return; // plain form: normal navigation
|
||||
}
|
||||
event.preventDefault();
|
||||
if (form.hasAttribute('aria-busy')) {
|
||||
return;
|
||||
}
|
||||
var item = form.closest('[data-slide-id]');
|
||||
var next = item ? item.nextElementSibling : null;
|
||||
var source = inDialog ? { id: focusId } : {
|
||||
id: item ? item.getAttribute('data-slide-id') : null,
|
||||
action: form.getAttribute('action'),
|
||||
nextId: next ? next.getAttribute('data-slide-id') : null
|
||||
};
|
||||
form.setAttribute('aria-busy', 'true');
|
||||
if (submitter) {
|
||||
submitter.disabled = true;
|
||||
}
|
||||
Fragments.request(form.action, { method: 'POST', body: new FormData(form) })
|
||||
.then(function (doc) { return handle(doc, source); })
|
||||
.catch(function () {
|
||||
form.removeAttribute('aria-busy');
|
||||
if (submitter) {
|
||||
submitter.disabled = false;
|
||||
}
|
||||
Fragments.fail(inDialog ? body : flashArea(), 'Das hat nicht geklappt. Bitte lade die Seite neu und versuche es noch einmal.');
|
||||
});
|
||||
});
|
||||
|
||||
if (!dialog) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.addEventListener('click', function (event) {
|
||||
var link = event.target.closest ? event.target.closest('a[data-modal]') : null;
|
||||
if (!link || event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
var item = link.closest('[data-slide-id]');
|
||||
focusId = item ? item.getAttribute('data-slide-id') : null;
|
||||
Fragments.request(link.href).then(openModal).catch(function () {
|
||||
window.location.href = link.href; // no dialog possible: open the page as usual
|
||||
});
|
||||
});
|
||||
|
||||
dialog.addEventListener('click', function (event) {
|
||||
if (event.target.closest('[data-modal-close]')) {
|
||||
event.preventDefault();
|
||||
requestClose();
|
||||
}
|
||||
});
|
||||
|
||||
// Only a click that starts and ends on the backdrop closes (not a text selection dragged outside).
|
||||
var pressedOnBackdrop = false;
|
||||
dialog.addEventListener('mousedown', function (event) { pressedOnBackdrop = event.target === dialog; });
|
||||
dialog.addEventListener('click', function (event) {
|
||||
if (event.target === dialog && pressedOnBackdrop) {
|
||||
requestClose();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.addEventListener('cancel', function (event) {
|
||||
if (dirty && !window.confirm('Änderungen verwerfen?')) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
dialog.addEventListener('close', function () {
|
||||
body.replaceChildren();
|
||||
dirty = false;
|
||||
});
|
||||
body.addEventListener('input', function () { dirty = true; });
|
||||
body.addEventListener('change', function () { dirty = true; });
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ boot
|
||||
|
||||
/** Initialises the widgets inside `root` (the whole page at boot, or a freshly inserted fragment). */
|
||||
function initWidgets(root) {
|
||||
initCopy(root);
|
||||
root.querySelectorAll('[data-youtube-form]').forEach(initYouTubeForm);
|
||||
root.querySelectorAll('[data-quiz-options]').forEach(initQuizOptions);
|
||||
root.querySelectorAll('[data-sortable]').forEach(initSortable);
|
||||
root.querySelectorAll('[data-order-options]').forEach(initOrderOptions);
|
||||
root.querySelectorAll('[data-scale-style]').forEach(initScaleStyle);
|
||||
}
|
||||
|
||||
// Flash messages: click hides them (delegated, no inline handlers because of the CSP).
|
||||
document.addEventListener('click', function (event) {
|
||||
var message = event.target.closest ? event.target.closest('[data-dismiss]') : null;
|
||||
@@ -2574,16 +2797,12 @@
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.querySelectorAll('[data-theme-switch]').forEach(initThemeSwitch);
|
||||
initCopy();
|
||||
initWidgets(document);
|
||||
initShare();
|
||||
document.querySelectorAll('[data-youtube-form]').forEach(initYouTubeForm);
|
||||
initAdminDashboard();
|
||||
document.querySelectorAll('[data-presenter]').forEach(initPresenter);
|
||||
document.querySelectorAll('[data-participant]').forEach(initParticipant);
|
||||
document.querySelectorAll('[data-quiz-options]').forEach(initQuizOptions);
|
||||
document.querySelectorAll('[data-sortable]').forEach(initSortable);
|
||||
document.querySelectorAll('[data-order-options]').forEach(initOrderOptions);
|
||||
document.querySelectorAll('[data-order-form]').forEach(initOrderForm);
|
||||
document.querySelectorAll('[data-scale-style]').forEach(initScaleStyle);
|
||||
|
||||
// Prevent double submits of vote forms.
|
||||
document.querySelectorAll('.vote-form').forEach(function (form) {
|
||||
|
||||
Reference in new issue
Block a user