Die Dateien, die in diesem Commit hinzugefügt wurden oder geändert wurden, sind:

This commit is contained in:
2025-06-12 11:22:08 +02:00
parent 3c0235f2b1
commit 57715ce04d
115 changed files with 1639 additions and 423 deletions

View File

@ -1,423 +0,0 @@
/* =============================================
MINIMAL RESPONSIVE NAVBAR - MYP PLATFORM
============================================= */
/* CSS Variables für einfache Anpassung */
:root {
--navbar-height: 3.5rem;
--navbar-bg: rgba(255, 255, 255, 0.9);
--navbar-border: rgba(229, 231, 235, 0.5);
--navbar-blur: 8px;
--nav-item-gap: 0.25rem;
--nav-item-padding: 0.5rem 0.75rem;
--button-size: 2rem;
--icon-size: 1rem;
}
.dark {
--navbar-bg: rgba(17, 24, 39, 0.9);
--navbar-border: rgba(55, 65, 81, 0.5);
}
/* Basis Navbar - Minimal */
.navbar {
position: sticky;
top: 0;
z-index: 50;
width: 100%;
height: var(--navbar-height);
background: var(--navbar-bg);
backdrop-filter: blur(var(--navbar-blur));
-webkit-backdrop-filter: blur(var(--navbar-blur));
border-bottom: 1px solid var(--navbar-border);
transition: all 0.15s ease;
}
/* Navbar Scroll State - Subtiler */
.navbar.scrolled {
--navbar-height: 3rem;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
/* Container - Vereinfacht */
.navbar > div {
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 1rem;
max-width: 100%;
}
/* Navbar Brand - Kompakter */
.navbar-brand {
display: flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
flex-shrink: 0;
}
.navbar-brand svg {
width: 1.25rem;
height: 1.25rem;
}
.navbar-brand span {
font-size: 0.875rem;
font-weight: 600;
}
/* Desktop Navigation - Minimalistisch */
.navbar-menu-new {
display: none;
align-items: center;
gap: var(--nav-item-gap);
flex: 1;
justify-content: center;
padding: 0;
}
@media (min-width: 1024px) {
.navbar-menu-new {
display: flex;
}
}
/* Navigation Items - Klein und einfach */
.nav-item {
display: flex;
align-items: center;
gap: 0.375rem;
padding: var(--nav-item-padding);
border-radius: 0.375rem;
color: rgb(107, 114, 128);
text-decoration: none;
font-size: 0.8125rem;
font-weight: 500;
white-space: nowrap;
transition: color 0.15s ease, background-color 0.15s ease;
}
.dark .nav-item {
color: rgb(156, 163, 175);
}
/* Minimale Hover-Effekte */
.nav-item:hover {
color: rgb(59, 130, 246);
background: rgba(59, 130, 246, 0.05);
}
.dark .nav-item:hover {
color: rgb(147, 197, 253);
background: rgba(59, 130, 246, 0.1);
}
.nav-item.active {
color: rgb(59, 130, 246);
background: rgba(59, 130, 246, 0.08);
}
.dark .nav-item.active {
color: rgb(147, 197, 253);
background: rgba(59, 130, 246, 0.15);
}
/* Icons - Klein */
.nav-item i,
.nav-item svg {
width: var(--icon-size);
height: var(--icon-size);
flex-shrink: 0;
}
/* Mobile Menu Button - Minimal */
#mobileMenuToggle {
display: flex;
align-items: center;
justify-content: center;
width: var(--button-size);
height: var(--button-size);
padding: 0;
background: transparent;
border: none;
border-radius: 0.375rem;
cursor: pointer;
}
#mobileMenuToggle svg {
width: 1.25rem;
height: 1.25rem;
color: rgb(107, 114, 128);
}
.dark #mobileMenuToggle svg {
color: rgb(156, 163, 175);
}
@media (min-width: 1024px) {
#mobileMenuToggle {
display: none;
}
}
/* Rechte Navbar Sektion - Kompakt */
.navbar .flex.items-center {
gap: 0.5rem;
}
/* Notification & User Buttons - Minimal */
#notificationToggle,
#user-menu-button {
width: var(--button-size);
height: var(--button-size);
padding: 0;
display: flex;
align-items: center;
justify-content: center;
background: transparent;
border: none;
border-radius: 0.375rem;
cursor: pointer;
transition: background-color 0.15s ease;
}
#notificationToggle:hover,
#user-menu-button:hover {
background: rgba(0, 0, 0, 0.05);
}
.dark #notificationToggle:hover,
.dark #user-menu-button:hover {
background: rgba(255, 255, 255, 0.05);
}
/* Button Icons */
#notificationToggle i {
font-size: var(--icon-size);
color: rgb(107, 114, 128);
}
.dark #notificationToggle i {
color: rgb(156, 163, 175);
}
/* User Avatar - Klein */
#user-menu-button .rounded-full {
width: 1.5rem;
height: 1.5rem;
font-size: 0.625rem;
}
/* Notification Badge - Minimal */
#notificationBadge {
position: absolute;
top: 0.25rem;
right: 0.25rem;
width: 0.75rem;
height: 0.75rem;
font-size: 0.5rem;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
}
/* Dark Mode Toggle - Ultra Minimal */
.dark-mode-toggle {
width: 2rem;
height: 1rem;
background: rgb(229, 231, 235);
border-radius: 0.5rem;
cursor: pointer;
border: none;
padding: 0;
position: relative;
transition: background-color 0.15s ease;
}
.dark .dark-mode-toggle {
background: rgb(55, 65, 81);
}
.dark-mode-toggle-slider {
position: absolute;
top: 0.125rem;
left: 0.125rem;
width: 0.75rem;
height: 0.75rem;
background: white;
border-radius: 50%;
transition: transform 0.15s ease;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.dark .dark-mode-toggle-slider {
transform: translateX(1rem);
}
/* Icon Größen in Toggle */
.dark-mode-toggle-icon {
font-size: 0.5rem;
}
/* Mobile Menu - Vereinfacht */
.mobile-menu-new {
position: fixed;
top: var(--navbar-height);
left: 0;
right: 0;
bottom: 0;
background: var(--navbar-bg);
backdrop-filter: blur(var(--navbar-blur));
-webkit-backdrop-filter: blur(var(--navbar-blur));
transform: translateX(-100%);
transition: transform 0.2s ease;
overflow-y: auto;
}
.mobile-menu-new.active {
transform: translateX(0);
}
/* Mobile Navigation Items - Einfacher */
.mobile-nav-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.875rem 1rem;
color: rgb(107, 114, 128);
text-decoration: none;
font-size: 0.875rem;
font-weight: 500;
transition: background-color 0.15s ease;
}
.dark .mobile-nav-item {
color: rgb(156, 163, 175);
}
.mobile-nav-item:active {
background: rgba(0, 0, 0, 0.03);
}
.dark .mobile-nav-item:active {
background: rgba(255, 255, 255, 0.03);
}
.mobile-nav-item.active {
color: rgb(59, 130, 246);
background: rgba(59, 130, 246, 0.05);
border-left: 2px solid rgb(59, 130, 246);
}
.dark .mobile-nav-item.active {
color: rgb(147, 197, 253);
background: rgba(59, 130, 246, 0.1);
}
.mobile-nav-item i,
.mobile-nav-item svg {
width: 1.125rem;
height: 1.125rem;
}
/* Dropdowns - Einfacher */
#notificationDropdown,
#user-dropdown {
position: absolute;
top: 100%;
right: 0;
margin-top: 0.25rem;
background: white;
border: 1px solid var(--navbar-border);
border-radius: 0.5rem;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
min-width: 16rem;
max-width: 90vw;
}
.dark #notificationDropdown,
.dark #user-dropdown {
background: rgb(17, 24, 39);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
/* Responsive Anpassungen */
@media (max-width: 640px) {
:root {
--navbar-height: 3rem;
--button-size: 1.75rem;
}
.navbar > div {
padding: 0 0.75rem;
}
.navbar-brand svg {
width: 1.125rem;
height: 1.125rem;
}
.navbar-brand span {
font-size: 0.8125rem;
}
.navbar-brand .text-xs {
display: none;
}
}
@media (max-width: 360px) {
:root {
--button-size: 1.625rem;
--icon-size: 0.875rem;
}
.navbar-brand span {
display: none;
}
}
/* Tablet - Nur Icons */
@media (min-width: 768px) and (max-width: 1023px) {
.nav-item {
padding: 0.5rem;
}
.nav-item span {
display: none;
}
}
/* Entferne alle Glassmorphism-Duplikate */
.navbar::before,
.navbar::after,
.glass-nav,
.glass-navbar {
display: none !important;
}
/* Focus States - Minimal */
.navbar *:focus-visible {
outline: 1px solid rgb(59, 130, 246);
outline-offset: 1px;
}
/* Performance */
@media (prefers-reduced-motion: reduce) {
* {
animation: none !important;
transition: none !important;
}
}
/* Touch Optimierung */
@media (hover: none) {
.nav-item:hover,
#notificationToggle:hover,
#user-menu-button:hover {
background: transparent;
}
}

