/* * Tooltip script * powered by jQuery (http://www.jquery.com) * * written by Alen Grakalic (http://cssglobe.com) * * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery * */ this.tooltip = function(){ /* CONFIG */ xOffset = 10; yOffset = 20; // these 2 variable determine popup's distance from the cursor // you might want to adjust to get the right result /* END CONFIG */ $("a.tooltips,img.tooltips,span.tooltips").hover( function(e){ var h=0; var w=0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE w = window.innerWidth; h = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' w = document.documentElement.clientWidth; h = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible w = document.body.clientWidth; h = document.body.clientHeight; } this.t = this.title; if(this.t!=null && this.t!=undefined && this.t!='undefined'){ this.title = ""; if((this.alt!=null && this.alt!='') || ($(this).find('img').attr('alt')!='' && $(this).find('img').attr('alt')!='undefined' && $(this).find('img').attr('alt')!=undefined)){ this._a=this.alt; this.alt=''; $(this).find('img').attr('alt',''); } $("body").append("

"+ this.t +"

"); $("#tooltips_jquery") .css("position",'absolute') .css("border",'solid 1px #000') .css("background-color",'#fff') .css("max-width",'150px') .css("font-size",'11px') .css("padding",'5px') .css("top",(e.pageY - xOffset) + "px") .css("left",(e.pageX + yOffset) + "px") .fadeIn("fast"); if( (e.pageX + yOffset +160)>w ){ $("#tooltips_jquery").css("left",(e.pageX-(yOffset +160)) + "px") } } }, function(){ this.title = this.t; /*if(this._a!=null && this._a!=''){ this.alt=this._a; }*/ $("#tooltips_jquery").remove(); }); $("a.tooltips,img.tooltips,span.tooltips").mousemove(function(e){ var h=0; var w=0; if( typeof( window.innerWidth ) == 'number' ) { //Non-IE w = window.innerWidth; h = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' w = document.documentElement.clientWidth; h = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible w = document.body.clientWidth; h = document.body.clientHeight; } $("#tooltips_jquery") .css("top",(e.pageY - xOffset) + "px") .css("left",(e.pageX + yOffset) + "px"); if( (e.pageX + yOffset +160)>w ){ $("#tooltips_jquery").css("left",(e.pageX-(yOffset +160)) + "px") } }); };