init
This commit is contained in:
16
public/js/inc.js
Normal file
16
public/js/inc.js
Normal file
@@ -0,0 +1,16 @@
|
||||
document.addEventListener("click", e => {
|
||||
const isDropdownButton = e.target.matches("[data-dropdown-button]")
|
||||
if (!isDropdownButton && e.target.closest("[data-dropdown]") != null) return
|
||||
|
||||
let currentDropdown
|
||||
if (isDropdownButton) {
|
||||
currentDropdown = e.target.closest("[data-dropdown]")
|
||||
currentDropdown.classList.toggle("active")
|
||||
}
|
||||
|
||||
document.querySelectorAll("[data-dropdown].active").forEach(dropdown => {
|
||||
if (dropdown === currentDropdown) return
|
||||
dropdown.classList.remove("active")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user