🚀feat(js) aktualisiere benutzerfreundliches Dropdown-Menü
This commit is contained in:
parent
bff0752eab
commit
b1be0b761d
1 changed files with 46 additions and 7 deletions
|
|
@ -1,10 +1,49 @@
|
||||||
function removeEmptyParagraphs() {
|
function removeEmptyParagraphs() {
|
||||||
const paragraphs = document.querySelectorAll('p');
|
const paragraphs = document.querySelectorAll('p')
|
||||||
paragraphs.forEach(paragraph => {
|
paragraphs.forEach((paragraph) => {
|
||||||
if (!paragraph.textContent.trim() && !paragraph.querySelector('i')) {
|
if (!paragraph.textContent.trim() && !paragraph.querySelector('i')) {
|
||||||
paragraph.remove();
|
paragraph.remove()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
removeEmptyParagraphs();
|
// removeEmptyParagraphs();
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
if ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0) {
|
||||||
|
const navDropdowns = document.querySelectorAll('.nav-dropdown')
|
||||||
|
|
||||||
|
navDropdowns.forEach(function (dropdown) {
|
||||||
|
const dropdownLink = dropdown.querySelector('a')
|
||||||
|
const dropdownIcon = dropdown.querySelector('svg')
|
||||||
|
const dropdownList = dropdown.querySelector('.nav-dropdown-list')
|
||||||
|
|
||||||
|
let clickCount = 0
|
||||||
|
|
||||||
|
dropdownLink.addEventListener('click', function (event) {
|
||||||
|
if (dropdownList) {
|
||||||
|
event.preventDefault()
|
||||||
|
clickCount++
|
||||||
|
|
||||||
|
if (clickCount % 2 === 1) {
|
||||||
|
dropdownList.classList.add('visible', 'opacity-100')
|
||||||
|
} else {
|
||||||
|
window.location.href = dropdownLink.getAttribute('href')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
dropdownIcon.addEventListener('click', function (event) {
|
||||||
|
// If the dropdown is already open, clicking
|
||||||
|
// on the icon should close it. Otherwise
|
||||||
|
// clicking on the icon should open it.
|
||||||
|
console.log('clickCount', clickCount)
|
||||||
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
|
dropdown.classList.toggle('active')
|
||||||
|
dropdownList.classList.toggle('visible')
|
||||||
|
dropdownList.classList.toggle('opacity-100')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue