2021-10-12 10:21:12 +02:00
|
|
|
<?php
|
|
|
|
if (!function_exists('getResolvableID')) {
|
|
|
|
function getResolvableID($sectionName, $panelName = false)
|
|
|
|
{
|
|
|
|
$id = sprintf('sp-%s', preg_replace('/(\.|\W)/', '_', h($sectionName)));
|
|
|
|
if (!empty($panelName)) {
|
|
|
|
$id .= '-' . preg_replace('/(\.|\W)/', '_', h($panelName));
|
|
|
|
}
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
2021-07-26 11:16:52 +02:00
|
|
|
<nav id="navbar-scrollspy-setting" class="navbar">
|
|
|
|
<nav class="nav nav-pills flex-column">
|
|
|
|
<?php foreach ($groupedSetting as $group => $sections): ?>
|
2021-07-30 08:18:30 +02:00
|
|
|
<a class="nav-link main-group text-reset p-1" href="#<?= getResolvableID($group) ?>"><?= h($group) ?></a>
|
|
|
|
<nav class="nav nav-pills sub-group collapse flex-column" data-maingroup="<?= getResolvableID($group) ?>">
|
2021-07-26 11:16:52 +02:00
|
|
|
<?php foreach ($sections as $section): ?>
|
2021-09-17 17:51:45 +02:00
|
|
|
<a class="nav-link nav-link-group text-reset ms-3 my-1 p-1" href="#<?= getResolvableID($group, $section) ?>"><?= h($section) ?></a>
|
2021-07-26 11:16:52 +02:00
|
|
|
<?php endforeach; ?>
|
|
|
|
</nav>
|
|
|
|
</a>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</nav>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
2021-09-18 10:33:27 +02:00
|
|
|
$('[data-bs-spy="scroll"]').on('activate.bs.scrollspy', function({relatedTarget}) {
|
2021-07-26 11:16:52 +02:00
|
|
|
const $associatedLink = $(`#navbar-scrollspy-setting nav.nav-pills .nav-link[href="${relatedTarget}"]`)
|
|
|
|
let $associatedNav
|
|
|
|
if ($associatedLink.hasClass('main-group')) {
|
|
|
|
$associatedNav = $associatedLink.next()
|
|
|
|
} else {
|
|
|
|
$associatedNav = $associatedLink.parent()
|
|
|
|
}
|
|
|
|
const $allNavs = $('#navbar-scrollspy-setting nav.nav-pills.sub-group')
|
|
|
|
$allNavs.removeClass('group-active').hide()
|
|
|
|
$associatedNav.addClass('group-active').show()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
#navbar-scrollspy-setting nav.nav-pills .nav-link {
|
|
|
|
background-color: unset !important;
|
|
|
|
color: black;
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
|
|
|
|
#navbar-scrollspy-setting nav.nav-pills .nav-link:not(.main-group).active {
|
|
|
|
color: #007bff !important;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
#navbar-scrollspy-setting nav.nav-pills .nav-link.main-group:before {
|
|
|
|
margin-right: 0.25em;
|
|
|
|
font-family: 'Font Awesome 5 Free';
|
|
|
|
font-weight: 900;
|
|
|
|
-webkit-font-smoothing: antialiased;
|
|
|
|
display: inline-block;
|
|
|
|
font-style: normal;
|
|
|
|
font-variant: normal;
|
|
|
|
text-rendering: auto;
|
|
|
|
line-height: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#navbar-scrollspy-setting nav.nav-pills .nav-link.main-group.active:before {
|
|
|
|
content: "\f0d7";
|
|
|
|
}
|
|
|
|
|
|
|
|
#navbar-scrollspy-setting nav.nav-pills .nav-link.main-group:before {
|
|
|
|
content: "\f0da";
|
|
|
|
}
|
|
|
|
</style>
|