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 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* global APP, config, $, interfaceConfig */
  2. import UIUtil from '../util/UIUtil';
  3. import Toolbar from './Toolbar';
  4. import SideContainerToggler from "../side_pannels/SideContainerToggler";
  5. import FilmStrip from '../videolayout/FilmStrip.js';
  6. let toolbarTimeoutObject;
  7. let toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  8. /**
  9. * If true the toolbar will be always displayed
  10. */
  11. let alwaysVisibleToolbar = false;
  12. function showDesktopSharingButton() {
  13. if (APP.conference.isDesktopSharingEnabled &&
  14. UIUtil.isButtonEnabled('desktop')) {
  15. $('#toolbar_button_desktopsharing').css({display: "inline-block"});
  16. } else {
  17. $('#toolbar_button_desktopsharing').css({display: "none"});
  18. }
  19. }
  20. /**
  21. * Hides the toolbar.
  22. *
  23. * @param force {true} to force the hiding of the toolbar without caring about
  24. * the extended toolbar side panels.
  25. */
  26. function hideToolbar(force) {
  27. if (alwaysVisibleToolbar) {
  28. return;
  29. }
  30. clearTimeout(toolbarTimeoutObject);
  31. toolbarTimeoutObject = null;
  32. if (Toolbar.isHovered()
  33. || APP.UI.isRingOverlayVisible()
  34. || SideContainerToggler.isVisible()) {
  35. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  36. } else {
  37. Toolbar.hide();
  38. $('#subject').animate({top: "-=40"}, 300);
  39. }
  40. }
  41. const ToolbarToggler = {
  42. /**
  43. * Initializes the ToolbarToggler
  44. */
  45. init() {
  46. alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
  47. // disabled
  48. //this._registerWindowClickListeners();
  49. },
  50. /**
  51. * Registers click listeners handling the show and hode of toolbars when
  52. * user clicks outside of toolbar area.
  53. */
  54. _registerWindowClickListeners() {
  55. $(window).click(function() {
  56. (Toolbar.isEnabled() && Toolbar.isVisible())
  57. ? hideToolbar(true)
  58. : this.showToolbar();
  59. }.bind(this));
  60. Toolbar.registerClickListeners(function(event){
  61. event.stopPropagation();
  62. });
  63. },
  64. /**
  65. * Sets the value of alwaysVisibleToolbar variable.
  66. * @param value {boolean} the new value of alwaysVisibleToolbar variable
  67. */
  68. setAlwaysVisibleToolbar(value) {
  69. alwaysVisibleToolbar = value;
  70. },
  71. /**
  72. * Resets the value of alwaysVisibleToolbar variable to the default one.
  73. */
  74. resetAlwaysVisibleToolbar() {
  75. alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
  76. },
  77. /**
  78. * Shows the main toolbar.
  79. * @param timeout (optional) to specify custom timeout value
  80. */
  81. showToolbar (timeout) {
  82. if (interfaceConfig.filmStripOnly) {
  83. return;
  84. }
  85. var updateTimeout = false;
  86. if (Toolbar.isEnabled() && !Toolbar.isVisible()) {
  87. Toolbar.show();
  88. $('#subject').animate({top: "+=40"}, 300);
  89. updateTimeout = true;
  90. }
  91. if (updateTimeout) {
  92. if (toolbarTimeoutObject) {
  93. clearTimeout(toolbarTimeoutObject);
  94. toolbarTimeoutObject = null;
  95. }
  96. toolbarTimeoutObject
  97. = setTimeout(hideToolbar, timeout || toolbarTimeout);
  98. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  99. }
  100. // Show/hide desktop sharing button
  101. showDesktopSharingButton();
  102. },
  103. /**
  104. * Docks/undocks the toolbar.
  105. *
  106. * @param isDock indicates what operation to perform
  107. */
  108. dockToolbar (isDock) {
  109. if (interfaceConfig.filmStripOnly || !Toolbar.isEnabled()) {
  110. return;
  111. }
  112. if (isDock) {
  113. // First make sure the toolbar is shown.
  114. if (!Toolbar.isVisible()) {
  115. this.showToolbar();
  116. }
  117. // Then clear the time out, to dock the toolbar.
  118. clearTimeout(toolbarTimeoutObject);
  119. toolbarTimeoutObject = null;
  120. } else {
  121. if (Toolbar.isVisible()) {
  122. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  123. } else {
  124. this.showToolbar();
  125. }
  126. }
  127. }
  128. };
  129. module.exports = ToolbarToggler;