0cb701778e6e819a7cb37a0a67b3d543b0a37ae7 chmalee Fri Oct 18 14:20:32 2024 -0700 Fix track group drag and drop on hgTracks image, another attr() vs prop() issue, refs #34661 diff --git src/hg/js/jquery.tablednd.js src/hg/js/jquery.tablednd.js index ac32e5b..ae82fc5 100644 --- src/hg/js/jquery.tablednd.js +++ src/hg/js/jquery.tablednd.js @@ -151,31 +151,31 @@ /////// UCSC // Initialize oldY to avoid movingDown as first action jQuery.tableDnD.oldY = jQuery.tableDnD.mouseCoords(ev).y - jQuery.tableDnD.mouseOffset.y; // Capture the mouse move events only if dragStart jQuery(document) .on('mousemove', jQuery.tableDnD.mousemove) .on('mouseup', jQuery.tableDnD.mouseup); config.downOffset = 0; config.upOffset = 0; if (config.dragObjects.length > 1) { for(var ix = 0; ix < config.dragObjects.length; ix++) { var row = config.dragObjects[ix]; - var rowIx = $(row).attr('rowIndex'); + var rowIx = $(row).prop('rowIndex'); if (rowIx < config.dragStartIndex) config.upOffset -= $(row).height(); else if (rowIx > config.dragStartIndex) config.downOffset += $(row).height(); } } /////// UCSC return false; }); }) } else { // For backwards compatibility, we add the event to the whole row var rows = jQuery("tr", table); // get all the rows as a wrapped set rows.each(function() { // Iterate through each row, the row is bound to "this" @@ -320,49 +320,49 @@ else ////// UCSC dragObj.css(config.onDragStyle); } // If we're over a row then move the dragged row to there so that the user sees the // effect dynamically ////// UCSC var currentRow = null; // While dragObjects is the set, the order could vary from table order. Therefore us rowIndexes. var rows = jQuery.tableDnD.currentTable.rows; var firstDragRowIx = 9999; // Discover indexes var lastDragRowIx = 0; if (config.dragObjects.length > 1) { for (var ix=0;ix < config.dragObjects.length;ix++) { - var thisIx = $( config.dragObjects[ix] ).attr('rowIndex'); + var thisIx = $( config.dragObjects[ix] ).prop('rowIndex'); if (firstDragRowIx > thisIx) firstDragRowIx = thisIx; if (lastDragRowIx < thisIx) lastDragRowIx = thisIx; } if (movingDown) currentRow = jQuery.tableDnD.findDropTargetRow(rows[lastDragRowIx], y + config.downOffset); else currentRow = jQuery.tableDnD.findDropTargetRow(rows[firstDragRowIx], y + config.upOffset); } else ////// UCSC currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y); if (currentRow) { ////// UCSC if (config.dragObjects.length > 1) { - var targetRowIx = $( currentRow ).attr('rowIndex'); + var targetRowIx = $( currentRow ).prop('rowIndex'); if (targetRowIx >= 0 && targetRowIx < rows.length) { var plusIx=0; var rIx; if (movingDown) { // && config.dragObjects[config.dragObjects.length - 1] != currentRow) { // A whole new tack: since movingUp never fails, always move target (and others) up if ((lastDragRowIx - firstDragRowIx) == (config.dragObjects.length - 1) && firstDragRowIx >= 0 && lastDragRowIx < targetRowIx) { plusIx=0; for(rIx=lastDragRowIx+1; rIx <= targetRowIx; rIx++) { $( rows[rIx] ).insertBefore( $( rows[firstDragRowIx + plusIx] ) ); plusIx++; } }