Hello guys, I'm trying to make my tooltips pop up in the left side of the cursor instead of the right side, with a jquery plugin called EasyTooltip.
I'm trying to give a negative value in the header's call, which aim would be to affect the x-axis positioning, but with no effects (nothing appears, while a positive value in both axis shall normally work) :
<script type="text/javascript">
$(document).ready(function() {
$(".middle img").easyTooltip({
tooltipId: "easyTooltip2",
xOffset: -300,
yOffset: 50
});
});
</script>
I'm quite new to javascript, and I think that I'd have to hack the script, but I would need your advice here. This is the script :
/*
* Easy Tooltip 1.0 - jQuery plugin
* written by Alen Grakalic
* http://cssglobe.com/post/4380/easy-tooltip--jquery-plugin
*
* Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Built for jQuery library
* http://jquery.com
*
*/
(function($) {
$.fn.easyTooltip = function(options){
// default configuration properties
var defaults = {
xOffset: 10,
yOffset: 20,
tooltipId: "easyTooltip",
clickRemove: false,
content: "",
useElement: ""
};
var options = $.extend(defaults, options);
var content;
this.each(function() {
var title = $(this).attr("title");
$(this).hover(function(e){
content = (options.content != "") ? options.content : title;
content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
$(this).attr("title","");
if (content != "" && content != undefined){
$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");
$("#" + options.tooltipId)
.css("position","absolute")
.css("top",(e.pageY - options.yOffset) + "px")
.css("left",(e.pageX + options.xOffset) + "px")
.css("display","none")
.fadeIn("fast")
}
},
function(){
$("#" + options.tooltipId).remove();
$(this).attr("title",title);
});
$(this).mousemove(function(e){
$("#" + options.tooltipId)
.css("top",(e.pageY - options.yOffset) + "px")
.css("left",(e.pageX + options.xOffset) + "px")
});
if(options.clickRemove){
$(this).mousedown(function(e){
$("#" + options.tooltipId).remove();
$(this).attr("title",title);
});
}
});
};
})(jQuery);
Many thanks for any input. Cheers,