summaryrefslogtreecommitdiffstats
path: root/static/script.js
blob: 00962e56e56d4683259cdafa003ad4551ce37b1e (plain) (blame)
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
27
28
'use strict';

//

document.addEventListener('DOMContentLoaded', () => {
    document.querySelectorAll('.is-indeterminate').forEach(el => el.indeterminate = true);
})

//

const enableFocusIndicator = e => {
    if (e.key !== 'Tab') {
        return;
    }

    document.body.classList.add('t-keyboard');
    document.removeEventListener('keydown', enableFocusIndicator);
    document.addEventListener('mousedown', disableFocusIndicator);
}

const disableFocusIndicator = () => {
    document.body.classList.remove('t-keyboard');

    document.removeEventListener('mousedown', disableFocusIndicator);
    document.addEventListener('keydown', enableFocusIndicator);
}

document.addEventListener('keydown', enableFocusIndicator);