From 144b7a2ea83507c98544d14ad9435cc5e51ac071 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 5 Feb 2022 12:26:35 +0100 Subject: Update --- static/script.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 static/script.js (limited to 'static') 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 @@ +'use strict'; + +// + +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 = e => { + document.body.classList.remove('t-keyboard'); + + document.removeEventListener('mousedown', disableFocusIndicator); + document.addEventListener('keydown', enableFocusIndicator); +} + +document.addEventListener('keydown', enableFocusIndicator); -- cgit v1.2.3-70-g09d2