summaryrefslogtreecommitdiff
path: root/misc/tabledrag.js
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-09-18 18:37:29 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-09-18 18:37:29 +0000
commitc8b23d9aed6d73ec443eb16aee4f2fc4b3303b81 (patch)
treef952d815595624bc3c00ce7e4fa69246ba978f89 /misc/tabledrag.js
parenta4cb8e0aba180533ddc8b56e9a3112bce251d746 (diff)
downloadbrdo-c8b23d9aed6d73ec443eb16aee4f2fc4b3303b81.tar.gz
brdo-c8b23d9aed6d73ec443eb16aee4f2fc4b3303b81.tar.bz2
#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)
Diffstat (limited to 'misc/tabledrag.js')
-rw-r--r--misc/tabledrag.js12
1 files changed, 7 insertions, 5 deletions
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);