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

View File

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

View File

@ -42,10 +42,10 @@ function toolsManager() {
}); });
} }
function setupDropdownHovers() { function setupDropdowns() {
const dropdowns = document.querySelectorAll('.navbar-nav > .nav-item.dropdown'); const dropdowns = document.querySelectorAll('.navbar-nav > .nav-item.dropdown');
dropdowns.forEach(dropdown => { dropdowns.forEach((dropdown) => {
const toggle = dropdown.querySelector('[data-bs-toggle="dropdown"]'); const toggle = dropdown.querySelector('[data-bs-toggle="dropdown"]');
if (!toggle) return; if (!toggle) return;
@ -54,46 +54,17 @@ function setupDropdownHovers() {
return; return;
} }
let timeout; dropdown.addEventListener('show.bs.dropdown', () => {
const instance = bootstrap.Dropdown.getOrCreateInstance(toggle); // Find all other dropdowns and hide them
bootstrap.Dropdown.getAllInstances().forEach((instance) => {
dropdown.addEventListener('mouseenter', () => { if (instance._element !== toggle) {
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(); 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 = () => { window.tooltipSetup = () => {
const tooltipElements = document.querySelectorAll('[title]'); const tooltipElements = document.querySelectorAll('[title]');
@ -130,5 +101,5 @@ window.tooltipSetup = () => {
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
tooltipSetup(); tooltipSetup();
setupDropdownHovers(); setupDropdowns();
}); });