fix column class name for table list cells

This commit is contained in:
rolux 2013-02-08 17:49:27 +05:30
parent f64ee18aa4
commit 32271e2578

View file

@ -416,7 +416,7 @@ Ox.TableList = function(options, self) {
self.visibleColumns.forEach(function(column, i) { self.visibleColumns.forEach(function(column, i) {
var $resize; var $resize;
self.$heads[i] = Ox.Element() self.$heads[i] = Ox.Element()
.addClass('OxHeadCell OxColumn' + Ox.toTitleCase(column.id)) .addClass('OxHeadCell ' + getColumnClassName(column.id))
.css({width: self.columnWidths[i] - 5 + 'px'}) .css({width: self.columnWidths[i] - 5 + 'px'})
.appendTo(that.$head.$content.$element); .appendTo(that.$head.$content.$element);
// if sort operator is set, bind click event // if sort operator is set, bind click event
@ -536,7 +536,7 @@ Ox.TableList = function(options, self) {
$cell = $('<div>'); $cell = $('<div>');
} }
$cell.addClass( $cell.addClass(
'OxCell OxColumn' + v.id[0].toUpperCase() + v.id.slice(1) 'OxCell ' + getColumnClassName(v.id)
+ (clickable ? ' OxClickable' : '') + (clickable ? ' OxClickable' : '')
+ (editable ? ' OxEditable' : '') + (editable ? ' OxEditable' : '')
) )
@ -568,7 +568,7 @@ Ox.TableList = function(options, self) {
startPos: getColumnPositionById(id) startPos: getColumnPositionById(id)
} }
self.drag.stopPos = self.drag.startPos; self.drag.stopPos = self.drag.startPos;
$('.OxColumn' + Ox.toTitleCase(id)).css({opacity: 0.25}); $('.' + getColumnClassName(id)).css({opacity: 0.25});
self.drag.startPos > 0 && self.$heads[self.drag.startPos].prev().children().eq(2).css({opacity: 0.25}); self.drag.startPos > 0 && self.$heads[self.drag.startPos].prev().children().eq(2).css({opacity: 0.25});
self.$heads[self.drag.startPos].next().children().eq(0).css({opacity: 0.25}); self.$heads[self.drag.startPos].next().children().eq(0).css({opacity: 0.25});
self.$heads[self.drag.startPos].addClass('OxDrag').css({ // fixme: why does the class not work? self.$heads[self.drag.startPos].addClass('OxDrag').css({ // fixme: why does the class not work?
@ -629,7 +629,7 @@ Ox.TableList = function(options, self) {
self.columnWidths.splice(self.drag.stopPos, 0, width); self.columnWidths.splice(self.drag.stopPos, 0, width);
that.$head.$content.empty(); that.$head.$content.empty();
constructHead(); constructHead();
$('.OxColumn' + Ox.toTitleCase(id)).css({opacity: 1}); $('.' + getColumnClassName(id)).css({opacity: 1});
self.$heads[self.drag.stopPos].removeClass('OxDrag').css({ self.$heads[self.drag.stopPos].removeClass('OxDrag').css({
cursor: 'pointer' cursor: 'pointer'
}); });
@ -709,10 +709,14 @@ Ox.TableList = function(options, self) {
var $item = getItem(id); var $item = getItem(id);
key = key || ''; // fixme: what is this? key = key || ''; // fixme: what is this?
return $($item.find( return $($item.find(
'.OxCell.OxColumn' + key[0].toUpperCase() + key.slice(1) '.OxCell.' + getColumnClassName(key)
)[0]); )[0]);
} }
function getColumnClassName(id) {
return 'OxColumn' + id[0].toUpperCase() + id.slice(1);
}
function getColumnOffsets() { function getColumnOffsets() {
return self.visibleColumns.map(function(column, i) { return self.visibleColumns.map(function(column, i) {
return Ox.sum(self.visibleColumns.map(function(column_, i_) { return Ox.sum(self.visibleColumns.map(function(column_, i_) {
@ -764,8 +768,8 @@ Ox.TableList = function(options, self) {
//Ox.Log('List', 'moveColumn', id, pos) //Ox.Log('List', 'moveColumn', id, pos)
var startPos = getColumnPositionById(id), var startPos = getColumnPositionById(id),
stopPos = pos, stopPos = pos,
startSelector = '.OxColumn' + Ox.toTitleCase(id), startSelector = '.' + getColumnClassName(id),
stopSelector = '.OxColumn' + Ox.toTitleCase(self.visibleColumns[stopPos].id), stopSelector = '.' + getColumnClassName(self.visibleColumns[stopPos].id),
insert = startPos < stopPos ? 'insertAfter' : 'insertBefore', insert = startPos < stopPos ? 'insertAfter' : 'insertBefore',
$column = $('.OxHeadCell' + startSelector), $column = $('.OxHeadCell' + startSelector),
$resize = $column.next(); $resize = $column.next();
@ -803,7 +807,7 @@ Ox.TableList = function(options, self) {
var index = getColumnIndexById(id), var index = getColumnIndexById(id),
itemWidth, itemWidth,
position = getColumnPositionById(id), position = getColumnPositionById(id),
selector = '.OxColumn' + Ox.toTitleCase(id), selector = '.' + getColumnClassName(id),
$column = $('.OxHeadCell ' + selector), $column = $('.OxHeadCell ' + selector),
$order = $column.next(), $order = $column.next(),
$resize = $order.next(); $resize = $order.next();
@ -854,7 +858,9 @@ Ox.TableList = function(options, self) {
width: width - 9 - (i == self.selectedColumn ? 16 : 0) + 'px' width: width - 9 - (i == self.selectedColumn ? 16 : 0) + 'px'
}); });
} }
that.find('.OxCell.OxColumn' + Ox.toTitleCase(self.options.columns[i].id)).css({ that.find(
'.OxCell.' + getColumnClassName(self.options.columns[i].id)
).css({
width: width - (self.options.columnsVisible ? 9 : 8) + 'px' width: width - (self.options.columnsVisible ? 9 : 8) + 'px'
}); });
setWidth(); setWidth();