您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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. 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 (force !== true &&
  32. (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;