summaryrefslogtreecommitdiff
path: root/resources/views/modules/random_media/slide-show.phtml
blob: c54bb50982ed44529892fb4d85e690fd9eb69460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php use Fisharebest\Webtrees\Functions\FunctionsPrint; ?>
<?php use Fisharebest\Webtrees\I18N; ?>

<div class="text-center slide-show-container">
    <?php if ($show_controls) : ?>
        <div class="slide-show-controls">
            <a href="#" title="<?= I18N::translate('Play') ?>" <?= $start_automatically ? 'hidden' : '' ?>>
                <?= view('icons/media-play') ?>
                <span class="sr-only"><?= I18N::translate('Play') ?></span>
            </a>
            <a href="#" title="<?= I18N::translate('Stop') ?>" <?= $start_automatically ? '' : 'hidden' ?>>
                <?= view('icons/media-stop') ?>
                <span class="sr-only"><?= I18N::translate('Stop') ?></span>
            </a>
            <a href="#" title="<?= I18N::translate('Next image') ?>">
                <?= view('icons/media-next') ?>
                <span class="sr-only"><?= I18N::translate('Next image') ?></span>
            </a>
        </div>
    <?php endif ?>

    <figure class="text-center slide-show-figure">
        <?= $media_file->displayImage(200, 200, '', ['class' => 'slide-show-image img-fluid']) ?>
        <figcaption class="slide-show-figcaption">
            <a href="<?= e($media->url()) ?>">
                <b><?= $media->fullName() ?></b>
            </a>
        </figcaption>
    </figure>

    <p class="slide-show-notes">
        <?= FunctionsPrint::printFactNotes($tree, $media->gedcom(), 1) ?>
    </p>

    <ul class="slide-show-links">
        <?php foreach ($media->linkedIndividuals('OBJE') as $individual) : ?>
            <?= I18N::translate('Individual') ?> —
            <a href="<?= e($individual->url()) ?>" class="slide-show-link">
                <?= $individual->fullName() ?>
            </a>
            <br>
        <?php endforeach ?>

        <?php foreach ($media->linkedFamilies('OBJE') as $family) : ?>
            <?= I18N::translate('View this family') ?> —
            <a href="<?= e($family->url()) ?>" class="slide-show-link">
                <?= $family->fullName() ?>
            </a>
            <br>
        <?php endforeach ?>

        <?php foreach ($media->linkedSources('OBJE') as $source) : ?>
            <?= I18N::translate('View this source') ?> —
            <a href="<?= e($source->url()) ?>" class="slide-show-link">
                <?= $source->fullName() ?>
            </a>
            <br>
        <?php endforeach ?>
    </ul>
</div>

<script>
    var play = <?= json_encode($start_automatically); ?>;

    if (play) {
        var timeout = setTimeout(slideShowReload, 6000);
    }

    function slideShowReload() {
        var block = $("#block-<?= $block_id ?>").parent();
        clearTimeout(timeout);
        block.load(block.data('ajaxUrl') + '&start=' + (play ? '1' : '0'));

        return false;
    }

    $(".wt-icon-media-play").on('click', function () {
        $(".wt-icon-media-play").parent().attr('hidden', true);
        $(".wt-icon-media-stop").parent().attr('hidden', false);
        play = true;
        return slideShowReload();
    });

    $(".wt-icon-media-stop").on('click', function () {
        $(".wt-icon-media-stop").parent().attr('hidden', true);
        $(".wt-icon-media-play").parent().attr('hidden', false);
        play = false;
        clearTimeout(timeout);
        return false;
    });

    $(".wt-icon-media-next").on('click', function () {
        return slideShowReload();
    });
</script>