-
Notifications
You must be signed in to change notification settings - Fork 8
/
script.js
62 lines (54 loc) · 2.1 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
52
53
54
55
56
57
58
59
60
61
62
// start: Sidebar
document.querySelector('.chat-sidebar-profile-toggle').addEventListener('click', function(e) {
e.preventDefault()
this.parentElement.classList.toggle('active')
})
document.addEventListener('click', function(e) {
if(!e.target.matches('.chat-sidebar-profile, .chat-sidebar-profile *')) {
document.querySelector('.chat-sidebar-profile').classList.remove('active')
}
})
// end: Sidebar
// start: Coversation
document.querySelectorAll('.conversation-item-dropdown-toggle').forEach(function(item) {
item.addEventListener('click', function(e) {
e.preventDefault()
if(this.parentElement.classList.contains('active')) {
this.parentElement.classList.remove('active')
} else {
document.querySelectorAll('.conversation-item-dropdown').forEach(function(i) {
i.classList.remove('active')
})
this.parentElement.classList.add('active')
}
})
})
document.addEventListener('click', function(e) {
if(!e.target.matches('.conversation-item-dropdown, .conversation-item-dropdown *')) {
document.querySelectorAll('.conversation-item-dropdown').forEach(function(i) {
i.classList.remove('active')
})
}
})
document.querySelectorAll('.conversation-form-input').forEach(function(item) {
item.addEventListener('input', function() {
this.rows = this.value.split('\n').length
})
})
document.querySelectorAll('[data-conversation]').forEach(function(item) {
item.addEventListener('click', function(e) {
e.preventDefault()
document.querySelectorAll('.conversation').forEach(function(i) {
i.classList.remove('active')
})
document.querySelector(this.dataset.conversation).classList.add('active')
})
})
document.querySelectorAll('.conversation-back').forEach(function(item) {
item.addEventListener('click', function(e) {
e.preventDefault()
this.closest('.conversation').classList.remove('active')
document.querySelector('.conversation-default').classList.add('active')
})
})
// end: Coversation