View File

@ -0,0 +1,468 @@
/* =============================================
MYP PLATFORM - MODERNE NAVBAR
Mercedes-Benz Design System
============================================= */
:root {
/* Mercedes-Benz Farbpalette */
--mb-primary: #00adef;
--mb-secondary: #6c757d;
--mb-dark: #1e2125;
--mb-light: #f8f9fa;
--mb-silver: #c7c7cc;
/* Navbar-spezifische Variablen */
--navbar-height: 4rem;
--navbar-bg: rgba(255, 255, 255, 0.95);
--navbar-border: rgba(0, 173, 239, 0.1);
--navbar-shadow: 0 2px 20px rgba(0, 173, 239, 0.1);
--navbar-blur: 20px;
/* Navigation Items */
--nav-item-hover: rgba(0, 173, 239, 0.1);
--nav-item-active: rgba(0, 173, 239, 0.15);
--nav-text-primary: #1e2125;
--nav-text-secondary: #6c757d;
--nav-text-active: #00adef;
/* Transitions */
--transition-fast: 0.15s ease;
--transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.dark {
--navbar-bg: rgba(30, 33, 37, 0.95);
--navbar-border: rgba(0, 173, 239, 0.2);
--navbar-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
--nav-item-hover: rgba(0, 173, 239, 0.15);
--nav-item-active: rgba(0, 173, 239, 0.25);
--nav-text-primary: #f8f9fa;
--nav-text-secondary: #c7c7cc;
}
/* ===== NAVBAR CONTAINER ===== */
.navbar {
position: sticky;
top: 0;
z-index: 1000;
width: 100%;
height: var(--navbar-height);
background: var(--navbar-bg);
backdrop-filter: blur(var(--navbar-blur));
-webkit-backdrop-filter: blur(var(--navbar-blur));
border-bottom: 1px solid var(--navbar-border);
box-shadow: var(--navbar-shadow);
transition: all var(--transition-smooth);
}
.navbar.scrolled {
--navbar-height: 3.5rem;
--navbar-blur: 30px;
--navbar-shadow: 0 4px 25px rgba(0, 173, 239, 0.15);
}
/* ===== NAVBAR LAYOUT ===== */
.navbar-container {
height: 100%;
max-width: 1400px;
margin: 0 auto;
padding: 0 1.5rem;
display: flex;
align-items: center;
justify-content: space-between;
gap: 2rem;
}
/* ===== BRAND SECTION ===== */
.navbar-brand {
display: flex;
align-items: center;
gap: 0.75rem;
text-decoration: none;
color: var(--nav-text-primary);
font-weight: 600;
transition: transform var(--transition-fast);
flex-shrink: 0;
}
.navbar-brand:hover {
transform: scale(1.02);
color: var(--mb-primary);
}
.navbar-brand .brand-icon {
width: 2rem;
height: 2rem;
color: var(--mb-primary);
transition: transform var(--transition-smooth);
}
.navbar-brand:hover .brand-icon {
transform: rotate(15deg);
}
.brand-text {
display: flex;
flex-direction: column;
line-height: 1.2;
}
.brand-title {
font-size: 1.1rem;
font-weight: 700;
color: var(--nav-text-primary);
}
.brand-subtitle {
font-size: 0.75rem;
color: var(--nav-text-secondary);
font-weight: 500;
}
/* ===== DESKTOP NAVIGATION ===== */
.navbar-nav {
display: none;
flex: 1;
justify-content: center;
align-items: center;
gap: 0.5rem;
background: rgba(0, 173, 239, 0.05);
border-radius: 1rem;
padding: 0.5rem;
backdrop-filter: blur(10px);
border: 1px solid rgba(0, 173, 239, 0.1);
}
@media (min-width: 1024px) {
.navbar-nav {
display: flex;
}
}
.nav-item {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 0.75rem;
border-radius: 0.5rem;
color: var(--nav-text-secondary);
text-decoration: none;
font-size: 0.875rem;
font-weight: 500;
white-space: nowrap;
transition: all var(--transition-fast);
position: relative;
}
.nav-item:hover {
color: var(--nav-text-active);
background: var(--nav-item-hover);
transform: translateY(-1px);
}
.nav-item.active {
color: var(--nav-text-active);
background: var(--nav-item-active);
font-weight: 600;
}
.nav-item.active::after {
content: '';
position: absolute;
bottom: -0.25rem;
left: 50%;
transform: translateX(-50%);
width: 0.25rem;
height: 0.25rem;
background: var(--mb-primary);
border-radius: 50%;
}
.nav-item i {
font-size: 1rem;
width: 1.25rem;
height: 1.25rem;
display: flex;
align-items: center;
justify-content: center;
}
/* ===== NAVBAR ACTIONS (Rechte Seite) ===== */
.navbar-actions {
display: flex;
align-items: center;
gap: 0.75rem;
flex-shrink: 0;
}
.navbar-btn {
display: flex;
align-items: center;
justify-content: center;
width: 2.5rem;
height: 2.5rem;
border-radius: 0.75rem;
background: transparent;
border: 1px solid transparent;
color: var(--nav-text-secondary);
cursor: pointer;
transition: all var(--transition-fast);
position: relative;
}
.navbar-btn:hover {
background: var(--nav-item-hover);
color: var(--nav-text-active);
border-color: var(--navbar-border);
transform: scale(1.05);
}
.navbar-btn.has-notifications::after {
content: '';
position: absolute;
top: 0.25rem;
right: 0.25rem;
width: 0.5rem;
height: 0.5rem;
background: #dc3545;
border-radius: 50%;
border: 2px solid var(--navbar-bg);
}
/* ===== MOBILE MENU TOGGLE ===== */
.mobile-menu-toggle {
display: flex;
align-items: center;
justify-content: center;
width: 2.5rem;
height: 2.5rem;
border: none;
background: transparent;
color: var(--nav-text-primary);
cursor: pointer;
border-radius: 0.5rem;
transition: all var(--transition-fast);
}
.mobile-menu-toggle:hover {
background: var(--nav-item-hover);
color: var(--nav-text-active);
}
@media (min-width: 1024px) {
.mobile-menu-toggle {
display: none;
}
}
/* ===== MOBILE MENU ===== */
.mobile-menu {
position: fixed;
top: var(--navbar-height);
left: 0;
right: 0;
bottom: 0;
background: var(--navbar-bg);
backdrop-filter: blur(var(--navbar-blur));
-webkit-backdrop-filter: blur(var(--navbar-blur));
transform: translateX(-100%);
transition: transform var(--transition-smooth);
overflow-y: auto;
z-index: 999;
}
.mobile-menu.active {
transform: translateX(0);
}
.mobile-nav {
padding: 2rem 1.5rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.mobile-nav-item {
display: flex;
align-items: center;
gap: 1rem;
padding: 1rem;
border-radius: 0.75rem;
color: var(--nav-text-secondary);
text-decoration: none;
font-size: 1rem;
font-weight: 500;
transition: all var(--transition-fast);
border: 1px solid transparent;
}
.mobile-nav-item:hover {
background: var(--nav-item-hover);
color: var(--nav-text-active);
border-color: var(--navbar-border);
}
.mobile-nav-item.active {
background: var(--nav-item-active);
color: var(--nav-text-active);
border-color: var(--mb-primary);
font-weight: 600;
}
.mobile-nav-item i {
font-size: 1.25rem;
width: 1.5rem;
height: 1.5rem;
display: flex;
align-items: center;
justify-content: center;
}
/* ===== DROPDOWN MENUS ===== */
.dropdown {
position: relative;
}
.dropdown-menu {
position: absolute;
top: calc(100% + 0.5rem);
right: 0;
min-width: 16rem;
background: var(--navbar-bg);
border: 1px solid var(--navbar-border);
border-radius: 0.75rem;
box-shadow: 0 8px 30px rgba(0, 173, 239, 0.15);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
opacity: 0;
visibility: hidden;
transform: translateY(-0.5rem);
transition: all var(--transition-fast);
z-index: 1001;
}
.dropdown.active .dropdown-menu {
opacity: 1;
visibility: visible;
transform: translateY(0);
}
.dropdown-header {
padding: 1rem;
border-bottom: 1px solid var(--navbar-border);
font-size: 0.875rem;
font-weight: 600;
color: var(--nav-text-primary);
}
.dropdown-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 1rem;
color: var(--nav-text-secondary);
text-decoration: none;
font-size: 0.875rem;
transition: all var(--transition-fast);
}
.dropdown-item:hover {
background: var(--nav-item-hover);
color: var(--nav-text-active);
}
.dropdown-divider {
margin: 0.5rem 0;
border-top: 1px solid var(--navbar-border);
}
/* ===== USER AVATAR ===== */
.user-avatar {
width: 2.25rem;
height: 2.25rem;
border-radius: 50%;
background: linear-gradient(135deg, var(--mb-primary), #0086c3);
color: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.875rem;
font-weight: 600;
cursor: pointer;
transition: all var(--transition-fast);
border: 2px solid transparent;
}
.user-avatar:hover {
transform: scale(1.05);
border-color: var(--mb-primary);
box-shadow: 0 4px 15px rgba(0, 173, 239, 0.3);
}
/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
.navbar-container {
padding: 0 1rem;
gap: 1rem;
}
.brand-text {
display: none;
}
.navbar-actions {
gap: 0.5rem;
}
}
@media (max-width: 480px) {
.navbar-container {
padding: 0 0.75rem;
}
.navbar-actions .navbar-btn:not(.mobile-menu-toggle) {
display: none;
}
}
/* ===== ACCESSIBILITY ===== */
.navbar-btn:focus,
.nav-item:focus,
.mobile-nav-item:focus {
outline: 2px solid var(--mb-primary);
outline-offset: 2px;
}
/* ===== ANIMATIONS ===== */
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-1rem);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.navbar {
animation: slideDown 0.5s ease;
}
/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.navbar * {
will-change: auto;
}
.navbar-brand:hover,
.nav-item:hover,
.navbar-btn:hover {
will-change: transform;
}
/* ===== PRINT STYLES ===== */
@media print {
.navbar {
display: none;
}
}

