Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 674: | Line 674: | ||
// Listen for changes in filter checkbox state. | // Listen for changes in filter checkbox state. | ||
document.getElementById('functions-filter').addEventListener('change', event => { | document.getElementById('functions-filter').addEventListener('change', event => { | ||
const filterBlock = event.target.closest('.func-filter-block'); | const filterBlock = event.target.closest('.func-filter-block'); | ||
const category = filterBlock.querySelector('input.func-cat'); | const category = filterBlock.querySelector('input.func-cat'); | ||
const subfunctions = filterBlock.querySelectorAll('.subfunc-filter-block input[type="checkbox"]'); | const subfunctions = filterBlock.querySelectorAll('.subfunc-filter-block input[type="checkbox"]'); | ||
if (event.target === category) { | if (event.target === category) { | ||
// Selecting/deselecting the category checks/unchecks all subfunctions. | |||
subfunctions.forEach(checkbox => checkbox.checked = category.checked); | subfunctions.forEach(checkbox => checkbox.checked = category.checked); | ||
} else { | |||
// If no subfunctions are selected, deactivate the category. Activate otherwise. | |||
const checkedSubs = Array.from(subfunctions).filter(sub => sub.checked).length; | |||
if (length > 0) { category.checked = true; } else { category.checked = false; } | |||
} | } | ||
applyFilters(); | applyFilters(); |
Revision as of 16:02, 18 November 2022
Development verstion of the DCT List.
Not ready for production!