mirror of https://github.com/freeCodeCamp/devdocs
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.
37 lines
751 B
37 lines
751 B
class app.views.Path extends app.View
|
|
@className: '_path'
|
|
|
|
@events:
|
|
click: 'onClick'
|
|
|
|
@routes:
|
|
after: 'afterRoute'
|
|
|
|
render: (args...) ->
|
|
@show()
|
|
@html @tmpl 'path', args...
|
|
|
|
show: ->
|
|
$.prepend $('._app'), @el unless @el.parentNode
|
|
|
|
hide: ->
|
|
$.remove @el if @el.parentNode
|
|
|
|
onClick: (event) =>
|
|
@clicked = true if link = $.closestLink event.target, @el
|
|
|
|
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()
|