瀏覽代碼

refactor BottomToolbar

master
isymchych 9 年之前
父節點
當前提交
e23dd62d86
共有 5 個檔案被更改,包括 77 行新增98 行删除
  1. 7
    6
      modules/UI/UI.js
  2. 38
    56
      modules/UI/toolbars/BottomToolbar.js
  3. 27
    25
      modules/UI/toolbars/Toolbar.js
  4. 2
    5
      modules/UI/videolayout/VideoLayout.js
  5. 3
    6
      service/UI/UIEvents.js

+ 7
- 6
modules/UI/UI.js 查看文件

188
         AudioLevels.init();
188
         AudioLevels.init();
189
     });
189
     });
190
 
190
 
191
-    UI.addListener(UIEvents.FILM_STRIP_TOGGLED, function (isToggled) {
192
-        VideoLayout.onFilmStripToggled(isToggled);
193
-    });
194
-
195
     UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
191
     UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
196
         UI.setUserAvatar(APP.conference.localId, email);
192
         UI.setUserAvatar(APP.conference.localId, email);
197
     });
193
     });
215
     UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
211
     UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
216
         PanelToggler.toggleSettingsMenu();
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
 function bindEvents() {
220
 function bindEvents() {
446
 
446
 
447
 UI.toggleFilmStrip = function () {
447
 UI.toggleFilmStrip = function () {
448
     BottomToolbar.toggleFilmStrip();
448
     BottomToolbar.toggleFilmStrip();
449
+    VideoLayout.updateLargeVideoSize();
449
 };
450
 };
450
 
451
 
451
 UI.toggleChat = function () {
452
 UI.toggleChat = function () {
452
-    BottomToolbar.toggleChat();
453
+    PanelToggler.toggleChat();
453
 };
454
 };
454
 
455
 
455
 UI.toggleContactList = function () {
456
 UI.toggleContactList = function () {
456
-    BottomToolbar.toggleContactList();
457
+    PanelToggler.toggleContactList();
457
 };
458
 };
458
 
459
 
459
 UI.inputDisplayNameHandler = function (value) {
460
 UI.inputDisplayNameHandler = function (value) {

+ 38
- 56
modules/UI/toolbars/BottomToolbar.js 查看文件

1
 /* global $ */
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
     'filmstrip': '#bottom_toolbar_film_strip'
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 查看文件

1
 /* global APP, $, config, interfaceConfig */
1
 /* global APP, $, config, interfaceConfig */
2
 /* jshint -W101 */
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
  * Opens the invite link dialog.
14
  * Opens the invite link dialog.
15
  */
15
  */
16
 function openLinkDialog () {
16
 function openLinkDialog () {
17
-    var inviteAttributes;
17
+    let inviteAttributes;
18
 
18
 
19
     if (roomUrl === null) {
19
     if (roomUrl === null) {
20
         inviteAttributes = 'data-i18n="[value]roomUrlDefaultMsg" value="' +
20
         inviteAttributes = 'data-i18n="[value]roomUrlDefaultMsg" value="' +
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
 function dialpadButtonClicked() {
198
 function dialpadButtonClicked() {
222
 const Toolbar = {
222
 const Toolbar = {
223
     init (eventEmitter) {
223
     init (eventEmitter) {
224
         emitter = eventEmitter;
224
         emitter = eventEmitter;
225
+
225
         UIUtil.hideDisabledButtons(defaultToolbarButtons);
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
         roomUrl = newRoomUrl;
237
         roomUrl = newRoomUrl;
236
 
238
 
237
         // If the invite dialog has been already opened we update the information.
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
         if (inviteLink) {
241
         if (inviteLink) {
240
             inviteLink.value = roomUrl;
242
             inviteLink.value = roomUrl;
241
             inviteLink.select();
243
             inviteLink.select();
333
      */
335
      */
334
     setAuthenticatedIdentity (authIdentity) {
336
     setAuthenticatedIdentity (authIdentity) {
335
         if (authIdentity) {
337
         if (authIdentity) {
336
-            var selector = $('#toolbar_auth_identity');
338
+            let selector = $('#toolbar_auth_identity');
337
             selector.css({display: "list-item"});
339
             selector.css({display: "list-item"});
338
             selector.text(authIdentity);
340
             selector.text(authIdentity);
339
         } else {
341
         } else {
371
      * @param active the state of the desktop streaming.
373
      * @param active the state of the desktop streaming.
372
      */
374
      */
373
     changeDesktopSharingButtonState (active) {
375
     changeDesktopSharingButtonState (active) {
374
-        var button = $("#toolbar_button_desktopsharing");
376
+        let button = $("#toolbar_button_desktopsharing");
375
         if (active) {
377
         if (active) {
376
             button.addClass("glow");
378
             button.addClass("glow");
377
         } else {
379
         } else {

+ 2
- 5
modules/UI/videolayout/VideoLayout.js 查看文件

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
         LargeVideo.updateVideoSizeAndPosition();
906
         LargeVideo.updateVideoSizeAndPosition();
910
         LargeVideo.position(null, null, null, null, true);
907
         LargeVideo.position(null, null, null, null, true);
911
     };
908
     };

+ 3
- 6
service/UI/UIEvents.js 查看文件

29
     AUTH_CLICKED: "UI.auth_clicked",
29
     AUTH_CLICKED: "UI.auth_clicked",
30
     TOGGLE_CHAT: "UI.toggle_chat",
30
     TOGGLE_CHAT: "UI.toggle_chat",
31
     TOGGLE_SETTINGS: "UI.toggle_settings",
31
     TOGGLE_SETTINGS: "UI.toggle_settings",
32
+    TOGGLE_CONTACT_LIST: "UI.toggle_contact_list",
33
+    TOGGLE_FILM_STRIP: "UI.toggle_film_strip",
32
     HANGUP: "UI.hangup",
34
     HANGUP: "UI.hangup",
33
     LOGOUT: "UI.logout",
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
 };

Loading…
取消
儲存