25f258c7fdfbdf417a917fcd00fff78d698def9b chmalee Fri Aug 30 12:01:24 2024 -0700 Big run through of changes to accomodate jquery 3.7.1 upgrade. Most of the changes are replacing the event methods with a change to .on(event, function(..)). A couple more changes are removing calls to jquery.type(). Also fixes various plugins and styles diff --git src/hg/js/jquery.tablednd.js src/hg/js/jquery.tablednd.js index 83ae042..ac32e5b 100644 --- src/hg/js/jquery.tablednd.js +++ src/hg/js/jquery.tablednd.js @@ -123,77 +123,77 @@ /////// UCSC .bind('mousemove', jQuery.tableDnD.mousemove) /////// UCSC .bind('mouseup', jQuery.tableDnD.mouseup); // Don't break the chain return this; }, /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */ makeDraggable: function(table) { var config = table.tableDnDConfig; if (table.tableDnDConfig.dragHandle) { // We only need to add the event to the specified cells var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table); cells.each(function() { // The cell is bound to "this" - jQuery(this).mousedown(function(ev) { + jQuery(this).on("mousedown", function(ev) { if(ev.button > 1) return true; if(jQuery.tableDnD == undefined) return false; jQuery.tableDnD.dragObject = this.parentNode; jQuery.tableDnD.currentTable = table; jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev); config.dragStartIndex = $(jQuery.tableDnD.dragObject).prop('rowIndex'); if (config.onDragStart) { // Call the onDrop method if there is one config.onDragStart(ev, table, this.parentNode); // UCSC } /////// 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) - .bind('mousemove', jQuery.tableDnD.mousemove) - .bind('mouseup', jQuery.tableDnD.mouseup); + .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'); 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" var row = jQuery(this); if (! row.hasClass("nodrag")) { - row.mousedown(function(ev) { + row.on("mousedown", function(ev) { 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).prop('rowIndex'); if (config.onDragStart) { // Call the onDrop method if there is one config.onDragStart(ev, table, this); } return false; } }).css("cursor", "move"); // Store the tableDnD object } }); } @@ -251,32 +251,32 @@ e = e.offsetParent; } left += e.offsetLeft; top += e.offsetTop; ///////return {x:left, y:top}; return {x:left, y:top, height:eHeight}; ///////////// Height was added by tim because of tall tracks }, mousemove: function(ev) { /* jshint -W014 */ // Don't complain about line break before '||' etc: if(jQuery.tableDnD === undefined || jQuery.tableDnD.dragObject === null) { //// UCSC Binding should occur at dragStart jQuery(document) - .unbind('mousemove')//, jQuery.tableDnD.mousemove); - .unbind('mouseup');//, jQuery.tableDnD.mouseup); + .off('mousemove')//, jQuery.tableDnD.mousemove); + .off('mouseup');//, jQuery.tableDnD.mouseup); return; } ///// UCSC if (jQuery.tableDnD.dragObject == null) { ///// UCSC return; ///// UCSC } var dragObj = jQuery(jQuery.tableDnD.dragObject); var config = jQuery.tableDnD.currentTable.tableDnDConfig; var mousePos = jQuery.tableDnD.mouseCoords(ev); var y = mousePos.y - jQuery.tableDnD.mouseOffset.y; //auto scroll the window var yOffset = window.pageYOffset; if (document.all) { // Windows version @@ -424,32 +424,32 @@ if (! nodrop) { return row; } else { return null; } } return row; } } return null; }, mouseup: function(e) { if(jQuery.tableDnD == undefined) { jQuery(document) - .unbind('mousemove')//, jQuery.tableDnD.mousemove); - .unbind('mouseup');//, jQuery.tableDnD.mouseup); + .off('mousemove')//, jQuery.tableDnD.mousemove); + .off('mouseup');//, jQuery.tableDnD.mouseup); return; } if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) { var droppedRow = jQuery.tableDnD.dragObject; var config = jQuery.tableDnD.currentTable.tableDnDConfig; // If we have a dragObject, then we need to release it, // The row will already have been moved to the right place so we just reset stuff if (config.onDragClass) { ////// UCSC if (config.dragObjects.length > 1) config.dragObjects.removeClass(config.onDragClass); else ////// UCSC jQuery(droppedRow).removeClass(config.onDragClass); } else { ////// UCSC