Skip to content

Commit

Permalink
Cache object parent key in tooltip; ensure orphaned tooltips are remo…
Browse files Browse the repository at this point in the history
…ved.
  • Loading branch information
malloch committed May 27, 2024
1 parent 19ce78c commit f73da3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion js/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ class Tooltip {
$('body').append("<div id='tooltip'></div>");
this._div = $('#tooltip');
this.margin = 20;
this.is_visible = false;
}

showTable(header, data, x, y) {
showTable(parent_key, header, data, x, y) {
this.key = parent_key;
this._div.stop(true, false)
.empty()
.append(Tooltip._makeInfoTable(header, data))
Expand All @@ -16,13 +18,15 @@ class Tooltip {
'top': this._vPosition(y, 0),
'opacity': 1,
'z-index': 10});
this.is_visible = true;
}

hide(immediate) {
var dur = 200;
if (immediate) dur = 0;
this._div.animate({opacity: 0}, {duration: dur});
this._div.css({'z-index': -10});
this.is_visible = false;
}

showBrief(line, x, y) {
Expand Down
5 changes: 5 additions & 0 deletions js/ViewManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ class ViewManager
self._update_sessions();
break;
}
if (event == 'removed') {
// check here if tooltip is visible and has same key as the removed object
if (self.tooltip.is_visible && self.tooltip.key == obj.key)
self.tooltip.hide();
}
});
};

Expand Down
6 changes: 4 additions & 2 deletions js/views/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class View {
filtered = Object.keys(filtered)
.sort()
.reduce((r, k) => (r[k] = filtered[k], r), {});
self.tooltip.showTable(dev.name+" (click to "+action+")", filtered, e.x, e.y);
self.tooltip.showTable(dev.key, dev.name+" (click to "+action+")", filtered, e.x, e.y);
}

setDevHover(dev) {
Expand Down Expand Up @@ -253,6 +253,7 @@ class View {
link.view.hover(
function(e) {
self.tooltip.showTable(
link.key,
link.status+" link", {
source: link.src.key,
destination: link.dst.key
Expand Down Expand Up @@ -376,7 +377,7 @@ class View {
filtered = Object.keys(filtered)
.sort()
.reduce((r, k) => (r[k] = filtered[k], r), {});
self.tooltip.showTable(sig.device.name+":"+sig.name, filtered, x, y);
self.tooltip.showTable(sig.key, sig.device.name+":"+sig.name, filtered, x, y);
sig.view.animate({'stroke-width': 15}, 0, 'linear');
}
self.hoverDev = sig.device;
Expand Down Expand Up @@ -546,6 +547,7 @@ class View {
function(e) {
if (!self.draggingFrom) {
self.tooltip.showTable(
map.key,
"Map", {
source: map.srcs.map(s => s.key).join(', '),
destination: map.dst.key,
Expand Down

0 comments on commit f73da3d

Please sign in to comment.