History

Show guide/tutorial types at the top of the list

Thibaut committed 11 years ago

Commit bff40331 parent 14464292 files · +17 −1Browse files

Unified · Split

2 files
  1. assets/javascripts/collections/types.coffee +14 −0
  2. assets/javascripts/views/sidebar/type_list.coffee +3 −1
assets/javascripts/collections/types.coffee+14−0
@@ -1,2 +1,16 @@
1class app.collections.Types extends app.Collection1class app.collections.Types extends app.Collection
2 @model: 'Type'2 @model: 'Type'
3
4 groups: ->
5 result = []
6 for type in @models
7 (result[@_groupFor(type)] ||= []).push(type)
8 result.filter (e) -> e.length > 0
9
10 GUIDES_RGX = /guide|tutorial/i
11
12 _groupFor: (type) ->
13 if GUIDES_RGX.test(type.name)
14 0
15 else
16 1
assets/javascripts/views/sidebar/type_list.coffee+3−1
@@ -25,7 +25,9 @@ class app.views.TypeList extends app.View · 24 unmodified lines
25 return25 return
26 26
27 render: ->27 render: ->
28 @html @tmpl('sidebarType', @doc.types.all())28 html = ''
29 html += @tmpl('sidebarType', group) for group in @doc.types.groups()
30 @html(html)
29 31
30 onOpen: (event) =>32 onOpen: (event) =>
31 $.stopEvent(event)33 $.stopEvent(event)