forked from freeCodeCamp/devdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpath.coffee
More file actions
43 lines (35 loc) · 839 Bytes
/
Copy pathpath.coffee
File metadata and controls
43 lines (35 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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