Widget: Compass: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 740: | Line 740: | ||
document.getElementById('cmp-container').addEventListener('click', event => { | document.getElementById('cmp-container').addEventListener('click', event => { | ||
if (event.target.tagName === 'H2') { | if (event.target.tagName === 'H2') { | ||
document.querySelectorAll('H2').forEach( | document.querySelectorAll('H2').forEach(el => { | ||
if ( | if (el === event.target) el.classList.toggle('opened'); | ||
else | else el.classList.remove('opened'); | ||
}); | }); | ||
const | const group = event.target.closest('.theme'); | ||
document.querySelectorAll('.subtheme').forEach(el => { | document.querySelectorAll('.subtheme').forEach(el => { | ||
if ( | if (group.contains(el)) el.classList.toggle('opened'); | ||
else el.classList.remove('opened'); | else el.classList.remove('opened'); | ||
}); | }); | ||
} | } | ||
if (event.target.tagName === 'H3') { | if (event.target.tagName === 'H3') { | ||
document.querySelectorAll('H3').forEach( | document.querySelectorAll('H3').forEach(el => { | ||
if ( | if (el === event.target) el.classList.toggle('opened'); | ||
else | else el.classList.remove('opened'); | ||
}); | }); | ||
const | const group = event.target.closest('.subtheme'); | ||
document.querySelectorAll('.question').forEach(el => { | document.querySelectorAll('.question').forEach(el => { | ||
if ( | if (group.contains(el)) el.classList.toggle('opened'); | ||
else el.classList.remove('opened'); | else el.classList.remove('opened'); | ||
}); | }); | ||
} | } | ||
if (event.target.tagName === 'H4') { | if (event.target.tagName === 'H4') { | ||
event.target.classList.toggle('opened'); | document.querySelectorAll('H4').forEach(el => { | ||
event.target.closest('.question'). | if (el === event.target) el.classList.toggle('opened'); | ||
else el.classList.remove('opened'); | |||
}); | |||
const group = event.target.closest('.question'); | |||
document.querySelectorAll('.answer').forEach(el => { | |||
if (group.contains(el)) el.classList.toggle('opened'); | |||
else el.classList.remove('opened'); | |||
}); | |||
} | } | ||
}); | }); |
Revision as of 17:45, 7 December 2022
Development version of the Compass.
Not ready for production!