sidebar_tmpl.js 4.0 KB

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