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