1
0
Fork 0
forked from 0x2620/oxjs

better sorting in DocPanel

This commit is contained in:
rolux 2011-05-11 15:53:29 +02:00
commit 7c8bacc7e8
2 changed files with 20 additions and 6 deletions

View file

@ -96,6 +96,13 @@ Ox.DocPanel = function(options, self) {
title: docItem.name
});
});
treeItems.sort(sortByTitle);
treeItems.forEach(function(item) {
item.items.sort(sortByTitle);
item.items.forEach(function(subitem) {
subitem.items.sort(sortByTitle);
})
});
self.$list = Ox.TreeList({
items: treeItems,
width: self.options.width
@ -128,6 +135,16 @@ Ox.DocPanel = function(options, self) {
}
}
function sortByTitle(a, b) {
var ret = 0;
if (a.title < b.title) {
ret = -1;
} else if (a.title > b.title) {
ret = 1;
}
return ret;
}
return that;
};