some quick and ugly fixes to make TreeList work again

This commit is contained in:
rolux 2012-04-04 19:09:10 +02:00
parent fb8dd98b8a
commit 1f8f9ffa7d
3 changed files with 8 additions and 7 deletions

View file

@ -7,7 +7,7 @@
/*
Since we will be doing some mapping, we have to load the Geo module.
*/
Ox.load({UI: {}, Geo: {}}, function() {
Ox.load({UI: {showScreen: true}, Geo: {}}, function() {
Ox.getJSON('json/cities.json', function(cities) {

View file

@ -1463,9 +1463,9 @@ Ox.List = function(options, self) {
$item.insertAfter($items[i - 1]);
}
});
self.options.items.splice.apply(self.options.items, Ox.merge([pos, 0], items));
///////self.options.items.splice.apply(self.options.items, Ox.merge([pos, 0], items));
self.$items.splice.apply(self.$items, Ox.merge([pos, 0], $items));
self.listLength = self.options.items.length;
///////self.listLength = self.options.items.length;
//loadItems();
updatePositions();
}
@ -1569,14 +1569,14 @@ Ox.List = function(options, self) {
self.selected.indexOf(i) > -1 && deselect(i);
self.$items[i].remove();
});
self.options.items.splice(pos, length);
///////self.options.items.splice(pos, length);
self.$items.splice(pos, length);
self.selected.forEach(function(v, i) {
if (v >= pos + length) {
self.selected[i] -= length;
}
});
self.listLength = self.options.items.length;
///////self.listLength = self.options.items.length;
updatePositions();
}
}

View file

@ -48,6 +48,7 @@ Ox.TreeList = function(options, self) {
itemHeight: 16,
items: parseItems(),
itemWidth: self.options.width,
keys: ['expanded', 'id', 'items', 'level', 'title'],
max: self.options.max,
min: self.options.min,
unique: 'id'
@ -73,7 +74,7 @@ Ox.TreeList = function(options, self) {
}
function constructItem(data) {
var $item = $('<div>'), //.css({width: self.options.width + 'px'}),
var $item = $('<div>').css({width: self.options.width + 'px'}),
padding = (data.level + !data.items) * 16 - 8;
if (data.level || !data.items) {
$('<div>')
@ -111,7 +112,7 @@ Ox.TreeList = function(options, self) {
.css({
width: (self.options.width - padding - 32 + !data.items * 16) + 'px'
})
.html(data.title)
.html(data.title || '')
.appendTo($item);
return $item;
}