Ver código fonte

do not use xmpp module in side_panels module

master
isymchych 9 anos atrás
pai
commit
de9d991f98

+ 6
- 0
app.js Ver arquivo

@@ -415,6 +415,12 @@ function initConference(localTracks, connection) {
415 415
         // }, APP.UI.updateRecordingState);
416 416
     });
417 417
 
418
+    APP.UI.addListener(UIEvents.TOPIC_CHANGED, function (topic) {
419
+        // FIXME handle topic change
420
+        // APP.xmpp.setSubject(topic);
421
+        // on SUBJECT_CHANGED UI.setSubject(topic);
422
+    });
423
+
418 424
     room.on(ConferenceEvents.DTMF_SUPPORT_CHANGED, function (isDTMFSupported) {
419 425
         APP.UI.updateDTMFSupport(isDTMFSupported);
420 426
     });

+ 9
- 9
modules/UI/UI.js Ver arquivo

@@ -2,11 +2,11 @@
2 2
 /* jshint -W101 */
3 3
 var UI = {};
4 4
 
5
-var VideoLayout = require("./videolayout/VideoLayout.js");
6
-var AudioLevels = require("./audio_levels/AudioLevels.js");
7
-var Prezi = require("./prezi/Prezi.js");
8
-var Etherpad = require("./etherpad/Etherpad.js");
9
-var Chat = require("./side_pannels/chat/Chat.js");
5
+var VideoLayout = require("./videolayout/VideoLayout");
6
+var AudioLevels = require("./audio_levels/AudioLevels");
7
+var Prezi = require("./prezi/Prezi");
8
+var Etherpad = require("./etherpad/Etherpad");
9
+var Chat = require("./side_pannels/chat/Chat");
10 10
 var Toolbar = require("./toolbars/Toolbar");
11 11
 var ToolbarToggler = require("./toolbars/ToolbarToggler");
12 12
 var BottomToolbar = require("./toolbars/BottomToolbar");
