|
572 | 572 | }); |
573 | 573 | }; |
574 | 574 |
|
575 | | - window.addEventListener('load', initSorting); |
| 575 | + window.addEventListener('load', () => { |
| 576 | + initSorting(); |
| 577 | + |
| 578 | + // Initialize bottom bar toggle functionality |
| 579 | + const bottomBarHidden = localStorage.getItem('grantsBottomBarHidden') === 'true'; |
| 580 | + const bottomBar = document.querySelector('.reviews-bottom-bar'); |
| 581 | + const toggleIcon = document.getElementById('toggle-icon'); |
| 582 | + const toggleButton = document.getElementById('bottom-bar-toggle'); |
| 583 | + |
| 584 | + if (bottomBarHidden) { |
| 585 | + bottomBar.classList.add('hidden'); |
| 586 | + toggleIcon.textContent = '▲'; |
| 587 | + toggleButton.setAttribute('aria-expanded', 'false'); |
| 588 | + } else { |
| 589 | + toggleButton.setAttribute('aria-expanded', 'true'); |
| 590 | + } |
| 591 | + |
| 592 | + toggleButton.addEventListener('click', toggleBottomBar); |
| 593 | + }); |
576 | 594 |
|
577 | 595 | // Toggle bottom bar visibility |
578 | 596 | const toggleBottomBar = () => { |
579 | 597 | const bottomBar = document.querySelector('.reviews-bottom-bar'); |
580 | 598 | const toggleIcon = document.getElementById('toggle-icon'); |
| 599 | + const toggleButton = document.getElementById('bottom-bar-toggle'); |
581 | 600 |
|
582 | 601 | bottomBar.classList.toggle('hidden'); |
583 | 602 |
|
584 | 603 | if (bottomBar.classList.contains('hidden')) { |
585 | 604 | toggleIcon.textContent = '▲'; |
| 605 | + toggleButton.setAttribute('aria-expanded', 'false'); |
586 | 606 | } else { |
587 | 607 | toggleIcon.textContent = '▼'; |
| 608 | + toggleButton.setAttribute('aria-expanded', 'true'); |
588 | 609 | } |
589 | 610 |
|
590 | 611 | // Save preference in localStorage |
591 | | - localStorage.setItem('bottomBarHidden', bottomBar.classList.contains('hidden')); |
| 612 | + localStorage.setItem('grantsBottomBarHidden', bottomBar.classList.contains('hidden')); |
592 | 613 | }; |
593 | | - |
594 | | - // Restore bottom bar state from localStorage |
595 | | - window.addEventListener('load', () => { |
596 | | - const bottomBarHidden = localStorage.getItem('bottomBarHidden') === 'true'; |
597 | | - const bottomBar = document.querySelector('.reviews-bottom-bar'); |
598 | | - const toggleIcon = document.getElementById('toggle-icon'); |
599 | | - const toggleButton = document.getElementById('bottom-bar-toggle'); |
600 | | - |
601 | | - if (bottomBarHidden) { |
602 | | - bottomBar.classList.add('hidden'); |
603 | | - toggleIcon.textContent = '▲'; |
604 | | - } |
605 | | - |
606 | | - toggleButton.addEventListener('click', toggleBottomBar); |
607 | | - }); |
608 | 614 | </script> |
609 | 615 | <ul class="object-tools"> |
610 | 616 | <li> |
@@ -972,8 +978,8 @@ <h2 class="current-grants-num"> |
972 | 978 | </div> |
973 | 979 | </div> |
974 | 980 | {% endif %} |
975 | | - <button type="button" class="reviews-bottom-bar-toggle" id="bottom-bar-toggle" title="Toggle bottom bar visibility"> |
976 | | - <span id="toggle-icon">▼</span> |
| 981 | + <button type="button" class="reviews-bottom-bar-toggle" id="bottom-bar-toggle" aria-label="Toggle bottom bar visibility" aria-expanded="true"> |
| 982 | + <span id="toggle-icon" aria-hidden="true">▼</span> |
977 | 983 | </button> |
978 | 984 | </form> |
979 | 985 | {% endblock %} |
0 commit comments