2020-06-04 00:54:45 +03:00
|
|
|
module.exports = function installToggle() {
|
2019-01-22 21:48:02 +03:00
|
|
|
/**
|
|
|
|
* @param {HTMLButtonElement} el
|
|
|
|
*/
|
2020-06-04 00:54:45 +03:00
|
|
|
function initializeToggler(el) {
|
2019-01-22 21:48:02 +03:00
|
|
|
el.addEventListener('click', () => {
|
|
|
|
const targetAttrib = el.getAttribute('data-toggle-target')
|
|
|
|
const targets = document.querySelectorAll(targetAttrib)
|
|
|
|
targets.forEach((target) => {
|
|
|
|
target.classList.toggle('d-none')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const togglers = document.querySelectorAll('[data-toggle-target]')
|
|
|
|
togglers.forEach(initializeToggler)
|
|
|
|
}
|