Skip to content

Commit bb11a4e

Browse files
author
Mark Robinson
committed
Add selection and hover highlighting when clicking the graph nodes
1 parent 74729c7 commit bb11a4e

File tree

3 files changed

+74
-15
lines changed

3 files changed

+74
-15
lines changed

src/main/resources/static/css/main.css

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ body {
2121
padding-top: 61px;
2222
}
2323

24-
.table-hover tbody tr:hover td, .table-hover tbody tr:hover th {
25-
background-color: rgba(0, 255, 0, 0.11);
26-
}
27-
2824
.hide {
2925
display: none;
3026
}
@@ -72,6 +68,18 @@ body {
7268
stroke-width: 0;
7369
}
7470

71+
#graph svg text {
72+
cursor: default;
73+
-webkit-user-select: none;
74+
-moz-user-select: none;
75+
-ms-user-select: none;
76+
user-select: none;
77+
}
78+
79+
#graph svg text::selection {
80+
background: none;
81+
}
82+
7583
#loading {
7684
width: 150px;
7785
margin: 0 auto;
@@ -81,6 +89,22 @@ body {
8189
margin-bottom: 5px;
8290
}
8391

92+
tr.selected, .table-hover tbody tr.selected:hover td, .table-hover tbody tr.selected:hover th {
93+
background-color: #adffaf !important;
94+
}
95+
96+
tr.hover, .table-hover tbody tr:hover td, .table-hover tbody tr:hover th {
97+
background-color: #c9ffcb !important;
98+
}
99+
100+
path.selected, path.hover.selected {
101+
fill: #adffaf;
102+
}
103+
104+
path.hover {
105+
fill: #c9ffcb;
106+
}
107+
84108
#footer {
85109
text-align: center;
86110
font-style: italic;

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

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ require(['jquery', 'bootstrap.modal', 'renderer', 'svg-pan-zoom'],
6161
setTimeout(function() {
6262
svgPanZoom('svg', {
6363
zoomEnabled: true,
64-
controlIconsEnabled: true
64+
controlIconsEnabled: true,
65+
preventMouseEventsDefault: false
6566
});
6667
}, 1000);
6768
});
@@ -171,15 +172,49 @@ require(['jquery'],
171172
}).siblings("path");
172173
}
173174

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)");
175+
// When a table row is hovered over, highlight
176+
var tableBodyRow = $("tr").not('thead tr');
177+
tableBodyRow.hover(function() {
178+
getGraphBox(this).addClass("hover");
180179
}, function() {
181-
// Unhighlight
182-
var graphBox = getGraphBox(this);
183-
graphBox.css("fill", graphBox.attr("data-prevfill"));
180+
getGraphBox(this).removeClass("hover");
181+
});
182+
183+
// When a table row is selected
184+
tableBodyRow.click(function() {
185+
getGraphBox(this).toggleClass("selected");
186+
$(this).toggleClass("selected");
184187
});
188+
189+
/**
190+
* Gets the corresponding table row for a graph box
191+
* @param trElement The graph box element
192+
* @return The table row(s)
193+
*/
194+
function getTableRow(gbElement) {
195+
// Title of the CWL element
196+
var elementTitle = $(gbElement).find("title").html();
197+
198+
// Find corresponding table row and return
199+
return $("tr").filter(function() {
200+
return $(this).find("td:first").html() == elementTitle;
201+
});
202+
}
203+
204+
// When a graph box is hovered over or clicked, highlight
205+
$(document).on({
206+
click: function() {
207+
getTableRow(this).toggleClass("selected");
208+
$(this).find("path").toggleClass("selected");
209+
},
210+
mouseenter: function() {
211+
getTableRow(this).addClass("hover");
212+
$(this).find("path").addClass("hover");
213+
},
214+
mouseleave: function() {
215+
getTableRow(this).removeClass("hover");
216+
$(this).find("path").removeClass("hover");
217+
}
218+
}, ".node");
219+
185220
});

src/main/resources/templates/workflow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<meta charset="UTF-8" />
2424
<meta name="viewport" content="width=device-width, initial-scale=1" />
2525
<title>Common Workflow Language Viewer</title>
26-
<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}" href="../static/css/main.css" />
2726
<link rel="stylesheet" th:href="@{/bower_components/bootstrap/dist/css/bootstrap.min.css}" href="../static/bower_components/bootstrap/dist/css/bootstrap.min.css" />
27+
<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}" href="../static/css/main.css" />
2828
</head>
2929
<body>
3030

0 commit comments

Comments
 (0)