xref: /webtrees/resources/views/lists/anniversaries-list.phtml (revision e24053e5c68a36a62ca2714caf7fca093e7dc791)
1<?php
2
3use Fisharebest\Webtrees\Carbon;
4use Fisharebest\Webtrees\Fact;
5use Fisharebest\Webtrees\I18N;
6use Fisharebest\Webtrees\Individual;
7use Fisharebest\Webtrees\View;
8use Illuminate\Support\Collection;
9
10/**
11 * @var Collection<Fact> $facts
12 */
13
14?>
15
16<?php foreach ($facts as $n => $fact) : ?>
17    <?php if ($n === $limit && $facts->count() > $limit) : ?>
18        <div>
19            <button class="btn btn-sm btn-secondary" id="show-more-<?= e($id) ?>">
20                <?= view('icons/add') ?>
21                <?= /* I18N: button label */ I18N::translate('show more') ?>
22            </button>
23        </div>
24    <?php endif ?>
25
26    <div class="<?= $n >= $limit ? 'd-none' : '' ?>">
27        <?php $record = $fact->record(); ?>
28        <a href="<?= e($record->url()) ?>" class="list_item name2">
29            <?= $record->fullName() ?>
30        </a>
31        <?php if ($record instanceof Individual) : ?>
32            <?= view('icons/sex', ['sex' => $record->sex()]) ?>
33        <?php endif ?>
34        <div class="indent">
35            <?= $fact->label() . ' — ' . $fact->date()->display(true) ?>
36            (<?= Carbon::now()->subYears($fact->anniv)->local()->diffForHumans() ?>)
37            <?php if ($fact->place()->gedcomName() !== '') : ?>
38                — <a href="<?= e($fact->place()->url()) ?>" title="<?= strip_tags($fact->place()->fullName()) ?>">
39                    <?= $fact->place()->shortName() ?>
40                </a>
41            <?php endif ?>
42        </div>
43    </div>
44<?php endforeach ?>
45
46
47<?php View::push('javascript') ?>
48<script>
49    document.getElementById("show-more-<?= e($id) ?>").addEventListener("click", function (ev) {
50        document.querySelectorAll("#block-<?= e($id) ?> .d-none").forEach(function (el) {
51            el.classList.remove("d-none");
52        });
53        ev.target.parentNode.removeChild(ev.target);
54    });
55</script>
56<?php View::endPush() ?>
57