18114c799ed1df9bc555b832ca21008c5bb63b45
kate
  Wed Jul 26 11:02:54 2017 -0700
Add autoscale feature. refs #19867

diff --git src/hg/js/utils.js src/hg/js/utils.js
index 71b0e02..41255b8 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -1338,33 +1338,49 @@
 
     // NOTE: selector strings are a bit complex due to dots GB vars/attributes (track.var)
     // so can't use more concise jQuery syntax
 
     // check log transform
     var logCheckbox = $("input[name='" + name + ".logTransform']");
     var isLogChecked = logCheckbox.attr('checked');
 
     // enable/disable view limits
     var maxTextbox = $("input[name='" + name + ".maxViewLimit']");
     maxTextbox.attr('disabled', isLogChecked);
     var maxTextLabel = $("." + name + "ViewLimitsMaxLabel");
     maxTextLabel.toggleClass("disabled", isLogChecked ? true : false);
 }
 
-function barChartUiTransformChanged(name) {
-// Disable view limits settings if log transform enabled
-    gtexTransformChanged(name);
+function barChartTransformChanged(event)
+{// When autoScale or logTransform is checked, uncheck the other and disable view limits
+ // When autoScale or logTransform is unchecked, enable view limits
+    var target = event.target;
+    var targetInfo = target.id.split('.');
+    var track = targetInfo[0];        
+    var transform = targetInfo[1];        
+    var $maxInput = $("input[name='" + track + ".maxViewLimit']");
+    var $maxLabel = $('.' + track + 'ViewLimitsMaxLabel');
+    if ($(target).attr('checked')) {
+        $maxInput.attr('disabled', true);
+        $maxLabel.addClass('disabled');
+        var $otherCheckbox = $("input[name='" + track + '.' + (transform === 'logTransform' ?
+                                        'autoScale' : 'logTransform') + "']");
+        $otherCheckbox.attr('checked', false);
+    } else {
+        $maxInput.attr('disabled', false);
+        $maxLabel.removeClass('disabled');
+    }
 }
 
 function gtexSamplesChanged(name)
 { // Disable and comparison controls if all samples selected
 
     // check sample select
     var sampleSelect = $("input[name='" + name + ".samples']:checked");
     var isAllSamples = (sampleSelect.val() === 'all');
 
     // enable/disable comparison options
     // limiting to radio buttons as there is a problem with tissue checkbox naming on popup
     var comparisonButtons = $("input[type='radio' name='" + name + ".comparison']");
     comparisonButtons.attr('disabled', isAllSamples);
     var comparisonLabel = $("." + name + "ComparisonLabel");
     comparisonLabel.toggleClass("disabled", isAllSamples ? true : false);