Merge pull request #967 from solgenomics/topic/expression_atlas_export
[sgn.git] / js / jquery / simpletooltip.js
blobaad0c2952fca8424ffade57c03fce9b3995014a6
1 //JSAN.use('jquery');
3 /**
5 * simpleTooltip jQuery plugin, by Marius ILIE
6 * visit http://dev.mariusilie.net for details
8 **/
9 (function($){ $.fn.simpletooltip = function(){
10 return this.each(function() {
11 var text = $(this).attr("title");
12 $(this).attr("title", "");
13 if(text != undefined) {
14 $(this).hover(function(e){
15 var tipX = e.pageX + 12;
16 var tipY = e.pageY + 12;
17 $(this).attr("title", "");
18 $("body").append("<div id='simpleTooltip' style='position: absolute; z-index: 100; display: none;'>" + text + "</div>");
19 if($.browser.msie) var tipWidth = $("#simpleTooltip").outerWidth(true)
20 else var tipWidth = $("#simpleTooltip").width()
21 $("#simpleTooltip").width(tipWidth);
22 $("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
23 }, function(){
24 $("#simpleTooltip").remove();
25 $(this).attr("title", text);
26 });
27 $(this).mousemove(function(e){
28 var tipX = e.pageX + 12;
29 var tipY = e.pageY + 12;
30 var tipWidth = $("#simpleTooltip").outerWidth(true);
31 var tipHeight = $("#simpleTooltip").outerHeight(true);
32 if(tipX + tipWidth > $(window).scrollLeft() + $(window).width()) tipX = e.pageX - tipWidth;
33 if($(window).height()+$(window).scrollTop() < tipY + tipHeight) tipY = e.pageY - tipHeight;
34 $("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
35 });
37 });
38 }})(jQuery);
41 jQuery( function() {
42 jQuery('.tooltipped').simpletooltip();
43 });