fa201373799159427e9e440bac05700f6db12348
tdreszer
  Mon Dec 20 15:17:05 2010 -0800
Track search should post selected tracks before sorting or going to a configuration page
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 207b552..b09df83 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -1183,31 +1183,31 @@
         }
         engine.set("token", newToken);
     });
 });
 
 function mapClk(obj)
 {
     return postToSaveSettings(obj);
 }
 
 function postToSaveSettings(obj)
 {
     if(blockUseMap==true) {
         return false;
     }
-    if(obj.href == undefined) // called directly with obj and from callback without obj
+    if(obj == undefined || obj.href == undefined) // called directly with obj and from callback without obj
         obj = this;
     if( obj.href.match('#') || obj.target.length > 0) {
         //alert("Matched # ["+obj.href+"] or has target:"+obj.target);
         return true;
     }
     var thisForm=$(obj).parents('form');
     if(thisForm == undefined || $(thisForm).length == 0)
         thisForm=$("FORM");
     if($(thisForm).length > 1 )
         thisForm=$(thisForm)[0];
     if(thisForm != undefined && $(thisForm).length == 1) {
         //alert("posting form:"+$(thisForm).attr('name'));
         return postTheForm($(thisForm).attr('name'),obj.href);
     }
     return true;
@@ -1585,32 +1585,37 @@
                                });
                     }
                 }
             }
     } else if (cmd == 'hgTrackUi_popup') {
 
         hgTrackUiPopUp( selectedMenuItem.id, false );  // Launches the popup but shields the ajax with a waitOnFunction
 
     } else if (cmd == 'hgTrackUi_follow') {
 
         var url = "hgTrackUi?hgsid=" + getHgsid() + "&g=";
         var id = selectedMenuItem.id;
         var rec = trackDbJson[id];
         if (tdbHasParent(rec) && tdbIsLeaf(rec))
             url += rec.parentTrack
+        else {
+            var link = $( 'td#td_btn_'+ selectedMenuItem.id ).children('a'); // The button already has the ref
+            if( $(link) != undefined)
+                url = $(link).attr('href');
         else
-            url = selectedMenuItem.id;
+                url += selectedMenuItem.id;
+        }
         location.assign(url);
 
     } else if (cmd == 'dragZoomMode') {
         autoHideSetting = true;
         var obj = imgAreaSelect.data('imgAreaSelect');
         obj.setOptions({autoHide : true, movable: false});
     } else if (cmd == 'hilightMode') {
         autoHideSetting = false;
         var obj = imgAreaSelect.data('imgAreaSelect');
         obj.setOptions({autoHide : false, movable: true});
     } else if (cmd == 'viewImg') {
         // Fetch a new copy of track img and show it to the user in another window. This code assume we have updated
         // remote cart with all relevant chages (e.g. drag-reorder).
         var data = "hgt.imageV1=1&hgt.trackImgOnly=1&hgsid=" + getHgsid();
         jQuery('body').css('cursor', 'wait');
@@ -2470,54 +2475,68 @@
     $('input[type="text"]').val(''); // This will always be found
     //$('select.mdbVar').attr('selectedIndex',0); // Do we want to set the first two to cell/antibody?
     $('select.mdbVal').attr('selectedIndex',0); // Should be 'Any'
     $('select.groupSearch').attr('selectedIndex',0);
     $('select.typeSearch').attr('selectedIndex',0);
     //findTracksSearchButtonsEnable(false);
     return false;
 }
 
 function findTracksSortNow(obj)
 {// Called by radio button to sort tracks
     if( $('#sortIt').length == 0 )
         $('form#trackSearch').append("<input TYPE=HIDDEN id='sortIt' name='"+$(obj).attr('name')+"' value='"+$(obj).val()+"'>");
     else
         $('#sortIt').val($(obj).val());
+
+    // How to hold onto selected tracks?
+    // There are 2 separate forms.  Scrape named inputs from searchResults form and dup them on trackSearch?
+    var inp = $('form#searchResults').find('input:hidden').not(':disabled').not("[name='hgsid']");
+    if($(inp).length > 0) {
+        $(inp).appendTo('form#trackSearch');
+        $('form#trackSearch').attr('method','POST'); // Must be post to avoid url too long  NOTE: probably needs to be post anyway
+    }
+
     $('#searchSubmit').click();
     return true;
 }
 
 function findTracksPage(pageVar,startAt)
 {// Called by radio button to sort tracks
     var pager = $("input[name='"+pageVar+"']");
     if( $(pager).length == 1)
         $(pager).val(startAt);
 
-    // FIXME: Remove this code if sving settings on paging is not wanted
     // How to hold onto selected tracks?
     // There are 2 separate forms.  Scrape named inputs from searchResults form and dup them on trackSearch?
     var inp = $('form#searchResults').find('input:hidden').not(':disabled').not("[name='hgsid']");
     if($(inp).length > 0) {
         $(inp).appendTo('form#trackSearch');
         $('form#trackSearch').attr('method','POST'); // Must be post to avoid url too long  NOTE: probably needs to be post anyway
     }
-    // FIXME: Remove this code if sving settings on paging is not wanted
 
     $('#searchSubmit').click();
     return false;
 }
 
+function findTracksConfigureSet(name)
+{// Called when configuring a composite or superTrack
+    var thisForm =  $('form#searchResults');
+    $(thisForm).attr('action',"../cgi-bin/hgTrackUi?hgt_tSearch=Search&g="+name);
+    $(thisForm).find('input.viewBtn').click();
+}
+
 /////////////////////////////////////////////////////
 
 function delSearchSelect(obj, rowNum)
 {
     obj = $(obj);
     $("input[name=hgt_tsDelRow]").val(rowNum);  // NOTE: Must match TRACK_SEARCH_DEL_ROW in hg/inc/searchTracks.h
     return true;
 }
 
 function addSearchSelect(obj, rowNum)
 {
     obj = $(obj);
     $("input[name=hgt_tsAddRow]").val(rowNum);  // NOTE: Must match TRACK_SEARCH_ADD_ROW in hg/inc/searchTracks.h
     return true;
 }