You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ToolbarToggler.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright @ 2015 Atlassian Pty Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* global $, interfaceConfig, Moderator, DesktopStreaming.showDesktopSharingButton */
  17. var toolbarTimeoutObject,
  18. toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  19. function showDesktopSharingButton() {
  20. if (APP.desktopsharing.isDesktopSharingEnabled()) {
  21. $('#desktopsharing').css({display: "inline"});
  22. } else {
  23. $('#desktopsharing').css({display: "none"});
  24. }
  25. }
  26. /**
  27. * Hides the toolbar.
  28. */
  29. function hideToolbar() {
  30. if(config.alwaysVisibleToolbar)
  31. return;
  32. var header = $("#header"),
  33. bottomToolbar = $("#bottomToolbar");
  34. var isToolbarHover = false;
  35. header.find('*').each(function () {
  36. var id = $(this).attr('id');
  37. if ($("#" + id + ":hover").length > 0) {
  38. isToolbarHover = true;
  39. }
  40. });
  41. if ($("#bottomToolbar:hover").length > 0) {
  42. isToolbarHover = true;
  43. }
  44. clearTimeout(toolbarTimeoutObject);
  45. toolbarTimeoutObject = null;
  46. if (!isToolbarHover) {
  47. header.hide("slide", { direction: "up", duration: 300});
  48. $('#subject').animate({top: "-=40"}, 300);
  49. if ($("#remoteVideos").hasClass("hidden")) {
  50. bottomToolbar.hide(
  51. "slide", {direction: "right", duration: 300});
  52. }
  53. }
  54. else {
  55. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  56. }
  57. }
  58. var ToolbarToggler = {
  59. /**
  60. * Shows the main toolbar.
  61. */
  62. showToolbar: function () {
  63. var header = $("#header"),
  64. bottomToolbar = $("#bottomToolbar");
  65. if (!header.is(':visible') || !bottomToolbar.is(":visible")) {
  66. header.show("slide", { direction: "up", duration: 300});
  67. $('#subject').animate({top: "+=40"}, 300);
  68. if (!bottomToolbar.is(":visible")) {
  69. bottomToolbar.show(
  70. "slide", {direction: "right", duration: 300});
  71. }
  72. if (toolbarTimeoutObject) {
  73. clearTimeout(toolbarTimeoutObject);
  74. toolbarTimeoutObject = null;
  75. }
  76. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  77. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  78. }
  79. if (APP.xmpp.isModerator())
  80. {
  81. // TODO: Enable settings functionality.
  82. // Need to uncomment the settings button in index.html.
  83. // $('#settingsButton').css({visibility:"visible"});
  84. }
  85. // Show/hide desktop sharing button
  86. showDesktopSharingButton();
  87. },
  88. /**
  89. * Docks/undocks the toolbar.
  90. *
  91. * @param isDock indicates what operation to perform
  92. */
  93. dockToolbar: function (isDock) {
  94. if (isDock) {
  95. // First make sure the toolbar is shown.
  96. if (!$('#header').is(':visible')) {
  97. this.showToolbar();
  98. }
  99. // Then clear the time out, to dock the toolbar.
  100. if (toolbarTimeoutObject) {
  101. clearTimeout(toolbarTimeoutObject);
  102. toolbarTimeoutObject = null;
  103. }
  104. }
  105. else {
  106. if (!$('#header').is(':visible')) {
  107. this.showToolbar();
  108. }
  109. else {
  110. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  111. }
  112. }
  113. },
  114. showDesktopSharingButton: showDesktopSharingButton
  115. };
  116. module.exports = ToolbarToggler;