notice.js 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. const Cls = (app.views.Notice = class Notice extends app.View {
  11. static initClass() {
  12. this.className = '_notice';
  13. this.attributes =
  14. {role: 'alert'};
  15. }
  16. constructor(type, ...rest) { this.type = type; [...this.args] = Array.from(rest); super(...arguments); }
  17. init() {
  18. this.activate();
  19. }
  20. activate() {
  21. if (super.activate(...arguments)) { this.show(); }
  22. }
  23. deactivate() {
  24. if (super.deactivate(...arguments)) { this.hide(); }
  25. }
  26. show() {
  27. this.html(this.tmpl(`${this.type}Notice`, ...Array.from(this.args)));
  28. this.prependTo(app.el);
  29. }
  30. hide() {
  31. $.remove(this.el);
  32. }
  33. });
  34. Cls.initClass();