Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

SideContainerToggler.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* global $ */
  2. import UIEvents from "../../../service/UI/UIEvents";
  3. /**
  4. * Handles open and close of the extended toolbar side panel
  5. * (chat, settings, etc.).
  6. *
  7. * @type {{init, toggle, isVisible, hide, show, resize}}
  8. */
  9. const SideContainerToggler = {
  10. /**
  11. * Initialises this toggler by registering the listeners.
  12. *
  13. * @param eventEmitter
  14. */
  15. init(eventEmitter) {
  16. this.eventEmitter = eventEmitter;
  17. // Adds a listener for the animation end event that would take care
  18. // of hiding all internal containers when the extendedToolbarPanel is
  19. // closed.
  20. document.getElementById("sideToolbarContainer")
  21. .addEventListener("animationend", function(e) {
  22. if(e.animationName === "slideOutExt")
  23. $("#sideToolbarContainer").children().each(function() {
  24. if ($(this).hasClass("show"))
  25. SideContainerToggler.hideInnerContainer($(this));
  26. });
  27. }, false);
  28. },
  29. /**
  30. * Toggles the container with the given element id.
  31. *
  32. * @param {String} elementId the identifier of the container element to
  33. * toggle
  34. */
  35. toggle(elementId) {
  36. let elementSelector = $(`#${elementId}`);
  37. let isSelectorVisible = elementSelector.hasClass("show");
  38. if (isSelectorVisible) {
  39. this.hide();
  40. }
  41. else {
  42. if (this.isVisible())
  43. $("#sideToolbarContainer").children().each(function() {
  44. if ($(this).id !== elementId && $(this).hasClass("show"))
  45. SideContainerToggler.hideInnerContainer($(this));
  46. });
  47. if (!this.isVisible())
  48. this.show();
  49. this.showInnerContainer(elementSelector);
  50. }
  51. },
  52. /**
  53. * Returns {true} if the side toolbar panel is currently visible,
  54. * otherwise returns {false}.
  55. */
  56. isVisible() {
  57. return $("#sideToolbarContainer").hasClass("slideInExt");
  58. },
  59. /**
  60. * Returns {true} if the side toolbar panel is currently hovered and
  61. * {false} otherwise.
  62. */
  63. isHovered() {
  64. return $("#sideToolbarContainer:hover").length > 0;
  65. },
  66. /**
  67. * Hides the side toolbar panel with a slide out animation.
  68. */
  69. hide() {
  70. $("#sideToolbarContainer")
  71. .removeClass("slideInExt").addClass("slideOutExt");
  72. },
  73. /**
  74. * Shows the side toolbar panel with a slide in animation.
  75. */
  76. show() {
  77. if (!this.isVisible())
  78. $("#sideToolbarContainer")
  79. .removeClass("slideOutExt").addClass("slideInExt");
  80. },
  81. /**
  82. * Hides the inner container given by the selector.
  83. *
  84. * @param {Object} containerSelector the jquery selector for the
  85. * element to hide
  86. */
  87. hideInnerContainer(containerSelector) {
  88. containerSelector.removeClass("show").addClass("hide");
  89. this.eventEmitter.emit(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
  90. containerSelector.attr('id'), false);
  91. },
  92. /**
  93. * Shows the inner container given by the selector.
  94. *
  95. * @param {Object} containerSelector the jquery selector for the
  96. * element to show
  97. */
  98. showInnerContainer(containerSelector) {
  99. containerSelector.removeClass("hide").addClass("show");
  100. this.eventEmitter.emit(UIEvents.SIDE_TOOLBAR_CONTAINER_TOGGLED,
  101. containerSelector.attr('id'), true);
  102. },
  103. /**
  104. * TO FIX: do we need to resize the chat?
  105. */
  106. resize () {
  107. //let [width, height] = UIUtil.getSidePanelSize();
  108. //Chat.resizeChat(width, height);
  109. }
  110. };
  111. export default SideContainerToggler;