root_page.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. * DS102: Remove unnecessary code created because of implicit returns
  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.RootPage = class RootPage extends app.View {
  11. constructor(...args) {
  12. this.onClick = this.onClick.bind(this);
  13. super(...args);
  14. }
  15. static initClass() {
  16. this.events =
  17. {click: 'onClick'};
  18. }
  19. init() {
  20. if (!this.isHidden()) { this.setHidden(false); } // reserve space in local storage
  21. this.render();
  22. }
  23. render() {
  24. this.empty();
  25. const tmpl = app.isAndroidWebview() ?
  26. 'androidWarning'
  27. : this.isHidden() ?
  28. 'splash'
  29. : app.isMobile() ?
  30. 'mobileIntro'
  31. :
  32. 'intro';
  33. this.append(this.tmpl(tmpl));
  34. }
  35. hideIntro() {
  36. this.setHidden(true);
  37. this.render();
  38. }
  39. setHidden(value) {
  40. app.settings.set('hideIntro', value);
  41. }
  42. isHidden() {
  43. return app.isSingleDoc() || app.settings.get('hideIntro');
  44. }
  45. onRoute() {}
  46. onClick(event) {
  47. if ($.eventTarget(event).hasAttribute('data-hide-intro')) {
  48. $.stopEvent(event);
  49. this.hideIntro();
  50. }
  51. }
  52. });
  53. Cls.initClass();