notice.js 648 B

12345678910111213141516171819202122232425262728293031323334353637
  1. app.views.Notice = class Notice extends app.View {
  2. static className = "_notice";
  3. static attributes = { role: "alert" };
  4. constructor(type, ...args) {
  5. super();
  6. this.type = type;
  7. this.args = args || [];
  8. this.init0(); // needs this.args
  9. this.refreshElements();
  10. }
  11. init0() {
  12. this.activate();
  13. }
  14. activate() {
  15. if (super.activate(...arguments)) {
  16. this.show();
  17. }
  18. }
  19. deactivate() {
  20. if (super.deactivate(...arguments)) {
  21. this.hide();
  22. }
  23. }
  24. show() {
  25. this.html(this.tmpl(`${this.type}Notice`, ...this.args));
  26. this.prependTo(app.el);
  27. }
  28. hide() {
  29. $.remove(this.el);
  30. }
  31. };