From a6710934892c00ca45eb4888de3f4ebea04037c8 Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 14 Sep 2016 15:13:15 -0500 Subject: [PATCH 1/4] Introduces chat_container_id variable. --- modules/UI/side_pannels/chat/Chat.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.js index 713cc1f88..ddd7ebe09 100644 --- a/modules/UI/side_pannels/chat/Chat.js +++ b/modules/UI/side_pannels/chat/Chat.js @@ -12,6 +12,10 @@ var smileys = require("./smileys.json").smileys; var notificationInterval = false; var unreadMessages = 0; +/** + * The container id, which is and the element id. + */ +var CHAT_CONTAINER_ID = "chat_container"; /** * Shows/hides a visual notification, indicating that a message has arrived. @@ -131,7 +135,7 @@ function addSmileys() { */ function resizeChatConversation() { var msgareaHeight = $('#usermsg').outerHeight(); - var chatspace = $('#chat_container'); + var chatspace = $('#' + CHAT_CONTAINER_ID); var width = chatspace.width(); var chat = $('#chatconversation'); var smileys = $('#smileysarea'); @@ -187,7 +191,7 @@ var Chat = { }; usermsg.autosize({callback: onTextAreaResize}); - $("#chat_container").bind("shown", + $("#" + CHAT_CONTAINER_ID).bind("shown", function () { unreadMessages = 0; setVisualNotification(false); @@ -275,7 +279,7 @@ var Chat = { * conversation mode or not. */ setChatConversationMode (isConversationMode) { - $('#chat_container') + $('#' + CHAT_CONTAINER_ID) .toggleClass('is-conversation-mode', isConversationMode); if (isConversationMode) { $('#usermsg').focus(); @@ -286,7 +290,7 @@ var Chat = { * Resizes the chat area. */ resizeChat (width, height) { - $('#chat_container').width(width).height(height); + $('#' + CHAT_CONTAINER_ID).width(width).height(height); resizeChatConversation(); }, @@ -296,7 +300,7 @@ var Chat = { */ isVisible () { return UIUtil.isVisible( - document.getElementById("chat_container")); + document.getElementById(CHAT_CONTAINER_ID)); }, /** * Shows and hides the window with the smileys From 407b08278040482eb589d431eca5d1424b70a136 Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 14 Sep 2016 15:18:14 -0500 Subject: [PATCH 2/4] Removes changing the message icon and flashing on new message. --- modules/UI/side_pannels/chat/Chat.js | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.js index ddd7ebe09..f5d2ba011 100644 --- a/modules/UI/side_pannels/chat/Chat.js +++ b/modules/UI/side_pannels/chat/Chat.js @@ -9,7 +9,6 @@ import UIEvents from '../../../../service/UI/UIEvents'; var smileys = require("./smileys.json").smileys; -var notificationInterval = false; var unreadMessages = 0; /** @@ -18,9 +17,9 @@ var unreadMessages = 0; var CHAT_CONTAINER_ID = "chat_container"; /** - * Shows/hides a visual notification, indicating that a message has arrived. + * Updates visual notification, indicating that a message has arrived. */ -function setVisualNotification(show) { +function updateVisualNotification() { var unreadMsgElement = document.getElementById('unreadMessages'); var glower = $('#toolbar_button_chat'); @@ -41,27 +40,9 @@ function setVisualNotification(show) { 'style', 'top:' + topIndent + '; left:' + leftIndent + ';'); - - if (!glower.hasClass('icon-chat-simple')) { - glower.removeClass('icon-chat'); - glower.addClass('icon-chat-simple'); - } } else { unreadMsgElement.innerHTML = ''; - glower.removeClass('icon-chat-simple'); - glower.addClass('icon-chat'); - } - - if (show && !notificationInterval) { - notificationInterval = window.setInterval(function () { - glower.toggleClass('active'); - }, 800); - } - else if (!show && notificationInterval) { - window.clearInterval(notificationInterval); - notificationInterval = false; - glower.removeClass('active'); } } @@ -194,7 +175,7 @@ var Chat = { $("#" + CHAT_CONTAINER_ID).bind("shown", function () { unreadMessages = 0; - setVisualNotification(false); + updateVisualNotification(); }); addSmileys(); @@ -214,7 +195,7 @@ var Chat = { if (!Chat.isVisible()) { unreadMessages++; UIUtil.playSoundNotification('chatNotification'); - setVisualNotification(true); + updateVisualNotification(); } } From d8dd564b06a9ba16212d1848dbd2fd0a96b6737a Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 14 Sep 2016 15:22:36 -0500 Subject: [PATCH 3/4] Fixes clearing message counter on opening the chat. --- modules/UI/side_pannels/chat/Chat.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.js index f5d2ba011..8e62c851f 100644 --- a/modules/UI/side_pannels/chat/Chat.js +++ b/modules/UI/side_pannels/chat/Chat.js @@ -172,8 +172,11 @@ var Chat = { }; usermsg.autosize({callback: onTextAreaResize}); - $("#" + CHAT_CONTAINER_ID).bind("shown", - function () { + eventEmitter.on(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED, + function(containerId, isVisible) { + if (containerId !== CHAT_CONTAINER_ID || !isVisible) + return; + unreadMessages = 0; updateVisualNotification(); }); From e1512e3776a2a531039d79e326c68d035f82ff1e Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 14 Sep 2016 15:26:38 -0500 Subject: [PATCH 4/4] Fixes focusing on write area or nickname input when chat is open. --- modules/UI/side_pannels/chat/Chat.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.js index 8e62c851f..00b2724de 100644 --- a/modules/UI/side_pannels/chat/Chat.js +++ b/modules/UI/side_pannels/chat/Chat.js @@ -179,6 +179,13 @@ var Chat = { unreadMessages = 0; updateVisualNotification(); + + // if we are in conversation mode focus on the text input + // if we are not, focus on the display name input + if (APP.settings.getDisplayName()) + $('#usermsg').focus(); + else + $('#nickinput').focus(); }); addSmileys(); @@ -259,12 +266,18 @@ var Chat = { /** * Sets the chat conversation mode. + * Conversation mode is the normal chat mode, non conversation mode is + * where we ask user to input its display name. * @param {boolean} isConversationMode if chat should be in * conversation mode or not. */ setChatConversationMode (isConversationMode) { $('#' + CHAT_CONTAINER_ID) .toggleClass('is-conversation-mode', isConversationMode); + + // this is needed when we transition from no conversation mode to + // conversation mode. When user enters his nickname and hits enter, + // to focus on the write area. if (isConversationMode) { $('#usermsg').focus(); }