Ox.CustomList: add public 'selectPosition' and 'size' methods, add 'resize' option (fn(, width) that runs for each item, on resize)

This commit is contained in:
rolux 2012-12-18 11:47:40 +01:00
parent 10eafb0bd4
commit 087c7eb956

View file

@ -20,6 +20,7 @@ Ox.CustomList = function(options, self) {
min: 0,
pageLength: 100,
query: {conditions: [], operator: '&'},
resize: null,
scrollbarVisible: false,
selected: [],
sort: [],
@ -32,6 +33,14 @@ Ox.CustomList = function(options, self) {
items: function() {
self.$list.options({items: self.options.items});
},
itemWidth: function() {
var width = self.options.itemWidth - Ox.UI.SCROLLBAR_SIZE;
if (self.options.resize) {
that.$element.find('.OxItem').each(function(element) {
self.options.resize($(this), width);
});
}
},
selected: function() {
self.$list.options({selected: self.options.selected});
// FIXME: TableList doesn't trigger event here
@ -42,7 +51,9 @@ Ox.CustomList = function(options, self) {
self.$list = Ox.List({
construct: function(data) {
return self.options.item(data, self.options.itemWidth - Ox.UI.SCROLLBAR_SIZE).addClass('OxTarget');
return self.options.item(
data, self.options.itemWidth - Ox.UI.SCROLLBAR_SIZE
).addClass('OxTarget');
},
draggable: self.options.draggable,
itemHeight: self.options.itemHeight,
@ -99,6 +110,22 @@ Ox.CustomList = function(options, self) {
return that;
};
/*@
selectPosition <f> select position
@*/
that.selectPosition = function(pos) {
self.$list.selectPosition(pos);
return that;
};
/*@
size <f> size
@*/
that.size = function() {
self.$list.size();
return that;
};
return that;
};