only allow one nav bar item to be open at a time

This commit is contained in:
EthanHealy01 2025-07-11 02:27:09 +01:00
parent 8bcdb4cf9e
commit 22a6567cc9
3 changed files with 24 additions and 52 deletions

View File

@ -10,7 +10,6 @@ import java.util.Properties;
import java.util.function.Predicate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -151,9 +150,8 @@ public class AppConfig {
@Bean(name = "activeSecurity")
public boolean missingActiveSecurity() {
return ClassUtils.isPresent(
"stirling.software.proprietary.security.configuration.SecurityConfiguration",
this.getClass().getClassLoader()
);
"stirling.software.proprietary.security.configuration.SecurityConfiguration",
this.getClass().getClassLoader());
}
@Bean(name = "directoryFilter")

View File

@ -40,7 +40,7 @@ textarea {
}
*::-webkit-scrollbar-corner {
background-color: var(--md-sys-color-surface);
background-color: var(--md-sys-color-surface);
}
/* Alerts */
@ -66,6 +66,9 @@ td {
background-color: var(--md-sys-color-surface-5);
border-radius: 3rem;
padding: 2.5rem;
max-width: 95vw;
margin-left: 2vw;
}
.card {

View File

@ -42,58 +42,29 @@ function toolsManager() {
});
}
function setupDropdownHovers() {
const dropdowns = document.querySelectorAll('.navbar-nav > .nav-item.dropdown');
function setupDropdowns() {
const dropdowns = document.querySelectorAll('.navbar-nav > .nav-item.dropdown');
dropdowns.forEach(dropdown => {
const toggle = dropdown.querySelector('[data-bs-toggle="dropdown"]');
if (!toggle) return;
dropdowns.forEach((dropdown) => {
const toggle = dropdown.querySelector('[data-bs-toggle="dropdown"]');
if (!toggle) return;
// Skip search dropdown, it has its own logic
if (toggle.id === 'searchDropdown') {
return;
// Skip search dropdown, it has its own logic
if (toggle.id === 'searchDropdown') {
return;
}
dropdown.addEventListener('show.bs.dropdown', () => {
// Find all other dropdowns and hide them
bootstrap.Dropdown.getAllInstances().forEach((instance) => {
if (instance._element !== toggle) {
instance.hide();
}
let timeout;
const instance = bootstrap.Dropdown.getOrCreateInstance(toggle);
dropdown.addEventListener('mouseenter', () => {
if (window.innerWidth >= 1200) {
clearTimeout(timeout);
if (!instance._isShown()) {
instance.show();
}
}
});
dropdown.addEventListener('mouseleave', () => {
if (window.innerWidth >= 1200) {
timeout = setTimeout(() => {
if (instance._isShown()) {
instance.hide();
}
}, 200);
}
});
toggle.addEventListener('click', (e) => {
if (window.innerWidth >= 1200) {
// On desktop, prevent Bootstrap's default click toggle
e.preventDefault();
e.stopPropagation();
// Still allow navigation if it's a link
const href = toggle.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
}
// On mobile (< 1200px), this listener does nothing, allowing default click behavior.
});
});
});
});
}
window.tooltipSetup = () => {
const tooltipElements = document.querySelectorAll('[title]');
@ -130,5 +101,5 @@ window.tooltipSetup = () => {
document.addEventListener('DOMContentLoaded', () => {
tooltipSetup();
setupDropdownHovers();
setupDropdowns();
});