96c06af45eb580a37595abc54fd8c0ed500688cc larrym Tue Aug 2 12:29:33 2011 -0700 add allowDragAndZoomEverywhere code (currently turned off; see redmine 4667); commented out my 1x panning test code diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 31ffa55..89a176e 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -10,30 +10,31 @@ 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 allowDragAndZoomEverywhere = false; // true only in larrym's tree (see redmine 4667) /* 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) { @@ -271,32 +272,33 @@ if(trackImg && jQuery.fn.contextMenu) { $('#hgTrackUiDialog').hide(); if(imageV2) { $("map[name!=ideoMap]").each( function(t) { parseMap($(this,false));}); } else { // XXXX still under debate whether we have to remove the map parseMap($('#map'),true); $('#map').empty(); } originalImgTitle = trackImg.attr("title"); if(imageV2) { loadContextMenu(trackImgTbl); //$(".trDraggable,.nodrop").each( function(t) { loadContextMenu($(this)); }); // FIXME: why isn't rightClick for sideLabel working??? Probably because there is no link! - if(inPlaceUpdate && !hgTracks.imgBoxPortal) { - // Larry's experimental version of 1x panning (aka cheap panning). + if(false && inPlaceUpdate && !hgTracks.imgBoxPortal) { + // Larry's experimental version of 1x panning (aka cheap panning). Currently turned off but being left + // here temporarily for illustrative purposes. var originalLeft; var originalClientX; var withinTrackImgTbl; var last; trackImgTbl.mousedown( function (e) { originalClientX = e.clientX; withinTrackImgTbl = true; last = new Date(); jQuery('body').css('cursor', 'w-resize'); $("img.dataImg").each( function(index, ele) { var left = $(ele).css('left'); originalLeft = left.substring(0, left.length - 2) // we only need to look at one element, so bail out now. return false; @@ -368,36 +370,56 @@ // 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 titleHeight; + $('div.cntrLab').each(function (i) { + titleHeight = $(this).css('height'); + titleHeight = titleHeight.substring(0, titleHeight.length - 2) * 1; + return false; + }); + $('img.sideLab').each(function (i) { + var top = $(this).css('top'); + top = top.substring(0, top.length - 2); + top = top * -1; + heights.push({ + top: top, + bottom: top + titleHeight + }); + }); + } else { + 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: hgTracks.rulerClickHeight})); + 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'); command.value = "makeItems " + trackName + " " + hgTracks.chromName + " " + pos.chromStart + " " + pos.chromEnd; document.TrackHeaderForm.submit(); return true; }