106 lines
2.9 KiB
JavaScript
106 lines
2.9 KiB
JavaScript
function toggleAccount() {
|
|
if ($("#dropdownAccount").hasClass("is-visible")) {
|
|
event.preventDefault();
|
|
$("#dropdownAccount").removeClass("is-visible");
|
|
$("#dropdownAccount").css("display", "none");
|
|
} else {
|
|
event.preventDefault();
|
|
$("#dropdownAccount").css("display", "inline-flex");
|
|
setTimeout(function () {
|
|
$("#dropdownAccount").addClass("is-visible");
|
|
}, 100);
|
|
}
|
|
}
|
|
|
|
$(document).on("click", function (event) {
|
|
if ($(event.target).closest("#userIcon").length) {
|
|
return;
|
|
} else {
|
|
if (!$(event.target).closest(".dropdown-account").length) {
|
|
$("#dropdownAccount").removeClass("is-visible");
|
|
setTimeout(function () {
|
|
$("#dropdownAccount").css("display", "none");
|
|
}, 200);
|
|
}
|
|
}
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
$(document).keydown(function (e) {
|
|
if (e.key === "Escape" || e.key === "Esc") {
|
|
$("#dropdownAccount").removeClass("is-visible");
|
|
setTimeout(function () {
|
|
$("#dropdownAccount").css("display", "none");
|
|
}, 200);
|
|
}
|
|
});
|
|
});
|
|
|
|
function toggleNotifications() {
|
|
if ($("#dropdownNotifications").hasClass("is-visible")) {
|
|
event.preventDefault();
|
|
$("#dropdownNotifications").removeClass("is-visible");
|
|
$("#dropdownNotifications").css("display", "none");
|
|
} else {
|
|
event.preventDefault();
|
|
$("#dropdownNotifications").css("display", "inline-flex");
|
|
setTimeout(function () {
|
|
$("#dropdownNotifications").addClass("is-visible");
|
|
}, 100);
|
|
}
|
|
}
|
|
|
|
$(document).on("click", function (event) {
|
|
if ($(event.target).closest("#notificationsIcon").length) {
|
|
return;
|
|
} else {
|
|
if (!$(event.target).closest(".dropdown-account").length) {
|
|
$("#dropdownNotifications").removeClass("is-visible");
|
|
setTimeout(function () {
|
|
$("#dropdownNotifications").css("display", "none");
|
|
}, 200);
|
|
}
|
|
}
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
$(document).keydown(function (e) {
|
|
if (e.key === "Escape" || e.key === "Esc") {
|
|
$("#dropdownNotifications").removeClass("is-visible");
|
|
setTimeout(function () {
|
|
$("#dropdownNotifications").css("display", "none");
|
|
}, 200);
|
|
}
|
|
});
|
|
});
|
|
|
|
function setTheme(theme) {
|
|
document.documentElement.setAttribute("data-theme", theme);
|
|
|
|
const themeButtons = document.querySelectorAll(".theme-btn");
|
|
themeButtons.forEach((button) => button.classList.remove("active"));
|
|
|
|
const selectedButton = document.getElementById(`${theme}-theme-btn`);
|
|
selectedButton.classList.add("active");
|
|
|
|
localStorage.setItem("theme", theme);
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
const savedTheme = localStorage.getItem("theme");
|
|
if (savedTheme) {
|
|
setTheme(savedTheme);
|
|
}
|
|
});
|
|
|
|
function getCookie(name) {
|
|
var cookies = document.cookie.split(";");
|
|
for (var i = 0; i < cookies.length; i++) {
|
|
var cookie = cookies[i].trim();
|
|
if (cookie.startsWith(name + "=")) {
|
|
return cookie.substring(name.length + 1);
|
|
}
|
|
}
|
|
return null;
|
|
}
|