Allow RED.notify.popover to have a position offset

This commit is contained in:
Nick O'Leary 2020-04-27 11:05:32 +01:00
parent 0150769c17
commit 28418288e3
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 4 additions and 3 deletions

View File

@ -278,6 +278,7 @@ RED.popover = (function() {
var closeCallback = options.onclose;
var target = options.target;
var align = options.align || "left";
var offset = options.offset || [0,0];
var pos = target.offset();
var targetWidth = target.width();
@ -285,7 +286,7 @@ RED.popover = (function() {
var panelHeight = panel.height();
var panelWidth = panel.width();
var top = (targetHeight+pos.top);
var top = (targetHeight+pos.top) + offset[1];
if (top+panelHeight > $(window).height()) {
top -= (top+panelHeight)-$(window).height() + 5;
}
@ -296,12 +297,12 @@ RED.popover = (function() {
if (align === "left") {
panel.css({
top: top+"px",
left: (pos.left)+"px",
left: (pos.left+offset[0])+"px",
});
} else if(align === "right") {
panel.css({
top: top+"px",
left: (pos.left-panelWidth)+"px",
left: (pos.left-panelWidth+offset[0])+"px",
});
}
panel.slideDown(100);