slightly improved treelist
This commit is contained in:
parent
ffa8f1738a
commit
baf0f72912
1 changed files with 15 additions and 12 deletions
|
@ -31,10 +31,7 @@ Ox.TreeList = function(options, self) {
|
||||||
selected: [],
|
selected: [],
|
||||||
width: 256
|
width: 256
|
||||||
})
|
})
|
||||||
.options(options || {})
|
.options(options || {});
|
||||||
.bindEvent({
|
|
||||||
select: selectItem
|
|
||||||
});
|
|
||||||
|
|
||||||
if (self.options.data) {
|
if (self.options.data) {
|
||||||
self.options.items = [];
|
self.options.items = [];
|
||||||
|
@ -62,10 +59,13 @@ Ox.TreeList = function(options, self) {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
anyclick: clickItem,
|
anyclick: clickItem,
|
||||||
|
select: selectItem,
|
||||||
toggle: toggleItems
|
toggle: toggleItems
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.options.selected.length && selectItem({ids: self.options.selected});
|
||||||
|
|
||||||
function clickItem(e) {
|
function clickItem(e) {
|
||||||
var $target = $(e.target),
|
var $target = $(e.target),
|
||||||
$item, id, item;
|
$item, id, item;
|
||||||
|
@ -155,7 +155,6 @@ Ox.TreeList = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseData(key, value) {
|
function parseData(key, value) {
|
||||||
//Ox.Log('List', 'parseData', key, value)
|
|
||||||
var ret = {
|
var ret = {
|
||||||
expanded: false,
|
expanded: false,
|
||||||
id: Ox.uid().toString(),
|
id: Ox.uid().toString(),
|
||||||
|
@ -208,7 +207,9 @@ Ox.TreeList = function(options, self) {
|
||||||
expanded: true,
|
expanded: true,
|
||||||
ids: parents
|
ids: parents
|
||||||
});
|
});
|
||||||
|
self.$list.options({selected: data.ids})
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleItem(item, expanded) {
|
function toggleItem(item, expanded) {
|
||||||
var $img, pos;
|
var $img, pos;
|
||||||
item.expanded = expanded;
|
item.expanded = expanded;
|
||||||
|
@ -248,7 +249,9 @@ Ox.TreeList = function(options, self) {
|
||||||
if (key == 'data') {
|
if (key == 'data') {
|
||||||
// ...
|
// ...
|
||||||
} else if (key == 'selected') {
|
} else if (key == 'selected') {
|
||||||
self.$list.options({selected: value});
|
//self.$list.options({selected: value});
|
||||||
|
selectItem({ids: value});
|
||||||
|
self.$list.scrollToSelection();
|
||||||
} else if (key == 'width') {
|
} else if (key == 'width') {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue