85d50be0698425886b76dbd31aed744b934586b9
tdreszer
  Tue Apr 26 14:46:27 2011 -0700
Added scrollbars to dropdownchecklist multi-selects
diff --git src/hg/js/utils.js src/hg/js/utils.js
index cc08d4a..0267dd3 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -1759,59 +1759,59 @@
         td.empty();
         td.append(response);
         var inp = $(td).find('.mdbVal');
         var tdIsLike = $('td#isLike'+this.num);
         if (inp != undefined && tdIsLike != undefined) {
             if ($(inp).hasClass('freeText')) {
                 $(tdIsLike).text('contains');
             } else if (usesFilterBy && $(inp).hasClass('filterBy')) {
                 $(tdIsLike).text('is among');
             } else {
                 $(tdIsLike).text('is');
             }
         }
         $(td).find('.filterBy').each( function(i) { // Do this by 'each' to set noneIsAll individually
             if (usesFilterBy) {
-                $(this).dropdownchecklist({ firstItemChecksAll: true, noneIsAll: true });
+                $(this).dropdownchecklist({ firstItemChecksAll: true, noneIsAll: true, maxDropHeight: filterByMaxHeight(this) });
             } else {
                 $(this).attr("multiple",false);
                 $(this).removeClass('filterBy');
                 $(this).show();
             }
         });
     }
     updateMetaDataHelpLinks(this.num);
 }
 
 function findTracksMdbValChanged(obj)
 { // Keep all tabs with same selects in sync  TODO: Change from name to id based identification and only have one set of inputs in form
   // This handles the currnet case when 2 vars have the same name (e.g. advanced, files tabs)
 
     findTracksClearFound();  // Changing values so abandon what has been found
 
     if ($('#advancedTab').length == 1 && $('#filesTab').length == 1) {
         var newVal = $(obj).val();
         var a = /hgt_mdbVal(\d+)/.exec(obj.name); // NOTE must match METADATA_NAME_PREFIX in hg/hgTracks/searchTracks.c
         if(newVal != undefined && a && a[1]) {
             var num = a[1];
             $("input.mdbVal[name='hgt_mdbVal"+num+"'][value!='"+newVal+"']").val(newVal);
             $("select.mdbVal[name='hgt_mdbVal"+num+"'][value!='"+newVal+"']").each( function (i) {
                 $(this).val(newVal);
                 if ($(this).hasClass('filterBy')) {
                     //$(this).dropdownchecklist("refresh");  // requires v1.1
                     $(this).dropdownchecklist("destroy");
-                    $(this).dropdownchecklist({ firstItemChecksAll: true, noneIsAll: true });
+                    $(this).dropdownchecklist({ firstItemChecksAll: true, noneIsAll: true, maxDropHeight: filterByMaxHeight(this) });
                 }
             });
         }
     }
     //findTracksSearchButtonsEnable(true);
 }
 
 function findTracksChangeVis(seenVis)
 { // called by onchange of vis
     var visName = $(seenVis).attr('id');
     var trackName = visName.substring(0,visName.length - "_id".length)
     var hiddenVis = $("input[name='"+trackName+"']");
     var tdb = tdbGetJsonRecord(trackName);
     if($(seenVis).val() != "hide")
         $(hiddenVis).val($(seenVis).val());
@@ -1958,40 +1958,53 @@
         $(counter).text("("+$(selCbs).filter(":enabled:checked").length + " of " +$(selCbs).length+ " selected)");
     }
 }
 
 function findTracksClearFound()
 {// Clear found tracks and all input controls
     var found = $('div#found');
     if(found != undefined)
         $(found).remove();
     found = $('div#filesFound');
     if(found != undefined)
         $(found).remove();
     return false;
 }
 
+function filterByMaxHeight(multiSel)
+{
+    var pos = $(multiSel).closest(':visible').offset().top + 30;
+    if (pos <= 0)
+        pos = 260;
+    var maxHeight = $(window).height() - pos;
+//    var maxHeight = $(window).height() - 260;
+    var selHeight = $(multiSel).children().length * 21;
+    if (maxHeight > selHeight)
+        maxHeight = selHeight;
+    return maxHeight;
+}
+
 function findTracksClear()
 {// Clear found tracks and all input controls
     findTracksClearFound();
     $('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.filterBy').each( function(i) { // Do this by 'each' to set noneIsAll individually
           //$(this).dropdownchecklist("refresh");  // requires v1.1
           $(this).dropdownchecklist("destroy");
-          $(this).dropdownchecklist({ firstItemChecksAll: true, noneIsAll: true });
+        $(this).dropdownchecklist({ firstItemChecksAll: true, noneIsAll: true, maxDropHeight: filterByMaxHeight(this) });
     });
 
     $('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());
 
