719242bfb0576b7c86c3accf65e2ef3cbb756a81
larrym
  Mon Apr 4 13:25:40 2011 -0700
make sure that appropriate track is visible when user selects something via gene suggest box (see redmine #3484)
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 0fa0053..210361d 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -1195,42 +1195,44 @@
 
 $(document).ready(function()
 {
     var db = getDb();
     if(document.getElementById("hgt.newJQuery") != null) {
         newJQuery = true;
     }
     if(jQuery.fn.autocomplete && $('input#suggest') && db) {
         if(newJQuery) {
             $('input#suggest').autocomplete({
                                                 delay: 500,
                                                 minLength: 2,
                                                 source: ajaxGet(function () {return db;}, new Object, true),
                                                 select: function (event, ui) {
                                                         setPosition(ui.item.id, commify(getSizeFromCoordinates(ui.item.id)));
+                                                        makeSureSuggestTrackIsVisible();
                                                         // jQuery('body').css('cursor', 'wait');
                                                         // document.TrackHeaderForm.submit();
                                                     }
                                             });
 
         } else {
             $('input#suggest').autocomplete({
                                                 delay: 500,
                                                 minchars: 2,
                                                 ajax_get: ajaxGet(function () {return db;}, new Object, false),
                                                 callback: function (obj) {
                                                     setPosition(obj.id, commify(getSizeFromCoordinates(obj.id)));
+                                                    makeSureSuggestTrackIsVisible();
                                                     // jQuery('body').css('cursor', 'wait');
                                                     // document.TrackHeaderForm.submit();
                                                 }
                                             });
         }
         // I want to set focus to the suggest element, but unforunately that prevents PgUp/PgDn from
         // working, which is a major annoyance.
         // $('input#suggest').focus();
     }
     initVars();
 
     if(jQuery.jStore) {
         // Experimental (currently dead) code to handle "user hits back button" problem.
         if(false) {
             jQuery.extend(jQuery.jStore.defaults, {
@@ -2413,30 +2415,55 @@
 // 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 getVisibility(track)
+{
+// return current visibility for given track
+    var rec = trackDbJson[track];
+    if(rec) {
+        if(rec.localVisibility) {
+            return rec.localVisibility;
+        } else {
+            return visibilityStrsOrder[rec.visibility];
+        }
+    } else {
+        return null;
+    }
+}
+
+function makeSureSuggestTrackIsVisible()
+{
+// make sure to show knownGene/refGene track is in at least pack (redmine #3484).
+    var track = $("#suggestTrack").val();
+    if(track != null && getVisibility(track) != "full") {
+        updateVisibility(track, 'pack');
+        $("<input type='hidden' name='" + track + "'value='pack'>").appendTo($(document.TrackHeaderForm));
+    }
+}
+
 function reloadFloatingItem()
 {
 // currently dead (experimental code)
     if(floatingMenuItem) {
         $('#img_data_' + floatingMenuItem).parent().makeFloat({x:"current",y:"current", speed: 'fast', alwaysVisible: true, alwaysTop: true});
     }
 }
 
 function handleZoomCodon(response, status)
 {
     var json = eval("(" + response + ")");
     if(json.pos) {
         setPosition(json.pos, 3);
         if(document.TrackForm)
             document.TrackForm.submit();
