Commit 6f1336a50c

r00ster91 <r00ster91@proton.me>
2023-05-02 04:41:25
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.
1 parent 2892347
Changed files (2)
lib/docs/index.html
@@ -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>
lib/docs/main.js
@@ -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!
\ No newline at end of file
+// We want to be able to search "Hash", for example!