7b7b0c1b25ef841ec99db2fc02b225a1999015af
chmalee
  Tue Feb 2 10:19:17 2021 -0800
Allow menubar links to hgTracks to use the current web browser window size for hgTracks image width

diff --git src/hg/lib/web.c src/hg/lib/web.c
index 3c6249d..6ee23d3 100644
--- src/hg/lib/web.c
+++ src/hg/lib/web.c
@@ -1397,30 +1397,31 @@
 FILE *fd;
 char *navBarFile = "inc/globalNavBar.inc";
 struct stat statBuf;
 char *scriptName = cgiScriptName();
 if (cart)
     safef(uiVars, sizeof(uiVars), "%s=%s", cartSessionVarName(), cartSessionId(cart));
 else
     uiVars[0] = 0;
 
 if(docRoot == NULL)
     // tolerate missing docRoot (i.e. don't bother with menu when running from command line)
     return NULL;
 
 jsIncludeFile("jquery.js", NULL);
 jsIncludeFile("jquery.plugins.js", NULL);
+jsIncludeFile("utils.js", NULL);
 webIncludeResourceFile("nice_menu.css");
 
 // Read in menu bar html
 safef(buf, sizeof(buf), "%s/%s", docRoot, navBarFile);
 fd = mustOpen(buf, "r");
 fstat(fileno(fd), &statBuf);
 int len = statBuf.st_size;
 menuStr = needMem(len + 1);
 mustRead(fd, menuStr, statBuf.st_size);
 menuStr[len] = 0;
 carefulClose(&fd);
 
 if (cart)
     {
     char *newMenuStr = menuBarAddUiVars(menuStr, "/cgi-bin/hg", uiVars);
@@ -1546,30 +1547,42 @@
         link = "../goldenPath/help/customTrack.html";
         label = "Help on Custom Tracks";
         }
     // Don't overwrite any previously set defaults
     if(!contextSpecificHelpLink && link)
         contextSpecificHelpLink = link;
     if(!contextSpecificHelpLabel && label)
         contextSpecificHelpLabel = label;
     }
 if(contextSpecificHelpLink)
     {
     char buf[1024];
     safef(buf, sizeof(buf), "<li><a href='%s'>%s</a></li>", contextSpecificHelpLink, contextSpecificHelpLabel);
     menuStr = replaceChars(menuStr, "<!-- CONTEXT_SPECIFIC_HELP -->", buf);
     }
+
+// links to hgTracks need to use the web browser width and set the hgTracks image
+// size in pixels correctly to match the hgGateway "GO" button
+jsInline("$(\"#tools1 ul li a\").each( function (a) {\n"
+"    if (this.href && this.href.indexOf(\"hgTracks\") !== -1) {\n"
+"        var obj = this;\n"
+"        obj.onclick = function(e) {\n"
+"            var pix = calculateHgTracksWidth();\n"
+"            e.currentTarget.href += \"&pix=\" + pix;\n"
+"        }\n"
+"    }\n"
+"});\n");
 return menuStr;
 }
 
 void checkForGeoMirrorRedirect(struct cart *cart)
 // Implement Geo/IP based redirection.
 {
 char *thisNodeStr = geoMirrorNode();
 if (thisNodeStr)   // if geo-mirroring is enabled
     {
     char *redirectCookie = findCookieData("redirect");
     char *redirect = cgiOptionalString("redirect");
 
     // if we're not already redirected
     if (redirect == NULL && redirectCookie == NULL) 
         {