DEV: Define keyboard shortcuts help onShow, and un-define onClose (#9355)

This is so we don't have a big hash just sitting in the controller definition, it is only created when it is needed. From comment here #9318 (comment)
This commit is contained in:
Martin Brennan 2020-04-07 14:40:03 +10:00 committed by GitHub
parent 93c38cc175
commit 7e42963590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,11 +50,17 @@ function buildShortcut(
export default Controller.extend(ModalFunctionality, {
onShow() {
this.set("modal.modalClass", "keyboard-shortcuts-modal");
this._defineShortcuts();
},
onClose() {
this.set("shortcuts", null);
},
showBookmarkShortcuts: setting("enable_bookmarks_with_reminders"),
shortcuts: {
_defineShortcuts() {
this.set("shortcuts", {
jump_to: {
home: buildShortcut("jump_to.home", { keys1: ["g", "h"] }),
latest: buildShortcut("jump_to.latest", { keys1: ["g", "l"] }),
@ -75,7 +81,10 @@ export default Controller.extend(ModalFunctionality, {
keys2: ["j"],
shortcutsDelimiter: "slash"
}),
open: buildShortcut("navigation.open", { keys1: ["o"], keys2: [ENTER] }),
open: buildShortcut("navigation.open", {
keys1: ["o"],
keys2: [ENTER]
}),
next_prev: buildShortcut("navigation.next_prev", {
keys1: [SHIFT, "j"],
keys2: [SHIFT, "k"],
@ -164,7 +173,9 @@ export default Controller.extend(ModalFunctionality, {
})
},
actions: {
bookmark_topic: buildShortcut("actions.bookmark_topic", { keys1: ["f"] }),
bookmark_topic: buildShortcut("actions.bookmark_topic", {
keys1: ["f"]
}),
reply_as_new_topic: buildShortcut("actions.reply_as_new_topic", {
keys1: ["t"]
}),
@ -221,5 +232,6 @@ export default Controller.extend(ModalFunctionality, {
keys1: ["a"]
})
}
});
}
});