xref: /webtrees/resources/views/modules/share-anniversary/share.phtml (revision d4ec5ec0fe611c85b1d77527db3e9becde7e473d)
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    const select = document.getElementById('share-anniversary-select');
32    let form = document.getElementById('share-anniversary-form');
33    form.action = select.options[select.selectedIndex].value;
34    form.submit();
35  });
36</script>
37