Skip to content

Commit e4e9981

Browse files
fix: fixes #209 and #93
1 parent 28d77b9 commit e4e9981

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

frontend/www/src/css/dashboard-stemmaweb.css

-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ edit-stemma-buttons a.greyed-out div {
173173
#graph-area {
174174
background-color: white;
175175
width: 100%;
176-
/* height: 40vw; */
177176
height: 90%;
178177
padding: 1em;
179178
}

frontend/www/src/js/modules/dashboard/tradition/section/sectionList.js

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class SectionList extends HTMLElement {
126126
(tradition) => { return tradition.id == traditionId }
127127
)
128128
);
129+
TraditionList.highlightFolderSelectedTradition( traditionId );
129130
SECTION_STORE.setSelectedSection( section );
130131
}
131132

frontend/www/src/js/modules/dashboard/tradition/stemma/stemmaButtons.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class StemmaButtons extends HTMLElement {
6060

6161
render() {
6262
this.innerHTML = `
63-
<div id="stemma_buttons" class="btn-toolbar mb-2 mb-md-0">
63+
<div id="stemma-buttons" class="btn-toolbar mb-2 mb-md-0">
6464
<div class="btn-group me-2">
6565
<button id="run-stemweb-button" type="button" class="btn btn-sm btn-outline-secondary">
6666
Run Stemweb

frontend/www/src/js/modules/dashboard/tradition/stemma/stemmaRenderer.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,33 @@ class StemmaRenderer {
6666
Download.set_downloads( stemma.dot );
6767
}
6868

69+
/**
70+
* Resizes the current graph/stemma when the browser window gets
71+
* resized. Also set the new corresponding with on the GraphViz
72+
* renderer so that subsequent stemmas are depicted at the right
73+
* size.
74+
*/
6975
resizeSVG() {
7076
const margin = 14;
77+
const stemmaButtonsRowHeight = document.querySelector( '#stemma-buttons' ).getBoundingClientRect()['height'];
7178
const bbrect = document.querySelector( '#graph-area' ).getBoundingClientRect();
72-
const width = bbrect['width'];
73-
const height = bbrect['height'];
79+
const width = bbrect['width'] - ( 2 * margin );
80+
const factor = bbrect['height'] / window.innerHeight;
81+
const height = bbrect['height'] - stemmaButtonsRowHeight;
7482
const graphArea = d3.select('#graph-area');
7583
const svg = graphArea.select("#graph").selectWithoutDataPropagation("svg");
7684
svg
7785
.transition()
7886
.duration(700)
79-
.attr("width", width - 2*margin)
80-
.attr("height", height - 2*margin);
81-
// var d = svg.datum();
82-
// d.attributes['width'] = width - margin;
83-
// d.attributes['height'] = height - margin;
87+
.attr("width", width )
88+
.attr("height", height );
89+
// This is a bit weird, but we need to reset the size of the original
90+
// graphviz renderer that was set when the line
91+
// `const stemmaRenderer = new StemmaRenderer();`
92+
// was executed, and not on `this`. There's probably
93+
// cleaner ways to do this.
94+
stemmaRenderer.graphvizRoot.width( width );
95+
stemmaRenderer.graphvizRoot.height( height );
8496
}
8597

8698
}

frontend/www/src/js/modules/dashboard/tradition/traditionList.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@ class TraditionList extends HTMLElement {
5555
*/
5656
selectTradition( evt, tradition ) {
5757
evt.preventDefault();
58-
document.querySelector( '#traditions-list div.folder-icon.selected' ).classList.toggle( 'selected' );
59-
document.querySelector( `#traditions-list div.folder-icon[trad-id="${tradition.id}"]` ).classList.toggle( 'selected' );
58+
TraditionList.highlightFolderSelectedTradition( tradition.id );
6059
TRADITION_STORE.setSelectedTradition( tradition );
6160
SECTION_STORE.setSelectedSection( null );
6261
}
63-
62+
63+
static highlightFolderSelectedTradition( tradition_id ){
64+
document.querySelector( '#traditions-list div.folder-icon.selected' ).classList.toggle( 'selected' );
65+
document.querySelector( `#traditions-list div.folder-icon[trad-id="${tradition_id}"]` ).classList.toggle( 'selected' );
66+
}
67+
6468
/**
6569
* Toggles the visibility of the sections list for each
6670
* tradition in the list or traditions.

0 commit comments

Comments
 (0)