mirror of
https://github.com/xvvvyz/tilde.git
synced 2026-03-11 14:44:24 +00:00
esc closes help + small bug fix
This commit is contained in:
parent
197dd510b1
commit
18f2fdbf6c
1 changed files with 14 additions and 9 deletions
23
index.html
23
index.html
|
|
@ -277,13 +277,8 @@
|
|||
|
||||
<script>
|
||||
const $ = {
|
||||
el: s => {
|
||||
return document.querySelector(s);
|
||||
},
|
||||
|
||||
els: s => {
|
||||
return document.querySelectorAll(s);
|
||||
},
|
||||
el: s => document.querySelector(s),
|
||||
els: s => document.querySelectorAll(s),
|
||||
};
|
||||
|
||||
class Clock {
|
||||
|
|
@ -314,7 +309,9 @@
|
|||
constructor() {
|
||||
this._overlayEl = $.el('#js-overlay');
|
||||
this._listsEl = $.el('#js-lists');
|
||||
this._handleKeydown = this._handleKeydown.bind(this);
|
||||
this._buildAndAppendLists();
|
||||
this._registerEvents();
|
||||
}
|
||||
|
||||
toggle(show) {
|
||||
|
|
@ -346,6 +343,14 @@
|
|||
</li>`
|
||||
)).join('');
|
||||
}
|
||||
|
||||
_handleKeydown(event) {
|
||||
if (event.which === 27) this.toggle(false);
|
||||
}
|
||||
|
||||
_registerEvents() {
|
||||
document.addEventListener('keydown', this._handleKeydown);
|
||||
}
|
||||
}
|
||||
|
||||
class History {
|
||||
|
|
@ -482,7 +487,7 @@
|
|||
}
|
||||
|
||||
_focusNext() {
|
||||
if (this._suggestionEls) {
|
||||
if (this._suggestionEls.length) {
|
||||
const active = document.activeElement;
|
||||
|
||||
if (active.classList.contains('js-search-suggestion')) {
|
||||
|
|
@ -497,7 +502,7 @@
|
|||
}
|
||||
|
||||
_focusPrevious() {
|
||||
if (this._suggestionEls) {
|
||||
if (this._suggestionEls.length) {
|
||||
const active = document.activeElement;
|
||||
|
||||
if (active.classList.contains('js-search-suggestion')) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue