-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript.js
More file actions
79 lines (37 loc) · 1.5 KB
/
Script.js
File metadata and controls
79 lines (37 loc) · 1.5 KB
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
const chatBoxIcon = document.getElementById('chatbox-btn-wrapper')
const chatBoxCloseBtn = document.querySelector('#chatbox .chatbox-close')
const chatBoxWrapper = document.getElementById('chatbox')
const chatBoxTextField = document.getElementById('chatbox-message-field')
chatBoxIcon.addEventListener('click', e =>{
e.preventDefault()
if(chatBoxWrapper.classList.contains('show')){
chatBoxWrapper.classList.remove('show')
}else{
chatBoxWrapper.classList.add('show')
chatBoxIcon.style.display = `none`
}
})
chatBoxCloseBtn.addEventListener('click', e => {
e.preventDefault()
if(chatBoxWrapper.classList.contains('show')){
if(!chatBoxWrapper.classList.contains('closing'))
chatBoxWrapper.classList.add('closing');
setTimeout(()=>{
chatBoxWrapper.classList.remove('show');
chatBoxWrapper.classList.remove('closing');
}, 500)
}
chatBoxIcon.removeAttribute('style')
})
const chatBoxTextFieldHeight = chatBoxTextField.clientHeight
chatBoxTextField.addEventListener('keyup', e=>{
var maxHeight = getComputedStyle(chatBoxTextField).getPropertyValue('--chatbox-max-height')
chatBoxTextField.removeAttribute('style')
setTimeout(()=>{
if(chatBoxTextField.scrollHeight > maxHeight){
chatBoxTextField.style.height = `${maxHeight}px`
}else{
chatBoxTextField.style.height = `${chatBoxTextField.scrollHeight}px`
}
},0)
})