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