2e96832a1aa406d75777694cc3f1ad34d57e9bd0 max Sat Apr 15 00:04:05 2017 -0700 fixing bug where escape did not work when zooming via base position track, refs #19214 diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 802babd..c8f3b13 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -962,41 +962,42 @@ { $('select.normalText,select.hiddenText').attr('disabled',false); } }; //////////////////////////////////////////////////////////// // dragSelect is also known as dragZoom or shift-dragZoom // //////////////////////////////////////////////////////////// var dragSelect = { hlColorDefault: '#aaedff', // default highlight color, if nothing specified hlColor : '#aaedff', // current highlight color areaSelector: null, // formerly "imgAreaSelect". jQuery element used for imgAreaSelect originalCursor: null, startTime: null, + escPressed : false, // flag is set when user presses Escape selectStart: function (img, selection) { initVars(); + dragSelect.escPressed = false; if (rightClick.menu) { rightClick.menu.hide(); } var now = new Date(); dragSelect.startTime = now.getTime(); posting.blockMapClicks(); - }, selectChange: function (img, selection) { if (selection.x1 !== selection.x2) { if (genomePos.check(img, selection)) { genomePos.update(img, selection, false); jQuery('body').css('cursor', dragSelect.originalCursor); } else { jQuery('body').css('cursor', 'not-allowed'); } } return true; }, @@ -1243,41 +1244,43 @@ }); $(dragSelectDialog).dialog('open'); // put the cursor into the input field // we are not doing this for now - default behavior was to zoom when enter was pressed // so people may still expect that "enter" on the dialog will zoom. //var el = $("#hlColorInput")[0]; //el.selectionStart = 0; //el.selectionEnd = el.value.length; //el.focus(); }, selectEnd: function (img, selection, event) { + if (dragSelect.escPressed) + return false; var now = new Date(); var doIt = false; - var rulerClicked = selection.y1 <= hgTracks.rulerClickHeight; + var rulerClicked = selection.y1 <= hgTracks.rulerClickHeight; // = drag on base position track (no shift) if (dragSelect.originalCursor) jQuery('body').css('cursor', dragSelect.originalCursor); // ignore releases outside of the image rectangle (allowing a 10 pixel slop) if (genomePos.check(img, selection)) { // ignore single clicks that aren't in the top of the image // (this happens b/c the clickClipHeight test in dragSelect.selectStart // doesn't occur when the user single clicks). - doIt = dragSelect.startTime !== null || rulerClicked; + doIt = (dragSelect.startTime !== null || rulerClicked); } if (doIt) { // dragSelect.startTime is null if mouse has never been moved var singleClick = ( (selection.x2 === selection.x1) || dragSelect.startTime === null || (now.getTime() - dragSelect.startTime) < 100); var newPosition = genomePos.update(img, selection, singleClick); if (newPosition) { if (event.altKey) { // with the alt-key, only highlight the region, do not zoom dragSelect.highlightThisRegion(newPosition, true); $(imageV2.imgTbl).imgAreaSelect({hide:true}); } else { if (hgTracks.enableHighlightingDialog && !(event.metaKey || event.ctrlKey)) @@ -1328,31 +1331,31 @@ minHeight: imgHeight, maxHeight: imgHeight, onSelectStart: dragSelect.selectStart, onSelectChange: dragSelect.selectChange, onSelectEnd: dragSelect.selectEnd, autoHide: false, // gets hidden after possible dialog movable: false, clickClipHeight: heights })); // remove any ongoing drag-selects when the esc key is pressed anywhere for this document // This allows to abort zooming / highlighting $(document).keyup(function(e){ if(e.keyCode === 27) { $(imageV2.imgTbl).imgAreaSelect({hide:true}); - dragSelect.startTime = null; + dragSelect.escPressed = true; } }); // hide and redraw all current highlights when the browser window is resized $(window).resize(function() { $(imageV2.imgTbl).imgAreaSelect({hide:true}); imageV2.highlightRegion(); }); } } }; ///////////////////////////////////// //// Chrom Drag/Zoom/Expand code ////