-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresume.js
33 lines (33 loc) · 1 KB
/
resume.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
console.log("setupDownloadButton")
const downloadButton = document.querySelector('.download-box')
const downloadLinks = document.querySelector('.download-links')
let dropDownOpen = false
document.addEventListener('click', (e) => {
if(!dropDownOpen) {
return
}
// detect click outside
const downloadButton = document.querySelector('.download-box')
let targetElement = e.target
do {
if(targetElement == downloadButton) {
return
}
targetElement = targetElement.parentNode
} while(targetElement)
// clicked outside
downloadButton.style.display = 'inline-block'
downloadLinks.style.display = 'none'
dropDownOpen = false
})
downloadButton.addEventListener('click', (e) => {
if (!dropDownOpen) {
e.target.style.display = 'flex'
downloadLinks.style.display = 'flex'
dropDownOpen = true
} else {
e.target.style.display = 'inline-block'
downloadLinks.style.display = 'none'
dropDownOpen = false
}
})