sidebar_tmpl.coffee 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. templates = app.templates
  2. arrow = """<svg class="_list-arrow"><use xlink:href="#dir"/></svg>"""
  3. templates.sidebarDoc = (doc, options = {}) ->
  4. link = """<a href="#{doc.fullPath()}" class="_list-item _icon-#{doc.icon} """
  5. link += if options.disabled then '_list-disabled' else '_list-dir'
  6. link += """" data-slug="#{doc.slug}" title="#{doc.fullName}" tabindex="-1">"""
  7. if options.disabled
  8. link += """<span class="_list-enable" data-enable="#{doc.slug}">Enable</span>"""
  9. else
  10. link += arrow
  11. link += """<span class="_list-count">#{doc.release}</span>""" if doc.release
  12. link += """<span class="_list-text">#{doc.name}"""
  13. link += " #{doc.version}" if options.fullName or options.disabled and doc.version
  14. link + "</span></a>"
  15. templates.sidebarType = (type) ->
  16. """<a href="#{type.fullPath()}" class="_list-item _list-dir" data-slug="#{type.slug}" tabindex="-1">#{arrow}<span class="_list-count">#{type.count}</span><span class="_list-text">#{$.escape type.name}</span></a>"""
  17. templates.sidebarEntry = (entry) ->
  18. """<a href="#{entry.fullPath()}" class="_list-item _list-hover" tabindex="-1">#{$.escape entry.name}</a>"""
  19. templates.sidebarResult = (entry) ->
  20. addons = if entry.isIndex() and app.disabledDocs.contains(entry.doc)
  21. """<span class="_list-enable" data-enable="#{entry.doc.slug}">Enable</span>"""
  22. else
  23. """<span class="_list-reveal" data-reset-list title="Reveal in list"></span>"""
  24. addons += """<span class="_list-count">#{entry.doc.short_version}</span>""" if entry.doc.version and not entry.isIndex()
  25. """<a href="#{entry.fullPath()}" class="_list-item _list-hover _list-result _icon-#{entry.doc.icon}" tabindex="-1">#{addons}<span class="_list-text">#{$.escape entry.name}</span></a>"""
  26. templates.sidebarNoResults = ->
  27. html = """ <div class="_list-note">No results.</div> """
  28. html += """
  29. <div class="_list-note">Note: documentations must be <a href="/settings" class="_list-note-link">enabled</a> to appear in the search.</div>
  30. """ unless app.isSingleDoc() or app.disabledDocs.isEmpty()
  31. html
  32. templates.sidebarPageLink = (count) ->
  33. """<span role="link" class="_list-item _list-pagelink">Show more\u2026 (#{count})</span>"""
  34. templates.sidebarLabel = (doc, options = {}) ->
  35. label = """<label class="_list-item"""
  36. label += " _icon-#{doc.icon}" unless doc.version
  37. label += """"><input type="checkbox" name="#{doc.slug}" class="_list-checkbox" """
  38. label += "checked" if options.checked
  39. label + """><span class="_list-text">#{doc.fullName}</span></label>"""
  40. templates.sidebarVersionedDoc = (doc, versions, options = {}) ->
  41. html = """<div class="_list-item _list-dir _list-rdir _icon-#{doc.icon}"""
  42. html += " open" if options.open
  43. html + """" tabindex="0">#{arrow}#{doc.name}</div><div class="_list _list-sub">#{versions}</div>"""
  44. templates.sidebarDisabled = (options) ->
  45. """<h6 class="_list-title">#{arrow}Disabled (#{options.count})</h6>"""
  46. templates.sidebarDisabledList = (html) ->
  47. """<div class="_disabled-list">#{html}</div>"""
  48. templates.sidebarDisabledVersionedDoc = (doc, versions) ->
  49. """<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>"""
  50. templates.docPickerNote = """
  51. <div class="_list-note">Tip: for faster and better search results, select only the docs you need.</div>
  52. <a href="https://trello.com/b/6BmTulfx/devdocs-documentation" class="_list-link" target="_blank" rel="noopener">Vote for new documentation</a>
  53. """