sorting the anchor

This commit is contained in:
Galen Wolfe-Pauly 2015-08-05 18:59:57 -07:00
parent cd35cc966d
commit 35c3974d0d
2 changed files with 21 additions and 3 deletions

View File

@ -20,7 +20,13 @@ Links = React.createFactory query {
displayName: "Links"
render: -> div {className:'links'}, @props.children, @_render()
_render: ->
keys = _(@props.kids).keys().sort()
sorted = true
keys = []
for k,v of @props.kids
if not v.meta.sort then sorted = false
keys[Number(v.meta.sort)] = k
if sorted isnt true
keys = _(@props.kids).keys().sort()
style = {marginTop: -24 * (keys.indexOf @props.curr) + "px"}
div {id:"sibs",style}, keys.map (key) =>
href = window.tree.basepath @props.path+"/"+key

View File

@ -91,8 +91,20 @@ Links = React.createFactory(query({
}, this.props.children, this._render());
},
_render: function() {
var keys, style;
keys = _(this.props.kids).keys().sort();
var k, keys, ref1, sorted, style, v;
sorted = true;
keys = [];
ref1 = this.props.kids;
for (k in ref1) {
v = ref1[k];
if (!v.meta.sort) {
sorted = false;
}
keys[Number(v.meta.sort)] = k;
}
if (sorted !== true) {
keys = _(this.props.kids).keys().sort();
}
style = {
marginTop: -24 * (keys.indexOf(this.props.curr)) + "px"
};