Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | 2x 2x 1x 1x 1x 1x 24x 24x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 12x 37x 12x 36x 12x 37x 37x 1x 12x 12x 21x 21x 23x 20x 13x 13x 39x 7x 7x 7x 21x 21x 16x 5x 8x 8x 8x 8x 7x 7x 9x 7x 2x 7x 7x 1x 5x 5x 5x 3x 3x 3x 8x 8x 5x 3x 12x 12x 12x | function initTopicFilters() { /** Toggles the expanded/collapsed classed on side navigation element. @param {HTMLElement} sideNavigation The side navigation element. @param {Boolean} show Whether to show or hide the drawer. */ function toggleDrawer(sideNavigation: HTMLElement, show: boolean) { Eif (sideNavigation) { if (show) { sideNavigation.classList.remove("is-collapsed"); sideNavigation.classList.add("is-expanded"); } else { sideNavigation.classList.remove("is-expanded"); sideNavigation.classList.add("is-collapsed"); } } } /** Attaches event listeners for the side navigation toggles @param {HTMLElement} sideNavigation The side navigation element. */ function setupSideNavigation(sideNavigation: HTMLElement) { const toggles: HTMLElement[] = [].slice.call( sideNavigation.querySelectorAll(".js-drawer-toggle") ); toggles.forEach(function (toggle) { toggle.addEventListener("click", function (event) { event.preventDefault(); const sideNav = document.getElementById( toggle.getAttribute("aria-controls") || "" ); if (sideNav) { toggleDrawer(sideNav, !sideNav.classList.contains("is-expanded")); } }); }); } /** Attaches event listeners for all the side navigations in the document. @param {String} sideNavigationSelector The CSS selector matching side navigation elements. */ function setupSideNavigations(sideNavigationSelector: string) { // Setup all side navigations on the page. const sideNavigations = [].slice.call( document.querySelectorAll(sideNavigationSelector) ); sideNavigations.forEach(setupSideNavigation); } function initFilters() { const urlParams = new URLSearchParams(window.location.search); const checkboxes: HTMLInputElement[] = [].slice.call( document.querySelectorAll("[data-js='filter']") ); const topics: HTMLElement[] = [].slice.call( document.querySelectorAll("[data-js='item']") ); const closeFiltersButtonMobile = document.querySelector( "[data-js='filter-button-mobile-close']" ) as HTMLElement; let filters: string[] = []; Iif (urlParams.get("filters")) { filters = urlParams.get("filters")?.split(",") ?? []; } populateCheckboxes(); filterDom(); checkboxes.forEach(function (checkbox) { checkbox.addEventListener("change", filterHandler); }); // Check any checkboxes that match URL filters query function populateCheckboxes() { // Create a list of topics values // Dedupe with a set and convert back to an array const topicValues = Array.from( new Set( topics.flatMap(function (topic: HTMLElement) { return topic.dataset.filter?.split(","); }) ) ); checkboxes.forEach(function (checkbox) { const value = checkbox.value; if (!topicValues.includes(value)) { checkbox.setAttribute("disabled", "disabled"); } }); Eif (filters) { filters.forEach(function (filter) { const selector = "[aria-labelledby='" + filter + "-filter']"; const checkboxObject = document.querySelector( selector ) as HTMLInputElement; if (checkboxObject) { const checkboxDisabled = checkboxObject.getAttribute("disabled"); if (checkboxDisabled) { removeFilter(filter); } else { checkboxObject.checked = true; } } }); } } // Check if element should be filtered function filterCheck(filterText: string) { const match = false; return !!filters.find(function (filter) { return filterText.includes(filter) && !match; }); } function filterDom() { if (filters.length === 0 && topics) { closeFiltersButtonMobile.innerHTML = "Hide filters"; topics.forEach(function (topic) { topic.classList.remove("u-hide"); }); } else Eif (topics) { closeFiltersButtonMobile.innerHTML = "Apply filters"; topics.forEach(function (topic) { const filterText = topic.getAttribute("data-filter"); if (filterText && filterCheck(filterText)) { topic.classList.remove("u-hide"); } else { topic.classList.add("u-hide"); } }); } } function updateUrl() { const currentUrl = window.location.href; const baseUrl = currentUrl.split("?")[0]; let newUrl = baseUrl; if (filters.length > 0) { let filtersString = ""; filters.forEach(function (filter, i) { if (i === filters.length - 1) { filtersString = filtersString + filter; } else { filtersString = filtersString + filter + ","; } }); newUrl = baseUrl + "?filters=" + filtersString; window.history.pushState({ filters: filters }, "", newUrl); } else { window.history.pushState({}, "", newUrl); } } function addFilter(filter: string) { filters.push(filter); filterDom(); updateUrl(); } function removeFilter(filter: string) { filters.splice(filters.indexOf(filter), 1); filterDom(); updateUrl(); } function filterHandler(e: Event) { const target = e.target as HTMLInputElement; if (target.checked) { addFilter(target.value); } else { removeFilter(target.value); } } } setupSideNavigations('.p-side-navigation, [class*="p-side-navigation--"]'); initFilters(); return { toggleDrawer, }; } export { initTopicFilters }; |