xref: /webtrees/resources/views/modules/hourglass-chart/chart.phtml (revision a8972480190614ca0d44723ad3201a5b85015140)
1<?php
2
3use Fisharebest\Webtrees\Family;
4use Fisharebest\Webtrees\Individual;
5use Fisharebest\Webtrees\View;
6use Illuminate\Support\Collection;
7
8/**
9 * @var int        $generations
10 * @var Individual $individual
11 * @var bool       $spouses
12 */
13
14$children = $individual->spouseFamilies()->map(static function (Family $family): Collection {
15    return $family->children();
16})->flatten();
17
18?>
19
20<div class="d-flex wt-chart-hourglass">
21    <?= view('modules/hourglass-chart/children', ['children' => $children, 'generations' => $generations - 1, 'spouses' => $spouses]) ?>
22    <div class="align-self-center">
23        <?= view('chart-box', ['individual' => $individual]) ?>
24        <?php if ($spouses) : ?>
25            <?php foreach ($individual->spouseFamilies() as $family) : ?>
26                <?= view('chart-box', ['individual' => $family->spouse($individual)]) ?>
27            <?php endforeach ?>
28        <?php endif ?>
29    </div>
30    <?php if ($individual->childFamilies()->first() !== null) : ?>
31        <?= view('modules/hourglass-chart/parents', ['generations' => $generations - 1, 'family' => $individual->childFamilies()->first()]) ?>
32    <?php endif ?>
33</div>
34
35<?php View::push('javascript') ?>
36<script>
37    $(".wt-chart-hourglass").on("click", ".hourglass-arrow[data-xref]", function () {
38        $(this.parentNode).load(this.dataset.xref);
39
40        return false;
41    });
42</script>
43<?php View::endpush() ?>
44