src/hg/js/lowetooltip.js 1.2

1.2 2010/02/12 18:03:11 markd
integrated archae tool tip changes from Andrew Holmes
Index: src/hg/js/lowetooltip.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/lowetooltip.js,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 4 -r1.1 -r1.2
--- src/hg/js/lowetooltip.js	2 Dec 2009 18:18:22 -0000	1.1
+++ src/hg/js/lowetooltip.js	12 Feb 2010 18:03:11 -0000	1.2
@@ -1,6 +1,7 @@
 
-var tipup = -1;
+var tipup;
+var chrom;
 
 function removetitles()
 {
     $(".hastip").each(function(i)
@@ -155,9 +156,9 @@
     return $(element);
 }
 function update(event)
 {
-    if(tipup == -1)
+    if(tipup.size() == 0)
     {
         resettip(event.target);
     }
     //console.log(tipup);
@@ -183,10 +184,11 @@
 }
 function showInfo(event,output)
 {
     
-    if($(event.target).data('num') === tipup)
+    if($(event.target).not( tipup ).size() == 0)
     {
+        //console.log("||");
         $(".tooltip").css('left',0).css('top',0);
         
         $(".tooltip").html(output);
         
@@ -198,22 +200,26 @@
         $(event.target).bind('mousemove', update);
     }    
     //$(this).unbind('mousemove')    
 }
-function ajaxError(XMLHttpRequest, textStatus, errorThrown)
+function ajaxtooltipError(XMLHttpRequest, textStatus, errorThrown,event)
 {
-    XMLHttpRequest.abort();
-    console.log(textStatus);
-    $("#tooltip").text(textStatus + "\n");
-    //console.log(errorThrown);
+    //XMLHttpRequest.abort();
+    //console.log(textStatus);
+    showInfo(event, "<B>Name:</B> "+$(event.target).data('title'));
+    //$("#tooltip").text("**"+$(event.target).data('title'));
+
+    //alert(textStatus + "\n");
+    //console.log(textStatus);
 }
 
 
 
 function resettip(hastip)
 {
+    $(hastip).attr("title",$(hastip).data("title"));
     //console.log("Tip gone"+tipup);
-    tipup = -1;
+    tipup = $();
     $(hastip).unbind('mousemove', update);
     $("#tooltip").hide();
     $("#tooltip").text('');
     $(".tooltip").css('width','auto');
@@ -222,8 +228,9 @@
 }
 
 function hidetip(event)
 {
+    
     resettip(event.target);
 }
 
 
@@ -232,42 +239,43 @@
     /*if(tipup != -1)
     {
         
     }*/
-    resettip($(".hastip").get(tipup));
-    tipup = $(event.target).data('num');
-    $(event.target).bind("mouseleave",hidetip );
+    if(!($(event.target).is("area[href^='../cgi-bin/hgc']")))
+    {
+        
+        return;
+    }
+    //console.log($(event.target).attr("title"));
+    $(event.target).data("title",$(event.target).attr("title"));
+    $(event.target).removeAttr("title");
+    resettip(tipup);
+    tipup = $(event.target);
+    $(event.target).bind("mouseleave",hidetip);
     
     if($("input[name=showtooltips]").attr('checked') === false)
     {
         return;
     }
     //$("#tooltip").load("../cgi-bin/tooltip?"+($(event.target).attr('href').split("?"))[1],"",makevisible);
     
-    
     $.ajax({
             type: "GET",
-            url: "../cgi-bin/tooltip?"+($(event.target).attr('href').split("?"))[1],
+            url: "../cgi-bin/tooltip?c="+chrom+"&"+($(event.target).attr('href').split("?"))[1],
             dataType: "html",
             success: function(output){showInfo(event,output);},
-            error: ajaxError,
+            error: function(XMLHttpRequest, textStatus, errorThrown){ajaxtooltipError(XMLHttpRequest, textStatus, errorThrown,event);},
             cache: true
     });
     
-    
-    
 }
 $(document).ready(function() 
 {
     //NEWVERSION
-    $("area[href^='../cgi-bin/hgc']").addClass('hastip');
+    $("area").addClass('hastip');
     
-    $(".hastip").each(function(i)
-    {
-        $(this).data('title', $(this).attr('title'));
-        $(this).data('num',i);
-        $(this).removeAttr("title");
-    });
+    
+    tipup = $()
     $("body").append("<div class='tooltip' id='tooltip'></div>");
     $("#tooltip").css({
     "background": "white",
     "border": "1px black solid",
@@ -281,8 +289,11 @@
     $("#tooltiptext").css({
     "font-size": "small",
     "opacity" : "1"});
     $("#trackMap").removeAttr("title");
+    chrom = $("input[name=chromName]").val();
+    //console.log();
+
     $(".hastip").bind("mouseenter", showtip);
     
     $("input[name=hgt.toggleRevCmplDisp]").after('  <input type="submit" class="setwidth" value="auto-set width" onclick="setwidth()"/>');