diff options
Diffstat (limited to 'static')
-rw-r--r-- | static/script.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/static/script.js b/static/script.js new file mode 100644 index 0000000..ece93e8 --- /dev/null +++ b/static/script.js | |||
@@ -0,0 +1,26 @@ | |||
1 | 'use strict'; | ||
2 | |||
3 | // | ||
4 | |||
5 | document.querySelectorAll('.is-indeterminate').forEach(el => el.indeterminate = true); | ||
6 | |||
7 | // | ||
8 | |||
9 | const enableFocusIndicator = e => { | ||
10 | if (e.key !== 'Tab') { | ||
11 | return; | ||
12 | } | ||
13 | |||
14 | document.body.classList.add('t-keyboard'); | ||
15 | document.removeEventListener('keydown', enableFocusIndicator); | ||
16 | document.addEventListener('mousedown', disableFocusIndicator); | ||
17 | } | ||
18 | |||
19 | const disableFocusIndicator = e => { | ||
20 | document.body.classList.remove('t-keyboard'); | ||
21 | |||
22 | document.removeEventListener('mousedown', disableFocusIndicator); | ||
23 | document.addEventListener('keydown', enableFocusIndicator); | ||
24 | } | ||
25 | |||
26 | document.addEventListener('keydown', enableFocusIndicator); | ||