Mercurial > defr > drupal > core
comparison 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 |
comparison
equal
deleted
inserted
replaced
10:6f15c9d74937 | 11:589fb7c02327 |
---|---|
1 // $Id: tabledrag.js,v 1.13.2.3 2008/06/12 19:13:25 dries Exp $ | 1 // $Id: tabledrag.js,v 1.13.2.4 2008/09/17 07:59:39 goba Exp $ |
2 | 2 |
3 /** | 3 /** |
4 * Drag and drop table rows with field manipulation. | 4 * Drag and drop table rows with field manipulation. |
5 * | 5 * |
6 * Using the drupal_add_tabledrag() function, any table with weights or parent | 6 * Using the drupal_add_tabledrag() function, any table with weights or parent |
71 } | 71 } |
72 if (this.indentEnabled) { | 72 if (this.indentEnabled) { |
73 this.indentCount = 1; // Total width of indents, set in makeDraggable. | 73 this.indentCount = 1; // Total width of indents, set in makeDraggable. |
74 // Find the width of indentations to measure mouse movements against. | 74 // Find the width of indentations to measure mouse movements against. |
75 // Because the table doesn't need to start with any indentations, we | 75 // Because the table doesn't need to start with any indentations, we |
76 // manually create an empty div, check it's width, then remove. | 76 // manually append 2 indentations in the first draggable row, measure |
77 var indent = $(Drupal.theme('tableDragIndentation')).appendTo('body'); | 77 // the offset, then remove. |
78 this.indentAmount = parseInt(indent.css('width')); | 78 var indent = Drupal.theme('tableDragIndentation'); |
79 indent.remove(); | 79 var testCell = $('tr.draggable:first td:first', table).prepend(indent).prepend(indent); |
80 this.indentAmount = $('.indentation', testCell).get(1).offsetLeft - $('.indentation', testCell).get(0).offsetLeft; | |
81 $('.indentation', testCell).slice(0, 2).remove(); | |
80 } | 82 } |
81 | 83 |
82 // Make each applicable row draggable. | 84 // Make each applicable row draggable. |
83 $('tr.draggable', table).each(function() { self.makeDraggable(this); }); | 85 $('tr.draggable', table).each(function() { self.makeDraggable(this); }); |
84 | 86 |
405 | 407 |
406 // Similar to row swapping, handle indentations. | 408 // Similar to row swapping, handle indentations. |
407 if (self.indentEnabled) { | 409 if (self.indentEnabled) { |
408 var xDiff = self.currentMouseCoords.x - self.dragObject.indentMousePos.x; | 410 var xDiff = self.currentMouseCoords.x - self.dragObject.indentMousePos.x; |
409 // Set the number of indentations the mouse has been moved left or right. | 411 // Set the number of indentations the mouse has been moved left or right. |
410 var indentDiff = parseInt(xDiff / self.indentAmount * self.rtl); | 412 var indentDiff = Math.round(xDiff / self.indentAmount * self.rtl); |
411 // Indent the row with our estimated diff, which may be further | 413 // Indent the row with our estimated diff, which may be further |
412 // restricted according to the rows around this row. | 414 // restricted according to the rows around this row. |
413 var indentChange = self.rowObject.indent(indentDiff); | 415 var indentChange = self.rowObject.indent(indentDiff); |
414 // Update table and mouse indentations. | 416 // Update table and mouse indentations. |
415 self.dragObject.indentMousePos.x += self.indentAmount * indentChange * self.rtl; | 417 self.dragObject.indentMousePos.x += self.indentAmount * indentChange * self.rtl; |