2dbde9834ab5086618df2619e2b21b78ccc863a2 larrym Wed Aug 3 23:59:20 2011 -0700 exeriment with using shift/cntrl to allow drag-and-select anywhere in the hgTracks images diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index d239973..c925434 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -207,31 +207,32 @@ function selectEnd(img, selection) { var now = new Date(); var doIt = false; if(originalCursor != null) jQuery('body').css('cursor', originalCursor); // ignore releases outside of the image rectangle (allowing a 10 pixel slop) if(autoHideSetting && checkPosition(img, selection)) { // ignore single clicks that aren't in the top of the image (this happens b/c the clickClipHeight test in selectStart // doesn't occur when the user single clicks). doIt = startDragZoom != null || selection.y1 <= hgTracks.rulerClickHeight; } if(doIt) { // startDragZoom is null if mouse has never been moved - newPosition = updatePosition(img, selection, (selection.x2 == selection.x1) || startDragZoom == null || (now.getTime() - startDragZoom) < 100); + var singleClick = (selection.x2 == selection.x1) || startDragZoom == null || (now.getTime() - startDragZoom) < 100; + newPosition = updatePosition(img, selection, singleClick); if(newPosition != undefined) { if(inPlaceUpdate) { navigateInPlace("position=" + newPosition); } else { jQuery('body').css('cursor', 'wait'); document.TrackHeaderForm.submit(); } } } else { setPosition(originalPosition, originalSize); originalPosition = originalSize = null; // if(mapHtml) { // $('#map').append(mapHtml); // } } @@ -370,44 +371,31 @@ // disable if ruler is not visible. if(typeof(hgTracks) != "undefined" && hgTracks.dragSelection && hgTracks.rulerClickHeight > 0) { var imgHeight = 0; trackImg = $('#img_data_ruler'); if(trackImg == undefined || trackImg.length == 0) { // Revert to old imageV1 trackImg = $('#trackMap'); imgHeight = jQuery(trackImg).height(); } else { imageV2 = true; trackImgTbl = $('#imgTbl'); imgHeight = trackImg.height(); // XXXX Tim, I think we should get height from trackImgTbl, b/c it automatically adjusts as we add/delete items. imgHeight = trackImgTbl.height(); } - var heights; - if(allowDragAndZoomEverywhere) { - heights = []; - var imgTop = trackImgTbl.offset().top; - $('div.cntrLab').each(function (i) { - var top = $(this).offset().top - imgTop; - heights.push({ - top: top, - bottom: top + $(this).height() - }); - }); - } else { - heights = hgTracks.rulerClickHeight; - } + var heights = hgTracks.rulerClickHeight; imgAreaSelect = jQuery((trackImgTbl || trackImg).imgAreaSelect({ selectionColor: 'blue', outerColor: '', minHeight: imgHeight, maxHeight: imgHeight, onSelectStart: selectStart, onSelectChange: selectChange, onSelectEnd: selectEnd, autoHide: autoHideSetting, movable: false, clickClipHeight: heights})); } } function makeItemsEnd(img, selection) { var image = $(img); var imageId = image.attr('id'); var trackName = imageId.substring('img_data_'.length); var pos = selectionPixelsToBases(image, selection); var command = document.getElementById('hgt_doJsCommand'); @@ -1056,31 +1044,31 @@ portalWidth = $(pan).width(); // globals to one panImage var newX = 0; var mouseDownX = 0; var mouseIsDown = false; var beyondImage = false; var atEdge = false; initialize(); function initialize(){ pan.css( 'cursor', 'w-resize'); pan.mousedown(function(e){ - if (e.which > 1 || e.button > 1) + if (e.which > 1 || e.button > 1 || e.shiftKey || e.ctrlKey) return true; if(mouseIsDown == false) { 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 ) {