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