Procházet zdrojové kódy

refactor BottomToolbar

j8
isymchych před 9 roky
rodič
revize
e23dd62d86

+ 7
- 6
modules/UI/UI.js Zobrazit soubor

@@ -188,10 +188,6 @@ function registerListeners() {
188 188
         AudioLevels.init();
189 189
     });
190 190
 
191
-    UI.addListener(UIEvents.FILM_STRIP_TOGGLED, function (isToggled) {
192
-        VideoLayout.onFilmStripToggled(isToggled);
193
-    });
194
-
195 191
     UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
196 192
         UI.setUserAvatar(APP.conference.localId, email);
197 193
     });
@@ -215,6 +211,10 @@ function registerListeners() {
215 211
     UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
216 212
         PanelToggler.toggleSettingsMenu();
217 213
     });
214
+
215
+    UI.addListener(UIEvents.TOGGLE_CONTACT_LIST, UI.toggleContactList);
216
+
217
+    UI.addListener(UIEvents.TOGGLE_FILM_STRIP, UI.toggleFilmStrip);
218 218
 }
219 219
 
220 220
 function bindEvents() {
@@ -446,14 +446,15 @@ UI.getSettings = function () {
446 446
 
447 447
 UI.toggleFilmStrip = function () {
448 448
     BottomToolbar.toggleFilmStrip();
449
+    VideoLayout.updateLargeVideoSize();
449 450
 };
450 451
 
451 452
 UI.toggleChat = function () {
452
-    BottomToolbar.toggleChat();
453
+    PanelToggler.toggleChat();
453 454
 };
454 455
 
455 456
 UI.toggleContactList = function () {
456
-    BottomToolbar.toggleContactList();
457
+    PanelToggler.toggleContactList();
457 458
 };
458 459
 
459 460
 UI.inputDisplayNameHandler = function (value) {

+ 38
- 56
modules/UI/toolbars/BottomToolbar.js Zobrazit soubor

@@ -1,66 +1,48 @@
1 1
 /* global $ */
2
-var PanelToggler = require("../side_pannels/SidePanelToggler");
3
-var UIUtil = require("../util/UIUtil");
4
-var AnalyticsAdapter = require("../../statistics/AnalyticsAdapter");
5
-var UIEvents = require("../../../service/UI/UIEvents");
2
+import UIUtil from '../util/UIUtil';
3
+import UIEvents from '../../../service/UI/UIEvents';
4
+import AnalyticsAdapter from '../../statistics/AnalyticsAdapter';
6 5
 
7
-var eventEmitter = null;
8
-
9
-var buttonHandlers = {
10
-    "bottom_toolbar_contact_list": function () {
11
-        AnalyticsAdapter.sendEvent('bottomtoolbar.contacts.toggled');
12
-        BottomToolbar.toggleContactList();
13
-    },
14
-    "bottom_toolbar_film_strip": function () {
15
-        AnalyticsAdapter.sendEvent('bottomtoolbar.filmstrip.toggled');
16
-        BottomToolbar.toggleFilmStrip();
17
-    },
18
-    "bottom_toolbar_chat": function () {
19
-        AnalyticsAdapter.sendEvent('bottomtoolbar.chat.toggled');
20
-        BottomToolbar.toggleChat();
21
-    }
22
-};
23
-
24
-
25
-var defaultBottomToolbarButtons = {
26
-    'chat': '#bottom_toolbar_chat',
27
-    'contacts': '#bottom_toolbar_contact_list',
6
+const defaultBottomToolbarButtons = {
7
+    'chat':      '#bottom_toolbar_chat',
8
+    'contacts':  '#bottom_toolbar_contact_list',
28 9
     'filmstrip': '#bottom_toolbar_film_strip'
29 10
 };
30 11
 
12
+$(document).bind("remotevideo.resized", function (event, width, height) {
13
+    let toolbar = $('#bottomToolbar');
14
+    let bottom = (height - toolbar.outerHeight())/2 + 18;
31 15
 
32
-var BottomToolbar = (function (my) {
33
-    my.init = function (emitter) {
34
-        eventEmitter = emitter;
35
-        UIUtil.hideDisabledButtons(defaultBottomToolbarButtons);
36
-
37
-        for(var k in buttonHandlers)
38
-            $("#" + k).click(buttonHandlers[k]);
39
-    };
16
+    toolbar.css({bottom});
17
+});
40 18
 
41
-    my.toggleChat = function() {
42
-        PanelToggler.toggleChat();
43
-    };
44
-
45
-    my.toggleContactList = function() {
46
-        PanelToggler.toggleContactList();
47
-    };
48
-
49
-    my.toggleFilmStrip = function() {
50
-        var filmstrip = $("#remoteVideos");
51
-        filmstrip.toggleClass("hidden");
52
-
53
-        eventEmitter.emit(  UIEvents.FILM_STRIP_TOGGLED,
54
-                            filmstrip.hasClass("hidden"));
55
-    };
56
-
57
-    $(document).bind("remotevideo.resized", function (event, width, height) {
58
-        var bottom = (height - $('#bottomToolbar').outerHeight())/2 + 18;
19
+const BottomToolbar = {
20
+    init (emitter) {
21
+        UIUtil.hideDisabledButtons(defaultBottomToolbarButtons);
59 22
 
60
-        $('#bottomToolbar').css({bottom: bottom + 'px'});
61
-    });
23
+        const buttonHandlers = {
24
+            "bottom_toolbar_contact_list": function () {
25
+                AnalyticsAdapter.sendEvent('bottomtoolbar.contacts.toggled');
26
+                emitter.emit(UIEvents.TOGGLE_CONTACT_LIST);
27
+            },
28
+            "bottom_toolbar_film_strip": function () {
29
+                AnalyticsAdapter.sendEvent('bottomtoolbar.filmstrip.toggled');
30
+                emitter.emit(UIEvents.TOGGLE_FILM_STRIP);
31
+            },
32
+            "bottom_toolbar_chat": function () {
33
+                AnalyticsAdapter.sendEvent('bottomtoolbar.chat.toggled');
34
+                emitter.emit(UIEvents.TOGGLE_CHAT);
35
+            }
36
+        };
37
+
38
+        Object.keys(buttonHandlers).forEach(
39
+            buttonId => $(`#${buttonId}`).click(buttonHandlers[buttonId])
40
+        );
41
+    },
62 42
 
63
-    return my;
64
-}(BottomToolbar || {}));
43
+    toggleFilmStrip () {
44
+        $("#remoteVideos").toggleClass("hidden");
45
+    }
46
+};
65 47
 
66
-module.exports = BottomToolbar;
48
+export default BottomToolbar;

+ 27
- 25
modules/UI/toolbars/Toolbar.js Zobrazit soubor

@@ -1,20 +1,20 @@
1 1
 /* global APP, $, config, interfaceConfig */
2 2
 /* jshint -W101 */
3
-var messageHandler = require("../util/MessageHandler");
4
-var UIUtil = require("../util/UIUtil");
5
-var AnalyticsAdapter = require("../../statistics/AnalyticsAdapter");
6
-var UIEvents = require("../../../service/UI/UIEvents");
3
+import messageHandler from '../util/MessageHandler';
4
+import UIUtil from '../util/UIUtil';
5
+import AnalyticsAdapter from '../../statistics/AnalyticsAdapter';
6
+import UIEvents from '../../../service/UI/UIEvents';
7 7
 
8
-var roomUrl = null;
9
-var recordingToaster = null;
10
-var emitter = null;
8
+let roomUrl = null;
9
+let recordingToaster = null;
10
+let emitter = null;
11 11
 
12 12
 
13 13
 /**
14 14
  * Opens the invite link dialog.
15 15
  */
16 16
 function openLinkDialog () {
17
-    var inviteAttributes;
17
+    let inviteAttributes;
18 18
 
19 19
     if (roomUrl === null) {
20 20
         inviteAttributes = 'data-i18n="[value]roomUrlDefaultMsg" value="' +
@@ -181,18 +181,18 @@ const buttonHandlers = {
181 181
         );
182 182
     }
183 183
 };
184
-var defaultToolbarButtons = {
185
-    'microphone': '#toolbar_button_mute',
186
-    'camera': '#toolbar_button_camera',
187
-    'desktop': '#toolbar_button_desktopsharing',
188
-    'security': '#toolbar_button_security',
189
-    'invite': '#toolbar_button_link',
190
-    'chat': '#toolbar_button_chat',
191
-    'prezi': '#toolbar_button_prezi',
192
-    'etherpad': '#toolbar_button_etherpad',
193
-    'fullscreen': '#toolbar_button_fullScreen',
194
-    'settings': '#toolbar_button_settings',
195
-    'hangup': '#toolbar_button_hangup'
184
+const defaultToolbarButtons = {
185
+  'microphone': '#toolbar_button_mute',
186
+  'camera':     '#toolbar_button_camera',
187
+  'desktop':    '#toolbar_button_desktopsharing',
188
+  'security':   '#toolbar_button_security',
189
+  'invite':     '#toolbar_button_link',
190
+  'chat':       '#toolbar_button_chat',
191
+  'prezi':      '#toolbar_button_prezi',
192
+  'etherpad':   '#toolbar_button_etherpad',
193
+  'fullscreen': '#toolbar_button_fullScreen',
194
+  'settings':   '#toolbar_button_settings',
195
+  'hangup':     '#toolbar_button_hangup'
196 196
 };
197 197
 
198 198
 function dialpadButtonClicked() {
@@ -222,10 +222,12 @@ function showSipNumberInput () {
222 222
 const Toolbar = {
223 223
     init (eventEmitter) {
224 224
         emitter = eventEmitter;
225
+
225 226
         UIUtil.hideDisabledButtons(defaultToolbarButtons);
226 227
 
227
-        for(var k in buttonHandlers)
228
-            $("#" + k).click(buttonHandlers[k]);
228
+        Object.keys(buttonHandlers).forEach(
229
+            buttonId => $(`#${buttonId}`).click(buttonHandlers[buttonId])
230
+        );
229 231
     },
230 232
 
231 233
     /**
@@ -235,7 +237,7 @@ const Toolbar = {
235 237
         roomUrl = newRoomUrl;
236 238
 
237 239
         // If the invite dialog has been already opened we update the information.
238
-        var inviteLink = document.getElementById('inviteLinkRef');
240
+        let inviteLink = document.getElementById('inviteLinkRef');
239 241
         if (inviteLink) {
240 242
             inviteLink.value = roomUrl;
241 243
             inviteLink.select();
@@ -333,7 +335,7 @@ const Toolbar = {
333 335
      */
334 336
     setAuthenticatedIdentity (authIdentity) {
335 337
         if (authIdentity) {
336
-            var selector = $('#toolbar_auth_identity');
338
+            let selector = $('#toolbar_auth_identity');
337 339
             selector.css({display: "list-item"});
338 340
             selector.text(authIdentity);
339 341
         } else {
@@ -371,7 +373,7 @@ const Toolbar = {
371 373
      * @param active the state of the desktop streaming.
372 374
      */
373 375
     changeDesktopSharingButtonState (active) {
374
-        var button = $("#toolbar_button_desktopsharing");
376
+        let button = $("#toolbar_button_desktopsharing");
375 377
         if (active) {
376 378
             button.addClass("glow");
377 379
         } else {

+ 2
- 5
modules/UI/videolayout/VideoLayout.js Zobrazit soubor

@@ -900,12 +900,9 @@ var VideoLayout = (function (my) {
900 900
     };
901 901
 
902 902
     /**
903
-     * Updates the video size and position when the film strip is toggled.
904
-     *
905
-     * @param isToggled indicates if the film strip is toggled or not. True
906
-     * would mean that the film strip is hidden, false would mean it's shown
903
+     * Updates the video size and position.
907 904
      */
908
-    my.onFilmStripToggled = function(isToggled) {
905
+    my.updateLargeVideoSize = function () {
909 906
         LargeVideo.updateVideoSizeAndPosition();
910 907
         LargeVideo.position(null, null, null, null, true);
911 908
     };

+ 3
- 6
service/UI/UIEvents.js Zobrazit soubor

@@ -29,12 +29,9 @@ export default {
29 29
     AUTH_CLICKED: "UI.auth_clicked",
30 30
     TOGGLE_CHAT: "UI.toggle_chat",
31 31
     TOGGLE_SETTINGS: "UI.toggle_settings",
32
+    TOGGLE_CONTACT_LIST: "UI.toggle_contact_list",
33
+    TOGGLE_FILM_STRIP: "UI.toggle_film_strip",
32 34
     HANGUP: "UI.hangup",
33 35
     LOGOUT: "UI.logout",
34
-    RECORDING_TOGGLE: "UI.recording_toggle",
35
-    /**
36
-     * Notifies interested parties when the film strip (remote video's panel)
37
-     * is hidden (toggled) or shown (un-toggled).
38
-     */
39
-    FILM_STRIP_TOGGLED: "UI.filmstrip_toggled"
36
+    RECORDING_TOGGLE: "UI.recording_toggle"
40 37
 };

Načítá se…
Zrušit
Uložit