flyout.js
23 lines
| 1 | |
| 2 | document.addEventListener('DOMContentLoaded', function() { |
| 3 | const button = document.getElementById('mlp-elements-button'); |
| 4 | const flyout = document.getElementById('mlp-flyout'); |
| 5 | const overlay = document.getElementById('mlp-overlay'); |
| 6 | |
| 7 | if (button && flyout && overlay) { |
| 8 | button.addEventListener('click', function(e) { |
| 9 | e.preventDefault(); |
| 10 | flyout.classList.toggle('opened'); |
| 11 | overlay.style.display = overlay.style.display === 'none' || overlay.style.display === '' ? 'block' : 'none'; |
| 12 | button.setAttribute('aria-expanded', flyout.classList.contains('opened') ? 'true' : 'false'); |
| 13 | }); |
| 14 | |
| 15 | overlay.addEventListener('click', function(e) { |
| 16 | e.preventDefault(); |
| 17 | overlay.style.display = 'none'; |
| 18 | flyout.classList.remove('opened'); |
| 19 | button.setAttribute('aria-expanded', 'false'); |
| 20 | }); |
| 21 | } |
| 22 | }); |
| 23 |