static_page.js 545 B

123456789101112131415161718192021222324252627282930
  1. app.views.StaticPage = class StaticPage extends app.View {
  2. static className = "_static";
  3. static titles = {
  4. about: "About",
  5. news: "News",
  6. help: "User Guide",
  7. notFound: "404",
  8. };
  9. deactivate() {
  10. if (super.deactivate(...arguments)) {
  11. this.empty();
  12. this.page = null;
  13. }
  14. }
  15. render(page) {
  16. this.page = page;
  17. this.html(this.tmpl(`${this.page}Page`));
  18. }
  19. getTitle() {
  20. return this.constructor.titles[this.page];
  21. }
  22. onRoute(context) {
  23. this.render(context.page || "notFound");
  24. }
  25. };