15229eadeSGreg Roach<?php 25229eadeSGreg Roach 3*7c2c99faSGreg Roachuse Fisharebest\Webtrees\Family; 45229eadeSGreg Roachuse Fisharebest\Webtrees\Gedcom; 55229eadeSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ReorderChildrenAction; 65229eadeSGreg Roachuse Fisharebest\Webtrees\I18N; 75229eadeSGreg Roachuse Fisharebest\Webtrees\View; 85229eadeSGreg Roach 9*7c2c99faSGreg Roach/** 10*7c2c99faSGreg Roach * @var Family $family 11*7c2c99faSGreg Roach * @var string $title 12*7c2c99faSGreg Roach */ 13*7c2c99faSGreg Roach 145229eadeSGreg Roach?> 15dd6b2bfcSGreg Roach 16dd6b2bfcSGreg Roach<h2 class="wt-page-title"><?= $title ?></h2> 17dd6b2bfcSGreg Roach 18*7c2c99faSGreg Roach<form method="post" action="<?= e(route(ReorderChildrenAction::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref()])) ?>" class="wt-page-content"> 19dd6b2bfcSGreg Roach <?= csrf_field() ?> 2083615acfSGreg Roach 21dd6b2bfcSGreg Roach <div class="wt-sortable-list"> 228d0ebef0SGreg Roach <?php foreach ($family->facts(['CHIL']) as $fact) : ?> 2392044e0dSGreg Roach <div class="card my-2 wt-sortable-item" data-sortbydate="<?= $fact->target()->getBirthDate()->julianDay() ?>"> 24905ab80aSGreg Roach <input type="hidden" name="order[]" value="<?= $fact->id() ?>"> 25aabcb63cSGreg Roach <div class="card-header"> 2692044e0dSGreg Roach <?= view('edit/reorder-card-header', ['title' => $fact->target()->fullName()]) ?> 27aabcb63cSGreg Roach </div> 2892044e0dSGreg Roach 29dd6b2bfcSGreg Roach <div class="card-body"> 308d0ebef0SGreg Roach <?= $fact->target()->formatFirstMajorFact(Gedcom::BIRTH_EVENTS, 2) ?> 318d0ebef0SGreg Roach <?= $fact->target()->formatFirstMajorFact(Gedcom::DEATH_EVENTS, 2) ?> 32dd6b2bfcSGreg Roach </div> 33dd6b2bfcSGreg Roach </div> 34dd6b2bfcSGreg Roach <?php endforeach ?> 35dd6b2bfcSGreg Roach </div> 36dd6b2bfcSGreg Roach 37dd6b2bfcSGreg Roach <p> 38dd6b2bfcSGreg Roach <button class="btn btn-primary" type="submit"> 39d993d560SGreg Roach <?= view('icons/save') ?> 40dd6b2bfcSGreg Roach <?= /* I18N: A button label. */ I18N::translate('save') ?> 41dd6b2bfcSGreg Roach </button> 42dd6b2bfcSGreg Roach 43dd6b2bfcSGreg Roach <button class="btn btn-secondary" id="btn-default-order" type="button"> 44d993d560SGreg Roach <?= view('icons/sort') ?> 45dd6b2bfcSGreg Roach <?= /* I18N: A button label. */ I18N::translate('sort by date of birth') ?> 46dd6b2bfcSGreg Roach </button> 47dd6b2bfcSGreg Roach 48dd6b2bfcSGreg Roach <a class="btn btn-secondary" href="<?= e($family->url()) ?>"> 49d993d560SGreg Roach <?= view('icons/cancel') ?> 50dd6b2bfcSGreg Roach <?= /* I18N: A button label. */ I18N::translate('cancel') ?> 51dd6b2bfcSGreg Roach </a> 52dd6b2bfcSGreg Roach </p> 53dd6b2bfcSGreg Roach</form> 54dd6b2bfcSGreg Roach 55dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 56dd6b2bfcSGreg Roach<script> 57aabcb63cSGreg Roach new Sortable(document.querySelector(".wt-sortable-list"), { 5892044e0dSGreg Roach handle: ".card-header", 59aabcb63cSGreg Roach }); 60dd6b2bfcSGreg Roach 61dd6b2bfcSGreg Roach $("#btn-default-order").on("click", function () { 62dd6b2bfcSGreg Roach $(".wt-sortable-list .wt-sortable-item").sort(function (x, y) { 63dd6b2bfcSGreg Roach return Math.sign(x.dataset.sortbydate - y.dataset.sortbydate); 64dd6b2bfcSGreg Roach }).appendTo(".wt-sortable-list"); 65dd6b2bfcSGreg Roach }); 66dd6b2bfcSGreg Roach</script> 67dd6b2bfcSGreg Roach<?php View::endpush() ?> 68