path.coffee 792 B

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