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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. */
  80. showToolbar () {
  81. if (interfaceConfig.filmStripOnly) {
  82. return;
  83. }
  84. var updateTimeout = false;
  85. if (Toolbar.isEnabled() && !Toolbar.isVisible()) {
  86. Toolbar.show();
  87. $('#subject').animate({top: "+=40"}, 300);
  88. updateTimeout = true;
  89. }
  90. if (updateTimeout) {
  91. if (toolbarTimeoutObject) {
  92. clearTimeout(toolbarTimeoutObject);
  93. toolbarTimeoutObject = null;
  94. }
  95. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  96. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  97. }
  98. // Show/hide desktop sharing button
  99. showDesktopSharingButton();
  100. },
  101. /**
  102. * Docks/undocks the toolbar.
  103. *
  104. * @param isDock indicates what operation to perform
  105. */
  106. dockToolbar (isDock) {
  107. if (interfaceConfig.filmStripOnly || !Toolbar.isEnabled()) {
  108. return;
  109. }
  110. if (isDock) {
  111. // First make sure the toolbar is shown.
  112. if (!Toolbar.isVisible()) {
  113. this.showToolbar();
  114. }
  115. // Then clear the time out, to dock the toolbar.
  116. clearTimeout(toolbarTimeoutObject);
  117. toolbarTimeoutObject = null;
  118. } else {
  119. if (Toolbar.isVisible()) {
  120. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  121. } else {
  122. this.showToolbar();
  123. }
  124. }
  125. }
  126. };
  127. module.exports = ToolbarToggler;