blob: 06e51203e61fcabfd808b9e20d2052796f217d5f (
plain)
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
|
// ==========================================================================
// tab-focus.js
// Detect keyboard tabbing
// ==========================================================================
(function() {
var className = 'tab-focus';
// Remove class on blur
document.addEventListener('focusout', function(event) {
event.target.classList.remove(className);
});
// Add classname to tabbed elements
document.addEventListener('keydown', function(event) {
if (event.keyCode !== 9) {
return;
}
// Delay the adding of classname until the focus has changed
// This event fires before the focusin event
window.setTimeout(function() {
document.activeElement.classList.add(className);
}, 0);
});
})();
|