From d06aef511f80e35216d40db8e47f0187ca021b5b Mon Sep 17 00:00:00 2001 From: Ilya Daynatovich Date: Mon, 17 Oct 2016 16:35:47 +0300 Subject: [PATCH] Fix shortcut dialog toggling --- modules/UI/UI.js | 15 ++++++++++----- modules/UI/util/MessageHandler.js | 9 +++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 95dec167e..6a62d5042 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -1491,12 +1491,17 @@ UI.hideUserMediaPermissionsGuidanceOverlay = function () { * Shows or hides the keyboard shortcuts panel, depending on the current state.' */ UI.toggleKeyboardShortcutsPanel = function() { - let titleKey = 'keyboardShortcuts.keyboardShortcuts'; - let title = APP.translation.translateString(titleKey); - let msg = $('#keyboard-shortcuts').html(); - let buttons = { Close: true }; + if (!messageHandler.isDialogOpened()) { + let titleKey = 'keyboardShortcuts.keyboardShortcuts'; + let title = APP.translation.translateString(titleKey); + let msg = $('#keyboard-shortcuts').html(); + let buttons = { Close: true }; + + messageHandler.openDialog(title, msg, true, buttons); + } else { + messageHandler.closeDialog(); + } - messageHandler.openDialog(title, msg, true, buttons); }; /** diff --git a/modules/UI/util/MessageHandler.js b/modules/UI/util/MessageHandler.js index 7239dba92..319a459e3 100644 --- a/modules/UI/util/MessageHandler.js +++ b/modules/UI/util/MessageHandler.js @@ -373,6 +373,15 @@ var messageHandler = { enablePopups: function (enable) { popupEnabled = enable; + }, + + /** + * Returns true if dialog is opened + * false otherwise + * @returns {boolean} isOpened + */ + isDialogOpened: function () { + return !!$.prompt.getCurrentStateName(); } };