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.

BottomToolbar.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* global $, APP, interfaceConfig, JitsiMeetJS */
  2. import UIUtil from '../util/UIUtil';
  3. import UIEvents from '../../../service/UI/UIEvents';
  4. const defaultBottomToolbarButtons = {
  5. 'chat': {
  6. id: '#bottom_toolbar_chat'
  7. },
  8. 'contacts': {
  9. id: '#bottom_toolbar_contact_list'
  10. },
  11. 'filmstrip': {
  12. id: '#bottom_toolbar_film_strip',
  13. shortcut: "F",
  14. shortcutAttr: "filmstripPopover",
  15. shortcutFunc: function() {
  16. JitsiMeetJS.analytics.sendEvent("shortcut.film.toggled");
  17. APP.UI.handleToggleFilmStrip();
  18. },
  19. shortcutDescription: "keyboardShortcuts.toggleFilmstrip"
  20. }
  21. };
  22. const BottomToolbar = {
  23. init () {
  24. this.toolbar = $('#bottomToolbar');
  25. // The bottom toolbar is enabled by default.
  26. this.enabled = true;
  27. },
  28. /**
  29. * Enables / disables the bottom toolbar.
  30. * @param {e} set to {true} to enable the bottom toolbar or {false}
  31. * to disable it
  32. */
  33. enable (e) {
  34. this.enabled = e;
  35. if (!e && this.isVisible())
  36. this.hide(false);
  37. },
  38. /**
  39. * Indicates if the bottom toolbar is currently enabled.
  40. * @return {this.enabled}
  41. */
  42. isEnabled() {
  43. return this.enabled;
  44. },
  45. setupListeners (emitter) {
  46. UIUtil.hideDisabledButtons(defaultBottomToolbarButtons);
  47. const buttonHandlers = {
  48. "bottom_toolbar_contact_list": function () {
  49. JitsiMeetJS.analytics.sendEvent(
  50. 'bottomtoolbar.contacts.toggled');
  51. emitter.emit(UIEvents.TOGGLE_CONTACT_LIST);
  52. },
  53. "bottom_toolbar_film_strip": function () {
  54. JitsiMeetJS.analytics.sendEvent(
  55. 'bottomtoolbar.filmstrip.toggled');
  56. emitter.emit(UIEvents.TOGGLE_FILM_STRIP);
  57. },
  58. "bottom_toolbar_chat": function () {
  59. JitsiMeetJS.analytics.sendEvent('bottomtoolbar.chat.toggled');
  60. emitter.emit(UIEvents.TOGGLE_CHAT);
  61. }
  62. };
  63. Object.keys(defaultBottomToolbarButtons).forEach(
  64. id => {
  65. if (UIUtil.isButtonEnabled(id)) {
  66. var button = defaultBottomToolbarButtons[id];
  67. if (button.shortcut)
  68. APP.keyboardshortcut.registerShortcut(
  69. button.shortcut,
  70. button.shortcutAttr,
  71. button.shortcutFunc,
  72. button.shortcutDescription
  73. );
  74. }
  75. }
  76. );
  77. Object.keys(buttonHandlers).forEach(
  78. buttonId => $(`#${buttonId}`).click(buttonHandlers[buttonId])
  79. );
  80. },
  81. resizeToolbar (thumbWidth, thumbHeight) {
  82. let bottom = (thumbHeight - this.toolbar.outerHeight())/2 + 18;
  83. this.toolbar.css({bottom});
  84. },
  85. /**
  86. * Returns true if this toolbar is currently visible, or false otherwise.
  87. * @return <tt>true</tt> if currently visible, <tt>false</tt> - otherwise
  88. */
  89. isVisible() {
  90. return this.toolbar.is(":visible");
  91. },
  92. /**
  93. * Hides the bottom toolbar with animation or not depending on the animate
  94. * parameter.
  95. * @param animate <tt>true</tt> to hide the bottom toolbar with animation,
  96. * <tt>false</tt> or nothing to hide it without animation.
  97. */
  98. hide(animate) {
  99. if (animate)
  100. this.toolbar.hide("slide", {direction: "right", duration: 300});
  101. else
  102. this.toolbar.css("display", "none");
  103. },
  104. /**
  105. * Shows the bottom toolbar with animation or not depending on the animate
  106. * parameter.
  107. * @param animate <tt>true</tt> to show the bottom toolbar with animation,
  108. * <tt>false</tt> or nothing to show it without animation.
  109. */
  110. show(animate) {
  111. if (animate)
  112. this.toolbar.show("slide", {direction: "right", duration: 300});
  113. else
  114. this.toolbar.css("display", "block");
  115. }
  116. };
  117. export default BottomToolbar;