diff misc/tabledrag.js @ 11:589fb7c02327 6.5

Drupal 6.5
author Franck Deroche <webmaster@defr.org>
date Tue, 23 Dec 2008 14:32:19 +0100
parents fff6d4c8c043
children
line wrap: on
line diff
--- a/misc/tabledrag.js	Tue Dec 23 14:32:08 2008 +0100
+++ b/misc/tabledrag.js	Tue Dec 23 14:32:19 2008 +0100
@@ -1,4 +1,4 @@
-// $Id: tabledrag.js,v 1.13.2.3 2008/06/12 19:13:25 dries Exp $
+// $Id: tabledrag.js,v 1.13.2.4 2008/09/17 07:59:39 goba Exp $
 
 /**
  * Drag and drop table rows with field manipulation.
@@ -73,10 +73,12 @@
     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 @@
     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);