xref: /webtrees/resources/views/modules/share-anniversary/share.phtml (revision 748dbe155a6d19d66918ad136947fa23ee8f8469)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Fact;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Individual;
8use Illuminate\Support\Collection;
9
10/**
11 * @var Collection<int,Fact> $facts
12 * @var Individual           $record
13 * @var string               $url
14 */
15
16?>
17<div class="input-group mb-3">
18    <span class="input-group-text" dir="ltr">iCalendar</span>
19
20    <select class="custom-select" id="share-anniversary-select" aria-label=" <?= I18N::translate('Anniversary') ?>" name="fact_id">
21        <?php foreach ($facts as $url => $label) : ?>
22            <option value="<?= e($url) ?>"><?= $label ?></option>
23        <?php endforeach ?>
24    </select>
25    <button class="btn btn-primary" type="button" id="share-anniversary-button">
26        <?= view('icons/download') ?>
27        <?= I18N::translate('Download') ?>
28    </button>
29</div>
30<form id="share-anniversary-form"></form>
31<script>
32  document.getElementById('share-anniversary-button').addEventListener('click', function () {
33    const select = document.getElementById('share-anniversary-select');
34    let form = document.getElementById('share-anniversary-form');
35    form.action = select.options[select.selectedIndex].value;
36    form.submit();
37  });
38</script>
39