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.2KB

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