5 * simpleTooltip jQuery plugin, by Marius ILIE
6 * visit http://dev.mariusilie.net for details
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");
24 $("#simpleTooltip").remove();
25 $(this).attr("title", text
);
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");
42 jQuery('.tooltipped').simpletooltip();