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