1/** 2 * @file 3 * Program category filter functionality. 4 */ 5(function (Drupal, once) { 6 'use strict'; 7 8 Drupal.behaviors.programFilter = { 9 attach: function (context) { 10 once('program-filter', '[data-program-filters]', context).forEach(function (filtersContainer) { 11 var buttons = filtersContainer.querySelectorAll('[data-filter]'); 12 13 buttons.forEach(function (btn) { 14 btn.addEventListener('click', function () { 15 var filter = btn.getAttribute('data-filter'); 16 17 // Update active state. 18 buttons.forEach(function (b) { b.classList.remove('is-active'); }); 19 btn.classList.add('is-active'); 20 21 // Query items at click time to include dynamically loaded ones. 22 var items = document.querySelectorAll('[data-program-format]'); 23 items.forEach(function (item) { 24 if (filter === 'all') { 25 item.closest('.views-row').style.display = ''; 26 } else { 27 var format = item.getAttribute('data-program-format'); 28 item.closest('.views-row').style.display = format === filter ? '' : 'none'; 29 } 30 }); 31 32 // Hide time headers whose program items are all hidden. 33 document.querySelectorAll('.amro-program-time-header').forEach(function (header) { 34 var list = header.nextElementSibling; 35 if (!list || !list.classList.contains('amro-program-list')) return; 36 var visibleRows = list.querySelectorAll('.views-row:not([style*="display: none"])'); 37 header.style.display = visibleRows.length ? '' : 'none'; 38 list.style.display = visibleRows.length ? '' : 'none'; 39 }); 40 }); 41 }); 42 }); 43 } 44 }; 45 46})(Drupal, once);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.