From 3652cfcda57d1f4fa040a2965b1a100df5c92fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arturo=20Filast=C3=B2?= Date: Sun, 17 Mar 2013 11:35:03 -0400 Subject: [PATCH] Fix bug in visualization of tooltip in Firefox --- js/libs/bootstrap/bootstrap-tooltip.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/libs/bootstrap/bootstrap-tooltip.js b/js/libs/bootstrap/bootstrap-tooltip.js index 21f2311..10c155f 100644 --- a/js/libs/bootstrap/bootstrap-tooltip.js +++ b/js/libs/bootstrap/bootstrap-tooltip.js @@ -129,13 +129,21 @@ actualWidth = $tip[0].offsetWidth actualHeight = $tip[0].offsetHeight - + // XXX this is a fix to a bug inside of firefox where the offsetWidth + // is not set on svg circle elements. + var left_fix; + if (pos.width) { + left_fix = pos.left + pos.width / 2 - actualWidth / 2; + } + else { + left_fix = pos.left - actualWidth / 2; + } switch (inside ? placement.split(' ')[1] : placement) { case 'bottom': - tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2} + tp = {top: pos.top + pos.height, left: left_fix}; break case 'top': - tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2} + tp = {top: pos.top - actualHeight, left: left_fix}; break case 'left': tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}