modal.js 492 B

12345678910111213141516171819202122232425
  1. import ReactDOM from 'react-dom';
  2. import mount from 'misago/utils/mount-component';
  3. export class Modal {
  4. init(element) {
  5. this._element = element;
  6. this._modal = $(element).modal({show: false});
  7. this._modal.on('hidden.bs.modal', () => {
  8. ReactDOM.unmountComponentAtNode(this._element);
  9. });
  10. }
  11. show(component) {
  12. mount(component, this._element.id);
  13. this._modal.modal('show');
  14. }
  15. hide() {
  16. this._modal.modal('hide');
  17. }
  18. }
  19. export default new Modal();