This commit is contained in:
2026-05-13 21:17:36 +03:00
parent e43b94ba20
commit 3a6ab777c9
49 changed files with 9247 additions and 210 deletions

58
public/js/init.js Normal file
View File

@@ -0,0 +1,58 @@
"use strict";
(function () {
const framexEngine = {
init() {
this.bindThemeToggle();
this.bindMobileMenu();
},
bindThemeToggle() {
const buttons = document.querySelectorAll("[data-theme-toggle]");
if (!buttons.length) {
return;
}
const applyTheme = (theme) => {
const isDark = theme === "dark";
document.documentElement.classList.toggle("dark", isDark);
try {
localStorage.setItem("framex-theme", theme);
} catch (error) {}
buttons.forEach((button) => {
button.setAttribute("aria-pressed", String(isDark));
});
};
buttons.forEach((button) => {
button.addEventListener("click", () => {
const nextTheme = document.documentElement.classList.contains("dark")
? "light"
: "dark";
applyTheme(nextTheme);
});
});
},
bindMobileMenu() {
const button = document.querySelector("[data-mobile-menu-toggle]");
const menu = document.querySelector("[data-mobile-menu]");
if (!button || !menu) {
return;
}
button.addEventListener("click", () => {
const isOpen = button.getAttribute("aria-expanded") === "true";
button.setAttribute("aria-expanded", String(!isOpen));
menu.classList.toggle("hidden", isOpen);
});
},
};
// Initialize on DOM ready
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", () => framexEngine.init());
} else {
framexEngine.init();
}
})();