mirror of
https://github.com/Balshgit/gpt_chat_bot.git
synced 2025-09-11 22:30:41 +03:00
35 lines
961 B
JavaScript
35 lines
961 B
JavaScript
const sidebar = document.querySelector(".sidebar");
|
|
const menuButton = document.querySelector(".menu-button");
|
|
|
|
function toggleSidebar(event) {
|
|
if (sidebar.classList.contains("shown")) {
|
|
hideSidebar(event.target);
|
|
} else {
|
|
showSidebar(event.target);
|
|
}
|
|
window.scrollTo(0, 0);
|
|
}
|
|
|
|
function showSidebar(target) {
|
|
sidebar.classList.add("shown");
|
|
target.classList.add("rotated");
|
|
document.body.style.overflow = "hidden";
|
|
}
|
|
|
|
function hideSidebar(target) {
|
|
sidebar.classList.remove("shown");
|
|
target.classList.remove("rotated");
|
|
document.body.style.overflow = "auto";
|
|
}
|
|
|
|
menuButton.addEventListener("click", toggleSidebar);
|
|
|
|
document.body.addEventListener('click', function(event) {
|
|
if (event.target.matches('.conversation-title')) {
|
|
const menuButtonStyle = window.getComputedStyle(menuButton);
|
|
if (menuButtonStyle.display !== 'none') {
|
|
hideSidebar(menuButton);
|
|
}
|
|
}
|
|
});
|