Update public/app.js
Browse files- public/app.js +25 -2
public/app.js
CHANGED
|
@@ -142,8 +142,30 @@
|
|
| 142 |
if (e.key !== 'Escape') return;
|
| 143 |
const opened = Array.from(document.querySelectorAll('.modal-overlay')).filter((o) => !o.classList.contains('hidden'));
|
| 144 |
if (opened.length) closeModal(opened[opened.length - 1].id);
|
|
|
|
| 145 |
});
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
// ---------- FILTER ----------
|
| 148 |
function filtered() {
|
| 149 |
let list = state.prompts.slice();
|
|
@@ -537,7 +559,7 @@
|
|
| 537 |
// ---------- NAV ----------
|
| 538 |
document.querySelectorAll('.nav-item').forEach((n) => {
|
| 539 |
n.addEventListener('click', async () => {
|
| 540 |
-
if (n.dataset.action === 'open-settings') { openSettings(); return; }
|
| 541 |
const v = n.dataset.view;
|
| 542 |
if (!v) return;
|
| 543 |
state.view = v;
|
|
@@ -547,6 +569,7 @@
|
|
| 547 |
try { await loadImages(); } catch (err) { toast(err.message || String(err), 'error'); }
|
| 548 |
}
|
| 549 |
render();
|
|
|
|
| 550 |
});
|
| 551 |
});
|
| 552 |
|
|
@@ -882,4 +905,4 @@
|
|
| 882 |
}
|
| 883 |
render();
|
| 884 |
})();
|
| 885 |
-
})();
|
|
|
|
| 142 |
if (e.key !== 'Escape') return;
|
| 143 |
const opened = Array.from(document.querySelectorAll('.modal-overlay')).filter((o) => !o.classList.contains('hidden'));
|
| 144 |
if (opened.length) closeModal(opened[opened.length - 1].id);
|
| 145 |
+
else closeSidebar();
|
| 146 |
});
|
| 147 |
|
| 148 |
+
// ---------- MOBILE SIDEBAR ----------
|
| 149 |
+
function openSidebar() {
|
| 150 |
+
$('sidebar').classList.add('open');
|
| 151 |
+
$('sidebarBackdrop').classList.remove('hidden');
|
| 152 |
+
$('mobileMenuBtn').setAttribute('aria-expanded', 'true');
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
function closeSidebar() {
|
| 156 |
+
$('sidebar').classList.remove('open');
|
| 157 |
+
$('sidebarBackdrop').classList.add('hidden');
|
| 158 |
+
$('mobileMenuBtn').setAttribute('aria-expanded', 'false');
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
function toggleSidebar() {
|
| 162 |
+
if ($('sidebar').classList.contains('open')) closeSidebar();
|
| 163 |
+
else openSidebar();
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
$('mobileMenuBtn').addEventListener('click', toggleSidebar);
|
| 167 |
+
$('sidebarBackdrop').addEventListener('click', closeSidebar);
|
| 168 |
+
|
| 169 |
// ---------- FILTER ----------
|
| 170 |
function filtered() {
|
| 171 |
let list = state.prompts.slice();
|
|
|
|
| 559 |
// ---------- NAV ----------
|
| 560 |
document.querySelectorAll('.nav-item').forEach((n) => {
|
| 561 |
n.addEventListener('click', async () => {
|
| 562 |
+
if (n.dataset.action === 'open-settings') { closeSidebar(); openSettings(); return; }
|
| 563 |
const v = n.dataset.view;
|
| 564 |
if (!v) return;
|
| 565 |
state.view = v;
|
|
|
|
| 569 |
try { await loadImages(); } catch (err) { toast(err.message || String(err), 'error'); }
|
| 570 |
}
|
| 571 |
render();
|
| 572 |
+
closeSidebar();
|
| 573 |
});
|
| 574 |
});
|
| 575 |
|
|
|
|
| 905 |
}
|
| 906 |
render();
|
| 907 |
})();
|
| 908 |
+
})();
|