path.coffee 751 B

123456789101112131415161718192021222324252627282930313233343536
  1. class app.views.Path extends app.View
  2. @className: '_path'
  3. @events:
  4. click: 'onClick'
  5. @routes:
  6. after: 'afterRoute'
  7. render: (args...) ->
  8. @show()
  9. @html @tmpl 'path', args...
  10. show: ->
  11. $.prepend $('._app'), @el unless @el.parentNode
  12. hide: ->
  13. $.remove @el if @el.parentNode
  14. onClick: (event) =>
  15. @clicked = true if link = $.closestLink event.target, @el
  16. afterRoute: (route, context) =>
  17. if context.type
  18. @render context.doc, context.type
  19. else if context.entry
  20. if context.entry.isIndex()
  21. @render context.doc
  22. else
  23. @render context.doc, context.entry.getType(), context.entry
  24. else
  25. @hide()
  26. if @clicked
  27. @clicked = null
  28. app.document.sidebar.reset()