Browse Source

refactor ToolbarToggler

master
isymchych 9 years ago
parent
commit
437a8a6ef0
3 changed files with 41 additions and 39 deletions
  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 View File

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

+ 0
- 1
modules/UI/prezi/Prezi.js View File

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

+ 40
- 37
modules/UI/toolbars/ToolbarToggler.js View File

@@ -1,8 +1,9 @@
1 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 8
 function showDesktopSharingButton() {
8 9
     if (APP.desktopsharing.isDesktopSharingEnabled() &&
@@ -13,19 +14,24 @@ function showDesktopSharingButton() {
13 14
     }
14 15
 }
15 16
 
17
+function isToolbarVisible () {
18
+    return $('#header').is(':visible');
19
+}
20
+
16 21
 /**
17 22
  * Hides the toolbar.
18 23
  */
19 24
 function hideToolbar() {
20
-    if(config.alwaysVisibleToolbar)
25
+    if (config.alwaysVisibleToolbar) {
21 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 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 35
             isToolbarHover = true;
30 36
         }
31 37
     });
@@ -36,34 +42,36 @@ function hideToolbar() {
36 42
     clearTimeout(toolbarTimeoutObject);
37 43
     toolbarTimeoutObject = null;
38 44
 
39
-    if (!isToolbarHover) {
45
+    if (isToolbarHover) {
46
+        toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
47
+    } else {
40 48
         header.hide("slide", { direction: "up", duration: 300});
41 49
         $('#subject').animate({top: "-=40"}, 300);
42 50
         if ($("#remoteVideos").hasClass("hidden")) {
43 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 60
      * Shows the main toolbar.
55 61
      */
56
-    showToolbar: function () {
57
-        if (interfaceConfig.filmStripOnly)
62
+    showToolbar () {
63
+        if (interfaceConfig.filmStripOnly) {
58 64
             return;
59
-        var header = $("#header"),
60
-            bottomToolbar = $("#bottomToolbar");
65
+        }
66
+        let header = $("#header");
67
+        let bottomToolbar = $("#bottomToolbar");
61 68
         if (!header.is(':visible') || !bottomToolbar.is(":visible")) {
62 69
             header.show("slide", { direction: "up", duration: 300});
63 70
             $('#subject').animate({top: "+=40"}, 300);
64 71
             if (!bottomToolbar.is(":visible")) {
65 72
                 bottomToolbar.show(
66
-                    "slide", {direction: "right", duration: 300});
73
+                    "slide", {direction: "right", duration: 300}
74
+                );
67 75
             }
68 76
 
69 77
             if (toolbarTimeoutObject) {
@@ -83,33 +91,28 @@ var ToolbarToggler = {
83 91
      *
84 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 96
             return;
97
+        }
89 98
 
90 99
         if (isDock) {
91 100
             // First make sure the toolbar is shown.
92
-            if (!$('#header').is(':visible')) {
101
+            if (!isToolbarVisible()) {
93 102
                 this.showToolbar();
94 103
             }
95 104
 
96 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 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;

Loading…
Cancel
Save