From c8b23d9aed6d73ec443eb16aee4f2fc4b3303b81 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Thu, 18 Sep 2008 18:37:29 +0000 Subject: #201799 by yched, quicksketch: compute identation width for draggables better, counting on padding and margin as well as measuring the width at the place where it is used (taking possible CSS overrides into account) --- misc/tabledrag.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'misc/tabledrag.js') diff --git a/misc/tabledrag.js b/misc/tabledrag.js index 1851f802d..94c259da3 100644 --- a/misc/tabledrag.js +++ b/misc/tabledrag.js @@ -73,10 +73,12 @@ Drupal.tableDrag = function(table, tableSettings) { this.indentCount = 1; // Total width of indents, set in makeDraggable. // Find the width of indentations to measure mouse movements against. // Because the table doesn't need to start with any indentations, we - // manually create an empty div, check it's width, then remove. - var indent = $(Drupal.theme('tableDragIndentation')).appendTo('body'); - this.indentAmount = parseInt(indent.css('width')); - indent.remove(); + // manually append 2 indentations in the first draggable row, measure + // the offset, then remove. + var indent = Drupal.theme('tableDragIndentation'); + var testCell = $('tr.draggable:first td:first', table).prepend(indent).prepend(indent); + this.indentAmount = $('.indentation', testCell).get(1).offsetLeft - $('.indentation', testCell).get(0).offsetLeft; + $('.indentation', testCell).slice(0, 2).remove(); } // Make each applicable row draggable. @@ -407,7 +409,7 @@ Drupal.tableDrag.prototype.dragRow = function(event, self) { if (self.indentEnabled) { var xDiff = self.currentMouseCoords.x - self.dragObject.indentMousePos.x; // Set the number of indentations the mouse has been moved left or right. - var indentDiff = parseInt(xDiff / self.indentAmount * self.rtl); + var indentDiff = Math.round(xDiff / self.indentAmount * self.rtl); // Indent the row with our estimated diff, which may be further // restricted according to the rows around this row. var indentChange = self.rowObject.indent(indentDiff); -- cgit v1.2.3