xref: /webtrees/resources/views/modules/hourglass-chart/chart.phtml (revision 50b578bcabecafb340f098799257a978dd06404e)
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       $show_spouse
12 */
13
14$children = $individual->spouseFamilies()->map(function (Family $family): Collection { return $family->children(); })->flatten();
15
16?>
17
18<div class="d-flex wt-chart-hourglass">
19    <?= view('modules/hourglass-chart/children', ['children' => $children, 'generations' => $generations - 1, 'show_spouse' => $show_spouse]) ?>
20    <div class="align-self-center">
21        <?= view('chart-box', ['individual' => $individual]) ?>
22        <?php if ($show_spouse): ?>
23            <?php foreach ($individual->spouseFamilies() as $family): ?>
24                <?= view('chart-box', ['individual' => $family->spouse($individual)]) ?>
25            <?php endforeach ?>
26        <?php endif ?>
27    </div>
28    <?php if ($individual->primaryChildFamily() !== null): ?>
29        <div class="wt-chart-horizontal-spacer">
30            <div class="wt-chart-horizontal-line"></div>
31        </div>
32        <?= view('modules/hourglass-chart/parents', ['generations' => $generations - 1, 'family' => $individual->primaryChildFamily()]) ?>
33    <?php endif ?>
34</div>
35
36<?php View::push('javascript') ?>
37<script>
38    $(".wt-chart-hourglass").on("click", "[data-xref]", function () {
39        $(this.parentNode).load(this.dataset.xref);
40
41        return false;
42    });
43</script>
44<?php View::endpush() ?>
45