cb245d0c42739a9904c6239e59817e5dec052f49 max Wed Nov 6 07:40:02 2024 -0800 hide legend if all gnomad pli tracks are hidden, refs #26169 diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index a78afdc..0513433 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -2130,31 +2130,43 @@ /* move a track to either "top" or "bottom" position */ let newPos = "0.5"; if (hgTracks.trackDb[0]!=="ruler") newPos = 0; if (topOrBottom==="bottom") { newPos = String(parseInt($(".imgOrd").last().attr("abbr"))+1); } let trEl = $(document.getElementById('tr_' + id)); trEl.attr('abbr', newPos); dragReorder.sort($("#imgTbl")); dragReorder.setOrder($("#imgTbl")); }, + hideLegends : function() { + /* if no pliBy track is shown, hide the pli legend */ + hasPliTracks = false; + for (var trDomEl of $(".imgOrd")){ + var trackName = trDomEl.id.split("_")[1]; + if (trackName.startsWith("pliBy")) + hasPliTracks = true; + } + if (!hasPliTracks) + $("#gnomadColorKeyLegend").hide(); + }, hideTracks: function (ids) + /* hide specified list of tracks, take care to hide parents rather than children, whenever possible */ { var cartVars = []; var cartVals = []; // find parent tracks that are losing all their children (lone parents) var familyAnalysis = tdbFindChildless(hgTracks.trackDb, ids); // lone parents get special treatment for (var delFam of familyAnalysis.loneParents) { var loneParent = delFam[0]; var loneParentChildren = delFam[1]; // remove all the lone parent children now from the track image // and also unselect them, if they are children of a composite for (var childName of loneParentChildren) { @@ -2164,30 +2176,31 @@ // current selection easily back, since we always hide them all, instead of just hiding the parent. // The problem is that it's not easy to find out if there is an easier way to hide them, the code // would have to go over all possible parents, not just topParents. Maybe one day. if (tdbIsSubtrack(rec)) { cartVars.push(childName+"_sel"); cartVals.push('0'); } } // and set the lone parent to hide in the cart cartVars.push(loneParent); cartVals.push('hide'); // need to explicitely set to "hide", not "[]", to hide the default tracks // update the track list below the image vis.update(loneParent, 'hide'); + rightClick.hideLegends(); } // handle all other tracks, they are either not parents or parents with at least one child left var delIds = familyAnalysis.others; for (var i = 0; i