1
0
Fork 0
forked from 0x2620/oxjs

improve InfoList

This commit is contained in:
rlx 2011-10-16 12:32:02 +00:00
commit 95f3d536ec
7 changed files with 105 additions and 46 deletions

View file

@ -31,6 +31,7 @@ Ox.IconItem = function(options, self) {
iconWidth: 128,
imageHeight: 128,
imageWidth: 128,
isInfoList: false,
itemHeight: 192,
itemWidth: 128,
id: '',
@ -72,7 +73,8 @@ Ox.IconItem = function(options, self) {
that.$icon = $('<div>')
.addClass('OxIcon')
.css({
top: self.options.iconWidth == 64 ? -64 : -124,
top: self.options._isInfoList
? 0 : self.options.iconWidth == 64 ? -64 : -124,
width: (self.options.iconWidth + 4) + 'px',
height: (self.options.iconHeight + 4) + 'px'
});
@ -93,7 +95,9 @@ Ox.IconItem = function(options, self) {
that.$textBox = $('<div>')
.addClass('OxText')
.css({
top: self.options.iconHeight - self.options.itemWidth / 2 + 'px',
top: self.options._isInfoList
? self.options.iconHeight
: self.options.iconHeight - self.options.itemWidth / 2 + 'px',
width: self.options.itemWidth + 4 + 'px',
height: (self.options.itemWidth == 64 ? 30 : 58) + 'px'
});

View file

@ -76,7 +76,7 @@ Ox.IconList = function(options, self) {
sort: self.options.sort,
type: 'icon',
unique: self.options.unique
}, Ox.extend({}, self)) // pass event handler
}, Ox.clone(self)) // pass event handler
.addClass('OxIconList Ox' + Ox.toTitleCase(self.options.orientation))
.bindEvent({
select: function() {

View file

@ -39,8 +39,13 @@ Ox.InfoList = function(options, self) {
sort: self.options.sort,
type: 'info',
unique: self.options.unique
})
.addClass('OxInfoList');
}, Ox.clone(self))
.addClass('OxInfoList')
.bindEvent({
select: function() {
self.options.selected = that.$element.options('selected');
}
});
updateKeys();
@ -64,10 +69,10 @@ Ox.InfoList = function(options, self) {
var $icon = Ox.Element()
.css({
float: 'left',
width: '128px',
height: '192px',
margin: '4px',
background: 'rgba(255, 255, 255, 0.1)'
width: '132px',
height: '194px',
margin: '2px',
//background: 'blue'
})
.append(
Ox.IconItem(Ox.extend(data.icon, {
@ -76,10 +81,11 @@ Ox.InfoList = function(options, self) {
iconWidth: 128, //self.iconWidth,
imageHeight: data.height,
imageWidth: data.width,
isInfoList: true,
itemHeight: self.itemHeight,
itemWidth: 128,
}))
.addClass('OxIcon')
.addClass('OxInfoIcon')
.css({
position: 'absolute'
})
@ -89,7 +95,8 @@ Ox.InfoList = function(options, self) {
float: 'left',
width: getItemWidth() - 152 + 'px',
height: '192px',
margin: '4px'
margin: '4px',
//background: 'green'
}),
$infobox = Ox.Element()
.css({
@ -103,7 +110,8 @@ Ox.InfoList = function(options, self) {
.css({
width: getItemWidth() - 8 + 'px',
height: 192 + 'px',
margin: '4px'
margin: '4px',
//background: 'red'
})
.append($icon)
.append($info);
@ -153,10 +161,6 @@ Ox.InfoList = function(options, self) {
$parent.parent().css({width: width - 152});
$parent.parent().parent().css({width: width - 8});
Ox.print('@@@', this.className, id)
Ox.print('@@@', this.className, id)
Ox.print('@@@', this.className, id)
Ox.print('@@@', this.className, id)
Ox.print('@@@', this.className, id)
Ox.UI.elements[id].options({width: width - 152});
});
}
@ -167,6 +171,47 @@ Ox.InfoList = function(options, self) {
return that;
};
that.paste = function(data) {
that.$element.paste(data);
return that;
};
that.reloadList = function() {
that.$element.reloadList();
return that;
};
that.scrollToSelection = function() {
that.$element.scrollToSelection();
return that;
};
that.size = function() {
that.$element.size();
};
that.sortList = function(key, operator) {
self.options.sort = [{
key: key,
operator: operator
}];
updateKeys();
that.$element.sortList(key, operator);
return that;
};
that.value = function(id, key, value) {
// fixme: make this accept id, {k: v, ...}
if (arguments.length == 1) {
return that.$element.value(id);
} else if (arguments.length == 2) {
return that.$element.value(id, key);
} else {
that.$element.value(id, key, value);
return that;
}
};
return that;
};