f9c068638aaeddd15d998a5fa840e08898c6e83b
kate
  Tue Mar 20 22:55:59 2012 -0700
Changes responding to QA (redmine #5149, issues note 27).  1. Save user-selected search type in cookie so it persists across pages.  2. Include ChIP-seq in cell-based experiment table on data summary page.  3. encode URL passed to hgEncodeVocab so cells having terms with weird chars (e.g. +) will work.  Also, override extra search dropdowns (until figure out how to remove mdbVar cart vars by URL)
diff --git src/hg/js/encodeMatrix.js src/hg/js/encodeMatrix.js
index dc1354a..6740261 100644
--- src/hg/js/encodeMatrix.js
+++ src/hg/js/encodeMatrix.js
@@ -1,51 +1,67 @@
 /* encodeMatrix.js - shared code for ENCODE data matrix apps
 
  Formatted: jsbeautify.py -j
  Syntax checked: jslint indent:4, plusplus: true, continue: true, unparam: true, sloppy: true, browser: true
 */
 /*global $, encodeProject */
 
 var encodeMatrix = (function () {
 
     // spinning image displayed during AJAX activity
     var spinner;
 
     // UI panel for search: select tracks or files
 
-    function addSearchPanel($div) {
-        // Create panel of radio buttons for user to select search type
+    function addSearchPanel($div, isFileSearch) {
+        // Create panel of radio buttons for user to change search type
+        // isFileSearch determines initial setting
         // Add to passed in div ID; e.g. #searchTypePanel
-        $div.append('<span id="searchPanelInstructions">search for:&nbsp;</span><input type="radio" name="searchType" id="searchTracks" value="tracks" checked="checked">tracks<input type="radio" name="searchType" id="searchFiles" value="files">files');
+        $div.append('<span id="searchPanelInstructions">search for:&nbsp;</span><input type="radio" name="searchType" id="searchTracks" value="tracks" onclick="encodeMatrix.setFileSearch(false);" checked="checked">tracks<input type="radio" name="searchType" id="searchFiles" value="files" onclick="encodeMatrix.setFileSearch(true);" >files');
+        if (isFileSearch) {
+            $('#searchFiles').attr('checked', true);
+        }
     }
 
     return {
 
         // UI panel for search: select tracks or files
 
+        setFileSearch: function (choice) {
+            // Set search type cookie to retain user choice
+            document.cookie = "encodeMatrix.search=" + (choice ? "file" : "track");
+        },
+
+        isFileSearch: function () {
+            // Check search type cookie to retain user choice
+            return document.cookie.match(/encodeMatrix.search=file/);
+        },
+
         getSearchUrl: function (assembly) {
             // Return URL for search of type requested in search panel
 
             var prog, cartVar, url;
             if ($('input:radio[name=searchType]:checked').val() === "tracks") {
                 prog = 'hgTracks';
                 cartVar = 'hgt_tSearch';
             } else {
                 prog = "hgFileSearch";
-                cartVar = "hgfs_Search";
+                cartVar = "fsFileType=Any&hgfs_Search";
             }
              url = '/cgi-bin/' + prog + '?db=' + assembly + '&' + cartVar + '=search' +
+                    // Intent to clear out search dropdowns we don't need
+                    //'&hgt_tsDelRow=true&hgt_tsDelRow=true&hgt_tsDelRow=true&hgt_tsDelRow=true' +
                     '&tsCurTab=advancedTab&hgt_tsPage=';
             return (url);
         },
 
         getSearchType: function () {
             return $('input:radio[name=searchType]:checked').val();
         },
 
         // General purpose functions
 
         start: function ($el) {
             // Initialize application. Caller passes in jQuery selector object to hide/show
 
             // get server from calling web page (e.g. can sub in genome-preview)
             if ('encodeMatrix_server' in window) {
@@ -60,31 +76,31 @@
             $('#assemblyLabel').text(assembly);
             header = encodeMatrix_pageHeader;
             $('#pageHeader').text(header);
             document.title = 'ENCODE ' + header;
 
             encodeProject.setup({
                 server: server,
                 assembly: assembly
             });
 
             // show only spinner until data is retrieved
             $el.hide();
             spinner = showLoadingImage('spinner', true);
 
             // add radio buttons for search type to specified div on page
-            addSearchPanel($('#searchTypePanel'));
+            addSearchPanel($('#searchTypePanel'), encodeMatrix.isFileSearch());
         },
 
     show: function ($el) {
         // Call after data loads to show display
         hideLoadingImage(spinner);
         $el.show();
         },
 
     // Table rendering special effects
 
     addTableFloatingHeader: function ($table) {
         // add callback for floating table header feature
 
        // NOTE: it may be possible to revive floating header functionality in IE 
        // using this plug-in, but I've timed out 
@@ -177,32 +193,35 @@
                 if (!term) {
                     return true;
                 }
                 if (!matrix[term]) {
                     return true;
                 }
                 cellType = encodeProject.getCellType(term);
                 karyotype = cellType.karyotype;
                 if (karyotype !== 'cancer' && karyotype !== 'normal') {
                     karyotype = 'unknown';
                 }
                 // note karyotype bullet layout requires non-intuitive placement
                 // in code before the span that shows to it's left
                 $row = $('<tr>' +
                     '<th class="elementType">' +
-                    '<span style="float:right; text-align: right;" title="karyotype: ' + karyotype + '" class="karyotype ' + karyotype + '">&bull;</span>' +
-                    '<span title="' + cellType.description + '"><a target="cvWindow" href="/cgi-bin/hgEncodeVocab?ra=encode/cv.ra&term=' + cellType.term + '">' + cellType.term + '</a>' +
+                    '<span style="float:right; text-align: right;" title="karyotype: ' + 
+                    karyotype + '" class="karyotype ' + karyotype + '">&bull;</span>' +
+                    '<span title="' + cellType.description + 
+                    '"><a target="cvWindow" href="/cgi-bin/hgEncodeVocab?ra=encode/cv.ra&deprecated=true&term=' + 
+                    encodeURIComponent(cellType.term) + '">' + cellType.term + '</a>' +
                     '</th>'
                     );
                 maxLen = Math.max(maxLen, cellType.term.length);
 
                 rowAddCells($row, groups, expCounts, matrix, cellType.term);
                 $table.append($row);
             });
             // adjust size of row headers based on longest label length
             $('tbody th').css('height', '1em');
             $('tbody th').css('width', (String((maxLen/2 + 2)).concat('em')));
         });
         $('body').append($table);
     },
 
     tableOut: function ($table, matrix, cellTiers, groups, expCounts, tableHeaderOut, rowAddCells) {