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 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* global APP, config, $, interfaceConfig */
  2. import UIUtil from '../util/UIUtil';
  3. import BottomToolbar from './BottomToolbar';
  4. import Toolbar from './Toolbar';
  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. function hideToolbar() {
  24. if (alwaysVisibleToolbar) {
  25. return;
  26. }
  27. clearTimeout(toolbarTimeoutObject);
  28. toolbarTimeoutObject = null;
  29. if (Toolbar.isHovered()) {
  30. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  31. } else {
  32. Toolbar.hide();
  33. $('#subject').animate({top: "-=40"}, 300);
  34. if (!FilmStrip.isFilmStripVisible()) {
  35. BottomToolbar.hide(true);
  36. }
  37. }
  38. }
  39. const ToolbarToggler = {
  40. /**
  41. * Initializes the ToolbarToggler
  42. */
  43. init() {
  44. alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
  45. },
  46. /**
  47. * Sets the value of alwaysVisibleToolbar variable.
  48. * @param value {boolean} the new value of alwaysVisibleToolbar variable
  49. */
  50. setAlwaysVisibleToolbar(value) {
  51. alwaysVisibleToolbar = value;
  52. },
  53. /**
  54. * Resets the value of alwaysVisibleToolbar variable to the default one.
  55. */
  56. resetAlwaysVisibleToolbar() {
  57. alwaysVisibleToolbar = (config.alwaysVisibleToolbar === true);
  58. },
  59. /**
  60. * Shows the main toolbar.
  61. */
  62. showToolbar () {
  63. if (interfaceConfig.filmStripOnly) {
  64. return;
  65. }
  66. var updateTimeout = false;
  67. if (Toolbar.isEnabled() && !Toolbar.isVisible()) {
  68. Toolbar.show();
  69. $('#subject').animate({top: "+=40"}, 300);
  70. updateTimeout = true;
  71. }
  72. if (BottomToolbar.isEnabled() && !BottomToolbar.isVisible()) {
  73. BottomToolbar.show(true);
  74. updateTimeout = true;
  75. }
  76. if (updateTimeout) {
  77. if (toolbarTimeoutObject) {
  78. clearTimeout(toolbarTimeoutObject);
  79. toolbarTimeoutObject = null;
  80. }
  81. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  82. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  83. }
  84. // Show/hide desktop sharing button
  85. showDesktopSharingButton();
  86. },
  87. /**
  88. * Docks/undocks the toolbar.
  89. *
  90. * @param isDock indicates what operation to perform
  91. */
  92. dockToolbar (isDock) {
  93. if (interfaceConfig.filmStripOnly || !Toolbar.isEnabled()) {
  94. return;
  95. }
  96. if (isDock) {
  97. // First make sure the toolbar is shown.
  98. if (!Toolbar.isVisible()) {
  99. this.showToolbar();
  100. }
  101. // Then clear the time out, to dock the toolbar.
  102. clearTimeout(toolbarTimeoutObject);
  103. toolbarTimeoutObject = null;
  104. } else {
  105. if (Toolbar.isVisible()) {
  106. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  107. } else {
  108. this.showToolbar();
  109. }
  110. }
  111. }
  112. };
  113. module.exports = ToolbarToggler;