Pārlūkot izejas kodu

refactor ToolbarToggler

master
isymchych 9 gadus atpakaļ
vecāks
revīzija
437a8a6ef0
3 mainītis faili ar 41 papildinājumiem un 39 dzēšanām
  1. 1
    1
      modules/UI/UI.js
  2. 0
    1
      modules/UI/prezi/Prezi.js
  3. 40
    37
      modules/UI/toolbars/ToolbarToggler.js

+ 1
- 1
modules/UI/UI.js Parādīt failu

539
 
539
 
540
 //Used by torture
540
 //Used by torture
541
 UI.dockToolbar = function (isDock) {
541
 UI.dockToolbar = function (isDock) {
542
-    return ToolbarToggler.dockToolbar(isDock);
542
+    ToolbarToggler.dockToolbar(isDock);
543
 };
543
 };
544
 
544
 
545
 UI.setUserAvatar = function (id, email) {
545
 UI.setUserAvatar = function (id, email) {

+ 0
- 1
modules/UI/prezi/Prezi.js Parādīt failu

1
-var ToolbarToggler = require("../toolbars/ToolbarToggler");
2
 var UIUtil = require("../util/UIUtil");
1
 var UIUtil = require("../util/UIUtil");
3
 var VideoLayout = require("../videolayout/VideoLayout");
2
 var VideoLayout = require("../videolayout/VideoLayout");
4
 var messageHandler = require("../util/MessageHandler");
3
 var messageHandler = require("../util/MessageHandler");

+ 40
- 37
modules/UI/toolbars/ToolbarToggler.js Parādīt failu

1
 /* global APP, config, $, interfaceConfig */
1
 /* global APP, config, $, interfaceConfig */
2
 
2
 
3
-var toolbarTimeoutObject,
4
-    toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT,
5
-    UIUtil = require("../util/UIUtil");
3
+import UIUtil from '../util/UIUtil';
4
+
5
+let toolbarTimeoutObject;
6
+let toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
6
 
7
 
7
 function showDesktopSharingButton() {
8
 function showDesktopSharingButton() {
8
     if (APP.desktopsharing.isDesktopSharingEnabled() &&
9
     if (APP.desktopsharing.isDesktopSharingEnabled() &&
13
     }
14
     }
14
 }
15
 }
15
 
16
 
17
+function isToolbarVisible () {
18
+    return $('#header').is(':visible');
19
+}
20
+
16
 /**
21
 /**
17
  * Hides the toolbar.
22
  * Hides the toolbar.
18
  */
23
  */
19
 function hideToolbar() {
24
 function hideToolbar() {
20
-    if(config.alwaysVisibleToolbar)
25
+    if (config.alwaysVisibleToolbar) {
21
         return;
26
         return;
27
+    }
22
 
28
 
23
-    var header = $("#header"),
24
-        bottomToolbar = $("#bottomToolbar");
25
-    var isToolbarHover = false;
29
+    let header = $("#header");
30
+    let bottomToolbar = $("#bottomToolbar");
31
+    let isToolbarHover = false;
26
     header.find('*').each(function () {
32
     header.find('*').each(function () {
27
-        var id = $(this).attr('id');
28
-        if ($("#" + id + ":hover").length > 0) {
33
+        let id = $(this).attr('id');
34
+        if ($(`#${id}:hover`).length > 0) {
29
             isToolbarHover = true;
35
             isToolbarHover = true;
30
         }
36
         }
31
     });
37
     });
36
     clearTimeout(toolbarTimeoutObject);
42
     clearTimeout(toolbarTimeoutObject);
37
     toolbarTimeoutObject = null;
43
     toolbarTimeoutObject = null;
38
 
44
 
39
-    if (!isToolbarHover) {
45
+    if (isToolbarHover) {
46
+        toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
47
+    } else {
40
         header.hide("slide", { direction: "up", duration: 300});
48
         header.hide("slide", { direction: "up", duration: 300});
41
         $('#subject').animate({top: "-=40"}, 300);
49
         $('#subject').animate({top: "-=40"}, 300);
42
         if ($("#remoteVideos").hasClass("hidden")) {
50
         if ($("#remoteVideos").hasClass("hidden")) {
43
             bottomToolbar.hide(
51
             bottomToolbar.hide(
44
-                "slide", {direction: "right", duration: 300});
52
+                "slide", {direction: "right", duration: 300}
53
+            );
45
         }
54
         }
46
     }
55
     }
47
-    else {
48
-        toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
49
-    }
50
 }
56
 }
51
 
57
 
52
-var ToolbarToggler = {
58
+const ToolbarToggler = {
53
     /**
59
     /**
54
      * Shows the main toolbar.
60
      * Shows the main toolbar.
55
      */
61
      */
56
-    showToolbar: function () {
57
-        if (interfaceConfig.filmStripOnly)
62
+    showToolbar () {
63
+        if (interfaceConfig.filmStripOnly) {
58
             return;
64
             return;
59
-        var header = $("#header"),
60
-            bottomToolbar = $("#bottomToolbar");
65
+        }
66
+        let header = $("#header");
67
+        let bottomToolbar = $("#bottomToolbar");
61
         if (!header.is(':visible') || !bottomToolbar.is(":visible")) {
68
         if (!header.is(':visible') || !bottomToolbar.is(":visible")) {
62
             header.show("slide", { direction: "up", duration: 300});
69
             header.show("slide", { direction: "up", duration: 300});
63
             $('#subject').animate({top: "+=40"}, 300);
70
             $('#subject').animate({top: "+=40"}, 300);
64
             if (!bottomToolbar.is(":visible")) {
71
             if (!bottomToolbar.is(":visible")) {
65
                 bottomToolbar.show(
72
                 bottomToolbar.show(
66
-                    "slide", {direction: "right", duration: 300});
73
+                    "slide", {direction: "right", duration: 300}
74
+                );
67
             }
75
             }
68
 
76
 
69
             if (toolbarTimeoutObject) {
77
             if (toolbarTimeoutObject) {
83
      *
91
      *
84
      * @param isDock indicates what operation to perform
92
      * @param isDock indicates what operation to perform
85
      */
93
      */
86
-    dockToolbar: function (isDock) {
87
-        if (interfaceConfig.filmStripOnly)
94
+    dockToolbar (isDock) {
95
+        if (interfaceConfig.filmStripOnly) {
88
             return;
96
             return;
97
+        }
89
 
98
 
90
         if (isDock) {
99
         if (isDock) {
91
             // First make sure the toolbar is shown.
100
             // First make sure the toolbar is shown.
92
-            if (!$('#header').is(':visible')) {
101
+            if (!isToolbarVisible()) {
93
                 this.showToolbar();
102
                 this.showToolbar();
94
             }
103
             }
95
 
104
 
96
             // Then clear the time out, to dock the toolbar.
105
             // Then clear the time out, to dock the toolbar.
97
-            if (toolbarTimeoutObject) {
98
-                clearTimeout(toolbarTimeoutObject);
99
-                toolbarTimeoutObject = null;
100
-            }
101
-        }
102
-        else {
103
-            if (!$('#header').is(':visible')) {
104
-                this.showToolbar();
105
-            }
106
-            else {
106
+            clearTimeout(toolbarTimeoutObject);
107
+            toolbarTimeoutObject = null;
108
+        } else {
109
+            if (isToolbarVisible()) {
107
                 toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
110
                 toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
111
+            } else {
112
+                this.showToolbar();
108
             }
113
             }
109
         }
114
         }
110
-    },
111
-
112
-    showDesktopSharingButton: showDesktopSharingButton
115
+    }
113
 };
116
 };
114
 
117
 
115
-module.exports = ToolbarToggler;
118
+module.exports = ToolbarToggler;

Notiek ielāde…
Atcelt
Saglabāt