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;
|
||||
|
||||
};
|
|
@ -160,8 +160,7 @@ Ox.TreeList = function(options, self) {
|
|||
function toggleItem(item, expanded) {
|
||||
var $img, pos;
|
||||
item.expanded = expanded;
|
||||
getItemById(item.id).expanded = expanded;
|
||||
Ox.print('>>>>', getItemById(item.id))
|
||||
//getItemById(item.id).expanded = expanded;
|
||||
$.each(that.$element.find('.OxItem'), function(i, v) {
|
||||
var $item = $(v);
|
||||
if ($item.data('id') == item.id) {
|
||||
|
@ -170,15 +169,13 @@ Ox.TreeList = function(options, self) {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
///*
|
||||
$img.attr({
|
||||
src: Ox.UI.getImagePath(
|
||||
'symbol' + (item.expanded ? 'Down' : 'Right') + '.svg'
|
||||
'symbol' + (expanded ? 'Down' : 'Right') + '.svg'
|
||||
)
|
||||
});
|
||||
//*/
|
||||
that.$element.value(item.id, 'expanded', expanded);
|
||||
item.expanded ?
|
||||
expanded ?
|
||||
that.$element.addItems(pos + 1, parseItems(item.items, item.level + 1)) :
|
||||
that.$element.removeItems(pos + 1, parseItems(item.items, item.level + 1).length);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue