(function($){ $.fn.tooltip = function(options) { var defaults = { title: null, description: null, left:false, cursor:"auto", delay : 1500, hide_delay : 100000, max_width : null }; var options = $.extend(defaults, options); this.mouseover(function(e) { $("body").children('div#tooltip').remove(); $("body").append('<div id="tooltip"><h4>'+ (options.title != null ? options.title : tip[0]) +'</h4><div>'+ (options.description != null ? options.description : tip[1]) +'</div></div>'); $('#tooltip').css('top', e.pageY + 20); $('#tooltip').css('left', (e.pageX - (options.left == true ? $('#tooltip').width()+15 : -15))); if (options.max_width != null && (options.max_width = parseInt(options.max_width)) > 0) $('#tooltip').css('max-width', options.max_width); $('#tooltip').hide().animate({opacity:0.0}, options.delay).fadeIn('500').fadeTo('1',0.94); $('#tooltip').animate({opacity:1.0}, options.hide_delay).fadeOut('500').fadeTo('fast', 0); }).mousemove(function(e) { $('#tooltip').css('top', e.pageY + 20); $('#tooltip').css('left', (e.pageX - (options.left == true ? $('#tooltip').width()+15 : -15))); }).mouseout(function() { $("body").children('div#tooltip').remove(); }); }; })(jQuery);
