3822feed53942771a91784da9aa04d24c5a1b4ff larrym Thu Jan 13 15:14:18 2011 -0800 fix problems with zoomed-out microarray tracks (redmine 2447); also include some experimental floating item code (currently dead code) diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index e1de7c1..d0df6c4 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -12,30 +12,31 @@ var startDragZoom = null; var newWinWidth; var imageV2 = false; var imgBoxPortal = false; 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 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) { @@ -1625,30 +1626,46 @@ var chrom = $("input[name=chromName]").val(); if(chrom && href.indexOf("c=" + chrom) == -1) { // make sure the link contains chrom info (necessary b/c we are stripping hgsid) href = href + "&c=" + chrom; } if(cmd == 'followLink') { // XXXX This is blocked by Safari's popup blocker (without any warning message). location.assign(href); } else { // Remove hgsid to force a new session (see redmine ticket 1333). href = removeHgsid(href); if(window.open(href) == null) { windowOpenFailedMsg(); } } + } else if (cmd == 'float') { + var id = selectedMenuItem.id; + if(floatingMenuItem && floatingMenuItem == id) { + $.floatMgr.FOArray = new Array(); + floatingMenuItem = null; + } else { + if(floatingMenuItem) { + // This doesn't work. + $('#img_data_' + floatingMenuItem).parent().restartFloat(); + // This does work + $.floatMgr.FOArray = new Array(); + } + floatingMenuItem = id; + reloadFloatingItem(); + updateTrackImg(id, "hgt.transparentImage=0", ""); + } } else { // if( cmd in 'hide','dense','squish','pack','full','show' ) // Change visibility settings: // // First change the select on our form: var id = selectedMenuItem.id; var rec = trackDbJson[id]; var selectUpdated = updateVisibility(id, cmd); // Now change the track image if(imageV2 && cmd == 'hide') { // Hide local display of this track and update server side cart. // Subtracks controlled by 2 settings so del vis and set sel=0. Others, just set vis hide. if(tdbIsSubtrack(rec)) setCartVars( [ id, id+"_sel" ], [ '[]', 0 ] ); // Remove subtrack level vis and explicitly uncheck. @@ -1762,47 +1779,60 @@ } else if(visibilityStrs[i] == visibilityStrsOrder[rec.visibility]) { str = selectedImg + " " + visibilityStrs[i]; } o[str] = {onclick: makeContextMenuHitCallback(visibilityStrs[i])}; menu.push(o); } } done = true; } } if(done) { var o = new Object(); var any = false; if(isGene || isHgc) { var title = selectedMenuItem.title || "feature"; - if(rec && !(rec.type.indexOf("wig") == 0 || rec.type.indexOf("bigWig") == 0)) { + var displayItemFunctions = false; + if(rec) { + if(rec.type.indexOf("wig") == 0 || rec.type.indexOf("bigWig") == 0) { + displayItemFunctions = false; + } else if(rec.type.indexOf("expRatio") == 0) { + displayItemFunctions = title != "zoomInMore"; + } else { + displayItemFunctions = true; + } + } + if(displayItemFunctions) { o[makeImgTag("magnify.png") + " Zoom to " + title] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "selectWholeGene"); return true; }}; o[makeImgTag("dnaIcon.png") + " Get DNA for " + title] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "getDna"); return true; }}; } o[makeImgTag("bookOut.png") + " Open details page in new window..."] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "openLink"); return true; }}; any = true; } if(selectedMenuItem.title != undefined && selectedMenuItem.title.length > 0 && selectedMenuItem.href != undefined && selectedMenuItem.href.length > 0) { var str = selectedMenuItem.title; if(str.indexOf("Click to alter ") == 0) { ; // suppress the "Click to alter..." items } else if(selectedMenuItem.href.indexOf("cgi-bin/hgTracks") != -1) { ; // suppress menu items for hgTracks links (e.g. Next/Prev map items). } else { if(str.indexOf("display density") != -1) str = makeImgTag("toggle.png") + str; + else if(str == "zoomInMore") + // avoid showing menu item that says "Show details for zoomInMore..." (redmine 2447) + str = makeImgTag("toggle.png") + " Show details..."; else str = makeImgTag("book.png") + " Show details for " + str + "..."; o[str] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "followLink"); return true; }}; any = true; } } if(any) { menu.push($.contextMenu.separator); menu.push(o); } } } if(!done) { if(false) { // Currently toggling b/n drag-and-zoom mode and hilite mode is disabled b/c we don't know how to keep hilite mode from disabling the @@ -1824,30 +1854,33 @@ o[str] = { onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hilightMode"); return true; }}; menu.push(o); } //menu.push({"view image": {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "viewImg"); return true; }}}); } if(selectedMenuItem && rec && rec["configureBy"] != 'none') { // Add cfg options at just shy of end... var o = new Object(); if(tdbIsLeaf(rec)) { o[makeImgTag("wrench.png") + " Configure " + rec.shortLabel] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hgTrackUi_popup"); return true; }}; if(rec.parentTrack != undefined) o[makeImgTag("folderWrench.png") + " Configure " + rec.parentLabel + " track set..."] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hgTrackUi_follow"); return true; }}; } else o[makeImgTag("folderWrench.png") + " Configure " + rec.shortLabel + " track set..."] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hgTrackUi_follow"); return true; }}; + if(jQuery.floatMgr) { + o[(selectedMenuItem.id == floatingMenuItem ? selectedImg : blankImg) + " float"] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "float"); return true; }}; + } menu.push($.contextMenu.separator); menu.push(o); } // Add view image at end var o = new Object(); o[makeImgTag("eye.png") + " View image"] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "viewImg"); return true; }}; menu.push($.contextMenu.separator); menu.push(o); return menu; }, { beforeShow: function(e) { // console.log(mapItems[selectedMenuItem]); @@ -2084,30 +2117,31 @@ var reg = new RegExp(str); a = reg.exec(response); if(a && a[1]) { // $('#tr_' + id).html(); // $('#tr_' + id).empty(); $('#tr_' + id).html(a[1]); // XXXX move following to a shared method parseMap(null, true); $("map[name!=ideoMap]").each( function(t) { parseMap($(this, false));}); initImgTblButtons(); loadImgAreaSelect(false); // Do NOT reload context menu (otherwise we get the "context menu sticks" problem). // loadContextMenu($('#tr_' + id)); if(trackImgTbl.tableDnDUpdate) trackImgTbl.tableDnDUpdate(); + reloadFloatingItem(); // NOTE: Want to examine the png? Uncomment: //var img = $('#tr_' + id).find("img[id^='img_data_']").attr('src'); //warn("Just parsed image:
"+img); } else { showWarning("Couldn't parse out new image for id: " + id); //alert("Couldn't parse out new image for id: " + id+"BR"+response); // Very helpful } } else { if(imageV2) { a= /]*>([\S\s]+?)<\/TABLE>/.exec(response); if(a[1]) { // This doesn't work (much weirdness ensues). $('#imgTbl').html(a[1]); } else { showWarning("Couldn't parse out new image"); @@ -2597,15 +2631,23 @@ { // Updates visibility state in trackDbJson and any visible elements on the page. // returns true if we modify at least one select in the group list var rec = trackDbJson[track]; var selectUpdated = false; $("select[name=" + track + "]").each(function(t) { $(this).attr('class', visibility == 'hide' ? 'hiddenText' : 'normalText'); $(this).val(visibility); selectUpdated = true; }); if(rec) { rec.localVisibility = visibility; } return selectUpdated; } + +function reloadFloatingItem() +{ +// currently dead (experimental code) + if(floatingMenuItem) { + $('#img_data_' + floatingMenuItem).parent().makeFloat({x:"current",y:"current", speed: 'fast', alwaysVisible: true, alwaysTop: true}); + } +}