summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-07-28 18:15:34 -0400
committerwebchick <webchick@24967.no-reply.drupal.org>2011-07-28 18:15:34 -0400
commit3a45b53736691dc6bdbe2f31f1bf98b8936cf17e (patch)
tree2343cf66c25f14631b7dcc26ad6fa2ecb6945c9b /misc
parenta2d21fd739a723901466fee1167e899e1c142acb (diff)
downloadbrdo-3a45b53736691dc6bdbe2f31f1bf98b8936cf17e.tar.gz
brdo-3a45b53736691dc6bdbe2f31f1bf98b8936cf17e.tar.bz2
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.
Diffstat (limited to 'misc')
-rw-r--r--misc/tabledrag.js27
1 files changed, 12 insertions, 15 deletions
diff --git a/misc/tabledrag.js b/misc/tabledrag.js
index b566168c3..41fd47b6e 100644
--- a/misc/tabledrag.js
+++ b/misc/tabledrag.js
@@ -131,31 +131,28 @@ Drupal.tableDrag.prototype.initColumns = function () {
}
// 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.
// Match immediate children of the parent element to allow nesting.
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 (){
- var row = $(this);
- var parentTag = row.parent().get(0).tagName.toLowerCase();
- var index = (parentTag == 'thead') ? headerIndex : columnIndex;
-
- // Adjust the index to take into account colspans.
- row.children().each(function (n) {
- if (n < index) {
- index -= (this.colSpan && this.colSpan > 1) ? this.colSpan - 1 : 0;
+ $('> thead > tr, > tbody > tr, > tr', this.table).each(function () {
+ // Get the columnIndex and adjust for any colspans in this row.
+ var index = columnIndex;
+ var cells = $(this).children();
+ cells.each(function (n) {
+ if (n < index && this.colSpan && this.colSpan > 1) {
+ index -= this.colSpan - 1;
}
});
if (index > 0) {
- cell = row.children(':nth-child(' + index + ')');
- if (cell[0].colSpan > 1) {
+ cell = cells.filter(':nth-child(' + index + ')');
+ if (cell[0].colSpan && cell[0].colSpan > 1) {
// 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 {
// Mark this cell so we can hide it.
- $(cell[0]).addClass('tabledrag-hide');
+ cell.addClass('tabledrag-hide');
}
}
});