12c3dad18SGreg Roach<?php 2852ede8cSGreg Roach 32c3dad18SGreg Roachuse Fisharebest\Webtrees\Auth; 42917771cSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact; 522e73debSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesAcceptRecord; 622e73debSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\PendingChangesRejectRecord; 72c3dad18SGreg Roachuse Fisharebest\Webtrees\I18N; 82c3dad18SGreg Roachuse Fisharebest\Webtrees\Individual; 9054771e9SGreg Roachuse Fisharebest\Webtrees\Tree; 102c3dad18SGreg Roachuse Fisharebest\Webtrees\View; 112c3dad18SGreg Roachuse Illuminate\Support\Collection; 122c3dad18SGreg Roach 132c3dad18SGreg Roach/** 14054771e9SGreg Roach * @var string $age 152c3dad18SGreg Roach * @var Individual $individual 162c3dad18SGreg Roach * @var string $user_link 172c3dad18SGreg Roach * @var Collection $sidebars 188e64ca84SGreg Roach * @var Collection $individual_media 192c3dad18SGreg Roach * @var Collection $name_records 202c3dad18SGreg Roach * @var Collection $sex_records 212c3dad18SGreg Roach * @var Collection $tabs 22054771e9SGreg Roach * @var Tree $tree 232c3dad18SGreg Roach */ 242c3dad18SGreg Roach?> 25dd6b2bfcSGreg Roach 26dd6b2bfcSGreg Roach<?php if ($individual->isPendingDeletion()) : ?> 27f4afa648SGreg Roach <?php if (Auth::isModerator($individual->tree())) : ?> 28dd6b2bfcSGreg Roach <?= view('components/alert-warning-dismissible', [ 29dd6b2bfcSGreg Roach 'alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ 300973b4d2SGreg Roach I18N::translate('This individual has been deleted. You should review the deletion and then %1$s or %2$s it.', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesRejectRecord::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the deletion and then accept or reject it.', 'reject') . '</a>') . ' ' . view('help/link', ['topic' => 'pending_changes']), 31dd6b2bfcSGreg Roach ]) ?> 32f4afa648SGreg Roach <?php elseif (Auth::isEditor($individual->tree())) : ?> 330973b4d2SGreg Roach <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This individual has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?> 34dd6b2bfcSGreg Roach <?php endif ?> 35dd6b2bfcSGreg Roach<?php elseif ($individual->isPendingAddition()) : ?> 36f4afa648SGreg Roach <?php if (Auth::isModerator($individual->tree())) : ?> 37dd6b2bfcSGreg Roach <?= view('components/alert-warning-dismissible', [ 38dd6b2bfcSGreg Roach 'alert' => /* I18N: %1$s is “accept”, %2$s is “reject”. These are links. */ 390973b4d2SGreg Roach I18N::translate('This individual has been edited. You should review the changes and then %1$s or %2$s them.', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesAcceptRecord::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', '<a href="#" class="alert-link" data-post-url="' . e(route(PendingChangesRejectRecord::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) . '">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>') . ' ' . view('help/link', ['topic' => 'pending_changes']), 40dd6b2bfcSGreg Roach ]) ?> 41f4afa648SGreg Roach <?php elseif (Auth::isEditor($individual->tree())) : ?> 420973b4d2SGreg Roach <?= view('components/alert-warning-dismissible', ['alert' => I18N::translate('This individual has been edited. The changes need to be reviewed by a moderator.') . ' ' . view('help/link', ['topic' => 'pending_changes'])]) ?> 43dd6b2bfcSGreg Roach <?php endif ?> 44dd6b2bfcSGreg Roach<?php endif ?> 45dd6b2bfcSGreg Roach 46dd6b2bfcSGreg Roach<div class="d-flex mb-4"> 47dd6b2bfcSGreg Roach <h2 class="wt-page-title mx-auto"> 485e6816beSGreg Roach <?= $individual->fullName() ?><?= $user_link ?>, <?= $individual->lifespan() ?> <?= $age ?> 49dd6b2bfcSGreg Roach </h2> 501450f098SGreg Roach <?php if ($individual->canEdit()) : ?> 517bb122d6SGreg Roach <?= view('individual-page-menu', ['individual' => $individual, 'tree' => $tree]) ?> 52dd6b2bfcSGreg Roach <?php endif ?> 53dd6b2bfcSGreg Roach</div> 54dd6b2bfcSGreg Roach 55dd6b2bfcSGreg Roach<div class="row"> 568d38dd5aSGreg Roach <div class="<?= $sidebars->isEmpty() ? 'col-sm-12' : 'col-sm-8' ?>"> 57dd6b2bfcSGreg Roach <div class="row mb-4"> 58dd6b2bfcSGreg Roach <!-- Individual images --> 598e64ca84SGreg Roach <?php if ($individual_media->isNotEmpty() || $tree->getPreference('USE_SILHOUETTE') === '1') : ?> 60dd6b2bfcSGreg Roach <div class="col-sm-3"> 618e64ca84SGreg Roach <?php if ($individual_media->isEmpty()) : ?> 628e64ca84SGreg Roach <div class="img-thumbnail"> 6339ca88baSGreg Roach <i class="wt-individual-silhouette wt-individual-silhouette-<?= strtolower($individual->sex()) ?>"></i> 648e64ca84SGreg Roach </div> 658e64ca84SGreg Roach <?php elseif ($individual_media->count() === 1) : ?> 668e64ca84SGreg Roach <?= $individual_media->first()->displayImage(200, 260, 'crop', ['class' => 'img-thumbnail img-fluid w-100']) ?> 67dd6b2bfcSGreg Roach <?php else : ?> 68dd6b2bfcSGreg Roach <div id="individual-images" class="carousel slide" data-ride="carousel" data-interval="false"> 69dd6b2bfcSGreg Roach <div class="carousel-inner"> 70dd6b2bfcSGreg Roach <?php foreach ($individual_media as $n => $media_file) : ?> 71dd6b2bfcSGreg Roach <div class="carousel-item <?= $n === 0 ? 'active' : '' ?>"> 72dd6b2bfcSGreg Roach <?= $media_file->displayImage(200, 260, 'crop', ['class' => 'img-thumbnail img-fluid w-100']) ?> 73dd6b2bfcSGreg Roach </div> 74dd6b2bfcSGreg Roach <?php endforeach ?> 75dd6b2bfcSGreg Roach </div> 76dd6b2bfcSGreg Roach <a class="carousel-control-prev" href="#individual-images" role="button" data-slide="prev"> 77dd6b2bfcSGreg Roach <span class="carousel-control-prev-icon" aria-hidden="true"></span> 78dd6b2bfcSGreg Roach <span class="sr-only"><?= I18N::translate('previous') ?></span> 79dd6b2bfcSGreg Roach </a> 80dd6b2bfcSGreg Roach <a class="carousel-control-next" href="#individual-images" role="button" data-slide="next"> 81dd6b2bfcSGreg Roach <span class="carousel-control-next-icon" aria-hidden="true"></span> 82dd6b2bfcSGreg Roach <span class="sr-only"><?= I18N::translate('next') ?></span> 83dd6b2bfcSGreg Roach </a> 84dd6b2bfcSGreg Roach </div> 85dd6b2bfcSGreg Roach <?php endif ?> 86dd6b2bfcSGreg Roach 87f4afa648SGreg Roach <?php if (Auth::isEditor($individual->tree())) : ?> 888e64ca84SGreg Roach <div class="text-center"> 892917771cSGreg Roach <a href="<?= e(route(AddNewFact::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact' => 'OBJE'])) ?>"> 90dd6b2bfcSGreg Roach <?= I18N::translate('Add a media object') ?> 91dd6b2bfcSGreg Roach </a> 92dd6b2bfcSGreg Roach </div> 93dd6b2bfcSGreg Roach <?php endif ?> 94dd6b2bfcSGreg Roach </div> 958e64ca84SGreg Roach <?php endif ?> 96dd6b2bfcSGreg Roach 97dd6b2bfcSGreg Roach <!-- Name accordion --> 988e64ca84SGreg Roach <div class="col-sm" id="individual-names" role="tablist"> 99dd6b2bfcSGreg Roach <?php foreach ($name_records as $name_record) : ?> 100dd6b2bfcSGreg Roach <?= $name_record ?> 101dd6b2bfcSGreg Roach <?php endforeach ?> 102dd6b2bfcSGreg Roach 103dd6b2bfcSGreg Roach <?php foreach ($sex_records as $sex_record) : ?> 104dd6b2bfcSGreg Roach <?= $sex_record ?> 105dd6b2bfcSGreg Roach <?php endforeach ?> 106dd6b2bfcSGreg Roach </div> 107dd6b2bfcSGreg Roach </div> 108dd6b2bfcSGreg Roach 1094a2590a5SGreg Roach <div class="wt-tabs-individual" id="individual-tabs"> 1106a4003b9SGreg Roach <ul class="nav nav-tabs flex-wrap" role="tablist"> 111dd6b2bfcSGreg Roach <?php foreach ($tabs as $tab) : ?> 1126a4003b9SGreg Roach <li class="nav-item" role="presentation"> 113852ede8cSGreg Roach <a class="nav-link<?= $tab->isGrayedOut($individual) ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" data-href="<?= e(route('module', ['module' => $tab->name(), 'action' => 'Tab', 'tree' => $individual->tree()->name(), 'xref' => $individual->xref()])) ?>" href="#<?= $tab->name() ?>"> 114defb8071SRichard Cissée <?= $tab->tabTitle() ?> 115dd6b2bfcSGreg Roach </a> 116dd6b2bfcSGreg Roach </li> 117dd6b2bfcSGreg Roach <?php endforeach ?> 118dd6b2bfcSGreg Roach </ul> 1196a4003b9SGreg Roach 120dd6b2bfcSGreg Roach <div class="tab-content"> 121dd6b2bfcSGreg Roach <?php foreach ($tabs as $tab) : ?> 122677aaceaSGreg Roach <div id="<?= $tab->name() ?>" class="tab-pane fade wt-ajax-load" role="tabpanel"><?php if (!$tab->canLoadAjax()) : 123d70512abSGreg Roach ?><?= $tab->getTabContent($individual) ?><?php 124d70512abSGreg Roach endif ?></div> 125dd6b2bfcSGreg Roach <?php endforeach ?> 126dd6b2bfcSGreg Roach </div> 127dd6b2bfcSGreg Roach </div> 128dd6b2bfcSGreg Roach </div> 129c72fc94cSGreg Roach <?php if ($sidebars->isNotEmpty()) : ?> 130dd6b2bfcSGreg Roach <div class="col-sm-4" id="sidebar" role="tablist"> 131dd6b2bfcSGreg Roach <?php foreach ($sidebars as $sidebar) : ?> 132dd6b2bfcSGreg Roach <div class="card"> 133677aaceaSGreg Roach <div class="card-header" role="tab" id="sidebar-header-<?= $sidebar->name() ?>"> 134dd6b2bfcSGreg Roach <div class="card-title mb-0"> 135677aaceaSGreg Roach <a data-toggle="collapse" data-parent="#sidebar" href="#sidebar-content-<?= $sidebar->name() ?>" aria-expanded="<?= $sidebar->name() === 'family_nav' ? 'true' : 'false' ?>" aria-controls="sidebar-content-<?= $sidebar->name() ?>"> 136defb8071SRichard Cissée <?= $sidebar->sidebarTitle() ?> 137dd6b2bfcSGreg Roach </a> 138dd6b2bfcSGreg Roach </div> 139dd6b2bfcSGreg Roach </div> 1406a4003b9SGreg Roach 141677aaceaSGreg Roach <div id="sidebar-content-<?= $sidebar->name() ?>" class="collapse<?= $sidebar->name() === 'family_nav' ? ' show' : '' ?>" role="tabpanel" aria-labelledby="sidebar-header-<?= $sidebar->name() ?>"> 142dd6b2bfcSGreg Roach <div class="card-body"> 143dd6b2bfcSGreg Roach <?= $sidebar->getSidebarContent($individual) ?></div> 144dd6b2bfcSGreg Roach </div> 145dd6b2bfcSGreg Roach </div> 146dd6b2bfcSGreg Roach <?php endforeach ?> 147dd6b2bfcSGreg Roach </div> 148c72fc94cSGreg Roach <?php endif ?> 149dd6b2bfcSGreg Roach</div> 150dd6b2bfcSGreg Roach 151dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 152dd6b2bfcSGreg Roach<script> 153dd6b2bfcSGreg Roach "use strict"; 154dd6b2bfcSGreg Roach 155dd6b2bfcSGreg Roach // Bootstrap tabs - load content dynamically using AJAX 156dd6b2bfcSGreg Roach $('a[data-toggle="tab"][data-href]').on('show.bs.tab', function () { 157*5675e46eSmiqrogroove let target = $(this.hash + ':empty'); 158*5675e46eSmiqrogroove if (target) { 159*5675e46eSmiqrogroove // Start the download immediately... 160*5675e46eSmiqrogroove let download = fetch(this.dataset.href); 161*5675e46eSmiqrogroove 162*5675e46eSmiqrogroove // ...but don't insert it until the tab is ready. 163*5675e46eSmiqrogroove $(this).one('shown.bs.tab', () => { 164*5675e46eSmiqrogroove download 165*5675e46eSmiqrogroove .then(data => data.text()) 166*5675e46eSmiqrogroove .then(data => target.html(data)); 167*5675e46eSmiqrogroove }); 168*5675e46eSmiqrogroove } 169dd6b2bfcSGreg Roach }); 170dd6b2bfcSGreg Roach 171dd6b2bfcSGreg Roach // If the URL contains a fragment, then activate the corresponding tab. 172dd6b2bfcSGreg Roach // Use a prefix on the fragment, to prevent scrolling to the element. 173054771e9SGreg Roach let target = window.location.hash.replace("tab-", ""); 174054771e9SGreg Roach let tab = $("#individual-tabs .nav-link[href='" + target + "']"); 175dd6b2bfcSGreg Roach // If not, then activate the first tab. 176dd6b2bfcSGreg Roach if (tab.length === 0) { 177dd6b2bfcSGreg Roach tab = $("#individual-tabs .nav-link:first"); 178dd6b2bfcSGreg Roach } 179dd6b2bfcSGreg Roach tab.tab("show"); 180dd6b2bfcSGreg Roach 181dd6b2bfcSGreg Roach // If the user selects a tab, update the URL to reflect this 182dd6b2bfcSGreg Roach $('#individual-tabs a[data-toggle="tab"]').on('shown.bs.tab', function (e) { 183dd6b2bfcSGreg Roach window.location.hash = "tab-" + e.target.href.substring(e.target.href.indexOf('#') + 1); 184dd6b2bfcSGreg Roach }); 185dd6b2bfcSGreg Roach</script> 186dd6b2bfcSGreg Roach<?php View::endpush() ?> 187dd6b2bfcSGreg Roach 188dd6b2bfcSGreg Roach<?= view('modals/ajax') ?> 189