8885686b3723a1a256cb1ff0677ca8a07927bed4 chmalee Thu Apr 4 13:24:20 2024 -0700 Make the hprc table stuff work in an hgc popup, make any javascript that would execute on document ready execute when the pop up is ready, refs #33216 diff --git src/hg/js/hgc.js src/hg/js/hgc.js index 7c2b124..65bf788 100644 --- src/hg/js/hgc.js +++ src/hg/js/hgc.js @@ -136,32 +136,32 @@ newTableNode = makeVepTable(data); else if (label === "Population Frequencies" || label === "Haplotype Frequencies") newTableNode = makePopTable(data); else newTableNode = makeGenericTable(data); return newTableNode ; } function makeVisInput(parentEl, name, trackName="", defaultVis="Hide") { ["Hide","Dense","Squish","Pack","Full"].forEach(function(vis) { let label = document.createElement("label"); //label.classList.add(name); let ctrl = document.createElement("input"); ctrl.classList.add(name); ctrl.type = "radio"; - ctrl.name = name; - ctrl.value = vis; + ctrl.name = "chainHprc" + trackName; + ctrl.value = vis.toLowerCase(); if (defaultVis.toLowerCase() === vis.toLowerCase()) { ctrl.checked = true; } ctrl.setAttribute("data-default", ctrl.checked); if (trackName.length > 0) { ctrl.setAttribute("data-trackName", trackName); } label.appendChild(ctrl); label.append(vis); parentEl.append(label); }); } function makeSetAllDiv(parentEl, text, classPre) { let textDiv = document.createElement("div"); @@ -248,46 +248,39 @@ e.checked = true; }); }); }); newForm.addEventListener("submit", function(e) { inputs = e.target.elements; for (let i = 0; i < inputs.length; i++) { input = inputs[i]; if (!input.checked) { // pass hgsid and other variables on through continue; } if (input.name.endsWith("SetAllVis") || (input.getAttribute("data-default") === input.checked.toString())) { input.disabled = true; } else { - // change the form name to a track name so the track can be on - trackName = "chainHprc" + input.getAttribute("data-trackName"); - input.name = trackName; input.value = input.value.toLowerCase(); } } }); } } - - -// on page load initialize VEP, Population Frequency and Haplotype Tables -// for gnomAD v3.1.1 track -$(document).ready(function() { +function initPage() { if (typeof doHPRCTable !== "undefined") { makeHPRCTable(); } if ($("#svgTable") !== null) { // redraw the svg with appropriate widths for all columns // swatchWidth and columnSpacer are taken from svgBarChart() in hgc/barChartClick.c // they should probably be dynamically determined var swatchWidth = 20.0; var columnSpacer = 4.0; var maxSampleWidth = 0.0; // determine the size taken up by the sample names $(".sampleLabel").each(function(s) { if ((sampleLength = this.getComputedTextLength()) >= maxSampleWidth) { maxSampleWidth = sampleLength; @@ -339,16 +332,25 @@ var label = _jsonHgcLabels[obj].label; var data = _jsonHgcLabels[obj].data; var newText = document.createTextNode(label); newCell.appendChild(newText); newCell = newRow.insertCell(); newCell.appendChild(dataToTable(label, data)); // find the last details table and add a new table on: var currTbl = $(".bedExtraTbl"); l = currTbl.length; var last = currTbl[l-1]; insertAfter(newTable, last); newTable.classList.add("bedExtraTbl"); last.parentNode.insertBefore(document.createElement("br"), newTable); } } +} + +// Export a way to call the document.ready() functions after ajax +var hgc = {initPage: initPage}; + +// on page load initialize VEP, Population Frequency and Haplotype Tables +// for gnomAD v3.1.1 track +$(document).ready(function() { + initPage(); });