1<?php 2 3declare(strict_types=1); 4 5use Fisharebest\Webtrees\Family; 6use Fisharebest\Webtrees\I18N; 7use Fisharebest\Webtrees\Individual; 8use Fisharebest\Webtrees\Media; 9use Fisharebest\Webtrees\MediaFile; 10use Fisharebest\Webtrees\Source; 11use Fisharebest\Webtrees\Tree; 12use Illuminate\Support\Collection; 13 14/** 15 * @var int $block_id 16 * @var int $delay 17 * @var Collection<int,Family> $linked_families 18 * @var Collection<int,Individual> $linked_individuals 19 * @var Collection<int,Source> $linked_sources 20 * @var Media $media 21 * @var MediaFile $media_file 22 * @var bool $show_controls 23 * @var bool $start_automatically 24 * @var Tree $tree 25 */ 26 27?> 28 29<div class="wt-slide-show-container"> 30 <?php if ($show_controls) : ?> 31 <div class="wt-slide-show-controls text-center"> 32 <a href="#" title="<?= I18N::translate('Play') ?>" <?= $start_automatically ? 'hidden' : '' ?>> 33 <?= view('icons/media-play') ?> 34 <span class="visually-hidden"><?= I18N::translate('Play') ?></span> 35 </a> 36 <a href="#" title="<?= I18N::translate('Stop') ?>" <?= $start_automatically ? '' : 'hidden' ?>> 37 <?= view('icons/media-stop') ?> 38 <span class="visually-hidden"><?= I18N::translate('Stop') ?></span> 39 </a> 40 <a href="#" title="<?= I18N::translate('Next image') ?>"> 41 <?= view('icons/media-next') ?> 42 <span class="visually-hidden"><?= I18N::translate('Next image') ?></span> 43 </a> 44 </div> 45 <?php endif ?> 46 47 <figure class="wt-slide-show-figure text-center"> 48 <?= $media_file->displayImage(200, 200, 'contain', ['class' => 'slide-show-image img-fluid']) ?> 49 <figcaption class="wt-slide-show-figcaption"> 50 <a href="<?= e($media->url()) ?>"> 51 <b><?= $media->fullName() ?></b> 52 </a> 53 </figcaption> 54 </figure> 55 56 <p class="wt-slide-show-notes text-center"> 57 <?php foreach ($media->facts(['NOTE']) as $fact) : ?> 58 <?= view('fact-gedcom-fields', ['gedcom' => $fact->gedcom(), 'parent' => $media->tag(), 'tree' => $tree]) ?> 59 <?php endforeach ?> 60 </p> 61 62 <ul class="fa-ul wt-slide-show-links"> 63 <?php foreach ($linked_individuals as $individual) : ?> 64 <li class="wt-slide-show-link"> 65 <span class="fa-li" title="<?= I18N::translate('Individual') ?>"><?= view('icons/individual') ?></span> 66 <a href="<?= e($individual->url()) ?>"> 67 <?= $individual->fullName() ?> 68 <span class="wt-slide-show-link-lifespan"><?= $individual->lifespan() ?></span> 69 </a> 70 </li> 71 <?php endforeach ?> 72 73 <?php foreach ($linked_families as $family) : ?> 74 <li class="wt-slide-show-link"> 75 <span class="fa-li" title="<?= I18N::translate('Family') ?>"><?= view('icons/family') ?></span> 76 <a href="<?= e($family->url()) ?>" class="wt-slide-show-link"> 77 <?= $family->fullName() ?> 78 </a> 79 </li> 80 <?php endforeach ?> 81 82 <?php foreach ($linked_sources as $source) : ?> 83 <li class="wt-slide-show-link"> 84 <span class="fa-li" title="<?= I18N::translate('Source') ?>"><?= view('icons/source') ?></span> 85 <a href="<?= e($source->url()) ?>" class="wt-slide-show-link"> 86 <?= $source->fullName() ?> 87 </a> 88 </li> 89 <?php endforeach ?> 90 </ul> 91</div> 92 93<script> 94 (function () { 95 let block = document.getElementById('block-<?= $block_id ?>'); 96 97 let play = <?= json_encode($start_automatically, JSON_THROW_ON_ERROR) ?>; 98 99 function slideShowReload () { 100 clearTimeout(timeout); 101 102 if (document.hidden) { 103 // No point loading images when nobody is looking. 104 timeout = setTimeout(slideShowReload, 1000); 105 } else { 106 $(block.parentNode).load($(block).parent().data('wtAjaxUrl') + '&start=' + (play ? '1' : '0')); 107 } 108 } 109 110 let timeout = null; 111 112 if (play) { 113 timeout = setTimeout(slideShowReload, <?= json_encode($delay * 1000, JSON_THROW_ON_ERROR) ?>); 114 } 115 116 block.querySelector('.wt-icon-media-play').addEventListener('click', (event) => { 117 event.preventDefault(); 118 block.querySelector('.wt-icon-media-play').parentNode.hidden = true; 119 block.querySelector('.wt-icon-media-stop').parentNode.hidden = false; 120 play = true; 121 slideShowReload(); 122 }); 123 124 block.querySelector('.wt-icon-media-stop').addEventListener('click', (event) => { 125 event.preventDefault(); 126 block.querySelector('.wt-icon-media-stop').parentNode.hidden = true; 127 block.querySelector('.wt-icon-media-play').parentNode.hidden = false; 128 play = false; 129 clearTimeout(timeout); 130 }); 131 132 block.querySelector('.wt-icon-media-next').addEventListener('click', (event) => { 133 event.preventDefault(); 134 slideShowReload(); 135 }); 136 })(); 137</script> 138