forked from 0x2620/oxjs
better sorting in DocPanel
This commit is contained in:
parent
c589594e8e
commit
7c8bacc7e8
2 changed files with 20 additions and 6 deletions
|
|
@ -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;
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue