(event)
| 62 | } |
| 63 | |
| 64 | function handleKeyDown(event) { |
| 65 | const tab = event.target.closest && event.target.closest('.mdbook-tab'); |
| 66 | if (!tab) return; |
| 67 | const nav = tab.parentElement; |
| 68 | if (!nav || !nav.classList.contains('mdbook-tabs')) return; |
| 69 | |
| 70 | const tabs = Array.from(nav.querySelectorAll('.mdbook-tab')); |
| 71 | const currentIndex = tabs.indexOf(tab); |
| 72 | if (currentIndex < 0) return; |
| 73 | |
| 74 | let newIndex = null; |
| 75 | switch (event.key) { |
| 76 | case 'ArrowRight': |
| 77 | case 'Right': |
| 78 | newIndex = (currentIndex + 1) % tabs.length; |
| 79 | break; |
| 80 | case 'ArrowLeft': |
| 81 | case 'Left': |
| 82 | newIndex = (currentIndex - 1 + tabs.length) % tabs.length; |
| 83 | break; |
| 84 | case 'Home': |
| 85 | newIndex = 0; |
| 86 | break; |
| 87 | case 'End': |
| 88 | newIndex = tabs.length - 1; |
| 89 | break; |
| 90 | } |
| 91 | if (newIndex === null) return; |
| 92 | |
| 93 | event.preventDefault(); |
| 94 | tabs[newIndex].focus(); |
| 95 | // Automatic activation: mirrors common tab widgets (Bootstrap, Radix, |
| 96 | // etc.) where focusing a tab also selects it. |
| 97 | tabs[newIndex].click(); |
| 98 | } |
| 99 | |
| 100 | document.addEventListener('DOMContentLoaded', function () { |
| 101 | document.querySelectorAll('.mdbook-tabs-container').forEach(initContainer); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…