notice.js 995 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Sanity-check the conversion and remove this comment.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS206: Consider reworking classes to avoid initClass
  6. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
  7. */
  8. app.views.Notice = class Notice extends app.View {
  9. static initClass() {
  10. this.className = "_notice";
  11. this.attributes = { role: "alert" };
  12. }
  13. constructor(type, ...args) {
  14. super();
  15. this.type = type;
  16. this.args = args || [];
  17. this.init0(); // needs this.args
  18. this.refreshElements();
  19. }
  20. init0() {
  21. this.activate();
  22. }
  23. activate() {
  24. if (super.activate(...arguments)) {
  25. this.show();
  26. }
  27. }
  28. deactivate() {
  29. if (super.deactivate(...arguments)) {
  30. this.hide();
  31. }
  32. }
  33. show() {
  34. this.html(this.tmpl(`${this.type}Notice`, ...this.args));
  35. this.prependTo(app.el);
  36. }
  37. hide() {
  38. $.remove(this.el);
  39. }
  40. };
  41. app.views.Notice.initClass();