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