mobile-navbar-dropdown.js 753 B

1234567891011121314151617181920212223242526272829303132333435
  1. import mount from 'misago/utils/mount-component';
  2. export class MobileNavbarDropdown {
  3. init(element) {
  4. this._element = element;
  5. this._component = null;
  6. }
  7. show(component) {
  8. if (this._component === component) {
  9. this.hide();
  10. } else {
  11. this._component = component;
  12. mount(component, this._element.id);
  13. $(this._element).addClass('open');
  14. }
  15. }
  16. showConnected(name, component) {
  17. if (this._component === name) {
  18. this.hide();
  19. } else {
  20. this._component = name;
  21. mount(component, this._element.id, true);
  22. $(this._element).addClass('open');
  23. }
  24. }
  25. hide() {
  26. $(this._element).removeClass('open');
  27. this._component = null;
  28. }
  29. }
  30. export default new MobileNavbarDropdown();