Feature/slide images #81
No files matched your search
@@ -47,6 +47,8 @@ $maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 *
|
|||||||
<img src="<?= h($this->Url->build(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $slide->image])) ?>"
|
<img src="<?= h($this->Url->build(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $slide->image])) ?>"
|
||||||
alt="<?= h((string)$slide->image_alt) ?>" width="<?= (int)$slide->image_width ?>" height="<?= (int)$slide->image_height ?>">
|
alt="<?= h((string)$slide->image_alt) ?>" width="<?= (int)$slide->image_width ?>" height="<?= (int)$slide->image_height ?>">
|
||||||
</figure>
|
</figure>
|
||||||
|
<?php // Without JavaScript the checkbox does the job; with it, the button toggles the same checkbox. ?>
|
||||||
|
<div class="image-fields__remove" data-image-remove>
|
||||||
<?= $this->Form->control('remove_image', [
|
<?= $this->Form->control('remove_image', [
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'label' => __('Bild entfernen'),
|
'label' => __('Bild entfernen'),
|
||||||
@@ -54,6 +56,16 @@ $maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 *
|
|||||||
'hiddenField' => false,
|
'hiddenField' => false,
|
||||||
'checked' => false,
|
'checked' => false,
|
||||||
]) ?>
|
]) ?>
|
||||||
|
<button type="button" class="button button--danger button--small" hidden aria-pressed="false" data-image-remove-button
|
||||||
|
data-label-remove="<?= h(__('Bild entfernen')) ?>" data-label-undo="<?= h(__('Entfernen rückgängig machen')) ?>">
|
||||||
|
<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||||
|
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||||
|
<path d="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14M10 11v5M14 11v5"/>
|
||||||
|
</svg>
|
||||||
|
<span data-label><?= __('Bild entfernen') ?></span>
|
||||||
|
</button>
|
||||||
|
<span class="hint" role="status" aria-live="polite" data-image-remove-status></span>
|
||||||
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="input file<?= $imageError ? ' error' : '' ?>">
|
<div class="input file<?= $imageError ? ' error' : '' ?>">
|
||||||
<label for="image-file"><?= $hasImage ? __('Anderes Bild hochladen') : __('Bild hochladen') ?></label>
|
<label for="image-file"><?= $hasImage ? __('Anderes Bild hochladen') : __('Bild hochladen') ?></label>
|
||||||
|
|||||||
@@ -800,4 +800,8 @@ body:has(dialog[open]) { overflow: hidden; }
|
|||||||
.image-fields > legend { font-weight: 600; padding: 0; margin-bottom: .5em; }
|
.image-fields > legend { font-weight: 600; padding: 0; margin-bottom: .5em; }
|
||||||
.image-fields__layout > legend { padding: 0; margin-bottom: .25em; }
|
.image-fields__layout > legend { padding: 0; margin-bottom: .25em; }
|
||||||
.image-fields__current { margin: 0 0 .75em; }
|
.image-fields__current { margin: 0 0 .75em; }
|
||||||
|
.image-fields__current.is-removed img { opacity: .3; filter: grayscale(1); }
|
||||||
|
.image-fields__remove { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 1em; }
|
||||||
|
.image-fields__remove .button { display: inline-flex; align-items: center; gap: 6px; }
|
||||||
|
.image-fields__remove .hint { margin: 0; }
|
||||||
.image-fields__current img { display: block; max-width: 100%; max-height: 180px; width: auto; height: auto; border-radius: 6px; }
|
.image-fields__current img { display: block; max-width: 100%; max-height: 180px; width: auto; height: auto; border-radius: 6px; }
|
||||||
@@ -2232,6 +2232,33 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------ slide form
|
// ------------------------------------------------------------------ slide form
|
||||||
|
|
||||||
|
/** Slide image: a trash button toggles the "remove image" checkbox (the checkbox stays for use without JavaScript). */
|
||||||
|
function initImageRemove(box) {
|
||||||
|
var checkbox = box.querySelector('input[type="checkbox"]');
|
||||||
|
var button = box.querySelector('[data-image-remove-button]');
|
||||||
|
var status = box.querySelector('[data-image-remove-status]');
|
||||||
|
var figure = box.parentNode.querySelector('.image-fields__current');
|
||||||
|
if (!checkbox || !button) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var field = checkbox.closest('.input');
|
||||||
|
if (field) {
|
||||||
|
field.hidden = true;
|
||||||
|
}
|
||||||
|
button.hidden = false;
|
||||||
|
button.addEventListener('click', function () {
|
||||||
|
checkbox.checked = !checkbox.checked;
|
||||||
|
button.setAttribute('aria-pressed', checkbox.checked ? 'true' : 'false');
|
||||||
|
button.querySelector('[data-label]').textContent = button.getAttribute(checkbox.checked ? 'data-label-undo' : 'data-label-remove');
|
||||||
|
if (figure) {
|
||||||
|
figure.classList.toggle('is-removed', checkbox.checked);
|
||||||
|
}
|
||||||
|
if (status) {
|
||||||
|
status.textContent = checkbox.checked ? 'Das Bild wird beim Speichern entfernt.' : '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** Quiz slide form: add further answer rows (the server renders a few already). */
|
/** Quiz slide form: add further answer rows (the server renders a few already). */
|
||||||
function initQuizOptions(fieldset) {
|
function initQuizOptions(fieldset) {
|
||||||
var list = fieldset.querySelector('[data-quiz-list]');
|
var list = fieldset.querySelector('[data-quiz-list]');
|
||||||
@@ -2851,6 +2878,7 @@
|
|||||||
initCopy(root);
|
initCopy(root);
|
||||||
root.querySelectorAll('[data-youtube-form]').forEach(initYouTubeForm);
|
root.querySelectorAll('[data-youtube-form]').forEach(initYouTubeForm);
|
||||||
root.querySelectorAll('[data-quiz-options]').forEach(initQuizOptions);
|
root.querySelectorAll('[data-quiz-options]').forEach(initQuizOptions);
|
||||||
|
root.querySelectorAll('[data-image-remove]').forEach(initImageRemove);
|
||||||
root.querySelectorAll('[data-sortable]').forEach(initSortable);
|
root.querySelectorAll('[data-sortable]').forEach(initSortable);
|
||||||
root.querySelectorAll('[data-order-options]').forEach(initOrderOptions);
|
root.querySelectorAll('[data-order-options]').forEach(initOrderOptions);
|
||||||
root.querySelectorAll('[data-scale-style]').forEach(initScaleStyle);
|
root.querySelectorAll('[data-scale-style]').forEach(initScaleStyle);
|
||||||
|
|||||||
Reference in new issue
Block a user