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. let toolbarTimeoutObject;
  6. let toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  7. /**
  8. * If true the toolbar will be always displayed
  9. */
  10. let alwaysVisibleToolbar = false;
  11. function showDesktopSharingButton() {
  12. if (APP.conference.isDesktopSharingEnabled &&
  13. UIUtil.isButtonEnabled('desktop')) {
  14. $('#toolbar_button_desktopsharing').css({display: "inline-block"});
  15. } else {
  16. $('#toolbar_button_desktopsharing').css({display: "none"});
  17. }
  18. }
  19. /**
  20. * Hides the toolbar.
  21. *
  22. * @param force {true} to force the hiding of the toolbar without caring about
  23. * the extended toolbar side panels.
  24. */
  25. function hideToolbar(force) { // eslint-disable-line no-unused-vars
  26. if (alwaysVisibleToolbar) {
  27. return;
  28. }
  29. clearTimeout(toolbarTimeoutObject);
  30. toolbarTimeoutObject = null;
  31. if (Toolbar.isHovered()
  32. || SideContainerToggler.isVisible()) {
  33. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  34. } else {
  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. // disabled
  46. //this._registerWindowClickListeners();
  47. },
  48. /**
  49. * Registers click listeners handling the show and hode of toolbars when
  50. * user clicks outside of toolbar area.
  51. */
  52. _registerWindowClickListeners() {
  53. $(window).click(function() {
  54. (Toolbar.isEnabled() && Toolbar.isVisible())
  55. ? hideToolbar(true)
  56. : this.showToolbar();
  57. }.bind(this));
  58. Toolbar.registerClickListeners(function(event){
  59. event.stopPropagation();
  60. });
  61. },
  62. /**
  63. * Sets the value of alwaysVisibleToolbar variable.
  64. * @param value {boolean} the new value of alwaysVisibleToolbar variable
  65. */
  66. setAlwaysVisibleToolbar(value) {
  67. alwaysVisibleToolbar = value;
  68. },
  69. /**
  70. * Resets the value of alwaysVisibleToolbar variable to the default one.
  71. */
  72. resetAlwaysVisibleToolbar() {
  73. alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
  74. },
  75. /**
  76. * Shows the main toolbar.
  77. * @param timeout (optional) to specify custom timeout value
  78. */
  79. showToolbar (timeout) {
  80. if (interfaceConfig.filmStripOnly) {
  81. return;
  82. }
  83. var updateTimeout = false;
  84. if (Toolbar.isEnabled() && !Toolbar.isVisible()) {
  85. Toolbar.show();
  86. $('#subject').animate({top: "+=40"}, 300);
  87. updateTimeout = true;
  88. }
  89. if (updateTimeout) {
  90. if (toolbarTimeoutObject) {
  91. clearTimeout(toolbarTimeoutObject);
  92. toolbarTimeoutObject = null;
  93. }
  94. toolbarTimeoutObject
  95. = setTimeout(hideToolbar, timeout || 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;