71ba2b30f03c0fb2b80d766382c80c235d2b674c
chmalee
  Thu Feb 23 09:04:00 2023 -0800
Fix broken check all/clear all buttons on hgTracks download menu, refs #30024

diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index df034c5..b40c131 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -5238,40 +5238,30 @@
         downloadCurrentTrackData.intervalId = setInterval(downloadCurrentTrackData.makeDownloadFile, 200, apiUrl);
     },
 
 
     showDownloadUi: function() {
         // Populate the dialog with the current list of tracks
         // and allow the user to select which ones to download
         // Grey out tracks that are currently unsupported by the api
         // or are protected data
         var downloadDialog = $("#downloadDialog")[0];
         if (!downloadDialog) {
             downloadDialog = document.createElement("div");
             downloadDialog.id = "downloadDialog";
             downloadDialog.style = "display: none";
             document.body.append(downloadDialog);
-            $("#checkAllDownloadTracks").click( function() {
-                $(".downloadTrackName").each(function(i, elem) {
-                    elem.checked = true;
-                });
-            });
-            $("#uncheckAllDownloadTracks").click( function() {
-                $(".downloadTrackName").each(function(i, elem) {
-                    elem.checked = false;
-                });
-            });
             var popMaxHeight = ($(window).height() - 40);
             var popMaxWidth  = ($(window).width() - 40);
             var popWidth     = 700;
             if (popWidth > popMaxWidth)
                 popWidth = popMaxWidth;
             downloadTrackDataButtons = {};
             downloadTrackDataButtons.Download = downloadCurrentTrackData.startDownload;
             downloadTrackDataButtons.Cancel = function(){
                 $(this).dialog("close");
             };
             $(downloadDialog).dialog({
                 title: "Download track data in view",
                 resizable: true,               // Let scroll vertically
                 height: 'auto',
                 width: popWidth,
@@ -5300,30 +5290,40 @@
                 htmlStr += "<br>";
             }
         });
         htmlStr += "<div ><label style='padding-right: 10px' for='downloadFileName'>Enter an output file name</label>";
         htmlStr += "<input type=text size=30 class='downloadFileName' id='downloadFileName'" +
             " value='" + getDb() + ".tracks'</input>";
         htmlStr += "<br>";
         htmlStr += "<label style='padding-right: 10px' for='outputFormat'>Choose an output format</label>";
         htmlStr += "<select name='outputFormat' id='outputFormat'>";
         htmlStr += "<option selected value='json'>JSON</option>";
         htmlStr += "<option value='csv'>CSV</option>";
         htmlStr += "<option value='tsv'>TSV</option>";
         htmlStr += "</select>";
         htmlStr += "</div>";
         downloadDialog.innerHTML = htmlStr;
+        $("#checkAllDownloadTracks").click( function() {
+            $(".downloadTrackName").each(function(i, elem) {
+                elem.checked = true;
+            });
+        });
+        $("#uncheckAllDownloadTracks").click( function() {
+            $(".downloadTrackName").each(function(i, elem) {
+                elem.checked = false;
+            });
+        });
         $(downloadDialog).dialog('open');
     }
 };
 
 
   ///////////////
  //// READY ////
 ///////////////
 $(document).ready(function()
 {
     imageV2.moveTiming();
 
     // hg.conf will turn this on 2020-10 - Hiram
     if (window.mouseOverEnabled) { mouseOver.addListener(); }