02646d7ea3d38d8e6dfd0584894dcf77b334447c
tdreszer
  Tue Nov 19 10:57:26 2013 -0800
Adding back-button suppoirt through jquery.history.js API. At this time back-button support is only for position.  At all times the image should agree with the cart.  This means that moving forward, the image must be stacked in window.History.state and moving back, the image must be refreshed using the old location.  Note that full page refreshes complicate the picure.  Back-button will recall a client side cached page which may be greatly out of sync with cart.  Stretegy is to use image only update, but if all else fails, a full page reload is used.  This means, that image only update is preferred going forward.  To that end, several previous places that required full page refresh can now be done with image only rtefresh.  At this time, anytime the chrom changes, the page will be fully refreshed.  Redmine #7473.
diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 89389f7..c57b6b2 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -4539,36 +4539,40 @@
     if (showTrackControls)
         {
 	/* Break into a second form so that zooming and scrolling
 	 * can be done with a 'GET' so that user can back up from details
 	 * page without Internet Explorer popping up an annoying dialog.
 	 * Do rest of page as a 'POST' so that the ultra-long URL from
 	 * all the track controls doesn't break things.  IE URL limit
 	 * is 2000 bytes, but some firewalls impose a ~1000 byte limit.
 	 * As a side effect of breaking up the page into two forms
 	 * we need to repeat the position in a hidden variable here
 	 * so that zoom/scrolling always has current position to work
 	 * from. */
         // This 'dirty' field is used to check if js/ajax changes to the page have occurred.
         // If so and it is reached by the back button, a page reload will occur instead.
         hPrintf("<INPUT TYPE='text' style='display:none;' name='dirty' id='dirty' VALUE='false'>\n");
+        // Define BACK_SUPPORT to support the back-button via jquery.histoty.js
+#define BACK_SUPPORT
+#ifndef BACK_SUPPORT
         // Unfortunately this does not work in IE, so IE will get reloaded only after this full load
         // NOTE: Larry and I have seen that the new URL is not even used, but this will abort
         //       the page load and hasten the isDirty() check in hgTracks.js
         hPrintf("<script type='text/javascript'>if (document.getElementById('dirty').value == "
                 "'true') {document.getElementById('dirty').value = 'false'; "
                 "window.location = '%s?hgsid=%d';}</script>\n",hgTracksName(),cart->sessionId);
+#endif//ndef BACK_SUPPORT
         hPrintf("<INPUT TYPE=HIDDEN id='positionHidden' NAME=\"position\" "
                 "VALUE=\"%s:%d-%d\">", chromName, winStart+1, winEnd);
         hPrintf("\n%s", trackGroupsHidden1->string);
         hPrintf("</CENTER></FORM>\n");
         hPrintf("<FORM ACTION=\"%s\" NAME=\"TrackForm\" id=\"TrackForm\" METHOD=\"POST\">\n\n",
                 hgTracksName());
 	    hPrintf("%s", trackGroupsHidden2->string);
 	    freeDyString(&trackGroupsHidden1);
 	    freeDyString(&trackGroupsHidden2);
 	if (!psOutput) cartSaveSession(cart);   /* Put up hgsid= as hidden variable. */
 	clearButtonJavascript = "document.TrackForm.position.value=''; document.getElementById('suggest').value='';";
 	hPrintf("<CENTER>");
 	}
 
 
@@ -5681,30 +5685,33 @@
     }
 
 jsonForClient = newJsonObject(newHash(8));
 jsonObjectAdd(jsonForClient, "cgiVersion", newJsonString(CGI_VERSION));
 boolean searching = differentString(cartUsualString(cart, TRACK_SEARCH,"0"), "0");
 
 if(!trackImgOnly)
     {
     // Write out includes for css and js files
     hWrites(commonCssStyles());
     jsIncludeFile("jquery.js", NULL);
     jsIncludeFile("jquery-ui.js", NULL);
     jsIncludeFile("utils.js", NULL);
     jsIncludeFile("ajax.js", NULL);
     jsIncludeFile("jquery.watermarkinput.js", NULL);
+#ifdef BACK_SUPPORT
+    jsIncludeFile("jquery.history.js", NULL);  // Experimental
+#endif//def BACK_SUPPORT
     if(!searching)
         {
         jsIncludeFile("jquery.imgareaselect.js", NULL);
         }
     jsIncludeFile("autocomplete.js", NULL);
     jsIncludeFile("hgTracks.js", NULL);
 
 #ifdef LOWELAB
     jsIncludeFile("lowetooltip.js", NULL);
 #endif///def LOWELAB
 
     webIncludeResourceFile("jquery-ui.css");
     if (!searching)     // NOT doing search
         {
         webIncludeResourceFile("jquery.contextmenu.css");