-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
51 lines (42 loc) · 1.44 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const darkLight = document.querySelector("#darkLight");
const sidebar = document.querySelector(".sidebar");
const submenuItems = document.querySelectorAll(".submenu_item");
const sidebarOpen = document.querySelector("#sidebarOpen");
const sidebarExpand = document.querySelector(".expand_sidebar");
sidebarOpen.addEventListener("click", () => sidebar.classList.toggle("close"));
sidebarExpand.addEventListener("click", () => {
sidebar.classList.remove("close", "hoverable");
});
sidebar.addEventListener("mouseenter", () => {
if (sidebar.classList.contains("hoverable")) {
sidebar.classList.remove("close");
}
});
sidebar.addEventListener("mouseleave", () => {
if (sidebar.classList.contains("hoverable")) {
sidebar.classList.add("close");
}
});
darkLight.addEventListener("click", () => {
document.body.classList.toggle("dark"); // body değişkenini document.body olarak güncelledik
if (document.body.classList.contains("dark")) {
darkLight.classList.replace("bx-sun", "bx-moon");
} else {
darkLight.classList.replace("bx-moon", "bx-sun");
}
});
submenuItems.forEach((item, index) => {
item.addEventListener("click", () => {
item.classList.toggle("show_submenu");
submenuItems.forEach((item2, index2) => {
if (index !== index2) {
item2.classList.remove("show_submenu");
}
});
});
});
if (window.innerWidth < 768) {
sidebar.classList.add("close");
} else {
sidebar.classList.remove("close");
}