posting.js 872 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import React from 'react'; // jshint ignore:line
  2. import ReactDOM from 'react-dom';
  3. import PostingComponent from 'misago/components/posting'; // jshint ignore:line
  4. import mount from 'misago/utils/mount-component'; // jshint ignore:line
  5. export class Posting {
  6. init(ajax, snackbar, placeholder) {
  7. this._ajax = ajax;
  8. this._snackbar = snackbar;
  9. this._placeholder = placeholder;
  10. this._isOpen = false;
  11. }
  12. open(options) {
  13. if (!this._isOpen) {
  14. this._isOpen = true;
  15. this._realOpen(options);
  16. }
  17. }
  18. // jshint ignore:start
  19. _realOpen(options) {
  20. mount(
  21. <PostingComponent options={options} />,
  22. 'posting-mount'
  23. );
  24. }
  25. // jshint ignore:end
  26. close() {
  27. if (this._isOpen) {
  28. ReactDOM.render(null, document.getElementById('posting-mount'));
  29. this._isOpen = false;
  30. }
  31. }
  32. }
  33. export default new Posting();