src/hg/js/hgTracks.js 1.59

1.59 2010/03/09 00:22:29 tdreszer
Move some javascript code into c to speed handling massive images
Index: src/hg/js/hgTracks.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hgTracks.js,v
retrieving revision 1.58
retrieving revision 1.59
diff -b -B -U 4 -r1.58 -r1.59
--- src/hg/js/hgTracks.js	28 Feb 2010 00:11:07 -0000	1.58
+++ src/hg/js/hgTracks.js	9 Mar 2010 00:22:29 -0000	1.59
@@ -113,9 +113,9 @@
 function getDb()
 {
     var db = document.getElementsByName("db");
     if(db == undefined || db.length == 0)
-        return undef;
+        return undefined;
     return db[0].value;
 }
 
 function checkPosition(img, selection)
@@ -1037,8 +1037,32 @@
         engine.set("token", newToken);
     });
 });
 
+function postToSaveSettings(obj)
+{
+    if(blockUseMap==true) {
+        return false;
+    }
+    if(obj.href == undefined) // called directly with obj and from callback without obj
+        obj = this;
+    if( obj.href.match('#') || obj.target.length > 0) {
+        //alert("Matched # or has target");
+        return true;
+    }
+    var thisForm=$(obj).parents('form');
+    if(thisForm == undefined || $(thisForm).length == 0)
+        thisForm=$("FORM");
+    if($(thisForm).length > 1)
+        thisForm=$(thisForm)[0];
+    if(thisForm != undefined && $(thisForm).length == 1) {
+        //alert("posting form:"+$(thisForm).attr('name'));
+        return postTheForm($(thisForm).attr('name'),this.href);
+    }
+
+    return true;
+}
+
 $(document).ready(function()
 {
     var db = getDb();
     if(jQuery.fn.autocomplete && $('input#suggest') && db) {
@@ -1072,24 +1096,11 @@
     }
 
     // Convert map AREA gets to post the form, ensuring that cart variables are kept up to date
     if($("FORM").length > 0) {
-        $('a,area').not("[href*='#']").not("[target]").click(function(i) {
-            if(blockUseMap==true) {
-                return false;
-            }
-            var thisForm=$(this).parents('form');
-            if(thisForm == undefined || $(thisForm).length == 0)
-                thisForm=$("FORM");
-            if($(thisForm).length > 1)
-                thisForm=$(thisForm)[0];
-            if(thisForm != undefined && $(thisForm).length == 1) {
-                //warn("posting form:"+$(thisForm).attr('name'));
-                return postTheForm($(thisForm).attr('name'),this.href);
-            }
-
-            return true;
-        });
+        var allLinks = $('a');
+        $( allLinks ).unbind('click');
+        $( allLinks ).click( postToSaveSettings );
     }
     if($('#pdfLink').length == 1) {
         $('#pdfLink').click(function(i) {
             var thisForm=$('#TrackForm');