Untitled
unknown
plain_text
a month ago
2.2 kB
4
Indexable
Never
initBlock(block) { // Check if groupTitles is present const groupTitles = block.dataset.grouptitles; const hasGroupTitles = groupTitles && groupTitles.trim() !== ''; if (hasGroupTitles) { // Dropdown-container logic const dropdownContainer = block.querySelector('.dropdown-container'); if (dropdownContainer) { const dropdownOptions = Array.from(dropdownContainer.querySelectorAll('.dropdown-option')); const dropdownButton = dropdownContainer.querySelector('.dropdown-button'); dropdownButton.addEventListener('click', () => { this.toggleDropdown(dropdownContainer); }); dropdownOptions.forEach(option => { option.addEventListener('click', (e) => { this.selectDropdownOption(e, block); }); }); document.addEventListener('click', (event) => { if (!event.target.closest('.dropdown-container')) { this.closeDropdown(dropdownContainer); } }); const windowhashdata = window.location.hash ? window.location.hash : ''; // phpcs:ignore this.updateDropdown(dropdownOptions, windowhashdata); this.selectTabOnloadDropdown(block, windowhashdata); } } else { // Base case: performance-data__select logic const select = block.querySelector('.performance-data__select'); const options = Array.from(select.querySelectorAll('option')); const windowhashdata = window.location.hash ? window.location.hash : ''; // phpcs:ignore select.addEventListener('change', (e) => this.selectTab(e, block)); document.addEventListener('setGatingState', () => { this.selectedState = getSelectedStateFromLocalStorage(); this.updateTabs(select, options, windowhashdata); }); this.updateTabs(select, options); this.selectTabOnload(block, windowhashdata); block.dataset.initiallyHidden = false; if (block.querySelector('.is-sticky')) { this.positionSelectDropdown(block); } } }
Leave a Comment