Skip to content

lightweight, client-only calendar web application. All data persists in the URL hash for instant sharing, No backend required. Optional AES-GCM password protection keeps shared links locked without a server

JavaScript

update UI UX

Supun Lakmalbe9b67afe69a
diff --git a/script.js b/script.js
index 9892297..2bca273 100644
--- a/script.js
+++ b/script.js
@@ -2407,6 +2407,14 @@ function handleClearAll() {
}
function bindEvents() {
+ const topbarDropdowns = Array.from(document.querySelectorAll(".topbar details.menu-dropdown"));
+ const closeTopbarDropdowns = (exceptDropdown = null) => {
+ topbarDropdowns.forEach((dropdown) => {
+ if (!dropdown || dropdown === exceptDropdown) return;
+ dropdown.open = false;
+ });
+ };
+
if (ui.titleInput) ui.titleInput.addEventListener("input", handleTitleInput);
if (ui.prevMonth) ui.prevMonth.addEventListener("click", handlePrevMonth);
if (ui.nextMonth) ui.nextMonth.addEventListener("click", handleNextMonth);
@@ -2424,6 +2432,14 @@ function bindEvents() {
});
});
}
+ if (topbarDropdowns.length) {
+ topbarDropdowns.forEach((dropdown) => {
+ dropdown.addEventListener("toggle", () => {
+ if (!dropdown.open) return;
+ closeTopbarDropdowns(dropdown);
+ });
+ });
+ }
if (ui.viewSelect) {
ui.viewSelect.addEventListener("change", (event) => {
setView(event.target.value);
@@ -2494,6 +2510,13 @@ function bindEvents() {
}
window.addEventListener("hashchange", handleHashChange);
window.addEventListener("resize", syncTopbarHeight);
+ document.addEventListener("click", (event) => {
+ const target = event.target;
+ const isInsideTopbarDropdown = topbarDropdowns.some((dropdown) => dropdown.contains(target));
+ if (!isInsideTopbarDropdown) {
+ closeTopbarDropdowns();
+ }
+ });
document.addEventListener("keydown", handleGlobalKeydown);
document.addEventListener("visibilitychange", () => {
if (document.hidden) return;