From 44d3aedd382f6b9f38776fd2f2a8119f4160da55 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 1 Dec 2018 18:10:30 +0300 Subject: [PATCH] prefs: hotkey handler to App --- js/prefs.js | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/js/prefs.js b/js/prefs.js index 032098f6f..15007d014 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -65,7 +65,7 @@ const App = { }); }, initSecondStage: function() { - document.onkeydown = pref_hotkey_handler; + document.onkeydown = this.hotkeyHandler; setLoadingProgress(50); notify(""); @@ -87,6 +87,30 @@ const App = { } setInterval(hotkeyPrefixTimeout, 5 * 1000); + }, + hotkeyHandler: function (event) { + if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return; + + const action_name = keyeventToAction(event); + + if (action_name) { + switch (action_name) { + case "feed_subscribe": + quickAddFeed(); + return false; + case "create_label": + addLabel(); + return false; + case "create_filter": + quickAddFilter(); + return false; + case "help_dialog": + Utils.helpDialog("main"); + return false; + default: + console.log("unhandled action: " + action_name + "; keycode: " + event.which); + } + } } } @@ -747,31 +771,6 @@ function validatePrefsReset() { return false; } -function pref_hotkey_handler(e) { - if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return; - - const action_name = keyeventToAction(e); - - if (action_name) { - switch (action_name) { - case "feed_subscribe": - quickAddFeed(); - return false; - case "create_label": - addLabel(); - return false; - case "create_filter": - quickAddFilter(); - return false; - case "help_dialog": - Utils.helpDialog("main"); - return false; - default: - console.log("unhandled action: " + action_name + "; keycode: " + e.which); - } - } -} - function removeCategory(id, item) { if (confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name))) {