-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.js
76 lines (50 loc) · 1.77 KB
/
dashboard.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const allSideMenu = document.querySelectorAll('#sidebar .side-menu.top li a');
allSideMenu.forEach(item=> {
const li = item.parentElement;
item.addEventListener('click', function () {
allSideMenu.forEach(i=> {
i.parentElement.classList.remove('active');
})
li.classList.add('active');
})
});
// TOGGLE SIDEBAR
const menuBar = document.querySelector('#content nav .bx.bx-menu');
const sidebar = document.getElementById('sidebar');
menuBar.addEventListener('click', function () {
sidebar.classList.toggle('hide');
})
const searchButton = document.querySelector('#content nav form .form-input button');
const searchButtonIcon = document.querySelector('#content nav form .form-input button .bx');
const searchForm = document.querySelector('#content nav form');
searchButton.addEventListener('click', function (e) {
if(window.innerWidth < 576) {
e.preventDefault();
searchForm.classList.toggle('show');
if(searchForm.classList.contains('show')) {
searchButtonIcon.classList.replace('bx-search', 'bx-x');
} else {
searchButtonIcon.classList.replace('bx-x', 'bx-search');
}
}
})
if(window.innerWidth < 768) {
sidebar.classList.add('hide');
} else if(window.innerWidth > 576) {
searchButtonIcon.classList.replace('bx-x', 'bx-search');
searchForm.classList.remove('show');
}
window.addEventListener('resize', function () {
if(this.innerWidth > 576) {
searchButtonIcon.classList.replace('bx-x', 'bx-search');
searchForm.classList.remove('show');
}
})
const switchMode = document.getElementById('switch-mode');
switchMode.addEventListener('change', function () {
if(this.checked) {
document.body.classList.add('dark');
} else {
document.body.classList.remove('dark');
}
})