Skip to content

Commit 74729c7

Browse files
author
Mark Robinson
committed
Graph highlighting when table row is hovered over
1 parent 27bf76a commit 74729c7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/main/resources/static/js/workflow.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,38 @@ require(['jquery'],
148148
getDownloadLink();
149149
}
150150
});
151+
152+
/**
153+
* Highlighting step in graph when table row is
154+
* hovered over or vice-versa
155+
*/
156+
require(['jquery'],
157+
function ($) {
158+
159+
/**
160+
* Gets the corresponding graph box for a table row
161+
* @param trElement The table row element
162+
* @return The graph box element(s)
163+
*/
164+
function getGraphBox(trElement) {
165+
// Title of the CWL element
166+
var elementTitle = $(trElement).find("td:first").html();
167+
168+
// Find corresponding graph box and return
169+
return $("title").filter(function() {
170+
return $(this).text() == elementTitle;
171+
}).siblings("path");
172+
}
173+
174+
// When a table row is selected
175+
$( "tr" ).hover(function() {
176+
// Highlight, keeping previous in an attribute
177+
var graphBox = getGraphBox(this);
178+
graphBox.attr("data-prevfill", graphBox.css("fill"));
179+
graphBox.css("fill", "rgba(0, 255, 0, 0.11)");
180+
}, function() {
181+
// Unhighlight
182+
var graphBox = getGraphBox(this);
183+
graphBox.css("fill", graphBox.attr("data-prevfill"));
184+
});
185+
});

0 commit comments

Comments
 (0)