@@ -219,7 +219,7 @@ function registerListeners() {
219 219
 
220 220
 function bindEvents() {
221 221
     function onResize() {
222
-        Chat.resizeChat();
222
+        PanelToggler.resizeChat();
223 223
         VideoLayout.resizeLargeVideoContainer();
224 224
     }
225 225
 
@@ -344,9 +344,9 @@ function chatAddError(errorMessage, originalText) {
344 344
     return Chat.chatAddError(errorMessage, originalText);
345 345
 }
346 346
 
347
-function chatSetSubject(text) {
348
-    return Chat.chatSetSubject(text);
349
-}
347
+UI.setSubject = function (subject) {
348
+    Chat.setSubject(subject);
349
+};
350 350
 
351 351
 function initEtherpad(name) {
352 352
     Etherpad.init(name);

+ 108
- 104
modules/UI/side_pannels/SidePanelToggler.js Ver arquivo

@@ -1,102 +1,101 @@
1 1
 /* global require, $ */
2
-var Chat = require("./chat/Chat");
3
-var ContactList = require("./contactlist/ContactList");
4
-var Settings = require("./../../settings/Settings");
5
-var SettingsMenu = require("./settings/SettingsMenu");
6
-var VideoLayout = require("../videolayout/VideoLayout");
7
-var ToolbarToggler = require("../toolbars/ToolbarToggler");
8
-var UIUtil = require("../util/UIUtil");
9
-var LargeVideo = require("../videolayout/LargeVideo");
2
+import Chat from "./chat/Chat";
3
+import ContactList from "./contactlist/ContactList";
4
+import Settings from "./../../settings/Settings";
5
+import SettingsMenu from "./settings/SettingsMenu";
6
+import VideoLayout from "../videolayout/VideoLayout";
7
+import ToolbarToggler from "../toolbars/ToolbarToggler";
8
+import UIUtil from "../util/UIUtil";
9
+import LargeVideo from "../videolayout/LargeVideo";
10
+
11
+const buttons = {
12
+    '#chatspace': '#chatBottomButton',
13
+    '#contactlist': '#contactListButton',
14
+    '#settingsmenu': '#toolbar_button_settings'
15
+};
16
+
17
+var currentlyOpen = null;
10 18
 
11 19
 /**
12
- * Toggler for the chat, contact list, settings menu, etc..
20
+ * Toggles the windows in the side panel
21
+ * @param object the window that should be shown
22
+ * @param selector the selector for the element containing the panel
23
+ * @param onOpenComplete function to be called when the panel is opened
24
+ * @param onOpen function to be called if the window is going to be opened
25
+ * @param onClose function to be called if the window is going to be closed
13 26
  */
14
-var PanelToggler = (function(my) {
27
+function toggle (object, selector, onOpenComplete, onOpen, onClose) {
28
+    UIUtil.buttonClick(buttons[selector], "active");
29
+
30
+    if (object.isVisible()) {
31
+        $("#toast-container").animate({
32
+            right: 5
33
+        }, {
34
+            queue: false,
35
+            duration: 500
36
+        });
37
+        $(selector).hide("slide", {
38
+            direction: "right",
39
+            queue: false,
40
+            duration: 500
41
+        });
42
+        if(typeof onClose === "function") {
43
+            onClose();
44
+        }
15 45
 
16
-    var currentlyOpen = null;
17
-    var buttons = {
18
-        '#chatspace': '#chatBottomButton',
19
-        '#contactlist': '#contactListButton',
20
-        '#settingsmenu': '#toolbar_button_settings'
21
-    };
46
+        currentlyOpen = null;
47
+    } else {
48
+        // Undock the toolbar when the chat is shown and if we're in a
49
+        // video mode.
50
+        if (LargeVideo.isLargeVideoVisible()) {
51
+            ToolbarToggler.dockToolbar(false);
52
+        }
22 53
 
23
-    /**
24
-     * Toggles the windows in the side panel
25
-     * @param object the window that should be shown
26
-     * @param selector the selector for the element containing the panel
27
-     * @param onOpenComplete function to be called when the panel is opened
28
-     * @param onOpen function to be called if the window is going to be opened
29
-     * @param onClose function to be called if the window is going to be closed
30
-     */
31
-    var toggle = function(object, selector, onOpenComplete, onOpen, onClose) {
32
-        UIUtil.buttonClick(buttons[selector], "active");
33
-
34
-        if (object.isVisible()) {
35
-            $("#toast-container").animate({
36
-                    right: '5px'
37
-                },
38
-                {
39
-                    queue: false,
40
-                    duration: 500
41
-                });
42
-            $(selector).hide("slide", {
43
-                direction: "right",
44
-                queue: false,
45
-                duration: 500
46
-            });
47
-            if(typeof onClose === "function") {
48
-                onClose();
49
-            }
50
-
51
-            currentlyOpen = null;
54
+        if (currentlyOpen) {
55
+            var current = $(currentlyOpen);
56
+            UIUtil.buttonClick(buttons[currentlyOpen], "active");
57
+            current.css('z-index', 4);
58
+            setTimeout(function () {
59
+                current.css('display', 'none');
60
+                current.css('z-index', 5);
61
+            }, 500);
52 62
         }
53
-        else {
54
-            // Undock the toolbar when the chat is shown and if we're in a
55
-            // video mode.
56
-            if (LargeVideo.isLargeVideoVisible()) {
57
-                ToolbarToggler.dockToolbar(false);
58
-            }
59
-
60
-            if(currentlyOpen) {
61
-                var current = $(currentlyOpen);
62
-                UIUtil.buttonClick(buttons[currentlyOpen], "active");
63
-                current.css('z-index', 4);
64
-                setTimeout(function () {
65
-                    current.css('display', 'none');
66
-                    current.css('z-index', 5);
67
-                }, 500);
68
-            }
69
-
70
-            $("#toast-container").animate({
71
-                    right: (PanelToggler.getPanelSize()[0] + 5) + 'px'
72
-                },
73
-                {
74
-                    queue: false,
75
-                    duration: 500
76
-                });
77
-            $(selector).show("slide", {
78
-                direction: "right",
79
-                queue: false,
80
-                duration: 500,
81
-                complete: onOpenComplete
82
-            });
83
-            if(typeof onOpen === "function") {
84
-                onOpen();
85
-            }
86
-
87
-            currentlyOpen = selector;
63
+
64
+        $("#toast-container").animate({
65
+            right: (PanelToggler.getPanelSize()[0] + 5)
66
+        }, {
67
+            queue: false,
68
+            duration: 500
69
+        });
70
+        $(selector).show("slide", {
71
+            direction: "right",
72
+            queue: false,
73
+            duration: 500,
74
+            complete: onOpenComplete
75
+        });
76
+        if(typeof onOpen === "function") {
77
+            onOpen();
88 78
         }
89
-    };
79
+
80
+        currentlyOpen = selector;
81
+    }
82
+}
83
+
84
+/**
85
+ * Toggler for the chat, contact list, settings menu, etc..
86
+ */
87
+var PanelToggler = {
90 88
 
91 89
     /**
92 90
      * Opens / closes the chat area.
93 91
      */
94
-    my.toggleChat = function() {
95
-        var chatCompleteFunction = Chat.isVisible() ?
96
-            function() {} : function () {
97
-            Chat.scrollChatToBottom();
98
-            $('#chatspace').trigger('shown');
99
-        };
92
+    toggleChat () {
93
+        var chatCompleteFunction = Chat.isVisible()
94
+            ? function () {}
95
+            : function () {
96
+                Chat.scrollChatToBottom();
97
+                $('#chatspace').trigger('shown');
98
+            };
100 99
 
101 100
         VideoLayout.resizeVideoArea(!Chat.isVisible(), chatCompleteFunction);
102 101
 
@@ -112,16 +111,24 @@ var PanelToggler = (function(my) {
112 111
                 }
113 112
             },
114 113
             null,
115
-            Chat.resizeChat,
114
+            () => this.resizeChat(),
116 115
             null);
117
-    };
116
+    },
117
+
118
+    resizeChat () {
119
+        let [width, height] = this.getPanelSize();
120
+        Chat.resizeChat(width, height);
121
+    },
118 122
 
119 123
     /**
120 124
      * Opens / closes the contact list area.
121 125
      */
122
-    my.toggleContactList = function () {
123
-        var completeFunction = ContactList.isVisible() ?
124
-            function() {} : function () { $('#contactlist').trigger('shown');};
126
+    toggleContactList () {
127
+        var completeFunction = ContactList.isVisible()
128
+            ? function () {}
129
+            : function () {
130
+                $('#contactlist').trigger('shown');
131
+            };
125 132
         VideoLayout.resizeVideoArea(!ContactList.isVisible(), completeFunction);
126 133
 
127 134
         toggle(ContactList,
@@ -131,12 +138,12 @@ var PanelToggler = (function(my) {
131 138
                 ContactList.setVisualNotification(false);
132 139
             },
133 140
             null);
134
-    };
141
+    },
135 142
 
136 143
     /**
137 144
      * Opens / closes the settings menu
138 145
      */
139
-    my.toggleSettingsMenu = function() {
146
+    toggleSettingsMenu () {
140 147
         VideoLayout.resizeVideoArea(!SettingsMenu.isVisible(), function (){});
141 148
         toggle(SettingsMenu,
142 149
             '#settingsmenu',
@@ -147,12 +154,12 @@ var PanelToggler = (function(my) {
147 154
                 $('#setEmail').get(0).value = settings.email;
148 155
             },
149 156
             null);
150
-    };
157
+    },
151 158
 
152 159
     /**
153 160
      * Returns the size of the side panel.
154 161
      */
155
-    my.getPanelSize = function () {
162
+    getPanelSize () {
156 163
         var availableHeight = window.innerHeight;
157 164
         var availableWidth = window.innerWidth;
158 165
 
@@ -162,16 +169,13 @@ var PanelToggler = (function(my) {
162 169
         }
163 170
 
164 171
         return [panelWidth, availableHeight];
165
-    };
172
+    },
166 173
 
167
-    my.isVisible = function() {
174
+    isVisible () {
168 175
         return (Chat.isVisible() ||
169 176
                 ContactList.isVisible() ||
170 177
                 SettingsMenu.isVisible());
171
-    };
172
-
173
-    return my;
174
-
175
-}(PanelToggler || {}));
178
+    }
179
+};
176 180
 
177
-module.exports = PanelToggler;
181
+export default PanelToggler;

+ 40
- 45
modules/UI/side_pannels/chat/Chat.js Ver arquivo

@@ -1,10 +1,13 @@
1 1
 /* global APP, $ */
2
-var Replacement = require("./Replacement");
3
-var CommandsProcessor = require("./Commands");
4
-var ToolbarToggler = require("../../toolbars/ToolbarToggler");
2
+
3
+import {processReplacements, linkify} from './Replacement';
4
+import CommandsProcessor from './Commands';
5
+import ToolbarToggler from '../../toolbars/ToolbarToggler';
6
+
7
+import UIUtil from '../../util/UIUtil';
8
+import UIEvents from '../../../../service/UI/UIEvents';
9
+
5 10
 var smileys = require("./smileys.json").smileys;
6
-var UIUtil = require("../../util/UIUtil");
7
-var UIEvents = require("../../../../service/UI/UIEvents");
8 11
 
9 12
 var notificationInterval = false;
10 13
 var unreadMessages = 0;
@@ -164,11 +167,11 @@ function resizeChatConversation() {
164 167
 /**
165 168
  * Chat related user interface.
166 169
  */
167
-var Chat = (function (my) {
170
+var Chat = {
168 171
     /**
169 172
      * Initializes chat related interface.
170 173
      */
171
-    my.init = function (eventEmitter) {
174
+    init (eventEmitter) {
172 175
         if (APP.settings.getDisplayName()) {
173 176
             Chat.setChatConversationMode(true);
174 177
         }
@@ -192,11 +195,10 @@ var Chat = (function (my) {
192 195
                 var value = this.value;
193 196
                 usermsg.val('').trigger('autosize.resize');
194 197
                 this.focus();
195
-                var command = new CommandsProcessor(value);
196
-                if(command.isCommand()) {
198
+                var command = new CommandsProcessor(value, eventEmitter);
199
+                if (command.isCommand()) {
197 200
                     command.processCommand();
198
-                }
199
-                else {
201
+                } else {
200 202
                     var message = UIUtil.escapeHtml(value);
201 203
                     eventEmitter.emit(UIEvents.MESSAGE_CREATED, message);
202 204
                 }
@@ -216,19 +218,17 @@ var Chat = (function (my) {
216 218
             });
217 219
 
218 220
         addSmileys();
219
-    };
221
+    },
220 222
 
221 223
     /**
222 224
      * Appends the given message to the chat conversation.
223 225
      */
224
-    my.updateChatConversation =
225
-        function (from, displayName, message, stamp) {
226
+    updateChatConversation (id, displayName, message, stamp) {
226 227
         var divClassName = '';
227 228
 
228
-        if (APP.xmpp.myJid() === from) {
229
+        if (APP.conference.isLocalId(id)) {
229 230
             divClassName = "localuser";
230
-        }
231
-        else {
231
+        } else {
232 232
             divClassName = "remoteuser";
233 233
 
234 234
             if (!Chat.isVisible()) {
@@ -244,7 +244,7 @@ var Chat = (function (my) {
244 244
         var escMessage = message.replace(/</g, '&lt;').
245 245
             replace(/>/g, '&gt;').replace(/\n/g, '<br/>');
246 246
         var escDisplayName = UIUtil.escapeHtml(displayName);
247
-        message = Replacement.processReplacements(escMessage);
247
+        message = processReplacements(escMessage);
248 248
 
249 249
         var messageContainer =
250 250
             '<div class="chatmessage">'+
@@ -257,14 +257,14 @@ var Chat = (function (my) {
257 257
         $('#chatconversation').append(messageContainer);
258 258
         $('#chatconversation').animate(
259 259
                 { scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
260
-    };
260
+    },
261 261
 
262 262
     /**
263 263
      * Appends error message to the conversation
264 264
      * @param errorMessage the received error message.
265 265
      * @param originalText the original message.
266 266
      */
267
-    my.chatAddError = function(errorMessage, originalText) {
267
+    chatAddError (errorMessage, originalText) {
268 268
         errorMessage = UIUtil.escapeHtml(errorMessage);
269 269
         originalText = UIUtil.escapeHtml(originalText);
270 270
 
@@ -275,28 +275,28 @@ var Chat = (function (my) {
275 275
             (errorMessage? (' Reason: ' + errorMessage) : '') +  '</div>');
276 276
         $('#chatconversation').animate(
277 277
             { scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
278
-    };
278
+    },
279 279
 
280 280
     /**
281 281
      * Sets the subject to the UI
282 282
      * @param subject the subject
283 283
      */
284
-    my.chatSetSubject = function(subject) {
285
-        if (subject)
284
+    setSubject (subject) {
285
+        if (subject) {
286 286
             subject = subject.trim();
287
-        $('#subject').html(Replacement.linkify(UIUtil.escapeHtml(subject)));
288
-        if(subject === "") {
289
-            $("#subject").css({display: "none"});
290 287
         }
291
-        else {
288
+        $('#subject').html(linkify(UIUtil.escapeHtml(subject)));
289
+        if (subject) {
292 290
             $("#subject").css({display: "block"});
291
+        } else {
292
+            $("#subject").css({display: "none"});
293 293
         }
294
-    };
294
+    },
295 295
 
296 296
     /**
297 297
      * Sets the chat conversation mode.
298 298
      */
299
-    my.setChatConversationMode = function (isConversationMode) {
299
+    setChatConversationMode (isConversationMode) {
300 300
         if (isConversationMode) {
301 301
             $('#nickname').css({visibility: 'hidden'});
302 302
             $('#chatconversation').css({visibility: 'visible'});
@@ -304,42 +304,37 @@ var Chat = (function (my) {
304 304
             $('#smileysarea').css({visibility: 'visible'});
305 305
             $('#usermsg').focus();
306 306
         }
307
-    };
307
+    },
308 308
 
309 309
     /**
310 310
      * Resizes the chat area.
311 311
      */
312
-    my.resizeChat = function () {
313
-        var chatSize = require("../SidePanelToggler").getPanelSize();
314
-
315
-        $('#chatspace').width(chatSize[0]);
316
-        $('#chatspace').height(chatSize[1]);
312
+    resizeChat (width, height) {
313
+        $('#chatspace').width(width).height(height);
317 314
 
318 315
         resizeChatConversation();
319
-    };
316
+    },
320 317
 
321 318
     /**
322 319
      * Indicates if the chat is currently visible.
323 320
      */
324
-    my.isVisible = function () {
321
+    isVisible () {
325 322
         return $('#chatspace').is(":visible");
326
-    };
323
+    },
327 324
     /**
328 325
      * Shows and hides the window with the smileys
329 326
      */
330
-    my.toggleSmileys = toggleSmileys;
327
+    toggleSmileys,
331 328
 
332 329
     /**
333 330
      * Scrolls chat to the bottom.
334 331
      */
335
-    my.scrollChatToBottom = function() {
332
+    scrollChatToBottom () {
336 333
         setTimeout(function () {
337 334
             $('#chatconversation').scrollTop(
338 335
                 $('#chatconversation')[0].scrollHeight);
339 336
         }, 5);
340
-    };
341
-
337
+    }
338
+};
342 339
 
343
-    return my;
344
-}(Chat || {}));
345
-module.exports = Chat;
340
+export default Chat;

+ 11
- 8
modules/UI/side_pannels/chat/Commands.js Ver arquivo

@@ -1,12 +1,13 @@
1
-/* global APP, require */
2
-var UIUtil = require("../../util/UIUtil");
1
+/* global APP */
2
+import UIUtil from '../../util/UIUtil';
3
+import UIEvents from '../../../../service/UI/UIEvents';
3 4
 
4 5
 /**
5 6
  * List with supported commands. The keys are the names of the commands and
6 7
  * the value is the function that processes the message.
7 8
  * @type {{String: function}}
8 9
  */
9
-var commands = {
10
+const commands = {
10 11
     "topic" : processTopic
11 12
 };
12 13
 
@@ -29,9 +30,9 @@ function getCommand(message) {
29 30
  * Processes the data for topic command.
30 31
  * @param commandArguments the arguments of the topic command.
31 32
  */
32
-function processTopic(commandArguments) {
33
+function processTopic(commandArguments, emitter) {
33 34
     var topic = UIUtil.escapeHtml(commandArguments);
34
-    APP.xmpp.setSubject(topic);
35
+    emitter.emit(UIEvents.TOPIC_CHANGED, topic);
35 36
 }
36 37
 
37 38
 /**
@@ -40,9 +41,11 @@ function processTopic(commandArguments) {
40 41
  * @param message the message
41 42
  * @constructor
42 43
  */
43
-function CommandsProcessor(message) {
44
+function CommandsProcessor(message, emitter) {
44 45
     var command = getCommand(message);
45 46
 
47
+    this.emitter = emitter;
48
+
46 49
     /**
47 50
      * Returns the name of the command.
48 51
      * @returns {String} the command
@@ -80,7 +83,7 @@ CommandsProcessor.prototype.processCommand = function() {
80 83
     if(!this.isCommand())
81 84
         return;
82 85
 
83
-    commands[this.getCommand()](this.getArgument());
86
+    commands[this.getCommand()](this.getArgument(), this.emitter);
84 87
 };
85 88
 
86
-module.exports = CommandsProcessor;
89
+export default CommandsProcessor;

+ 4
- 11
modules/UI/side_pannels/chat/Replacement.js Ver arquivo

@@ -1,10 +1,10 @@
1 1
 /* jshint -W101 */
2 2
 var Smileys = require("./smileys.json");
3
+
3 4
 /**
4 5
  * Processes links and smileys in "body"
5 6
  */
6
-function processReplacements(body)
7
-{
7
+export function processReplacements(body) {
8 8
     //make links clickable
9 9
     body = linkify(body);
10 10
 
@@ -18,8 +18,7 @@ function processReplacements(body)
18 18
  * Finds and replaces all links in the links in "body"
19 19
  * with their <a href=""></a>
20 20
  */
21
-function linkify(inputText)
22
-{
21
+export function linkify(inputText) {
23 22
     var replacedText, replacePattern1, replacePattern2, replacePattern3;
24 23
 
25 24
     //URLs starting with http://, https://, or ftp://
@@ -40,8 +39,7 @@ function linkify(inputText)
40 39
 /**
41 40
  * Replaces common smiley strings with images
42 41
  */
43
-function smilify(body)
44
-{
42
+function smilify(body) {
45 43
     if(!body) {
46 44
         return body;
47 45
     }
@@ -56,8 +54,3 @@ function smilify(body)
56 54
 
57 55
     return body;
58 56
 }
59
-
60
-module.exports = {
61
-    processReplacements: processReplacements,
62
-    linkify: linkify
63
-};

+ 37
- 49
modules/UI/side_pannels/contactlist/ContactList.js Ver arquivo

@@ -1,5 +1,5 @@
1
-/* global $, APP, Strophe */
2
-var Avatar = require('../../avatar/Avatar');
1
+/* global $, APP */
2
+import Avatar from '../../avatar/Avatar';
3 3
 
4 4
 var numberOfContacts = 0;
5 5
 var notificationInterval;
@@ -44,9 +44,9 @@ function createAvatar(jid) {
44 44
  */
45 45
 function createDisplayNameParagraph(key, displayName) {
46 46
     var p = document.createElement('p');
47
-    if(displayName)
47
+    if (displayName) {
48 48
         p.innerText = displayName;
49
-    else if(key) {
49
+    } else if(key) {
50 50
         p.setAttribute("data-i18n",key);
51 51
         p.innerText = APP.translation.translateString(key);
52 52
     }
@@ -64,6 +64,14 @@ function stopGlowing(glower) {
64 64
     }
65 65
 }
66 66
 
67
+function getContactEl (id) {
68
+    return $(`#contacts>li[id="${id}"]`);
69
+}
70
+
71
+function contactElExists (id) {
72
+    return getContactEl(id).length > 0;
73
+}
74
+
67 75
 /**
68 76
  * Contact list.
69 77
  */
@@ -79,65 +87,51 @@ var ContactList = {
79 87
     },
80 88
 
81 89
     /**
82
-     * Adds a contact for the given peerJid if such doesn't yet exist.
90
+     * Adds a contact for the given id if such doesn't yet exist.
83 91
      *
84
-     * @param peerJid the peerJid corresponding to the contact
85 92
      */
86
-    ensureAddContact: function (peerJid) {
87
-        var resourceJid = Strophe.getResourceFromJid(peerJid);
88
-
89
-        var contact = $('#contacts>li[id="' + resourceJid + '"]');
90
-
91
-        if (!contact || contact.length <= 0)
92
-            ContactList.addContact(peerJid);
93
+    ensureAddContact: function (id) {
94
+        if (!contactElExists(id)) {
95
+            ContactList.addContact(id);
96
+        }
93 97
     },
94 98
 
95 99
     /**
96
-     * Adds a contact for the given peer jid.
100
+     * Adds a contact for the given id.
97 101
      *
98
-     * @param peerJid the jid of the contact to add
99 102
      */
100
-    addContact: function (peerJid) {
101
-        var resourceJid = Strophe.getResourceFromJid(peerJid);
102
-
103
+    addContact: function (id) {
103 104
         var contactlist = $('#contacts');
104 105
 
105 106
         var newContact = document.createElement('li');
106
-        newContact.id = resourceJid;
107
+        newContact.id = id;
107 108
         newContact.className = "clickable";
108 109
         newContact.onclick = function (event) {
109 110
             if (event.currentTarget.className === "clickable") {
110
-                $(ContactList).trigger('contactclicked', [peerJid]);
111
+                $(ContactList).trigger('contactclicked', [id]);
111 112
             }
112 113
         };
113 114
 
114
-        newContact.appendChild(createAvatar(peerJid));
115
+        newContact.appendChild(createAvatar(id));
115 116
         newContact.appendChild(createDisplayNameParagraph("participant"));
116 117
 
117
-        if (resourceJid === APP.xmpp.myResource()) {
118
+        if (APP.conference.isLocalId(id)) {
118 119
             contactlist.prepend(newContact);
119
-        }
120
-        else {
120
+        } else {
121 121
             contactlist.append(newContact);
122 122
         }
123 123
         updateNumberOfParticipants(1);
124 124
     },
125 125
 
126 126
     /**
127
-     * Removes a contact for the given peer jid.
127
+     * Removes a contact for the given id.
128 128
      *
129
-     * @param peerJid the peerJid corresponding to the contact to remove
130 129
      */
131
-    removeContact: function (peerJid) {
132
-        var resourceJid = Strophe.getResourceFromJid(peerJid);
133
-
134
-        var contact = $('#contacts>li[id="' + resourceJid + '"]');
135
-
136
-        if (contact && contact.length > 0) {
137
-            var contactlist = $('#contactlist>ul');
138
-
139
-            contactlist.get(0).removeChild(contact.get(0));
130
+    removeContact: function (id) {
131
+        let contact = getContactEl(id);
140 132
 
133
+        if (contact.length > 0) {
134
+            contact.remove();
141 135
             updateNumberOfParticipants(-1);
142 136
         }
143 137
     },
@@ -160,34 +154,28 @@ var ContactList = {
160 154
         }
161 155
     },
162 156
 
163
-    setClickable: function (resourceJid, isClickable) {
164
-        var contact = $('#contacts>li[id="' + resourceJid + '"]');
165
-        if (isClickable) {
166
-            contact.addClass('clickable');
167
-        } else {
168
-            contact.removeClass('clickable');
169
-        }
157
+    setClickable: function (id, isClickable) {
158
+        getContactEl(id).toggleClass('clickable', isClickable);
170 159
     },
171 160
 
172 161
     onDisplayNameChange: function (id, displayName) {
173 162
         if (id === 'localVideoContainer') {
174 163
             id = APP.conference.localId;
175 164
         }
176
-        var contactName = $('#contacts #' + id + '>p');
165
+        var contactName = $(`#contacts #${id}>p`);
177 166
 
178
-        if (contactName && displayName && displayName.length > 0) {
167
+        if (displayName) {
179 168
             contactName.html(displayName);
180 169
         }
181 170
     },
182 171
 
183 172
     changeUserAvatar: function (id, contactListUrl) {
184 173
         // set the avatar in the contact list
185
-        var contact = $('#' + id + '>img');
186
-        if (contact && contact.length > 0) {
187
-            contact.get(0).src = contactListUrl;
174
+        var contact = $(`#${id}>img`);
175
+        if (contact.length > 0) {
176
+            contact.attr('src', contactListUrl);
188 177
         }
189
-
190 178
     }
191 179
 };
192 180
 
193
-module.exports = ContactList;
181
+module.exports = ContactList;

+ 5
- 6
modules/UI/side_pannels/settings/SettingsMenu.js Ver arquivo

@@ -1,12 +1,11 @@
1 1
 /* global APP, $ */
2
-var Settings = require("./../../../settings/Settings");
3
-var UIUtil = require("../../util/UIUtil");
4
-var languages = require("../../../../service/translation/languages");
5
-var UIEvents = require("../../../../service/UI/UIEvents");
2
+import UIUtil from "../../util/UIUtil";
3
+import UIEvents from "../../../../service/UI/UIEvents";
4
+import languages from "../../../../service/translation/languages";
6 5
 
7 6
 function generateLanguagesSelectBox() {
8 7
     var currentLang = APP.translation.getCurrentLanguage();
9
-    var html = "<select id=\"languages_selectbox\">";
8
+    var html = '<select id="languages_selectbox">';
10 9
     var langArray = languages.getLanguages();
11 10
     for(var i = 0; i < langArray.length; i++) {
12 11
         var lang = langArray[i];
@@ -99,4 +98,4 @@ var SettingsMenu = {
99 98
 };
100 99
 
101 100
 
102
-module.exports = SettingsMenu;
101
+module.exports = SettingsMenu;

+ 1
- 1
modules/UI/util/UIUtil.js Ver arquivo

@@ -113,4 +113,4 @@ var UIUtil = module.exports = {
113 113
           .join(',');
114 114
         $(selector).hide();
115 115
     }
116
-};
116
+};

+ 2
- 1
service/UI/UIEvents.js Ver arquivo

@@ -33,5 +33,6 @@ export default {
33 33
     TOGGLE_FILM_STRIP: "UI.toggle_film_strip",
34 34
     HANGUP: "UI.hangup",
35 35
     LOGOUT: "UI.logout",
36
-    RECORDING_TOGGLE: "UI.recording_toggle"
36
+    RECORDING_TOGGLE: "UI.recording_toggle",
37
+    TOPIC_CHANGED: "UI.topic_changed"
37 38
 };

Carregando…
Cancelar
Salvar