up
This commit is contained in:
@@ -84,6 +84,10 @@ try {
|
||||
</small>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<!-- Sidebar toggle (visible en pantallas pequeñas) -->
|
||||
<button id="sidebar-toggle" class="btn btn-light d-md-none me-2" title="Abrir menú">
|
||||
<i class="fas fa-bars"></i>
|
||||
</button>
|
||||
<div class="status-badge">
|
||||
<span class="status-dot status-online"></span>
|
||||
<span class="status-text">En línea</span>
|
||||
@@ -1133,6 +1137,56 @@ try {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
try { NotificationManager.init(); } catch(e) { console.error('NotificationManager init failed', e); }
|
||||
|
||||
// Sidebar toggle logic for responsive/mobile
|
||||
const sidebar = document.querySelector('.sidebar');
|
||||
const toggleBtn = document.getElementById('sidebar-toggle');
|
||||
let overlayEl = null;
|
||||
|
||||
function ensureOverlay() {
|
||||
if (!overlayEl) {
|
||||
overlayEl = document.createElement('div');
|
||||
overlayEl.className = 'sidebar-overlay';
|
||||
document.body.appendChild(overlayEl);
|
||||
overlayEl.addEventListener('click', closeSidebar);
|
||||
}
|
||||
}
|
||||
|
||||
function openSidebar() {
|
||||
if (!sidebar) return;
|
||||
sidebar.classList.add('open');
|
||||
document.body.classList.add('sidebar-open');
|
||||
ensureOverlay();
|
||||
overlayEl.style.display = 'block';
|
||||
}
|
||||
|
||||
function closeSidebar() {
|
||||
if (!sidebar) return;
|
||||
sidebar.classList.remove('open');
|
||||
document.body.classList.remove('sidebar-open');
|
||||
if (overlayEl) overlayEl.style.display = 'none';
|
||||
}
|
||||
|
||||
if (toggleBtn) {
|
||||
toggleBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
if (sidebar && sidebar.classList.contains('open')) {
|
||||
closeSidebar();
|
||||
} else {
|
||||
openSidebar();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Close sidebar on Escape
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') closeSidebar();
|
||||
});
|
||||
|
||||
// Close sidebar when navigating in main content on small screens
|
||||
document.querySelector('.main-content')?.addEventListener('click', () => {
|
||||
if (window.innerWidth < 992) closeSidebar();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user