From fc97bc826620a3c90fa88eaff7c67ba6395afd25 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Fri, 16 Oct 2015 15:00:26 -0700 Subject: [PATCH] Add help button toggle --- client/main.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/client/main.js b/client/main.js index 924585623a..2d6a526c77 100644 --- a/client/main.js +++ b/client/main.js @@ -33,7 +33,22 @@ main = (function(main) { }); $(helpChatBtnClass).on('click', function() { - main.chat.helpChat.toggleChat(true); + // is button already pressed? + // no? open chat + // yes? close chat + var shouldChatBeOpen = !$(this).hasClass('active'); + main.chat.helpChat.toggleChat(shouldChatBeOpen); + if (shouldChatBeOpen) { + $(helpChatBtnClass).addClass('active'); + } + }); + + $('#chat-embed-help').on('gitter-chat-toggle', function(e) { + var shouldButtonBePressed = !!e.originalEvent.detail.state; + if (shouldButtonBePressed) { + return $(helpChatBtnClass).addClass('active'); + } + return $(helpChatBtnClass).removeClass('active'); }); };