settings_tmpl.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. const themeOption = ({ label, value }, settings) => `\
  2. <label class="_settings-label _theme-label">
  3. <input type="radio" name="theme" value="${value}"${
  4. settings.theme === value ? " checked" : ""
  5. }>
  6. ${label}
  7. </label>\
  8. `;
  9. app.templates.settingsPage = (settings) => `\
  10. <h1 class="_lined-heading">Preferences</h1>
  11. <div class="_settings-fieldset">
  12. <h2 class="_settings-legend">Theme:</h2>
  13. <div class="_settings-inputs">
  14. ${
  15. settings.autoSupported
  16. ? themeOption(
  17. {
  18. label: "Automatic <small>Matches system setting</small>",
  19. value: "auto",
  20. },
  21. settings,
  22. )
  23. : ""
  24. }
  25. ${themeOption({ label: "Light", value: "default" }, settings)}
  26. ${themeOption({ label: "Dark", value: "dark" }, settings)}
  27. </div>
  28. </div>
  29. <div class="_settings-fieldset">
  30. <h2 class="_settings-legend">General:</h2>
  31. <div class="_settings-inputs">
  32. <label class="_settings-label _setting-max-width">
  33. <input type="checkbox" form="settings" name="layout" value="_max-width"${
  34. settings["_max-width"] ? " checked" : ""
  35. }>Enable fixed-width layout
  36. </label>
  37. <label class="_settings-label _setting-text-justify-hyphenate">
  38. <input type="checkbox" form="settings" name="layout" value="_text-justify-hyphenate"${
  39. settings["_text-justify-hyphenate"] ? " checked" : ""
  40. }>Enable justified layout and automatic hyphenation
  41. </label>
  42. <label class="_settings-label _hide-on-mobile">
  43. <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"${
  44. settings["_sidebar-hidden"] ? " checked" : ""
  45. }>Automatically hide and show the sidebar
  46. <small>Tip: drag the edge of the sidebar to resize it.</small>
  47. </label>
  48. <label class="_settings-label _hide-on-mobile">
  49. <input type="checkbox" form="settings" name="noAutofocus" value="_no-autofocus"${
  50. settings.noAutofocus ? " checked" : ""
  51. }>Disable autofocus of search input
  52. </label>
  53. <label class="_settings-label">
  54. <input type="checkbox" form="settings" name="autoInstall" value="_auto-install"${
  55. settings.autoInstall ? " checked" : ""
  56. }>Automatically download documentation for offline use
  57. <small>Only enable this when bandwidth isn't a concern to you.</small>
  58. </label>
  59. <label class="_settings-label _hide-in-development">
  60. <input type="checkbox" form="settings" name="analyticsConsent"${
  61. settings.analyticsConsent ? " checked" : ""
  62. }>Enable tracking cookies
  63. <small>With this checked, we enable Google Analytics and Gauges to collect anonymous traffic information.</small>
  64. </label>
  65. </div>
  66. </div>
  67. <div class="_settings-fieldset _hide-on-mobile">
  68. <h2 class="_settings-legend">Scrolling:</h2>
  69. <div class="_settings-inputs">
  70. <label class="_settings-label">
  71. <input type="checkbox" form="settings" name="smoothScroll" value="1"${
  72. settings.smoothScroll ? " checked" : ""
  73. }>Use smooth scrolling
  74. </label>
  75. <label class="_settings-label _setting-native-scrollbar">
  76. <input type="checkbox" form="settings" name="layout" value="_native-scrollbars"${
  77. settings["_native-scrollbars"] ? " checked" : ""
  78. }>Use native scrollbars
  79. </label>
  80. <label class="_settings-label">
  81. <input type="checkbox" form="settings" name="arrowScroll" value="1"${
  82. settings.arrowScroll ? " checked" : ""
  83. }>Use arrow keys to scroll the main content area
  84. <small>With this checked, use <code class="_label">shift</code> + <code class="_label">&uarr;</code><code class="_label">&darr;</code><code class="_label">&larr;</code><code class="_label">&rarr;</code> to navigate the sidebar.</small>
  85. </label>
  86. <label class="_settings-label">
  87. <input type="checkbox" form="settings" name="spaceScroll" value="1"${
  88. settings.spaceScroll ? " checked" : ""
  89. }>Use spacebar to scroll during search
  90. </label>
  91. <label class="_settings-label">
  92. <input type="number" step="0.1" form="settings" name="spaceTimeout" min="0" max="5" value="${
  93. settings.spaceTimeout
  94. }"> Delay until you can scroll by pressing space
  95. <small>Time in seconds</small>
  96. </label>
  97. </div>
  98. </div>
  99. <p class="_hide-on-mobile">
  100. <button type="button" class="_btn" data-action="export">Export</button>
  101. <label class="_btn _file-btn"><input type="file" form="settings" name="import" accept=".json">Import</label>
  102. <p>
  103. <button type="button" class="_btn-link _reset-btn" data-behavior="reset">Reset all preferences and data</button>\
  104. `;