Issue #303189 by Darren Oh, fietserwin, q0rban, bdragon, osopolar, dboulet, Peter Törnstrand: Fixed Tabledrag doesn't hide columns when the whole table is initially hidden.

8.0.x
webchick 2011-07-28 18:15:41 -04:00
parent d9c39038bf
commit ca20bc0457
1 changed files with 12 additions and 15 deletions

View File

@ -131,31 +131,28 @@ Drupal.tableDrag.prototype.initColumns = function () {
} }
// Mark the column containing this field so it can be hidden. // Mark the column containing this field so it can be hidden.
if (hidden && cell[0] && cell.css('display') != 'none') { if (hidden && cell[0]) {
// Add 1 to our indexes. The nth-child selector is 1 based, not 0 based. // Add 1 to our indexes. The nth-child selector is 1 based, not 0 based.
// Match immediate children of the parent element to allow nesting. // Match immediate children of the parent element to allow nesting.
var columnIndex = $('> td', cell.parent()).index(cell.get(0)) + 1; var columnIndex = $('> td', cell.parent()).index(cell.get(0)) + 1;
var headerIndex = $('> td:not(:hidden)', cell.parent()).index(cell.get(0)) + 1; $('> thead > tr, > tbody > tr, > tr', this.table).each(function () {
$('> thead > tr, > tbody > tr, > tr', this.table).each(function (){ // Get the columnIndex and adjust for any colspans in this row.
var row = $(this); var index = columnIndex;
var parentTag = row.parent().get(0).tagName.toLowerCase(); var cells = $(this).children();
var index = (parentTag == 'thead') ? headerIndex : columnIndex; cells.each(function (n) {
if (n < index && this.colSpan && this.colSpan > 1) {
// Adjust the index to take into account colspans. index -= this.colSpan - 1;
row.children().each(function (n) {
if (n < index) {
index -= (this.colSpan && this.colSpan > 1) ? this.colSpan - 1 : 0;
} }
}); });
if (index > 0) { if (index > 0) {
cell = row.children(':nth-child(' + index + ')'); cell = cells.filter(':nth-child(' + index + ')');
if (cell[0].colSpan > 1) { if (cell[0].colSpan && cell[0].colSpan > 1) {
// If this cell has a colspan, mark it so we can reduce the colspan. // If this cell has a colspan, mark it so we can reduce the colspan.
$(cell[0]).addClass('tabledrag-has-colspan'); cell.addClass('tabledrag-has-colspan');
} }
else { else {
// Mark this cell so we can hide it. // Mark this cell so we can hide it.
$(cell[0]).addClass('tabledrag-hide'); cell.addClass('tabledrag-hide');
} }
} }
}); });