From 00b22d40dd9f3c8e178d7ab86007e948cada6363 Mon Sep 17 00:00:00 2001 From: willianganzert Date: Fri, 4 Jul 2014 08:32:01 -0300 Subject: [PATCH] Add "id" to tooltip element Was added a optional "id" in tooltip element. This model made possible to have and manipulate many tooltips in same document. --- js/jquery.flot.tooltip.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/jquery.flot.tooltip.js b/js/jquery.flot.tooltip.js index c712742..fe75691 100644 --- a/js/jquery.flot.tooltip.js +++ b/js/jquery.flot.tooltip.js @@ -43,6 +43,7 @@ if (!Array.prototype.indexOf) { var defaultOptions = { tooltip: false, tooltipOpts: { + id: "flotTip", content: "%s | X: %x | Y: %y", // allowed templates are: // %s -> series label, @@ -155,10 +156,10 @@ if (!Array.prototype.indexOf) { * @return jQuery object */ FlotTooltip.prototype.getDomElement = function() { - var $tip = $('#flotTip'); + var $tip = $('#'+this.tooltipOptions.id); if( $tip.length === 0 ){ - $tip = $('
').attr('id', 'flotTip'); + $tip = $('
').attr('id', this.tooltipOptions.id); $tip.appendTo('body').hide().css({position: 'absolute'}); if(this.tooltipOptions.defaultTheme) { @@ -180,7 +181,7 @@ if (!Array.prototype.indexOf) { // as the name says FlotTooltip.prototype.updateTooltipPosition = function(pos) { - var $tip = $('#flotTip'); + var $tip = $('#'+this.tooltipOptions.id); var totalTipWidth = $tip.outerWidth() + this.tooltipOptions.shifts.x; var totalTipHeight = $tip.outerHeight() + this.tooltipOptions.shifts.y;