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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* global $ */
  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.filmStrip = $('#remoteVideos');
  13. this.toolbar = $('#bottomToolbar');
  14. },
  15. setupListeners (emitter) {
  16. UIUtil.hideDisabledButtons(defaultBottomToolbarButtons);
  17. const buttonHandlers = {
  18. "bottom_toolbar_contact_list": function () {
  19. AnalyticsAdapter.sendEvent('bottomtoolbar.contacts.toggled');
  20. emitter.emit(UIEvents.TOGGLE_CONTACT_LIST);
  21. },
  22. "bottom_toolbar_film_strip": function () {
  23. AnalyticsAdapter.sendEvent('bottomtoolbar.filmstrip.toggled');
  24. emitter.emit(UIEvents.TOGGLE_FILM_STRIP);
  25. },
  26. "bottom_toolbar_chat": function () {
  27. AnalyticsAdapter.sendEvent('bottomtoolbar.chat.toggled');
  28. emitter.emit(UIEvents.TOGGLE_CHAT);
  29. }
  30. };
  31. Object.keys(buttonHandlers).forEach(
  32. buttonId => $(`#${buttonId}`).click(buttonHandlers[buttonId])
  33. );
  34. },
  35. toggleFilmStrip () {
  36. this.filmStrip.toggleClass("hidden");
  37. },
  38. isFilmStripVisible () {
  39. return !this.filmStrip.hasClass('hidden');
  40. },
  41. setupFilmStripOnly () {
  42. this.filmStrip.css({
  43. padding: "0px 0px 18px 0px",
  44. right: 0
  45. });
  46. },
  47. getFilmStripHeight () {
  48. if (this.isFilmStripVisible()) {
  49. return this.filmStrip.outerHeight();
  50. } else {
  51. return 0;
  52. }
  53. },
  54. getFilmStripWidth () {
  55. return this.filmStrip.width();
  56. },
  57. resizeThumbnails (thumbWidth, thumbHeight, animate = false) {
  58. return new Promise(resolve => {
  59. this.filmStrip.animate({
  60. // adds 2 px because of small video 1px border
  61. height: thumbHeight + 2
  62. }, {
  63. queue: false,
  64. duration: animate ? 500 : 0
  65. });
  66. this.getThumbs().animate({
  67. height: thumbHeight,
  68. width: thumbWidth
  69. }, {
  70. queue: false,
  71. duration: animate ? 500 : 0,
  72. complete: resolve
  73. });
  74. if (!animate) {
  75. resolve();
  76. }
  77. });
  78. },
  79. resizeToolbar (thumbWidth, thumbHeight) {
  80. let bottom = (thumbHeight - this.toolbar.outerHeight())/2 + 18;
  81. this.toolbar.css({bottom});
  82. },
  83. getThumbs (visible = false) {
  84. let selector = 'span';
  85. if (visible) {
  86. selector += ':visible';
  87. }
  88. return this.filmStrip.children(selector);
  89. }
  90. };
  91. export default BottomToolbar;