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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. function showDesktopSharingButton() {
  9. if (APP.conference.isDesktopSharingEnabled &&
  10. UIUtil.isButtonEnabled('desktop')) {
  11. $('#toolbar_button_desktopsharing').css({display: "inline-block"});
  12. } else {
  13. $('#toolbar_button_desktopsharing').css({display: "none"});
  14. }
  15. }
  16. /**
  17. * Hides the toolbar.
  18. */
  19. function hideToolbar() {
  20. if (config.alwaysVisibleToolbar) {
  21. return;
  22. }
  23. clearTimeout(toolbarTimeoutObject);
  24. toolbarTimeoutObject = null;
  25. if (Toolbar.isHovered()) {
  26. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  27. } else {
  28. Toolbar.hide();
  29. $('#subject').animate({top: "-=40"}, 300);
  30. if (!FilmStrip.isFilmStripVisible()) {
  31. BottomToolbar.hide(true);
  32. }
  33. }
  34. }
  35. const ToolbarToggler = {
  36. /**
  37. * Shows the main toolbar.
  38. */
  39. showToolbar () {
  40. if (interfaceConfig.filmStripOnly) {
  41. return;
  42. }
  43. var updateTimeout = false;
  44. if (Toolbar.isEnabled() && !Toolbar.isVisible()) {
  45. Toolbar.show();
  46. $('#subject').animate({top: "+=40"}, 300);
  47. updateTimeout = true;
  48. }
  49. if (BottomToolbar.isEnabled() && !BottomToolbar.isVisible()) {
  50. BottomToolbar.show(true);
  51. updateTimeout = true;
  52. }
  53. if (updateTimeout) {
  54. if (toolbarTimeoutObject) {
  55. clearTimeout(toolbarTimeoutObject);
  56. toolbarTimeoutObject = null;
  57. }
  58. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  59. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  60. }
  61. // Show/hide desktop sharing button
  62. showDesktopSharingButton();
  63. },
  64. /**
  65. * Docks/undocks the toolbar.
  66. *
  67. * @param isDock indicates what operation to perform
  68. */
  69. dockToolbar (isDock) {
  70. if (interfaceConfig.filmStripOnly || !Toolbar.isEnabled()) {
  71. return;
  72. }
  73. if (isDock) {
  74. // First make sure the toolbar is shown.
  75. if (!Toolbar.isVisible()) {
  76. this.showToolbar();
  77. }
  78. // Then clear the time out, to dock the toolbar.
  79. clearTimeout(toolbarTimeoutObject);
  80. toolbarTimeoutObject = null;
  81. } else {
  82. if (Toolbar.isVisible()) {
  83. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  84. } else {
  85. this.showToolbar();
  86. }
  87. }
  88. }
  89. };
  90. module.exports = ToolbarToggler;