summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-18 15:23:49 -0500
committerGitHub <noreply@github.com>2021-01-18 15:23:49 -0500
commitcbc5ab5696a64fe10d5a37d25cc6e87d8d44481f (patch)
tree1b4de6a6176926b1c2251de291264b33de67eb2c /ext/bg/js
parent0420a29d77e7e91a87f8f70623e1dff067640fd8 (diff)
Hotkey help controller (#1272)
* Create HotkeyHelpController * Expose getAllTemplates * Update hotkeys on the context page * Update hotkeys on the display pages * Fix display issue where a hotkey used to be defined but no longer is
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/context-main.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/bg/js/context-main.js b/ext/bg/js/context-main.js
index 839b534e..65853514 100644
--- a/ext/bg/js/context-main.js
+++ b/ext/bg/js/context-main.js
@@ -16,6 +16,7 @@
*/
/* global
+ * HotkeyHelpController
* api
*/
@@ -35,6 +36,8 @@ class DisplayController {
const optionsFull = await api.optionsGetFull();
this._optionsFull = optionsFull;
+ this._setupHotkeys();
+
const optionsPageUrl = optionsFull.global.useSettingsV2 ? '/bg/settings2.html' : manifest.options_ui.page;
this._setupButtonEvents('.action-open-settings', 'openSettingsPage', chrome.runtime.getURL(optionsPageUrl));
@@ -99,6 +102,19 @@ class DisplayController {
}
}
+ async _setupHotkeys() {
+ const hotkeyHelpController = new HotkeyHelpController();
+ await hotkeyHelpController.prepare();
+
+ const {profiles, profileCurrent} = this._optionsFull;
+ const primaryProfile = (profileCurrent >= 0 && profileCurrent < profiles.length) ? profiles[profileCurrent] : null;
+ if (primaryProfile !== null) {
+ hotkeyHelpController.setOptions(primaryProfile.options);
+ }
+
+ hotkeyHelpController.setupNode(document.documentElement);
+ }
+
_updateProfileSelect(profiles, profileCurrent) {
const select = document.querySelector('#profile-select');
const optionGroup = document.querySelector('#profile-select-option-group');