src/hg/js/jquery.tablednd.js 1.2
1.2 2009/11/20 23:49:42 tdreszer
Added dragStartIndex to be returned by onDrag() callback.
Index: src/hg/js/jquery.tablednd.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/jquery.tablednd.js,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 4 -r1.1 -r1.2
--- src/hg/js/jquery.tablednd.js 15 Aug 2008 22:08:51 -0000 1.1
+++ src/hg/js/jquery.tablednd.js 20 Nov 2009 23:49:42 -0000 1.2
@@ -3,8 +3,11 @@
* You can set up various options to control how the system will work
* Copyright (c) Denis Howlett <denish@isocra.com>
* Licensed like jQuery, see http://docs.jquery.com/License.
*
+ * NOTE for Browser staff: Tim Dreszer has modified this from original:
+ * dragStartIndex is returned as third param in onDrop() callback.
+ *
* Configuration options:
*
* onDragStyle
* This is the style that is assigned to the row during drag. There are limitations to the styles that can be
@@ -22,9 +25,9 @@
* stylesheet.
* onDrop
* Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
* and the row that was dropped. You can work out the new order of the rows by using
- * table.rows.
+ * table.rows. NOTE: function now returns a third param: dragStartIndex (of row that was dragged)
* onDragStart
* Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
* table and the row which the user has started to drag.
* onAllowDrop
@@ -101,9 +104,10 @@
onDragStart: null,
scrollAmount: 5,
serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
serializeParamName: null, // If you want to specify another parameter name instead of the table ID
- dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
+ dragHandle: null, // If you give the name of a class here, then only Cells with this class will be draggable
+ dragStartIndex : 0
}, options || {});
// Now make the rows draggable
jQuery.tableDnD.makeDraggable(this);
});
@@ -129,8 +133,9 @@
jQuery(this).mousedown(function(ev) {
jQuery.tableDnD.dragObject = this.parentNode;
jQuery.tableDnD.currentTable = table;
jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
+ config.dragStartIndex = $(jQuery.tableDnD.dragObject).attr('rowIndex');
if (config.onDragStart) {
// Call the onDrop method if there is one
config.onDragStart(table, this);
}
@@ -148,8 +153,9 @@
if (ev.target.tagName == "TD") {
jQuery.tableDnD.dragObject = this;
jQuery.tableDnD.currentTable = table;
jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
+ config.dragStartIndex = $(jQuery.tableDnD.dragObject).attr('rowIndex');
if (config.onDragStart) {
// Call the onDrop method if there is one
config.onDragStart(table, this);
}
@@ -331,9 +337,9 @@
}
jQuery.tableDnD.dragObject = null;
if (config.onDrop) {
// Call the onDrop method if there is one
- config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
+ config.onDrop(jQuery.tableDnD.currentTable, droppedRow, config.dragStartIndex);
}
jQuery.tableDnD.currentTable = null; // let go of the table too
}
},