sidebar_tmpl.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Sanity-check the conversion and remove this comment.
  3. /*
  4. * decaffeinate suggestions:
  5. * DS102: Remove unnecessary code created because of implicit returns
  6. * DS207: Consider shorter variations of null checks
  7. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
  8. */
  9. const { templates } = app;
  10. const arrow = '<svg class="_list-arrow"><use xlink:href="#icon-dir"/></svg>';
  11. templates.sidebarDoc = function (doc, options) {
  12. if (options == null) {
  13. options = {};
  14. }
  15. let link = `<a href="${doc.fullPath()}" class="_list-item _icon-${doc.icon} `;
  16. link += options.disabled ? "_list-disabled" : "_list-dir";
  17. link += `" data-slug="${doc.slug}" title="${doc.fullName}" tabindex="-1">`;
  18. if (options.disabled) {
  19. link += `<span class="_list-enable" data-enable="${doc.slug}">Enable</span>`;
  20. } else {
  21. link += arrow;
  22. }
  23. if (doc.release) {
  24. link += `<span class="_list-count">${doc.release}</span>`;
  25. }
  26. link += `<span class="_list-text">${doc.name}`;
  27. if (options.fullName || (options.disabled && doc.version)) {
  28. link += ` ${doc.version}`;
  29. }
  30. return link + "</span></a>";
  31. };
  32. templates.sidebarType = (type) =>
  33. `<a href="${type.fullPath()}" class="_list-item _list-dir" data-slug="${
  34. type.slug
  35. }" tabindex="-1">${arrow}<span class="_list-count">${
  36. type.count
  37. }</span><span class="_list-text">${$.escape(type.name)}</span></a>`;
  38. templates.sidebarEntry = (entry) =>
  39. `<a href="${entry.fullPath()}" class="_list-item _list-hover" tabindex="-1">${$.escape(
  40. entry.name,
  41. )}</a>`;
  42. templates.sidebarResult = function (entry) {
  43. let addons =
  44. entry.isIndex() && app.disabledDocs.contains(entry.doc)
  45. ? `<span class="_list-enable" data-enable="${entry.doc.slug}">Enable</span>`
  46. : '<span class="_list-reveal" data-reset-list title="Reveal in list"></span>';
  47. if (entry.doc.version && !entry.isIndex()) {
  48. addons += `<span class="_list-count">${entry.doc.short_version}</span>`;
  49. }
  50. return `<a href="${entry.fullPath()}" class="_list-item _list-hover _list-result _icon-${
  51. entry.doc.icon
  52. }" tabindex="-1">${addons}<span class="_list-text">${$.escape(
  53. entry.name,
  54. )}</span></a>`;
  55. };
  56. templates.sidebarNoResults = function () {
  57. let html = ' <div class="_list-note">No results.</div> ';
  58. if (!app.isSingleDoc() && !app.disabledDocs.isEmpty()) {
  59. html += `\
  60. <div class="_list-note">Note: documentations must be <a href="/settings" class="_list-note-link">enabled</a> to appear in the search.</div>\
  61. `;
  62. }
  63. return html;
  64. };
  65. templates.sidebarPageLink = (count) =>
  66. `<span role="link" class="_list-item _list-pagelink">Show more\u2026 (${count})</span>`;
  67. templates.sidebarLabel = function (doc, options) {
  68. if (options == null) {
  69. options = {};
  70. }
  71. let label = '<label class="_list-item';
  72. if (!doc.version) {
  73. label += ` _icon-${doc.icon}`;
  74. }
  75. label += `"><input type="checkbox" name="${doc.slug}" class="_list-checkbox" `;
  76. if (options.checked) {
  77. label += "checked";
  78. }
  79. return label + `><span class="_list-text">${doc.fullName}</span></label>`;
  80. };
  81. templates.sidebarVersionedDoc = function (doc, versions, options) {
  82. if (options == null) {
  83. options = {};
  84. }
  85. let html = `<div class="_list-item _list-dir _list-rdir _icon-${doc.icon}`;
  86. if (options.open) {
  87. html += " open";
  88. }
  89. return (
  90. html +
  91. `" tabindex="0">${arrow}${doc.name}</div><div class="_list _list-sub">${versions}</div>`
  92. );
  93. };
  94. templates.sidebarDisabled = (options) =>
  95. `<h6 class="_list-title">${arrow}Disabled (${options.count}) <a href="/settings" class="_list-title-link" tabindex="-1">Customize</a></h6>`;
  96. templates.sidebarDisabledList = (html) =>
  97. `<div class="_disabled-list">${html}</div>`;
  98. templates.sidebarDisabledVersionedDoc = (doc, versions) =>
  99. `<a class="_list-item _list-dir _icon-${doc.icon} _list-disabled" data-slug="${doc.slug_without_version}" tabindex="-1">${arrow}${doc.name}</a><div class="_list _list-sub">${versions}</div>`;
  100. templates.docPickerHeader =
  101. '<div class="_list-picker-head"><span>Documentation</span> <span>Enable</span></div>';
  102. templates.docPickerNote = `\
  103. <div class="_list-note">Tip: for faster and better search results, select only the docs you need.</div>
  104. <a href="https://trello.com/b/6BmTulfx/devdocs-documentation" class="_list-link" target="_blank" rel="noopener">Vote for new documentation</a>\
  105. `;