61 lines
2.3 KiB
PHP
61 lines
2.3 KiB
PHP
<script>
|
|
$(document).ready(function() {
|
|
$('#iva-month-select').on('change', function() {
|
|
$('#iva-filter-form').submit();
|
|
});
|
|
});
|
|
|
|
(function() {
|
|
const hierBoxes = document.querySelectorAll('.iva-hier-checkbox');
|
|
const hierBtn = document.getElementById('ivaHierDropdown');
|
|
const brandBoxes = document.querySelectorAll('.iva-brand-checkbox');
|
|
const brandBtn = document.getElementById('ivaBrandDropdown');
|
|
|
|
function updateCount(boxes, btn, label) {
|
|
if (!btn) {
|
|
return;
|
|
}
|
|
const checked = document.querySelectorAll(boxes + ':checked').length;
|
|
btn.innerText = checked ? label + ' (' + checked + ')' : label;
|
|
}
|
|
|
|
updateCount('.iva-hier-checkbox', hierBtn, 'Hierarchy');
|
|
updateCount('.iva-brand-checkbox', brandBtn, 'Brand');
|
|
hierBoxes.forEach(function(cb) {
|
|
cb.addEventListener('change', function() {
|
|
updateCount('.iva-hier-checkbox', hierBtn, 'Hierarchy');
|
|
});
|
|
});
|
|
brandBoxes.forEach(function(cb) {
|
|
cb.addEventListener('change', function() {
|
|
updateCount('.iva-brand-checkbox', brandBtn, 'Brand');
|
|
});
|
|
});
|
|
|
|
const clearHier = document.getElementById('ivaClearHier');
|
|
if (clearHier) {
|
|
clearHier.addEventListener('click', function() {
|
|
hierBoxes.forEach(function(cb) { cb.checked = false; });
|
|
updateCount('.iva-hier-checkbox', hierBtn, 'Hierarchy');
|
|
});
|
|
}
|
|
const clearBrand = document.getElementById('ivaClearBrand');
|
|
if (clearBrand) {
|
|
clearBrand.addEventListener('click', function() {
|
|
brandBoxes.forEach(function(cb) { cb.checked = false; });
|
|
updateCount('.iva-brand-checkbox', brandBtn, 'Brand');
|
|
});
|
|
}
|
|
|
|
const hierSearch = document.getElementById('ivaHierSearch');
|
|
if (hierSearch) {
|
|
hierSearch.addEventListener('keyup', function() {
|
|
const term = this.value.toLowerCase();
|
|
document.querySelectorAll('.iva-hier-item').forEach(function(item) {
|
|
item.style.display = item.innerText.toLowerCase().includes(term) ? '' : 'none';
|
|
});
|
|
});
|
|
}
|
|
})();
|
|
</script>
|