xref: /webtrees/resources/views/modules/random_media/slide-show.phtml (revision a0801ffbb59d5bed474fc7a91bf1863ebca47791)
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 img-fluid']) ?>
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    var play = <?= json_encode($start_automatically); ?>;
64
65    if (play) {
66        var timeout = setTimeout(slideShowReload, 6000);
67    }
68
69    function slideShowReload() {
70        var block = $("#block-<?= $block_id ?>").parent();
71        clearTimeout(timeout);
72        block.load(block.data('ajaxUrl') + '&start=' + (play ? '1' : '0'));
73
74        return false;
75    }
76
77    $(".wt-icon-media-play").on('click', function () {
78        $(".wt-icon-media-play").parent().attr('hidden', true);
79        $(".wt-icon-media-stop").parent().attr('hidden', false);
80        play = true;
81        return slideShowReload();
82    });
83
84    $(".wt-icon-media-stop").on('click', function () {
85        $(".wt-icon-media-stop").parent().attr('hidden', true);
86        $(".wt-icon-media-play").parent().attr('hidden', false);
87        play = false;
88        clearTimeout(timeout);
89        return false;
90    });
91
92    $(".wt-icon-media-next").on('click', function () {
93        return slideShowReload();
94    });
95</script>
96