pique/static/main.js

47 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-03-24 05:28:21 +00:00
let mobile_open_button = document.getElementById("mobile-menu-open-button");
let mobile_close_button = document.getElementById("mobile-menu-close-button");
let mobile_menu = document.getElementById("mobile-menu");
const profile_button = document.getElementById("profile-menu-button");
let profile_dropdown = document.getElementById("profile-dropdown");
function toggle_mobile_menu() {
if (mobile_open_button.classList.contains("block")) {
mobile_menu.classList.remove("hidden");
mobile_open_button.classList.remove("block");
mobile_open_button.classList.add("hidden");
mobile_close_button.classList.remove("hidden");
mobile_close_button.classList.add("block");
} else {
mobile_menu.classList.add("hidden");
mobile_close_button.classList.remove("block");
mobile_close_button.classList.add("hidden");
mobile_open_button.classList.remove("hidden");
mobile_open_button.classList.add("block");
}
}
function toggle_profile_dropdown() {
if (profile_dropdown.classList.contains("hidden")) {
profile_dropdown.classList.remove("hidden");
} else {
profile_dropdown.classList.add("hidden");
}
}
function hide_profile_dropdown() {
let profile_dropdown = document.getElementById("profile-dropdown");
if (!profile_dropdown.classList.contains("hidden")) {
profile_dropdown.classList.add("hidden");
}
}
document.addEventListener("click", (event) => {
if (!profile_button.contains(event.target) && !profile_dropdown.contains(event.target)) {
profile_dropdown.classList.add("hidden");
}
});