1
0
Fork 0
forked from 0x2620/oxjs

url controller updates, list bugfixes

This commit is contained in:
rlx 2011-09-28 17:31:35 +00:00
commit 3965eed153
12 changed files with 98 additions and 48 deletions

View file

@ -134,6 +134,7 @@ Ox.IconItem = function(options, self) {
);
function formatText(text, maxLines, maxLength) {
text = Ox.isArray(text) ? text.join(', ') : text;
var lines = Ox.wordwrap(text, maxLength, '<br/>', true, false).split('<br/>');
return Ox.map(lines, function(line, i) {
if (i < maxLines - 1) {

View file

@ -113,9 +113,8 @@ Ox.IconList = function(options, self) {
}
function updateKeys() {
self.options.keys = Ox.unique(Ox.merge(self.options.keys, [self.options.sort[0].key]));
that.$element.options({
keys: self.options.keys
keys: Ox.unique(Ox.merge(self.options.sort[0].key, self.options.keys))
});
}
@ -129,7 +128,9 @@ Ox.IconList = function(options, self) {
} else if (key == 'selected') {
that.$element.options(key, value);
} else if (key == 'sort') {
updateKeys();
that.$element.options(key, value);
//that.$element.sortList(key, operator);
}
};
@ -177,6 +178,7 @@ Ox.IconList = function(options, self) {
that.$element.size();
};
// fixme: deprecate, use options()
/*@
sortList <f> sort list
(key, operator) -> <o> the list

View file

@ -37,7 +37,7 @@ Ox.List <f:Ox.Element> List Element
draganddropstart <i> Fires when drag starts
copy <!> copy
paste <!> paste
movie <!> move item
move <!> move item
load <!> list loaded
openpreview <!> preview of selected item opened
closepreview <!> preview closed
@ -291,7 +291,7 @@ Ox.List = function(options, self) {
Ox.Request.cancel(v);
});
Ox.extend(self, {
//$items: [],
$items: [],
$pages: [],
page: 0,
requests: []
@ -677,6 +677,7 @@ Ox.List = function(options, self) {
function loadItems() {
that.$content.empty();
self.$items = [];
self.options.items.forEach(function(item, pos) {
// fixme: duplicated
self.$items[pos] = Ox.ListItem({
@ -1649,17 +1650,20 @@ Ox.List = function(options, self) {
value <s> value, can be whatever that property is
@*/
that.value = function(id, key, value) {
//Ox.print('that.value', id, getPositionById(id))
var pos = getPositionById(id),
$item = self.$items[pos],
data = $item.options('data'),
oldValue;
data = $item.options('data');
if (arguments.length == 1) {
return data;
} else if (arguments.length == 2) {
return data[key];
} else {
oldValue = data[key];
if (key == self.options.unique) {
// unique id has changed
self.options.selected = self.options.selected.map(function(id_) {
return id_ == data[key] ? value : id_
});
}
data[key] = value;
$item.options({data: data});
return that;

View file

@ -196,7 +196,7 @@ Ox.TextList = function(options, self) {
sortable: self.options.sortable,
type: 'text',
unique: self.unique
}, Ox.extend({}, self)) // pass event handler
}, Ox.clone(self)) // pass event handler
.addClass('OxBody')
.css({
top: (self.options.columnsVisible ? 16 : 0) + 'px',
@ -222,7 +222,6 @@ Ox.TextList = function(options, self) {
//that.triggerEvent('init', data);
},
select: function() {
Ox.print('SELECT????')
self.options.selected = that.$body.options('selected');
}
})
@ -929,18 +928,19 @@ Ox.TextList = function(options, self) {
return that.$body.value(id, key);
} else {
that.$body.value(id, key, value);
//Ox.print('? ? ?', column, column.format)
if (key == self.unique) {
// unique id has changed
self.options.selected = self.options.selected.map(function(id_) {
return id_ == id ? value : id_
});
id = value;
}
$cell = getCell(id, key);
$cell && $cell.html(formatValue(key, value));
if (key == self.options.sort[0].key) {
// sort key has changed
that.$body.sort();
}
/* fixme: something like this is needed:
if (column.unique) {
that.$body.setId($item.data('id'), value);
$item.data({id: value});
}
*/
return that;
}
}