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

ToolbarToggler.js 4.1KB

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