feat: add optional page-turn sound toggle and refine flipbook UI
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
$GLOBALS['TL_DCA']['tl_content']['palettes']['blatterbares_pdf'] = '{type_legend},type,headline;{flipbook_legend},flipbookPdfSrc,flipbookInitialPages,flipbookStartMode,flipbookShowNavigation;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},cssID;{invisible_legend:hide},invisible,start,stop';
|
$GLOBALS['TL_DCA']['tl_content']['palettes']['blatterbares_pdf'] = '{type_legend},type,headline;{flipbook_legend},flipbookPdfSrc,flipbookInitialPages,flipbookStartMode,flipbookShowNavigation,flipbookPlaySound;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},cssID;{invisible_legend:hide},invisible,start,stop';
|
||||||
|
|
||||||
$GLOBALS['TL_DCA']['tl_content']['fields']['flipbookPdfSrc'] = [
|
$GLOBALS['TL_DCA']['tl_content']['fields']['flipbookPdfSrc'] = [
|
||||||
'label' => &$GLOBALS['TL_LANG']['tl_content']['flipbookPdfSrc'],
|
'label' => &$GLOBALS['TL_LANG']['tl_content']['flipbookPdfSrc'],
|
||||||
@@ -39,3 +39,11 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['flipbookShowNavigation'] = [
|
|||||||
'eval' => ['tl_class' => 'w50 m12'],
|
'eval' => ['tl_class' => 'w50 m12'],
|
||||||
'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => '1'],
|
'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => '1'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$GLOBALS['TL_DCA']['tl_content']['fields']['flipbookPlaySound'] = [
|
||||||
|
'label' => &$GLOBALS['TL_LANG']['tl_content']['flipbookPlaySound'],
|
||||||
|
'exclude' => true,
|
||||||
|
'inputType' => 'checkbox',
|
||||||
|
'eval' => ['tl_class' => 'w50 m12'],
|
||||||
|
'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => '1'],
|
||||||
|
];
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ $GLOBALS['TL_LANG']['tl_content']['flipbookStartModeOptions'] = [
|
|||||||
'spread' => 'als Doppelseite starten',
|
'spread' => 'als Doppelseite starten',
|
||||||
];
|
];
|
||||||
$GLOBALS['TL_LANG']['tl_content']['flipbookShowNavigation'] = ['Navigation anzeigen', 'Zeigt Vor-/Zurueck-Buttons unter dem Flipbook an.'];
|
$GLOBALS['TL_LANG']['tl_content']['flipbookShowNavigation'] = ['Navigation anzeigen', 'Zeigt Vor-/Zurueck-Buttons unter dem Flipbook an.'];
|
||||||
|
$GLOBALS['TL_LANG']['tl_content']['flipbookPlaySound'] = ['Blättersound abspielen', 'Spielt beim Blättern einen Sound ab.'];
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ $GLOBALS['TL_LANG']['tl_content']['flipbookStartModeOptions'] = [
|
|||||||
'spread' => 'Start with double-page spread',
|
'spread' => 'Start with double-page spread',
|
||||||
];
|
];
|
||||||
$GLOBALS['TL_LANG']['tl_content']['flipbookShowNavigation'] = ['Show navigation', 'Displays previous/next buttons below the flipbook.'];
|
$GLOBALS['TL_LANG']['tl_content']['flipbookShowNavigation'] = ['Show navigation', 'Displays previous/next buttons below the flipbook.'];
|
||||||
|
$GLOBALS['TL_LANG']['tl_content']['flipbookPlaySound'] = ['Play page-turn sound', 'Plays a sound effect while turning pages.'];
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
data-initial-pages="{{ initialRenderPages|default(4)|e('html_attr') }}"
|
data-initial-pages="{{ initialRenderPages|default(4)|e('html_attr') }}"
|
||||||
data-start-mode="{{ startMode|default('center')|e('html_attr') }}"
|
data-start-mode="{{ startMode|default('center')|e('html_attr') }}"
|
||||||
data-show-navigation="{{ showNavigation ? '1' : '0' }}"
|
data-show-navigation="{{ showNavigation ? '1' : '0' }}"
|
||||||
|
data-play-turn-sound="{{ ((playTurnSound is defined) ? playTurnSound : true) ? '1' : '0' }}"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<div class="mod-pdf-flipbook__status" data-flipbook-loader="1" aria-live="polite">PDF wird geladen ...</div>
|
<div class="mod-pdf-flipbook__status" data-flipbook-loader="1" aria-live="polite">PDF wird geladen ...</div>
|
||||||
@@ -27,6 +28,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<link rel="stylesheet" href="/bundles/flipbook/assets/vendor/flipbook.min.css?v=20260414d">
|
<link rel="stylesheet" href="/bundles/flipbook/assets/vendor/flipbook.min.css?v=20260414f">
|
||||||
<link rel="stylesheet" href="/bundles/flipbook/assets/flipbook-module.css?v=20260414d">
|
<link rel="stylesheet" href="/bundles/flipbook/assets/flipbook-module.css?v=20260414f">
|
||||||
<script type="module" src="/bundles/flipbook/assets/flipbook-module.js?v=20260414d"></script>
|
<script type="module" src="/bundles/flipbook/assets/flipbook-module.js?v=20260414f"></script>
|
||||||
|
|||||||
Binary file not shown.
@@ -31,6 +31,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
background: #e0e0e0;
|
background: #e0e0e0;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mod-pdf-flipbook .c-flipbook {
|
.mod-pdf-flipbook .c-flipbook {
|
||||||
@@ -67,6 +68,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mod-pdf-flipbook__controls {
|
.mod-pdf-flipbook__controls {
|
||||||
|
position: relative;
|
||||||
|
z-index: 20;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.6rem;
|
gap: 0.6rem;
|
||||||
margin-top: 0.9rem;
|
margin-top: 0.9rem;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const MODULE_SELECTOR = '[data-pdf-flipbook-element="1"]';
|
|||||||
const PDF_MODULE_URL = '/bundles/flipbook/assets/vendor/pdf.min.mjs';
|
const PDF_MODULE_URL = '/bundles/flipbook/assets/vendor/pdf.min.mjs';
|
||||||
const PDF_WORKER_URL = '/bundles/flipbook/assets/vendor/pdf.worker.min.mjs';
|
const PDF_WORKER_URL = '/bundles/flipbook/assets/vendor/pdf.worker.min.mjs';
|
||||||
const FLIPBOOK_MODULE_URL = '/bundles/flipbook/assets/vendor/flipbook.esm.min.js';
|
const FLIPBOOK_MODULE_URL = '/bundles/flipbook/assets/vendor/flipbook.esm.min.js';
|
||||||
|
const TURN_SOUND_URL = '/bundles/flipbook/assets/audio/turn.mp3';
|
||||||
const INIT_MARKER = 'pdfFlipbookInitialized';
|
const INIT_MARKER = 'pdfFlipbookInitialized';
|
||||||
const BOOTSTRAP_MARKER = '__mummertPdfFlipbookBootstrapBound';
|
const BOOTSTRAP_MARKER = '__mummertPdfFlipbookBootstrapBound';
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ class PdfFlipbookModule {
|
|||||||
? Math.min(4, Math.max(2, parsedInitialPages))
|
? Math.min(4, Math.max(2, parsedInitialPages))
|
||||||
: 4;
|
: 4;
|
||||||
this.showNavigation = root.dataset.showNavigation === '1';
|
this.showNavigation = root.dataset.showNavigation === '1';
|
||||||
|
this.playTurnSoundEnabled = root.dataset.playTurnSound !== '0';
|
||||||
this.startMode = (root.dataset.startMode === 'spread' || root.dataset.startMode === 'cover')
|
this.startMode = (root.dataset.startMode === 'spread' || root.dataset.startMode === 'cover')
|
||||||
? 'spread'
|
? 'spread'
|
||||||
: 'center';
|
: 'center';
|
||||||
@@ -57,6 +59,7 @@ class PdfFlipbookModule {
|
|||||||
this.renderInProgress = false;
|
this.renderInProgress = false;
|
||||||
this.resizeTimer = null;
|
this.resizeTimer = null;
|
||||||
this.touchStart = null;
|
this.touchStart = null;
|
||||||
|
this.turnSound = this.playTurnSoundEnabled ? this.createTurnSound() : null;
|
||||||
this.aspectRatio = 1.4142;
|
this.aspectRatio = 1.4142;
|
||||||
this.pageWidth = 0;
|
this.pageWidth = 0;
|
||||||
this.pageHeight = 0;
|
this.pageHeight = 0;
|
||||||
@@ -185,11 +188,30 @@ class PdfFlipbookModule {
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
height: `${this.pageHeight}px`,
|
height: `${this.pageHeight}px`,
|
||||||
onPageTurn: () => {
|
onPageTurn: () => {
|
||||||
|
this.playTurnSound();
|
||||||
this.queuePages(this.getLazyCandidates());
|
this.queuePages(this.getLazyCandidates());
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createTurnSound() {
|
||||||
|
const audio = new Audio(TURN_SOUND_URL);
|
||||||
|
audio.preload = 'auto';
|
||||||
|
|
||||||
|
return audio;
|
||||||
|
}
|
||||||
|
|
||||||
|
playTurnSound() {
|
||||||
|
if (!this.playTurnSoundEnabled || !this.turnSound) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.turnSound.currentTime = 0;
|
||||||
|
|
||||||
|
this.turnSound.play().catch(() => {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bindKeyboard() {
|
bindKeyboard() {
|
||||||
this.root.addEventListener('pointerdown', () => {
|
this.root.addEventListener('pointerdown', () => {
|
||||||
this.root.focus();
|
this.root.focus();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class BlatterbaresPdfController extends AbstractContentElementController
|
|||||||
{
|
{
|
||||||
$template->set('pdfUrl', $this->resolvePdfUrl($model));
|
$template->set('pdfUrl', $this->resolvePdfUrl($model));
|
||||||
$template->set('showNavigation', '1' === (string) ($model->flipbookShowNavigation ?? '1'));
|
$template->set('showNavigation', '1' === (string) ($model->flipbookShowNavigation ?? '1'));
|
||||||
|
$template->set('playTurnSound', '1' === (string) ($model->flipbookPlaySound ?? '1'));
|
||||||
$template->set('initialRenderPages', $this->normalizeInitialRenderPages((string) ($model->flipbookInitialPages ?? '4')));
|
$template->set('initialRenderPages', $this->normalizeInitialRenderPages((string) ($model->flipbookInitialPages ?? '4')));
|
||||||
$template->set('startMode', $this->normalizeStartMode((string) ($model->flipbookStartMode ?? 'center')));
|
$template->set('startMode', $this->normalizeStartMode((string) ($model->flipbookStartMode ?? 'center')));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user