Browse Source

do not use xmpp module in side_panels module

master
isymchych 10 years ago
parent
commit
de9d991f98

+ 6
- 0
app.js View File

415
         // }, APP.UI.updateRecordingState);
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
     room.on(ConferenceEvents.DTMF_SUPPORT_CHANGED, function (isDTMFSupported) {
424
     room.on(ConferenceEvents.DTMF_SUPPORT_CHANGED, function (isDTMFSupported) {
419
         APP.UI.updateDTMFSupport(isDTMFSupported);
425
         APP.UI.updateDTMFSupport(isDTMFSupported);
420
     });
426
     });

+ 9
- 9
modules/UI/UI.js View File

2
 /* jshint -W101 */
2
 /* jshint -W101 */
3
 var UI = {};
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
 var Toolbar = require("./toolbars/Toolbar");
10
 var Toolbar = require("./toolbars/Toolbar");
11
 var ToolbarToggler = require("./toolbars/ToolbarToggler");
11
 var ToolbarToggler = require("./toolbars/ToolbarToggler");
12
 var BottomToolbar = require("./toolbars/BottomToolbar");
12
 var BottomToolbar = require("./toolbars/BottomToolbar");
219
 
219
 
220
 function bindEvents() {
220
 function bindEvents() {
221
     function onResize() {
221
     function onResize() {
222
-        Chat.resizeChat();
222
+        PanelToggler.resizeChat();
223
         VideoLayout.resizeLargeVideoContainer();
223
         VideoLayout.resizeLargeVideoContainer();
224
     }
224
     }
225
 
225
 
344
     return Chat.chatAddError(errorMessage, originalText);
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
 function initEtherpad(name) {
351
 function initEtherpad(name) {
352
     Etherpad.init(name);
352
     Etherpad.init(name);

+ 108
- 104
modules/UI/side_pannels/SidePanelToggler.js View File

1
 /* global require, $ */
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
      * Opens / closes the chat area.
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
         VideoLayout.resizeVideoArea(!Chat.isVisible(), chatCompleteFunction);
100
         VideoLayout.resizeVideoArea(!Chat.isVisible(), chatCompleteFunction);
102
 
101
 
112
                 }
111
                 }
113
             },
112
             },
114
             null,
113
             null,
115
-            Chat.resizeChat,
114
+            () => this.resizeChat(),
116
             null);
115
             null);
117
-    };
116
+    },
117
+
118
+    resizeChat () {
119
+        let [width, height] = this.getPanelSize();
120
+        Chat.resizeChat(width, height);
121
+    },
118
 
122
 
119
     /**
123
     /**
120
      * Opens / closes the contact list area.
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
         VideoLayout.resizeVideoArea(!ContactList.isVisible(), completeFunction);
132
         VideoLayout.resizeVideoArea(!ContactList.isVisible(), completeFunction);
126
 
133
 
127
         toggle(ContactList,
134
         toggle(ContactList,
131
                 ContactList.setVisualNotification(false);
138
                 ContactList.setVisualNotification(false);
132
             },
139
             },
133
             null);
140
             null);
134
-    };
141
+    },
135
 
142
 
136
     /**
143
     /**
137
      * Opens / closes the settings menu
144
      * Opens / closes the settings menu
138
      */
145
      */
139
-    my.toggleSettingsMenu = function() {
146
+    toggleSettingsMenu () {
140
         VideoLayout.resizeVideoArea(!SettingsMenu.isVisible(), function (){});
147
         VideoLayout.resizeVideoArea(!SettingsMenu.isVisible(), function (){});
141
         toggle(SettingsMenu,
148
         toggle(SettingsMenu,
142
             '#settingsmenu',
149
             '#settingsmenu',
147
                 $('#setEmail').get(0).value = settings.email;
154
                 $('#setEmail').get(0).value = settings.email;
148
             },
155
             },
149
             null);
156
             null);
150
-    };
157
+    },
151
 
158
 
152
     /**
159
     /**
153
      * Returns the size of the side panel.
160
      * Returns the size of the side panel.
154
      */
161
      */
155
-    my.getPanelSize = function () {
162
+    getPanelSize () {
156
         var availableHeight = window.innerHeight;
163
         var availableHeight = window.innerHeight;
157
         var availableWidth = window.innerWidth;
164
         var availableWidth = window.innerWidth;
158
 
165
 
162
         }
169
         }
163
 
170
 
164
         return [panelWidth, availableHeight];
171
         return [panelWidth, availableHeight];
165
-    };
172
+    },
166
 
173
 
