esc closes help + small bug fix
This commit is contained in:
+14
-9
@@ -277,13 +277,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const $ = {
|
const $ = {
|
||||||
el: s => {
|
el: s => document.querySelector(s),
|
||||||
return document.querySelector(s);
|
els: s => document.querySelectorAll(s),
|
||||||
},
|
|
||||||
|
|
||||||
els: s => {
|
|
||||||
return document.querySelectorAll(s);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Clock {
|
class Clock {
|
||||||
@@ -314,7 +309,9 @@
|
|||||||
constructor() {
|
constructor() {
|
||||||
this._overlayEl = $.el('#js-overlay');
|
this._overlayEl = $.el('#js-overlay');
|
||||||
this._listsEl = $.el('#js-lists');
|
this._listsEl = $.el('#js-lists');
|
||||||
|
this._handleKeydown = this._handleKeydown.bind(this);
|
||||||
this._buildAndAppendLists();
|
this._buildAndAppendLists();
|
||||||
|
this._registerEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle(show) {
|
toggle(show) {
|
||||||
@@ -346,6 +343,14 @@
|
|||||||
</li>`
|
</li>`
|
||||||
)).join('');
|
)).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_handleKeydown(event) {
|
||||||
|
if (event.which === 27) this.toggle(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
_registerEvents() {
|
||||||
|
document.addEventListener('keydown', this._handleKeydown);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class History {
|
class History {
|
||||||
@@ -482,7 +487,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_focusNext() {
|
_focusNext() {
|
||||||
if (this._suggestionEls) {
|
if (this._suggestionEls.length) {
|
||||||
const active = document.activeElement;
|
const active = document.activeElement;
|
||||||
|
|
||||||
if (active.classList.contains('js-search-suggestion')) {
|
if (active.classList.contains('js-search-suggestion')) {
|
||||||
@@ -497,7 +502,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_focusPrevious() {
|
_focusPrevious() {
|
||||||
if (this._suggestionEls) {
|
if (this._suggestionEls.length) {
|
||||||
const active = document.activeElement;
|
const active = document.activeElement;
|
||||||
|
|
||||||
if (active.classList.contains('js-search-suggestion')) {
|
if (active.classList.contains('js-search-suggestion')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user