diff --git a/js/makegrid.js b/js/makegrid.js index 6abbe6eabf..66161add37 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -52,8 +52,10 @@ left: objPos.left }); } - // get the column index - var n = $(this.t).find('th.draggable').index(obj); + + // get the column index, zero-based + var n = this.getHeaderIdx(obj); + this.colMov = { x0: e.pageX, y0: e.pageY, @@ -89,7 +91,7 @@ // pointer animation var hoveredCol = this.getHoveredCol(e); if (hoveredCol) { - var newn = $(this.t).find('th.draggable').index(hoveredCol); + var newn = this.getHeaderIdx(hoveredCol); this.colMov.newn = newn; if (newn != this.colMov.n) { // show the column pointer in the right place @@ -127,12 +129,9 @@ var n = this.colRsz.n; // do the resizing if (this.alignment != 'vertical') { - // resize the header - $(this.t).find('th.draggable:eq(' + n + ') span') - .css('width', nw); - // resize the data - $(this.t).find('tr:gt(0)').each(function() { - $(this).find('td:eq(' + (g.actionSpan + n) + ') span') + $(this.t).find('tr').each(function() { + $(this).find('th.draggable:eq(' + n + ') span,' + + 'td:eq(' + (g.actionSpan + n) + ') span') .css('width', nw); }); } else { // vertical alignment @@ -176,7 +175,7 @@ reposRsz: function() { $(this.cRsz).find('div').hide(); $firstRowCols = this.alignment != 'vertical' ? - $(this.t).find('th.draggable') : + $(this.t).find('tr:first th.draggable') : $(this.t).find('tr:first td'); var firstElmtIdx = $firstRowCols.index(); $firstRowCols.each(function() { @@ -194,24 +193,17 @@ */ shiftCol: function(oldn, newn) { if (this.alignment != 'vertical') { - // shift header - $(this.t).find('thead tr').each(function() { + $(this.t).find('tr').each(function() { if (newn < oldn) { - $(this).find('th.draggable:eq(' + newn + ')') - .before($(this).find('th.draggable:eq(' + oldn + ')')); + $(this).find('th.draggable:eq(' + newn + '),' + + 'td:eq(' + (g.actionSpan + newn) + ')') + .before($(this).find('th.draggable:eq(' + oldn + '),' + + 'td:eq(' + (g.actionSpan + oldn) + ')')); } else { - $(this).find('th.draggable:eq(' + newn + ')') - .after($(this).find('th.draggable:eq(' + oldn + ')')); - } - }); - // shift data - $(this.t).find('tbody tr').each(function() { - if (newn < oldn) { - $(this).find('td:eq(' + (g.actionSpan + newn) + ')') - .before($(this).find('td:eq(' + (g.actionSpan + oldn) + ')')); - } else { - $(this).find('td:eq(' + (g.actionSpan + newn) + ')') - .after($(this).find('td:eq(' + (g.actionSpan + oldn) + ')')); + $(this).find('th.draggable:eq(' + newn + '),' + + 'td:eq(' + (g.actionSpan + newn) + ')') + .after($(this).find('th.draggable:eq(' + oldn + '),' + + 'td:eq(' + (g.actionSpan + oldn) + ')')); } }); // reposition the column resize bars @@ -254,6 +246,21 @@ }); } return hoveredCol; + }, + + /** + * Get a zero-based index from a tag in a table. + */ + getHeaderIdx: function(obj) { + var n; + if (this.alignment != 'vertical') { + n = $(obj).parents('tr').find('th.draggable').index(obj); + } else { + var column_idx = $(obj).index(); + var $th_in_same_column = $(this.t).find('th.draggable:nth-child(' + (column_idx + 1) + ')'); + n = $th_in_same_column.index(obj); + } + return n; } } @@ -279,7 +286,7 @@ // get first row data columns var $firstRowCols = g.alignment != 'vertical' ? - $(t).find('th.draggable') : + $(t).find('tr:first th.draggable') : $(t).find('tr:first td'); // assign first column (actions) span diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php index 9805ca219a..6e64fe4976 100644 --- a/themes/original/css/theme_right.css.php +++ b/themes/original/css/theme_right.css.php @@ -1881,7 +1881,7 @@ span.mysql-number { width: 5px; } -.pma_table thead th span, .pma_table tbody td span { +.pma_table th.draggable span, .pma_table tbody td span { display: block; overflow: hidden; } diff --git a/themes/pmahomme/css/theme_right.css.php b/themes/pmahomme/css/theme_right.css.php index 6494e27616..56e57f2a81 100644 --- a/themes/pmahomme/css/theme_right.css.php +++ b/themes/pmahomme/css/theme_right.css.php @@ -2215,7 +2215,7 @@ span.mysql-number { width: 5px; } -.pma_table thead th span, .pma_table tbody td span { +.pma_table th.draggable span, .pma_table tbody td span { display: block; overflow: hidden; }