瀏覽代碼

Merge pull request #873 from jitsi/chat-updates

Chat updates
master
yanas 9 年之前
父節點
當前提交
e1fa5ecb34
共有 1 個文件被更改,包括 30 次插入29 次删除
  1. 30
    29
      modules/UI/side_pannels/chat/Chat.js

+ 30
- 29
modules/UI/side_pannels/chat/Chat.js 查看文件

9
 
9
 
10
 var smileys = require("./smileys.json").smileys;
10
 var smileys = require("./smileys.json").smileys;
11
 
11
 
12
-var notificationInterval = false;
13
 var unreadMessages = 0;
12
 var unreadMessages = 0;
14
 
13
 
14
+/**
15
+ * The container id, which is and the element id.
16
+ */
17
+var CHAT_CONTAINER_ID = "chat_container";
15
 
18
 
16
 /**
19
 /**
17
- * Shows/hides a visual notification, indicating that a message has arrived.
20
+ *  Updates visual notification, indicating that a message has arrived.
18
  */
21
  */
19
-function setVisualNotification(show) {
22
+function updateVisualNotification() {
20
     var unreadMsgElement = document.getElementById('unreadMessages');
23
     var unreadMsgElement = document.getElementById('unreadMessages');
21
 
24
 
22
     var glower = $('#toolbar_button_chat');
25
     var glower = $('#toolbar_button_chat');
37
             'style',
40
             'style',
38
                 'top:' + topIndent +
41
                 'top:' + topIndent +
39
                 '; left:' + leftIndent + ';');
42
                 '; left:' + leftIndent + ';');
40
-
41
-        if (!glower.hasClass('icon-chat-simple')) {
42
-            glower.removeClass('icon-chat');
43
-            glower.addClass('icon-chat-simple');
44
-        }
45
     }
43
     }
46
     else {
44
     else {
47
         unreadMsgElement.innerHTML = '';
45
         unreadMsgElement.innerHTML = '';
48
-        glower.removeClass('icon-chat-simple');
49
-        glower.addClass('icon-chat');
50
-    }
51
-
52
-    if (show && !notificationInterval) {
53
-        notificationInterval = window.setInterval(function () {
54
-            glower.toggleClass('active');
55
-        }, 800);
56
-    }
57
-    else if (!show && notificationInterval) {
58
-        window.clearInterval(notificationInterval);
59
-        notificationInterval = false;
60
-        glower.removeClass('active');
61
     }
46
     }
62
 }
47
 }
63
 
48
 
131
  */
116
  */
132
 function resizeChatConversation() {
117
 function resizeChatConversation() {
133
     var msgareaHeight = $('#usermsg').outerHeight();
118
     var msgareaHeight = $('#usermsg').outerHeight();
134
-    var chatspace = $('#chat_container');
119
+    var chatspace = $('#' + CHAT_CONTAINER_ID);
135
     var width = chatspace.width();
120
     var width = chatspace.width();
136
     var chat = $('#chatconversation');
121
     var chat = $('#chatconversation');
137
     var smileys = $('#smileysarea');
122
     var smileys = $('#smileysarea');
187
         };
172
         };
188
         usermsg.autosize({callback: onTextAreaResize});
173
         usermsg.autosize({callback: onTextAreaResize});
189
 
174
 
190
-        $("#chat_container").bind("shown",
191
-            function () {
175
+        eventEmitter.on(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
176
+            function(containerId, isVisible) {
177
+                if (containerId !== CHAT_CONTAINER_ID || !isVisible)
178
+                    return;
179
+
192
                 unreadMessages = 0;
180
                 unreadMessages = 0;
193
-                setVisualNotification(false);
181
+                updateVisualNotification();
182
+
183
+                // if we are in conversation mode focus on the text input
184
+                // if we are not, focus on the display name input
185
+                if (APP.settings.getDisplayName())
186
+                    $('#usermsg').focus();
187
+                else
188
+                    $('#nickinput').focus();
194
             });
189
             });
195
 
190
 
196
         addSmileys();
191
         addSmileys();
210
             if (!Chat.isVisible()) {
205
             if (!Chat.isVisible()) {
211
                 unreadMessages++;
206
                 unreadMessages++;
212
                 UIUtil.playSoundNotification('chatNotification');
207
                 UIUtil.playSoundNotification('chatNotification');
213
-                setVisualNotification(true);
208
+                updateVisualNotification();
214
             }
209
             }
215
         }
210
         }
216
 
211
 
271
 
266
 
272
     /**
267
     /**
273
      * Sets the chat conversation mode.
268
      * Sets the chat conversation mode.
269
+     * Conversation mode is the normal chat mode, non conversation mode is
270
+     * where we ask user to input its display name.
274
      * @param {boolean} isConversationMode if chat should be in
271
      * @param {boolean} isConversationMode if chat should be in
275
      * conversation mode or not.
272
      * conversation mode or not.
276
      */
273
      */
277
     setChatConversationMode (isConversationMode) {
274
     setChatConversationMode (isConversationMode) {
278
-        $('#chat_container')
275
+        $('#' + CHAT_CONTAINER_ID)
279
             .toggleClass('is-conversation-mode', isConversationMode);
276
             .toggleClass('is-conversation-mode', isConversationMode);
277
+
278
+        // this is needed when we transition from no conversation mode to
279
+        // conversation mode. When user enters his nickname and hits enter,
280
+        // to focus on the write area.
280
         if (isConversationMode) {
281
         if (isConversationMode) {
281
             $('#usermsg').focus();
282
             $('#usermsg').focus();
282
         }
283
         }
286
      * Resizes the chat area.
287
      * Resizes the chat area.
287
      */
288
      */
288
     resizeChat (width, height) {
289
     resizeChat (width, height) {
289
-        $('#chat_container').width(width).height(height);
290
+        $('#' + CHAT_CONTAINER_ID).width(width).height(height);
290
 
291
 
291
         resizeChatConversation();
292
         resizeChatConversation();
292
     },
293
     },
296
      */
297
      */
297
     isVisible () {
298
     isVisible () {
298
         return UIUtil.isVisible(
299
         return UIUtil.isVisible(
299
-            document.getElementById("chat_container"));
300
+            document.getElementById(CHAT_CONTAINER_ID));
300
     },
301
     },
301
     /**
302
     /**
302
      * Shows and hides the window with the smileys
303
      * Shows and hides the window with the smileys

Loading…
取消
儲存