Added tooltip option to all nodes

This commit is contained in:
Gerwin van Beek 2022-06-16 10:02:16 +02:00
parent 8762d0e164
commit bb5a19b3fd

View File

@ -3104,6 +3104,7 @@ RED.view = (function() {
var portLabelHoverTimeout = null; var portLabelHoverTimeout = null;
var portLabelHover = null; var portLabelHover = null;
var popover = null;
function getElementPosition(node) { function getElementPosition(node) {
@ -3661,19 +3662,25 @@ RED.view = (function() {
this.parentNode.classList.add("red-ui-flow-node-hovered"); this.parentNode.classList.add("red-ui-flow-node-hovered");
} }
clearTimeout(portLabelHoverTimeout); clearTimeout(portLabelHoverTimeout);
if (d.hasOwnProperty('l')?!d.l : (d.type === "link in" || d.type === "link out")) {
var displayLabel = d.hasOwnProperty('l')?!d.l : (d.type === "link in" || d.type === "link out");
if (displayLabel || d._def.tooltip) {
var parentNode = this.parentNode; var parentNode = this.parentNode;
portLabelHoverTimeout = setTimeout(function() { portLabelHoverTimeout = setTimeout(function() {
var tooltip; var tooltip;
if (d._def.label) {
tooltip = d._def.label;
try { try {
if (d._def.tooltip) {
tooltip = d._def.tooltip;
tooltip = (typeof tooltip === "function" ? tooltip.call(d) : tooltip)||""; tooltip = (typeof tooltip === "function" ? tooltip.call(d) : tooltip)||"";
}
if (displayLabel && d._def.label && !tooltip){
tooltip = d._def.label;
tooltip = (typeof tooltip === "function" ? tooltip.call(d) : tooltip)||"";
}
} catch(err) { } catch(err) {
console.log("Definition error: "+d.type+".label",err); console.log("Definition error: "+d.type+".label",err);
tooltip = d.type; tooltip = d.type;
} }
}
if (tooltip !== "") { if (tooltip !== "") {
var pos = getElementPosition(parentNode); var pos = getElementPosition(parentNode);
portLabelHoverTimeout = null; portLabelHoverTimeout = null;