167
-    my.isVisible = function() {
174
+    isVisible () {
168
         return (Chat.isVisible() ||
175
         return (Chat.isVisible() ||
169
                 ContactList.isVisible() ||
176
                 ContactList.isVisible() ||
170
                 SettingsMenu.isVisible());
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 View File

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

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
  * List with supported commands. The keys are the names of the commands and
6
  * List with supported commands. The keys are the names of the commands and
6
  * the value is the function that processes the message.
7
  * the value is the function that processes the message.
7
  * @type {{String: function}}
8
  * @type {{String: function}}
8
  */
9
  */
9
-var commands = {
10
+const commands = {
10
     "topic" : processTopic
11
     "topic" : processTopic
11
 };
12
 };
12
 
13
 
29
  * Processes the data for topic command.
30
  * Processes the data for topic command.
30
  * @param commandArguments the arguments of the topic command.
31
  * @param commandArguments the arguments of the topic command.
31
  */
32
  */
32
-function processTopic(commandArguments) {
33
+function processTopic(commandArguments, emitter) {
33
     var topic = UIUtil.escapeHtml(commandArguments);
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
  * @param message the message
41
  * @param message the message
41
  * @constructor
42
  * @constructor
42
  */
43
  */
43
-function CommandsProcessor(message) {
44
+function CommandsProcessor(message, emitter) {
44
     var command = getCommand(message);
45
     var command = getCommand(message);
45
 
46
 
47
+    this.emitter = emitter;
48
+
46
     /**
49
     /**
47
      * Returns the name of the command.
50
      * Returns the name of the command.
48
      * @returns {String} the command
51
      * @returns {String} the command
80
     if(!this.isCommand())
83
     if(!this.isCommand())
81
         return;
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 View File

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

1
-/* global $, APP, Strophe */
2
-var Avatar = require('../../avatar/Avatar');
1
+/* global $, APP */
2
+import Avatar from '../../avatar/Avatar';
3
 
3
 
4
 var numberOfContacts = 0;
4
 var numberOfContacts = 0;
5
 var notificationInterval;
5
 var notificationInterval;
44
  */
44
  */
45
 function createDisplayNameParagraph(key, displayName) {
45
 function createDisplayNameParagraph(key, displayName) {
46
     var p = document.createElement('p');
46
     var p = document.createElement('p');
47
-    if(displayName)
47
+    if (displayName) {
48
         p.innerText = displayName;
48
         p.innerText = displayName;
49
-    else if(key) {
49
+    } else if(key) {
50
         p.setAttribute("data-i18n",key);
50
         p.setAttribute("data-i18n",key);
51
         p.innerText = APP.translation.translateString(key);
51
         p.innerText = APP.translation.translateString(key);
52
     }
52
     }
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
  * Contact list.
76
  * Contact list.
69
  */
77
  */
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
         var contactlist = $('#contacts');
104
         var contactlist = $('#contacts');
104
 
105
 
105
         var newContact = document.createElement('li');
106
         var newContact = document.createElement('li');
106
-        newContact.id = resourceJid;
107
+        newContact.id = id;
107
         newContact.className = "clickable";
108
         newContact.className = "clickable";
108
         newContact.onclick = function (event) {
109
         newContact.onclick = function (event) {
109
             if (event.currentTarget.className === "clickable") {
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
         newContact.appendChild(createDisplayNameParagraph("participant"));
116
         newContact.appendChild(createDisplayNameParagraph("participant"));
116
 
117
 
117
-        if (resourceJid === APP.xmpp.myResource()) {
118
+        if (APP.conference.isLocalId(id)) {
118
             contactlist.prepend(newContact);
119
             contactlist.prepend(newContact);
119
-        }
120
-        else {
120
+        } else {
121
             contactlist.append(newContact);
121
             contactlist.append(newContact);
122
         }
122
         }
123
         updateNumberOfParticipants(1);
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
             updateNumberOfParticipants(-1);
135
             updateNumberOfParticipants(-1);
142
         }
136
         }
143
     },
137
     },
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
     onDisplayNameChange: function (id, displayName) {
161
     onDisplayNameChange: function (id, displayName) {
173
         if (id === 'localVideoContainer') {
162
         if (id === 'localVideoContainer') {
174
             id = APP.conference.localId;
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
             contactName.html(displayName);
168
             contactName.html(displayName);
180
         }
169
         }
181
     },
170
     },
182
 
171
 
183
     changeUserAvatar: function (id, contactListUrl) {
172
     changeUserAvatar: function (id, contactListUrl) {
184
         // set the avatar in the contact list
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 View File

1
 /* global APP, $ */
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
 function generateLanguagesSelectBox() {
6
 function generateLanguagesSelectBox() {
8
     var currentLang = APP.translation.getCurrentLanguage();
7
     var currentLang = APP.translation.getCurrentLanguage();
9
-    var html = "<select id=\"languages_selectbox\">";
8
+    var html = '<select id="languages_selectbox">';
10
     var langArray = languages.getLanguages();
9
     var langArray = languages.getLanguages();
11
     for(var i = 0; i < langArray.length; i++) {
10
     for(var i = 0; i < langArray.length; i++) {
12
         var lang = langArray[i];
11
         var lang = langArray[i];
99
 };
98
 };
100
 
99
 
101
 
100
 
102
-module.exports = SettingsMenu;
101
+module.exports = SettingsMenu;

+ 1
- 1
modules/UI/util/UIUtil.js View File

113
           .join(',');
113
           .join(',');
114
         $(selector).hide();
114
         $(selector).hide();
115
     }
115
     }
116
-};
116
+};

+ 2
- 1
service/UI/UIEvents.js View File

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

Loading…
Cancel
Save