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

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