-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.js
120 lines (101 loc) · 3.43 KB
/
js.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const menuItems = document.querySelectorAll('.menu-item');
const messagesNotif = document.querySelector('#message-notification');
const messages = document.querySelector('.messages');
const message = messages.querySelectorAll('.message');
const messageSearch = document.querySelector('#message-search');
const theme = document.querySelector('#theme');
const themeModal = document.querySelector('.customize-theme');
var root = document.querySelector(':root');
const bgLight = document.querySelector('.bg-light');
const bgDim = document.querySelector('.bg-dim');
const bgDark = document.querySelector('.bg-dark');
//***************SIDEBAR****************//
//remove active class
const changeActiveItem = () => {
menuItems.forEach(item => {
item.classList.remove('active');
})
}
menuItems.forEach(item => {
item.addEventListener('click', () => {
item.classList.add('active');
if(item.id != 'notifications') {
document.querySelector('.notification-popup').style.display = 'none';
} else {
document.querySelector('.notification-popup').style.display = 'block';
document.querySelector('#notifications .notification-count').style.display = 'none';
}
})
})
//***************MESSAGES****************//
//search chat
const searchMessege = () => {
const val = messageSearch.value.toLowerCase();
console.log(val);
message.forEach(chat => {
let name = chat.querySelector('h5').textContent.toLowerCase();
if(name.indexOf(val) != -1) {
chat.style.display = 'flex';
} else {
chat.style.display = 'none';
}
})
}
messageSearch.addEventListener('keyup', searchMessege);
messagesNotif.addEventListener('click', () => {
messages.style.boxShadow = '0 0 0.4rem var(--color-primary)';
messagesNotif.querySelector('.notification-count').style.display = 'none';
setTimeout(() => {
messages.style.boxShadow = 'none';
}, 2000)
})
//***************THEME****************//
const openThemeModal = () => {
themeModal.style.display = 'grid';
}
const closeThemeModal = () => {
themeModal.style.display = 'none';
}
themeModal.addEventListener('click', closeThemeModal);
theme.addEventListener('click', openThemeModal);
//*******************BACKGROUND*****************//
//values
let darkColorLightness;
let lightColorLightness;
let whiteColorLightness;
//change
const changeBg = () => {
root.style.setProperty('--light-color-lightness', lightColorLightness);
root.style.setProperty('--white-color-lightness', whiteColorLightness);
root.style.setProperty('--dark-color-lightness', darkColorLightness);
}
bgLight.addEventListener('click', () => {
//active
bgLight.classList.add('active');
//remove
bgDim.classList.remove('active');
bgDark.classList.remove('active');
window.location.reload();
})
bgDim.addEventListener('click', () => {
darkColorLightness = '95%';
lightColorLightness = '22%';
whiteColorLightness = '20%';
//active
bgDim.classList.add('active');
//remove
bgLight.classList.remove('active');
bgDark.classList.remove('active');
changeBg();
});
bgDark.addEventListener('click', () => {
darkColorLightness = '95%';
lightColorLightness = '15%';
whiteColorLightness = '5%';
//active
bgDark.classList.add('active');
//remove
bgLight.classList.remove('active');
bgDim.classList.remove('active');
changeBg();
});