slightly faster text list construction for cells that don't have tooltips; make calendar layout deterministic for events that have the same time span

This commit is contained in:
rlx 2011-10-11 06:32:20 +00:00
commit 527f75b009
4 changed files with 44 additions and 26 deletions

View file

@ -687,18 +687,24 @@ Ox.List = function(options, self) {
function loadItems() {
self.$page.empty();
self.$items = [];
var timeC = 0, timeA = 0;
self.options.items.forEach(function(item, pos) {
// fixme: duplicated
var time0 = +new Date();
self.$items[pos] = Ox.ListItem({
construct: self.options.construct,
data: item,
position: pos,
unique: self.options.unique
});
timeC += +new Date() - time0;
isSelected(pos) && self.$items[pos].addClass('OxSelected');
var time0 = +new Date();
self.$items[pos].appendTo(self.$page);
timeA += +new Date() - time0;
});
self.selected.length && scrollToPosition(self.selected[0]);
Ox.print('CONSTRUCT:', timeC, 'APPEND:', timeA);
// that.triggerEvent('init', {items: self.options.items.length});
// fixme: do sync lists need to trigger init?
// will this only be reached in sync lists?

View file

@ -404,30 +404,35 @@ Ox.TextList = function(options, self) {
self.visibleColumns.forEach(function(v, i) {
var clickable = Ox.isBoolean(v.clickable) ? v.clickable : v.clickable(data),
editable = Ox.isBoolean(v.editable) ? v.editable : v.editable(data),
$cell;
if (v.tooltip) {
$cell = Ox.Element({
tooltip: v.tooltip ? function() {
return self.options.selected.indexOf(data[self.unique]) > -1
? (Ox.isString(v.tooltip) ? v.tooltip : v.tooltip(data)) : '';
} : null
})
.addClass(
'OxCell OxColumn' + Ox.toTitleCase(v.id) +
(clickable ? ' OxClickable' : '') +
(editable ? ' OxEditable' : '')
)
.css({
width: (self.columnWidths[i] - (self.options.columnsVisible ? 9 : 8)) + 'px',
borderRightWidth: (self.options.columnsVisible ? 1 : 0) + 'px',
textAlign: v.align
})
.html(v.id in data ? formatValue(v.id, data[v.id], data) : '')
.appendTo($item);
tooltip: function() {
return self.options.selected.indexOf(data[self.unique]) > -1
? (Ox.isString(v.tooltip) ? v.tooltip : v.tooltip(data)) : '';
}
});
} else {
$cell = $('<div>');
}
$cell.addClass(
'OxCell OxColumn' + Ox.toTitleCase(v.id) +
(clickable ? ' OxClickable' : '') +
(editable ? ' OxEditable' : '')
)
.css({
width: (self.columnWidths[i] - (self.options.columnsVisible ? 9 : 8)) + 'px',
borderRightWidth: (self.options.columnsVisible ? 1 : 0) + 'px',
textAlign: v.align
})
// if the column id is not in data, we're constructing an empty cell
.html(v.id in data ? formatValue(v.id, data[v.id], data) : '')
.appendTo($item);
});
return $item;
}
function dragstartColumn(id, e) {
//Ox.print(that.$body.scrollLeft(), '??')
self.drag = {
columnOffsets: getColumnOffsets(),
listOffset: that.$element.offset().left - that.$body.scrollLeft(),
@ -440,7 +445,6 @@ Ox.TextList = function(options, self) {
self.$heads[self.drag.startPos].addClass('OxDrag').css({ // fixme: why does the class not work?
cursor: 'move'
});
//Ox.print('columnOffsets', self.drag.columnOffsets)
}
function dragColumn(id, e) {