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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* global APP, config, $, interfaceConfig */
  2. import UIUtil from '../util/UIUtil';
  3. import BottomToolbar from './BottomToolbar';
  4. import FilmStrip from '../videolayout/FilmStrip.js';
  5. let toolbarTimeoutObject;
  6. let toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  7. function showDesktopSharingButton() {
  8. if (APP.conference.isDesktopSharingEnabled &&
  9. UIUtil.isButtonEnabled('desktop')) {
  10. $('#toolbar_button_desktopsharing').css({display: "inline-block"});
  11. } else {
  12. $('#toolbar_button_desktopsharing').css({display: "none"});
  13. }
  14. }
  15. function isToolbarVisible () {
  16. return $('#header').is(':visible');
  17. }
  18. /**
  19. * Hides the toolbar.
  20. */
  21. function hideToolbar() {
  22. if (config.alwaysVisibleToolbar) {
  23. return;
  24. }
  25. let header = $("#header");
  26. let isToolbarHover = false;
  27. header.find('*').each(function () {
  28. let id = $(this).attr('id');
  29. if ($(`#${id}:hover`).length > 0) {
  30. isToolbarHover = true;
  31. }
  32. });
  33. if ($("#bottomToolbar:hover").length > 0) {
  34. isToolbarHover = true;
  35. }
  36. clearTimeout(toolbarTimeoutObject);
  37. toolbarTimeoutObject = null;
  38. if (isToolbarHover) {
  39. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  40. } else {
  41. header.hide("slide", { direction: "up", duration: 300});
  42. $('#subject').animate({top: "-=40"}, 300);
  43. if (!FilmStrip.isFilmStripVisible()) {
  44. BottomToolbar.hide(true);
  45. }
  46. }
  47. }
  48. const ToolbarToggler = {
  49. /**
  50. * Shows the main toolbar.
  51. */
  52. showToolbar () {
  53. if (interfaceConfig.filmStripOnly) {
  54. return;
  55. }
  56. let header = $("#header");
  57. if (!header.is(':visible') || !BottomToolbar.isVisible()) {
  58. header.show("slide", { direction: "up", duration: 300});
  59. $('#subject').animate({top: "+=40"}, 300);
  60. if (!BottomToolbar.isVisible()) {
  61. BottomToolbar.show(true);
  62. }
  63. if (toolbarTimeoutObject) {
  64. clearTimeout(toolbarTimeoutObject);
  65. toolbarTimeoutObject = null;
  66. }
  67. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  68. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  69. }
  70. // Show/hide desktop sharing button
  71. showDesktopSharingButton();
  72. },
  73. /**
  74. * Docks/undocks the toolbar.
  75. *
  76. * @param isDock indicates what operation to perform
  77. */
  78. dockToolbar (isDock) {
  79. if (interfaceConfig.filmStripOnly) {
  80. return;
  81. }
  82. if (isDock) {
  83. // First make sure the toolbar is shown.
  84. if (!isToolbarVisible()) {
  85. this.showToolbar();
  86. }
  87. // Then clear the time out, to dock the toolbar.
  88. clearTimeout(toolbarTimeoutObject);
  89. toolbarTimeoutObject = null;
  90. } else {
  91. if (isToolbarVisible()) {
  92. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  93. } else {
  94. this.showToolbar();
  95. }
  96. }
  97. }
  98. };
  99. module.exports = ToolbarToggler;