xref: /webtrees/resources/views/modules/random_media/slide-show.phtml (revision 7ef421a4290b6b468944b845497d6139b0eddd3f)
1<?php
2
3use Fisharebest\Webtrees\Functions\FunctionsPrint;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Media;
6use Fisharebest\Webtrees\MediaFile;
7
8/**
9 * @var int       $block_id
10 * @var bool      $show_controls
11 * @var bool      $start_automatically
12 * @var Media     $media
13 * @var MediaFile $media_file
14 */
15
16?>
17
18<div class="wt-slide-show-container">
19    <?php if ($show_controls) : ?>
20        <div class="wt-slide-show-controls text-center">
21            <a href="#" title="<?= I18N::translate('Play') ?>" <?= $start_automatically ? 'hidden' : '' ?>>
22                <?= view('icons/media-play') ?>
23                <span class="sr-only"><?= I18N::translate('Play') ?></span>
24            </a>
25            <a href="#" title="<?= I18N::translate('Stop') ?>" <?= $start_automatically ? '' : 'hidden' ?>>
26                <?= view('icons/media-stop') ?>
27                <span class="sr-only"><?= I18N::translate('Stop') ?></span>
28            </a>
29            <a href="#" title="<?= I18N::translate('Next image') ?>">
30                <?= view('icons/media-next') ?>
31                <span class="sr-only"><?= I18N::translate('Next image') ?></span>
32            </a>
33        </div>
34    <?php endif ?>
35
36    <figure class="wt-slide-show-figure text-center">
37        <?= $media_file->displayImage(200, 200, '', ['class' => 'slide-show-image img-fluid']) ?>
38        <figcaption class="slide-show-figcaption">
39            <a href="<?= e($media->url()) ?>">
40                <b><?= $media->fullName() ?></b>
41            </a>
42        </figcaption>
43    </figure>
44
45    <p class="wt-slide-show-notes text-center">
46        <?= FunctionsPrint::printFactNotes($tree, $media->gedcom(), 1) ?>
47    </p>
48
49    <ul class="fa-ul wt-slide-show-links">
50        <?php foreach ($media->linkedIndividuals('OBJE') as $individual) : ?>
51            <li>
52                <span class="fa-li" title="<?= I18N::translate('Individual') ?>"><?= view('icons/individual') ?></span>
53                <a href="<?= e($individual->url()) ?>" class="wt-slide-show-link">
54                    <?= $individual->fullName() ?>
55                </a>
56            </li>
57        <?php endforeach ?>
58
59        <?php foreach ($media->linkedFamilies('OBJE') as $family) : ?>
60            <li>
61                <span class="fa-li" title="<?= I18N::translate('Family') ?>"><?= view('icons/family') ?></span>
62                <a href="<?= e($family->url()) ?>" class="wt-slide-show-link">
63                    <?= $family->fullName() ?>
64                </a>
65            </li>
66        <?php endforeach ?>
67
68        <?php foreach ($media->linkedSources('OBJE') as $source) : ?>
69            <li>
70                <span class="fa-li" title="<?= I18N::translate('Source') ?>"><?= view('icons/source') ?></span>
71                <a href="<?= e($source->url()) ?>" class="wt-slide-show-link">
72                    <?= $source->fullName() ?>
73                </a>
74            </li>
75        <?php endforeach ?>
76    </ul>
77</div>
78
79<script>
80    var play = <?= json_encode($start_automatically) ?>;
81
82    if (play) {
83        var timeout = setTimeout(slideShowReload, <?= json_encode($delay * 1000) ?>);
84    }
85
86    function slideShowReload() {
87        var block = $("#block-<?= $block_id ?>").parent();
88        clearTimeout(timeout);
89        block.load(block.data("ajaxUrl") + "&start=" + (play ? "1" : "0"));
90
91        return false;
92    }
93
94    $(".wt-icon-media-play").on("click", function () {
95        $(".wt-icon-media-play").parent().attr("hidden", true);
96        $(".wt-icon-media-stop").parent().attr("hidden", false);
97        play = true;
98        return slideShowReload();
99    });
100
101    $(".wt-icon-media-stop").on("click", function () {
102        $(".wt-icon-media-stop").parent().attr("hidden", true);
103        $(".wt-icon-media-play").parent().attr("hidden", false);
104        play = false;
105        clearTimeout(timeout);
106        return false;
107    });
108
109    $(".wt-icon-media-next").on("click", function () {
110        return slideShowReload();
111    });
112</script>
113