403
backend/static/js/navbar.js Normal file
View File

@ -0,0 +1,403 @@
/**
* MYP Platform - Moderne Navbar Controller
* Optimiert für Mercedes-Benz 3D-Druck-Management-System
*/
class MYPNavbar {
constructor() {
this.navbar = document.querySelector('.navbar');
this.mobileToggle = document.querySelector('.mobile-menu-toggle');
this.mobileMenu = document.querySelector('.mobile-menu');
this.dropdowns = document.querySelectorAll('.dropdown');
this.isOpen = false;
this.activeDropdown = null;
this.scrollThreshold = 50;
this.lastScroll = 0;
this.init();
}
/**
* Initialisierung aller Event-Listener und Grundfunktionen
*/
init() {
this.setupEventListeners();
this.handleInitialState();
this.preloadAnimations();
// Debug-Logging nur in Development
if (window.location.hostname === 'localhost') {
console.log('MYP Navbar initialisiert');
}
}
/**
* Setup aller Event-Listener mit Performance-Optimierung
*/
setupEventListeners() {
// Mobile Menu Toggle
if (this.mobileToggle && this.mobileMenu) {
this.mobileToggle.addEventListener('click', this.toggleMobileMenu.bind(this));
}
// Scroll-Handler mit Throttling
let scrollTimer;
window.addEventListener('scroll', () => {
if (scrollTimer) return;
scrollTimer = setTimeout(() => {
this.handleScroll();
scrollTimer = null;
}, 16); // ~60fps
}, { passive: true });
// Dropdown-Handler
this.dropdowns.forEach(dropdown => {
const trigger = dropdown.querySelector('.navbar-btn, .user-avatar');
if (trigger) {
trigger.addEventListener('click', (e) => {
e.stopPropagation();
this.toggleDropdown(dropdown);
});
}
});
// Global Click Handler für das Schließen von Dropdowns und Mobile Menu
document.addEventListener('click', (e) => {
if (this.isOpen && !this.mobileMenu.contains(e.target)) {
this.closeMobileMenu();
}
if (this.activeDropdown && !this.activeDropdown.contains(e.target)) {
this.closeDropdowns();
}
});
// ESC-Taste Handler
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
if (this.isOpen) this.closeMobileMenu();
if (this.activeDropdown) this.closeDropdowns();
}
});
// Resize-Handler mit Debouncing
let resizeTimer;
window.addEventListener('resize', () => {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
this.handleResize();
}, 250);
});
// Fokus-Management für Accessibility
this.setupAccessibility();
}
/**
* Behandlung des Scroll-Events mit optimierter Performance
*/
handleScroll() {
const currentScroll = window.pageYOffset;
// Scroll-Direction Detection
const isScrollingDown = currentScroll > this.lastScroll;
// Navbar Scrolled State
if (currentScroll > this.scrollThreshold) {
this.navbar.classList.add('scrolled');
} else {
this.navbar.classList.remove('scrolled');
}
// Auto-hide auf sehr kleinen Bildschirmen beim Scrollen nach unten
if (window.innerWidth <= 480 && isScrollingDown && currentScroll > 200) {
this.navbar.style.transform = 'translateY(-100%)';
} else {
this.navbar.style.transform = 'translateY(0)';
}
this.lastScroll = currentScroll;
}
/**
* Mobile Menu Toggle-Funktionalität
*/
toggleMobileMenu() {
this.isOpen ? this.closeMobileMenu() : this.openMobileMenu();
}
/**
* Mobile Menu öffnen mit Animation
*/
openMobileMenu() {
this.isOpen = true;
this.mobileMenu.classList.add('active');
this.mobileToggle.setAttribute('aria-expanded', 'true');
// Icon-Animation
const icon = this.mobileToggle.querySelector('i');
if (icon) {
icon.className = 'fas fa-times';
}
// Body-Scroll blockieren
document.body.style.overflow = 'hidden';
// Focus auf erstes Menü-Item
const firstItem = this.mobileMenu.querySelector('.mobile-nav-item');
if (firstItem) {
setTimeout(() => firstItem.focus(), 300);
}
this.logEvent('Mobile Menu geöffnet');
}
/**
* Mobile Menu schließen mit Animation
*/
closeMobileMenu() {
this.isOpen = false;
this.mobileMenu.classList.remove('active');
this.mobileToggle.setAttribute('aria-expanded', 'false');
// Icon-Animation zurücksetzen
const icon = this.mobileToggle.querySelector('i');
if (icon) {
icon.className = 'fas fa-bars';
}
// Body-Scroll wiederherstellen
document.body.style.overflow = '';
this.logEvent('Mobile Menu geschlossen');
}
/**
* Dropdown Toggle-Funktionalität
*/
toggleDropdown(dropdown) {
if (this.activeDropdown === dropdown) {
this.closeDropdowns();
} else {
this.closeDropdowns();
this.openDropdown(dropdown);
}
}
/**
* Dropdown öffnen
*/
openDropdown(dropdown) {
this.activeDropdown = dropdown;
dropdown.classList.add('active');
dropdown.setAttribute('aria-expanded', 'true');
// Focus auf erstes Dropdown-Item
const firstItem = dropdown.querySelector('.dropdown-item');
if (firstItem) {
setTimeout(() => firstItem.focus(), 100);
}
this.logEvent('Dropdown geöffnet');
}
/**
* Alle Dropdowns schließen
*/
closeDropdowns() {
this.dropdowns.forEach(dropdown => {
dropdown.classList.remove('active');
dropdown.setAttribute('aria-expanded', 'false');
});
this.activeDropdown = null;
this.logEvent('Dropdowns geschlossen');
}
/**
* Resize-Handler für responsive Anpassungen
*/
handleResize() {
// Mobile Menu schließen wenn Desktop-Größe erreicht
if (window.innerWidth >= 1024 && this.isOpen) {
this.closeMobileMenu();
}
// Dropdowns schließen bei Größenänderung
this.closeDropdowns();
this.logEvent(`Fenster-Resize: ${window.innerWidth}x${window.innerHeight}`);
}
/**
* Initialzustand der Navbar basierend auf aktueller Seite setzen
*/
handleInitialState() {
// Aktive Navigation markieren
const currentPath = window.location.pathname;
const navItems = document.querySelectorAll('.nav-item, .mobile-nav-item');
navItems.forEach(item => {
const href = item.getAttribute('href');
if (href && (currentPath === href || currentPath.startsWith(href + '/'))) {
item.classList.add('active');
}
});
// Scroll-Position prüfen
if (window.pageYOffset > this.scrollThreshold) {
this.navbar.classList.add('scrolled');
}
}
/**
* Accessibility-Features einrichten
*/
setupAccessibility() {
// Aria-Labels für bessere Zugänglichkeit
if (this.mobileToggle) {
this.mobileToggle.setAttribute('aria-label', 'Menü öffnen/schließen');
this.mobileToggle.setAttribute('aria-expanded', 'false');
}
// Keyboard-Navigation für Dropdown-Menüs
this.dropdowns.forEach(dropdown => {
const items = dropdown.querySelectorAll('.dropdown-item');
items.forEach((item, index) => {
item.addEventListener('keydown', (e) => {
if (e.key === 'ArrowDown') {
e.preventDefault();
const nextItem = items[index + 1] || items[0];
nextItem.focus();
} else if (e.key === 'ArrowUp') {
e.preventDefault();
const prevItem = items[index - 1] || items[items.length - 1];
prevItem.focus();
}
});
});
});
}
/**
* Performance-Optimierung: Animationen vorladen
*/
preloadAnimations() {
// CSS-Animationen vorbereiten
if (this.navbar) {
this.navbar.style.willChange = 'transform, box-shadow';
}
if (this.mobileMenu) {
this.mobileMenu.style.willChange = 'transform';
}
}
/**
* Notification Badge Update
*/
updateNotificationBadge(count) {
const notificationBtn = document.querySelector('.navbar-btn.has-notifications');
if (notificationBtn) {
if (count > 0) {
notificationBtn.classList.add('has-notifications');
notificationBtn.setAttribute('aria-label', `${count} neue Benachrichtigungen`);
} else {
notificationBtn.classList.remove('has-notifications');
notificationBtn.setAttribute('aria-label', 'Benachrichtigungen');
}
}
}
/**
* User-Avatar Update
*/
updateUserAvatar(initials, imageUrl = null) {
const avatar = document.querySelector('.user-avatar');
if (avatar) {
if (imageUrl) {
avatar.style.backgroundImage = `url(${imageUrl})`;
avatar.style.backgroundSize = 'cover';
avatar.textContent = '';
} else {
avatar.style.backgroundImage = '';
avatar.textContent = initials || '?';
}
}
}
/**
* Navbar Zustand zurücksetzen
*/
reset() {
this.closeMobileMenu();
this.closeDropdowns();
this.navbar.classList.remove('scrolled');
document.body.style.overflow = '';
this.logEvent('Navbar zurückgesetzt');
}
/**
* Debug-Logging mit Zeitstempel
*/
logEvent(message) {
if (window.location.hostname === 'localhost' && window.console) {
const timestamp = new Date().toLocaleTimeString();
console.log(`[${timestamp}] MYP Navbar: ${message}`);
}
}
/**
* Cleanup für Single-Page-Applications
*/
destroy() {
// Event-Listener entfernen
window.removeEventListener('scroll', this.handleScroll);
window.removeEventListener('resize', this.handleResize);
document.removeEventListener('click', this.closeDropdowns);
document.removeEventListener('keydown', this.handleKeydown);
// Styles zurücksetzen
if (this.navbar) {
this.navbar.style.willChange = 'auto';
}
this.logEvent('Navbar zerstört');
}
}
/**
* Auto-Initialisierung nach DOM-Load
*/
document.addEventListener('DOMContentLoaded', () => {
// Globale Instanz für externe Zugriffe
window.MYPNavbar = new MYPNavbar();
// Notification-System Integration
if (window.NotificationManager) {
window.NotificationManager.onUpdate = (count) => {
window.MYPNavbar.updateNotificationBadge(count);
};
}
// Performance-Monitoring
if (window.performance && window.performance.mark) {
window.performance.mark('navbar-init-complete');
}
});
/**
* Error-Handler für unerwartete Fehler
*/
window.addEventListener('error', (e) => {
if (e.filename && e.filename.includes('navbar.js')) {
console.error('MYP Navbar Fehler:', e.message, e.lineno);
// Fallback: Navbar in sicheren Zustand versetzen
if (window.MYPNavbar) {
window.MYPNavbar.reset();
}
}
});