From 3a267b5cc672c1737b4eab10862236c08a42aced Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 11 Sep 2018 11:04:57 +0000 Subject: [PATCH] Have ESC zoom out topics if you're zoomed in. This is the natural behavior that most users will probably expect. If you need to go to All Messages when topics are zoomed in, you can just hit ESC twice. --- static/js/hotkey.js | 5 +++++ static/js/topic_zoom.js | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/static/js/hotkey.js b/static/js/hotkey.js index 655de82e1c..1ff1c6f66b 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -278,6 +278,11 @@ exports.process_escape_key = function (e) { return true; } + if (topic_zoom.is_zoomed_in()) { + topic_zoom.zoom_out(); + return true; + } + narrow.deactivate(); return true; }; diff --git a/static/js/topic_zoom.js b/static/js/topic_zoom.js index 1691fa7162..cd4842c8d1 100644 --- a/static/js/topic_zoom.js +++ b/static/js/topic_zoom.js @@ -4,6 +4,10 @@ var exports = {}; var zoomed_in = false; +exports.is_zoomed_in = function () { + return zoomed_in; +}; + function zoom_in() { var stream_id = topic_list.active_stream_id(); @@ -16,7 +20,7 @@ function zoom_in() { zoomed_in = true; } -function zoom_out() { +exports.zoom_out = function () { var stream_li = topic_list.get_stream_li(); popovers.hide_all(); @@ -28,7 +32,7 @@ function zoom_out() { } zoomed_in = false; -} +}; exports.clear_topics = function () { var stream_li = topic_list.get_stream_li(); @@ -55,7 +59,7 @@ exports.initialize = function () { }); $('.show-all-streams').on('click', function (e) { - zoom_out(); + exports.zoom_out(); e.preventDefault(); e.stopPropagation();