autodoc: make the help modal toggleable

Now you can simply press "?" again to toggle the help modal instead of
requiring Esc. Both Esc and "?" work.
This commit is contained in:
r00ster91
2023-05-02 04:41:25 +02:00
parent 2892347440
commit 6f1336a50c
2 changed files with 10 additions and 5 deletions

View File

@@ -875,7 +875,7 @@
<div class="help-modal">
<div class="modal">
<h1>Keyboard Shortcuts</h1>
<dl><dt><kbd>?</kbd></dt><dd>Show this help modal</dd></dl>
<dl><dt><kbd>?</kbd></dt><dd>Toggle this help modal</dd></dl>
<dl><dt><kbd>s</kbd></dt><dd>Focus the search field</dd></dl>
<div style="margin-left: 1em">
<dl><dt><kbd></kbd></dt><dd>Move up in search results</dd></dl>

View File

@@ -4044,9 +4044,14 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {
}
break;
case "?":
ev.preventDefault();
ev.stopPropagation();
showHelpModal();
// toggle the help modal
if (!domHelpModal.classList.contains("hidden")) {
onEscape(ev);
} else {
ev.preventDefault();
ev.stopPropagation();
showHelpModal();
}
break;
}
}
@@ -4850,4 +4855,4 @@ function RadixTree() {
// BUT!
// We want to be able to search "Hash", for example!
// We want to be able to search "Hash", for example!