Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ToolbarToggler.js 4.0KB

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