diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-08 23:52:40 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-08 23:52:40 +0900 |
| commit | 2f6b0b142a1512829a1089627e103cc57c614856 (patch) | |
| tree | e928d07f9b8c59cb0d7682b4d75c7b7ad23d73cb /src/client/scripts | |
| parent | :v: (diff) | |
| download | sharkey-2f6b0b142a1512829a1089627e103cc57c614856.tar.gz sharkey-2f6b0b142a1512829a1089627e103cc57c614856.tar.bz2 sharkey-2f6b0b142a1512829a1089627e103cc57c614856.zip | |
nanka iroiro
Diffstat (limited to 'src/client/scripts')
| -rw-r--r-- | src/client/scripts/focus.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/client/scripts/focus.ts b/src/client/scripts/focus.ts new file mode 100644 index 0000000000..a2a8516d36 --- /dev/null +++ b/src/client/scripts/focus.ts @@ -0,0 +1,23 @@ +export function focusPrev(el: Element | null, self = false) { + if (el == null) return; + if (!self) el = el.previousElementSibling; + if (el) { + if (el.hasAttribute('tabindex')) { + (el as HTMLElement).focus(); + } else { + focusPrev(el.previousElementSibling, true); + } + } +} + +export function focusNext(el: Element | null, self = false) { + if (el == null) return; + if (!self) el = el.nextElementSibling; + if (el) { + if (el.hasAttribute('tabindex')) { + (el as HTMLElement).focus(); + } else { + focusPrev(el.nextElementSibling, true); + } + } +} |