14849ecb53b3453ebfb5f5d0777e36ea5e1f0e19 larrym Mon Aug 15 13:48:45 2011 -0700 hide contextmenu when initiating a drag-select or drag-scroll diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index cb768ad..44176f9 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -10,57 +10,61 @@ var blockUseMap = false; var mapItems; var trackImg; // jQuery element for the track image var trackImgTbl; // jQuery element used for image table under imageV2 var imgAreaSelect; // jQuery element used for imgAreaSelect var originalImgTitle; var autoHideSetting = true; // Current state of imgAreaSelect autoHide setting var selectedMenuItem; // currently choosen context menu item (via context menu). var browser; // browser ("msie", "safari" etc.) var mapIsUpdateable = true; var currentMapItem; var floatingMenuItem; var visibilityStrsOrder = new Array("hide", "dense", "full", "pack", "squish"); // map browser numeric visibility codes to strings var supportZoomCodon = false; // turn on experimental zoom-to-codon functionality (currently only on in larrym's tree). var inPlaceUpdate = false; // modified based on value of hgTracks.inPlaceUpdate and mapIsUpdateable +var contextMenu; /* Data passed in from CGI via the hgTracks object: * * string chromName // current chromosome * int winStart // genomic start coordinate (0-based, half-open) * int winEnd // genomic end coordinate * int newWinWidth // new width if user clicks on the top ruler (in bps) * boolean dragSelection // true if we should allow drag and select * boolean revCmplDisp // true if we are in reverse display * int insideX // width of side-bar (in pixels) * int rulerClickHeight // height of ruler (in pixels) */ function initVars(img) { // There are various entry points, so we call initVars in several places to make sure this variables get updated. if(!originalPosition) { // remember initial position and size so we can restore it if user cancels originalPosition = getOriginalPosition(); originalSize = $('#size').text(); originalCursor = jQuery('body').css('cursor'); } } function selectStart(img, selection) { initVars(); + if(contextMenu) { + contextMenu.hide(); + } var now = new Date(); startDragZoom = now.getTime(); blockUseMap = true; // vvvvvvv Should be obsolete since maps items are ignored when startDragZoom is set // if(imageV2 == false) { // jQuery.each(jQuery.browser, function(i, val) { // if(i=="msie" && val) { // // Very hacky way to solve following probem specif to IE: // // If the user ends selection with the mouse in a map box item, the map item // // is choosen instead of the selection; to fix this, we remove map box items // // during the mouse selection process. // mapHtml = $('#map').html(); // $('#map').empty(); // } // }); @@ -994,30 +998,33 @@ var mouseIsDown = false; var beyondImage = false; var atEdge = false; initialize(); function initialize(){ if ( !($.browser.msie) ) // IE will override map items cursors as well! $(pan).parents('td.tdData').css('cursor',"url(../images/grabber.cur),w-resize"); pan.mousedown(function(e){ if (e.which > 1 || e.button > 1 || e.shiftKey) return true; if(mouseIsDown == false) { + if(contextMenu) { + contextMenu.hide(); + } mouseIsDown = true; mouseDownX = e.clientX; atEdge = (!beyondImage && (prevX >= leftLimit || prevX <= rightLimit)); $(document).bind('mousemove',panner); $(document).bind( 'mouseup', panMouseUp); // Will exec only once return false; } }); } function panner(e) { //if(!e) e = window.event; if ( mouseIsDown ) { var relativeX = (e.clientX - mouseDownX); @@ -2000,31 +2007,31 @@ return function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, title); return true; }; } function makeImgTag(img) { // Return img tag with explicit dimensions for img (dimensions are currently hardwired). // This fixes the "weird shadow problem when first loading the right-click menu" seen in FireFox 3.X, // which occurred b/c FF doesn't actually fetch the image until the menu is being shown. return "<img style='width:16px; height:16px; border-style:none;' src='../images/" + img + "' />"; } function loadContextMenu(img) { - var menu = img.contextMenu( + contextMenu = img.contextMenu( function() { popUpBoxCleanup(); // Popup box is not getting closed properly so must do it here var menu = []; var selectedImg = makeImgTag("greenChecksm.png"); var blankImg = makeImgTag("invisible16.png"); var done = false; if(selectedMenuItem && selectedMenuItem.id != null) { var href = selectedMenuItem.href; var isHgc, isGene; if(href) { isGene = href.match("hgGene"); isHgc = href.match("hgc"); } var id = selectedMenuItem.id;