You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/assets/javascripts/views/layout/path.coffee

44 lines
839 B

class app.views.Path extends app.View
@className: '_path'
@attributes:
role: 'complementary'
@events:
click: 'onClick'
@routes:
after: 'afterRoute'
render: (args...) ->
@html @tmpl 'path', args...
@show()
return
show: ->
@prependTo app.el unless @el.parentNode
return
hide: ->
$.remove @el if @el.parentNode
return
onClick: (event) =>
@clicked = true if link = $.closestLink event.target, @el
return
afterRoute: (route, context) =>
if context.type
@render context.doc, context.type
else if context.entry
if context.entry.isIndex()
@render context.doc
else
@render context.doc, context.entry.getType(), context.entry
else
@hide()
if @clicked
@clicked = null
app.document.sidebar.reset()
return