notice.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Sanity-check the conversion and remove this comment.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS002: Fix invalid constructor
  6. * DS101: Remove unnecessary use of Array.from
  7. * DS206: Consider reworking classes to avoid initClass
  8. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
  9. */
  10. app.views.Notice = class Notice extends app.View {
  11. static initClass() {
  12. this.className = "_notice";
  13. this.attributes = { role: "alert" };
  14. }
  15. constructor(type, ...rest) {
  16. this.type = type;
  17. [...this.args] = Array.from(rest);
  18. super(...arguments);
  19. }
  20. init() {
  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`, ...Array.from(this.args)));
  35. this.prependTo(app.el);
  36. }
  37. hide() {
  38. $.remove(this.el);
  39. }
  40. };
  41. app.views.Notice.initClass();