xref: /webtrees/resources/views/modules/share-anniversary/share.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
1354a9dbaSGreg Roach<?php
2354a9dbaSGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
5354a9dbaSGreg Roachuse Fisharebest\Webtrees\Fact;
6354a9dbaSGreg Roachuse Fisharebest\Webtrees\I18N;
7354a9dbaSGreg Roachuse Fisharebest\Webtrees\Individual;
8354a9dbaSGreg Roachuse Illuminate\Support\Collection;
9354a9dbaSGreg Roach
10354a9dbaSGreg Roach/**
1136779af1SGreg Roach * @var Collection<int,Fact> $facts
12354a9dbaSGreg Roach * @var Individual           $record
13354a9dbaSGreg Roach * @var string               $url
14354a9dbaSGreg Roach */
15354a9dbaSGreg Roach
16354a9dbaSGreg Roach?>
17354a9dbaSGreg Roach<div class="input-group mb-3">
18354a9dbaSGreg Roach    <span class="input-group-text" dir="ltr">iCalendar</span>
19315eb316SGreg Roach
20354a9dbaSGreg Roach    <select class="custom-select" id="share-anniversary-select" aria-label=" <?= I18N::translate('Anniversary') ?>" name="fact_id">
21354a9dbaSGreg Roach        <?php foreach ($facts as $url => $label) : ?>
22354a9dbaSGreg Roach            <option value="<?= e($url) ?>"><?= $label ?></option>
23354a9dbaSGreg Roach        <?php endforeach ?>
24354a9dbaSGreg Roach    </select>
25315eb316SGreg Roach    <button class="btn btn-primary" type="button" id="share-anniversary-button">
26315eb316SGreg Roach        <?= view('icons/download') ?>
27315eb316SGreg Roach        <?= I18N::translate('Download') ?>
28315eb316SGreg Roach    </button>
29354a9dbaSGreg Roach</div>
30354a9dbaSGreg Roach<form id="share-anniversary-form"></form>
31354a9dbaSGreg Roach<script>
32354a9dbaSGreg Roach  document.getElementById('share-anniversary-button').addEventListener('click', function () {
33354a9dbaSGreg Roach    const select = document.getElementById('share-anniversary-select');
34354a9dbaSGreg Roach    let form = document.getElementById('share-anniversary-form');
35c8d78f19SGreg Roach    form.action = select.options[select.selectedIndex].value;
36354a9dbaSGreg Roach    form.submit();
37354a9dbaSGreg Roach  });
38354a9dbaSGreg Roach</script>
39