in js/tooltip.js [80:202]
function buildTooltip(data) {
removeTooltip();
var html = '';
html += '<div class="';
html += [RawClasses.base, RawClasses[data.direction] ].join(" ");
html += '">';
html += '<div class="' + RawClasses.content + '">';
html += data.formatter.call(data.$el, data);
html += '<span class="' + RawClasses.caret + '"></span>';
html += '</div>';
html += '</div>';
Instance = {
$tooltip : $(html),
$el : data.$el
};
Formstone.$body.append(Instance.$tooltip);
var $content = Instance.$tooltip.find(Classes.content),
$caret = Instance.$tooltip.find(Classes.caret),
offset = data.$el.offset(),
height = data.$el.outerHeight(),
width = data.$el.outerWidth(),
tooltipLeft = 0,
tooltipTop = 0,
contentLeft = 0,
contentTop = 0,
caretLeft = false,
caretTop = false,
caretHeight = $caret.outerHeight(true),
caretWidth = $caret.outerWidth(true),
contentHeight = $content.outerHeight(true),
contentWidth = $content.outerWidth(true);
// position content
if (data.direction === "right" || data.direction === "left") {
caretTop = (contentHeight - caretHeight) / 2;
contentTop = -contentHeight / 2;
if (data.direction === "right") {
contentLeft = data.margin;
} else if (data.direction === "left") {
contentLeft = -(contentWidth + data.margin);
}
} else {
caretLeft = (contentWidth - caretWidth) / 2;
contentLeft = -contentWidth / 2;
if (data.direction === "bottom") {
contentTop = data.margin;
} else if (data.direction === "top") {
contentTop = -(contentHeight + data.margin);
}
}
// Modify Dom
$content.css({
top: contentTop,
left: contentLeft
});
$caret.css({
top: caretTop,
left: caretLeft
});
// Position tooltip
if (data.follow) {
data.$el.on(Events.mouseMove, data, onMouseMove);
} else {
if (data.match) {
if (data.direction === "right" || data.direction === "left") {
tooltipTop = data.top; // mouse pos
if (data.direction === "right") {
tooltipLeft = offset.left + width;
} else if (data.direction === "left") {
tooltipLeft = offset.left;
}
} else {
tooltipLeft = data.left; // mouse pos
if (data.direction === "bottom") {
tooltipTop = offset.top + height;
} else if (data.direction === "top") {
tooltipTop = offset.top;
}
}
} else {
if (data.direction === "right" || data.direction === "left") {
tooltipTop = offset.top + (height / 2);
if (data.direction === "right") {
tooltipLeft = offset.left + width;
} else if (data.direction === "left") {
tooltipLeft = offset.left;
}
} else {
tooltipLeft = offset.left + (width / 2);
if (data.direction === "bottom") {
tooltipTop = offset.top + height;
} else if (data.direction === "top") {
tooltipTop = offset.top;
}
}
}
positionTooltip(tooltipLeft, tooltipTop);
}
data.timer = Functions.startTimer(data.timer, data.delay, function() {
Instance.$tooltip.addClass(RawClasses.visible);
});
data.$el.one(Events.mouseLeave, data, onMouseLeave);
}