Add RED.popover.tooltip for common reuse

This commit is contained in:
Nick O'Leary 2018-06-25 22:31:36 +01:00
parent fe22cedc1d
commit 73a18891c5
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 20 additions and 12 deletions

View File

@ -53,7 +53,12 @@ RED.popover = (function() {
div.addClass("red-ui-popover-size-"+size);
}
if (typeof content === 'function') {
content.call(res).appendTo(div);
var result = content.call(res);
if (typeof result === 'string') {
div.text(result);
} else {
div.append(result);
}
} else {
div.html(content);
}
@ -63,8 +68,8 @@ RED.popover = (function() {
var targetPos = target.offset();
var targetWidth = target.width();
var targetHeight = target.height();
var targetWidth = target.outerWidth();
var targetHeight = target.outerHeight();
var divHeight = div.height();
var divWidth = div.width();
if (direction === 'right') {
@ -147,7 +152,17 @@ RED.popover = (function() {
}
return {
create: createPopover
create: createPopover,
tooltip: function(target,content) {
RED.popover.create({
target:target,
trigger: "hover",
size: "small",
direction: "bottom",
content: content,
delay: { show: 550, hide: 10 }
});
}
}
})();

View File

@ -349,14 +349,7 @@ RED.tabs = (function() {
pinnedLink.addClass("red-ui-tab-link-button-pinned");
pinnedTabsCount++;
}
RED.popover.create({
target:$(pinnedLink),
trigger: "hover",
size: "small",
direction: "bottom",
content: tab.name,
delay: { show: 550, hide: 10 }
});
RED.popover.tooltip($(pinnedLink), tab.name);
}
link.on("click",onTabClick);