daf92c0f9eb331ea60740e6802aabd241d4be363
tdreszer
  Wed Sep 1 13:40:10 2010 -0700
Change popup cfg to recognize only changed vars for update to cart and page update
diff --git src/hg/js/hui.js src/hg/js/hui.js
index 0228fa9..be02582 100644
--- src/hg/js/hui.js
+++ src/hg/js/hui.js
@@ -587,6 +587,24 @@
 
 var popUpTrackName;
 var popUpTitle = "";
+var popSaveAllVars = null;
+function popUpCfgOk(popObj, trackName)
+{ // Kicks off a Modal Dialog for the provided content.
+    var allVars = getAllVars(popObj, trackName );   // always subtrack cfg
+    var changedVars = varHashChanges(allVars,popSaveAllVars);
+    //warn("cfgVars:"+varHashToQueryString(changedVars));
+    setVarsFromHash(changedVars);  // FIXME: These settings will be lost, unless the composite/view settings are ajaxed over on change!
+    var newVis = changedVars[trackName];
+    if(newVis != null) {
+        var sel = $('input[name="'+trackName+'_sel"]:checkbox');
+        var checked = (newVis != 'hide' && newVis != '[]');  // subtracks do not have "hide", thus '[]'
+        if( $(sel) != undefined ) {
+            $(sel).each( function (i) { matSubCBcheckOne(this,checked); });  // Though there is only one, the each works but the direct call does not!
+            matSubCBsSelected();
+        }
+    }
+}
+
 function popUpCfg(content, status)
 { // Kicks off a Modal Dialog for the provided content.
     // Set up the modal dialog
@@ -603,18 +621,10 @@
         closeOnEscape: true,
         autoOpen: false,
         buttons: { "Ok": function() {
-            setAllVars($('#popit'),popUpTrackName); // Assumes subtrack, will do the right thing with "_sel" on hide // FIXME: sets vis even if same as inherited or unchanged!
-            var vis = $(this).find('select[name="'+popUpTrackName+'"]');
-            var sel = $('input[name="'+popUpTrackName+'_sel"]:checkbox');
-            if(vis != undefined && sel != undefined) {
-                var check = ($(vis).attr('selectedIndex') > 0);
-                $(sel).each( function (i) { matSubCBcheckOne(this,check); });  // Though there is only one, the each works but the direct call does not!
-                setCartVar( $(sel).attr('name'), $(sel).val() );
-                matSubCBsSelected();
-                // FIXME: These settings will be lost, unless the composite/view settings are ajaxed over on change!
-            }
+            popUpCfgOk(this,popUpTrackName);
             $(this).dialog("close");
         }},
+        open: function() { popSaveAllVars = getAllVars( this, popUpTrackName ); }, // always subtrack cfg
         close: function() { $('#popit').empty(); }
     });
     // Apparently the options above to dialog take only once, so we set title explicitly.