History

Add path bar

Closes #32.

Thibaut committed 12 years ago

Commit 06bdb771 parent f3cfcd011 files · +94 −-3Browse files

Showing the changes to assets/javascripts (4 of 11 files). Show all

Unified · Split

4 files
  1. assets/javascripts/templates/pages/news_tmpl.coffee +4 −1
  2. assets/javascripts/templates/path_tmpl.coffee +5 −0
  3. assets/javascripts/views/layout/document.coffee +1 −0
  4. assets/javascripts/views/layout/path.coffee +36 −0
assets/javascripts/templates/pages/news_tmpl.coffee+4−1
@@ -24,7 +24,10 @@ newsItem = (date, news) -> · 23 unmodified lines
2424 result
2525
2626 app.news = [
27− [ 1393027200000, # February 22, 2013
27+ [ 1394236800000, # March 8, 2013
28+ """ Added path bar. """,
29+ ], [
30+ 1393027200000, # February 22, 2013
2831 """ New <a href="/c/">C</a> documentation """,
2932 ], [
3033 1392508800000, # February 16, 2013
assets/javascripts/templates/path_tmpl.coffee+5−0
@@ -0,0 +1,5 @@
1+app.templates.path = (doc, type, entry) ->
2+ html = """<a href="#{doc.fullPath()}" class="_path-item _icon-#{doc.slug}">#{doc.name}</a>"""
3+ html += """<a href="#{type.fullPath()}" class="_path-item">#{type.name}</a>""" if type
4+ html += """<span class="_path-item">#{entry.name}</span>""" if entry
5+ html
assets/javascripts/views/layout/document.coffee+1−0
@@ -11,6 +11,7 @@ class app.views.Document extends app.View · 10 unmodified lines
1111 @addSubview @nav = new app.views.Nav,
1212 @addSubview @sidebar = new app.views.Sidebar
1313 @addSubview @content = new app.views.Content
14+ @addSubview @path = new app.views.Path unless app.isSingleDoc() or app.isMobile()
1415
1516 @setTitle()
1617 @activate()
assets/javascripts/views/layout/path.coffee+36−0
@@ -0,0 +1,36 @@
1+class app.views.Path extends app.View
2+ @className: '_path'
3+
4+ @events:
5+ click: 'onClick'
6+
7+ @routes:
8+ after: 'afterRoute'
9+
10+ render: (args...) ->
11+ @show()
12+ @html @tmpl 'path', args...
13+
14+ show: ->
15+ $.prepend $('._app'), @el unless @el.parentNode
16+
17+ hide: ->
18+ $.remove @el if @el.parentNode
19+
20+ onClick: (event) =>
21+ @clicked = true if link = $.closestLink event.target, @el
22+
23+ afterRoute: (route, context) =>
24+ if context.type
25+ @render context.doc, context.type
26+ else if context.entry
27+ if context.entry.isIndex()
28+ @render context.doc
29+ else
30+ @render context.doc, context.entry.getType(), context.entry
31+ else
32+ @hide()
33+
34+ if @clicked
35+ @clicked = null
36+ app.document.sidebar.reset()