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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. },
  14. setupListeners (emitter) {
  15. UIUtil.hideDisabledButtons(defaultBottomToolbarButtons);
  16. const buttonHandlers = {
  17. "bottom_toolbar_contact_list": function () {
  18. AnalyticsAdapter.sendEvent('bottomtoolbar.contacts.toggled');
  19. emitter.emit(UIEvents.TOGGLE_CONTACT_LIST);
  20. },
  21. "bottom_toolbar_film_strip": function () {
  22. AnalyticsAdapter.sendEvent('bottomtoolbar.filmstrip.toggled');
  23. emitter.emit(UIEvents.TOGGLE_FILM_STRIP);
  24. },
  25. "bottom_toolbar_chat": function () {
  26. AnalyticsAdapter.sendEvent('bottomtoolbar.chat.toggled');
  27. emitter.emit(UIEvents.TOGGLE_CHAT);
  28. }
  29. };
  30. Object.keys(buttonHandlers).forEach(
  31. buttonId => $(`#${buttonId}`).click(buttonHandlers[buttonId])
  32. );
  33. },
  34. resizeToolbar (thumbWidth, thumbHeight) {
  35. let bottom = (thumbHeight - this.toolbar.outerHeight())/2 + 18;
  36. this.toolbar.css({bottom});
  37. },
  38. /**
  39. * Returns true if this toolbar is currently visible, or false otherwise.
  40. * @return <tt>true</tt> if currently visible, <tt>false</tt> - otherwise
  41. */
  42. isVisible() {
  43. return this.toolbar.is(":visible");
  44. },
  45. /**
  46. * Hides the bottom toolbar with animation or not depending on the animate
  47. * parameter.
  48. * @param animate <tt>true</tt> to hide the bottom toolbar with animation,
  49. * <tt>false</tt> or nothing to hide it without animation.
  50. */
  51. hide(animate) {
  52. if (animate)
  53. this.toolbar.hide("slide", {direction: "right", duration: 300});
  54. else
  55. this.toolbar.css("display", "none");
  56. },
  57. /**
  58. * Shows the bottom toolbar with animation or not depending on the animate
  59. * parameter.
  60. * @param animate <tt>true</tt> to show the bottom toolbar with animation,
  61. * <tt>false</tt> or nothing to show it without animation.
  62. */
  63. show(animate) {
  64. if (animate)
  65. this.toolbar.show("slide", {direction: "right", duration: 300});
  66. else
  67. this.toolbar.css("display", "block");
  68. }
  69. };
  70. export default BottomToolbar;