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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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() || APP.UI.isRingOverlayVisible()) {
  33. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  34. } else if (!SideContainerToggler.isVisible() || force) {
  35. Toolbar.hide();
  36. $('#subject').animate({top: "-=40"}, 300);
  37. }
  38. }
  39. const ToolbarToggler = {
  40. /**
  41. * Initializes the ToolbarToggler
  42. */
  43. init() {
  44. alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
  45. this._registerWindowClickListeners();
  46. },
  47. /**
  48. * Registers click listeners handling the show and hode of toolbars when
  49. * user clicks outside of toolbar area.
  50. */
  51. _registerWindowClickListeners() {
  52. $(window).click(function() {
  53. (Toolbar.isEnabled() && Toolbar.isVisible())
  54. ? hideToolbar(true)
  55. : this.showToolbar();
  56. }.bind(this));
  57. Toolbar.registerClickListeners(function(event){
  58. event.stopPropagation();
  59. });
  60. },
  61. /**
  62. * Sets the value of alwaysVisibleToolbar variable.
  63. * @param value {boolean} the new value of alwaysVisibleToolbar variable
  64. */
  65. setAlwaysVisibleToolbar(value) {
  66. alwaysVisibleToolbar = value;
  67. },
  68. /**
  69. * Resets the value of alwaysVisibleToolbar variable to the default one.
  70. */
  71. resetAlwaysVisibleToolbar() {
  72. alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
  73. },
  74. /**
  75. * Shows the main toolbar.
  76. */
  77. showToolbar () {
  78. if (interfaceConfig.filmStripOnly) {
  79. return;
  80. }
  81. var updateTimeout = false;
  82. if (Toolbar.isEnabled() && !Toolbar.isVisible()) {
  83. Toolbar.show();
  84. $('#subject').animate({top: "+=40"}, 300);
  85. updateTimeout = true;
  86. }
  87. if (updateTimeout) {
  88. if (toolbarTimeoutObject) {
  89. clearTimeout(toolbarTimeoutObject);
  90. toolbarTimeoutObject = null;
  91. }
  92. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  93. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  94. }
  95. // Show/hide desktop sharing button
  96. showDesktopSharingButton();
  97. },
  98. /**
  99. * Docks/undocks the toolbar.
  100. *
  101. * @param isDock indicates what operation to perform
  102. */
  103. dockToolbar (isDock) {
  104. if (interfaceConfig.filmStripOnly || !Toolbar.isEnabled()) {
  105. return;
  106. }
  107. if (isDock) {
  108. // First make sure the toolbar is shown.
  109. if (!Toolbar.isVisible()) {
  110. this.showToolbar();
  111. }
  112. // Then clear the time out, to dock the toolbar.
  113. clearTimeout(toolbarTimeoutObject);
  114. toolbarTimeoutObject = null;
  115. } else {
  116. if (Toolbar.isVisible()) {
  117. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  118. } else {
  119. this.showToolbar();
  120. }
  121. }
  122. }
  123. };
  124. module.exports = ToolbarToggler;