Sort docs by name in the sidebar

pull/110/head
Thibaut 11 years ago
parent 115ffa8fc8
commit 8edeeffc4f

@ -69,6 +69,8 @@
docs = @settings.getDocs()
for doc in @DOCS
(if docs.indexOf(doc.slug) >= 0 then @docs else @disabledDocs).add(doc)
@docs.sort()
@disabledDocs.sort()
@docs.load @start.bind(@), @onBootError.bind(@), readCache: true, writeCache: true
delete @DOCS
return

@ -1,6 +1,12 @@
class app.collections.Docs extends app.Collection
@model: 'Doc'
sort: ->
@models.sort (a, b) ->
a = a.name.toLowerCase()
b = b.name.toLowerCase()
if a < b then -1 else if a > b then 1 else 0
# Load models concurrently.
# It's not pretty but I didn't want to import a promise library only for this.
CONCURRENCY = 3

Loading…
Cancel
Save