Skip to content

Commit bc02361

Browse files
Fixed id-col not resizing properly
1 parent e312c2e commit bc02361

2 files changed

Lines changed: 63 additions & 35 deletions

File tree

js/widgets/settings_table.js

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ $(function() {
246246
upload_col = primary_row.append("td")
247247
.classed("upload-col", true),
248248
id_col = primary_row.append("td")
249-
.style("width", "30%")
250249
.style("white-space", "normal")
251250
.classed("id-col", true),
252251
more_options_col = primary_row.append("td")
@@ -297,8 +296,20 @@ $(function() {
297296
.on("change", function() {$(row.node()).settings_row("change_secondary_color", this.value)});
298297
};
299298

300-
//Creates elements for scale column right-to-left
301-
scale_col.append("input")
299+
//Creates scale input
300+
scale_div = scale_col.append("div")
301+
.classed("slider-div", true)
302+
scale_div.append("label")
303+
.text("Scale:");
304+
scale_div.append("input")
305+
.attr("type", "text")
306+
.classed("setting-text", true)
307+
.attr("value", 1)
308+
.on("change", function() {$(row.node()).settings_row("change_scale", this.value)})
309+
.on("mousedown", function() {$(row.node()).settings_row("toggle_draggable", false)})
310+
.on("mouseup", function() {$(row.node()).settings_row("toggle_draggable", true)})
311+
.on("mouseleave", function() {$(row.node()).settings_row("toggle_draggable", true)});
312+
scale_div.append("input")
302313
.attr("type", "range")
303314
.classed("scale-slider", true)
304315
.attr("value", 50)
@@ -308,18 +319,6 @@ $(function() {
308319
.on("mouseup", function() {$(row.node()).settings_row("toggle_draggable", true)})
309320
.on("mousedown", function() {$(row.node()).settings_row("toggle_draggable", false)})
310321

311-
scale_col.append("input")
312-
.attr("type", "text")
313-
.classed("setting-text", true)
314-
.attr("value", 1)
315-
.on("change", function() {$(row.node()).settings_row("change_scale", this.value)})
316-
.on("mousedown", function() {$(row.node()).settings_row("toggle_draggable", false)})
317-
.on("mouseup", function() {$(row.node()).settings_row("toggle_draggable", true)})
318-
.on("mouseleave", function() {$(row.node()).settings_row("toggle_draggable", true)});
319-
320-
scale_col.append("label")
321-
.text("Scale:");
322-
323322
// Add opacity input
324323
opacity_col.append("label")
325324
.text("Opacity:");
@@ -468,17 +467,13 @@ $(function() {
468467
reset_col = secondary_row.append("td")
469468
.classed("reset-col", true);
470469

471-
//Creates elements for baseline col, right-to-left
472-
baseline_col.append("input")
473-
.attr("type", "range")
474-
.classed("shift-slider", true)
475-
.attr("value", 50)
476-
.attr("min", 1)
477-
.attr("max", 100)
478-
.on("input", function() {$(row.node()).settings_row("change_baseline", (this.value - 50) * (1 / $("#main-plot").main_plot("export").ymax))})
479-
.on("mouseup", function() {$(row.node()).settings_row("toggle_draggable", true)})
480-
.on("mousedown", function() {$(row.node()).settings_row("toggle_draggable", false)})
481-
baseline_col.append("input")
470+
//Creates input for shifting baseline
471+
baseline_div = baseline_col.append("div")
472+
.classed("slider-div", true)
473+
baseline_div.append("label")
474+
.text("Shift occupancy:")
475+
.style("float", "right");
476+
baseline_div.append("input")
482477
.attr("type", "text")
483478
.classed("setting-text", true)
484479
.attr("value", 0)
@@ -488,9 +483,15 @@ $(function() {
488483
.on("mousedown", function() {$(row.node()).settings_row("toggle_draggable", false)})
489484
.on("mouseup", function() {$(row.node()).settings_row("toggle_draggable", true)})
490485
.on("mouseleave", function() {$(row.node()).settings_row("toggle_draggable", true)});
491-
baseline_col.append("label")
492-
.text("Shift occupancy:")
493-
.style("float", "right");
486+
baseline_div.append("input")
487+
.attr("type", "range")
488+
.classed("shift-slider", true)
489+
.attr("value", 50)
490+
.attr("min", 1)
491+
.attr("max", 100)
492+
.on("input", function() {$(row.node()).settings_row("change_baseline", (this.value - 50) * (1 / $("#main-plot").main_plot("export").ymax))})
493+
.on("mouseup", function() {$(row.node()).settings_row("toggle_draggable", true)})
494+
.on("mousedown", function() {$(row.node()).settings_row("toggle_draggable", false)})
494495

495496
//Creates hide-strand input
496497
forward = hide_strand_col.append("div")
@@ -502,6 +503,7 @@ $(function() {
502503
.text("Show forward:")
503504
forward.append("input")
504505
.attr("type", "checkbox")
506+
.property("checked", true)
505507
.classed("direction_checkbox", true)
506508
.classed("forward_checkbox", true)
507509
.style("transform", "scale(1.2)")
@@ -515,6 +517,7 @@ $(function() {
515517
.style("display", "inline")
516518
reverse.append("input")
517519
.attr("type", "checkbox")
520+
.property("checked", true)
518521
.classed("direction_checkbox", true)
519522
.classed("reverse_checkbox", true)
520523
.style("transform", "scale(1.2)")
@@ -875,8 +878,24 @@ $(function() {
875878
},
876879

877880
update_ids: function(new_ids) {
878-
this.options.ids = new_ids;
879-
d3.select(this.element.context).select(".id-col .id-list").text(new_ids.join(", "))
881+
if (new_ids != null){
882+
this.options.ids = new_ids;
883+
d3.select(this.element.context).select(".id-col .id-list").text(new_ids.join(", "))
884+
}
885+
886+
//Manually adjust width of id-list divs
887+
let largestWidth = 0;
888+
d3.selectAll('td.id-col').each(function() {
889+
let box = d3.select(this);
890+
box.style("min-width", "0px")
891+
let width = box.node().getBoundingClientRect().width;
892+
largestWidth = Math.max(largestWidth, width);
893+
});
894+
console.log(largestWidth);
895+
896+
//Largest width usually falls short by a few pixels
897+
d3.selectAll('td.id-col')
898+
.style("min-width", (largestWidth + 10) + "px");
880899
},
881900

882901
toggle_color_separated_strands: function(separate) {
@@ -1026,3 +1045,7 @@ $(function() {
10261045

10271046
$("#settings-table").settings_table()
10281047
})
1048+
1049+
$(window).resize(function() {
1050+
$("#settings-table").settings_table("update_ids", 0, null);
1051+
});

style.css

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,20 @@ td.remove-row {
131131
min-height: 60px;
132132
}
133133

134-
#settings-table .slider-col > *{
135-
float: right;
136-
margin: 5px;
134+
#settings-table .slider-div {
135+
display: flex;
136+
justify-content: flex-end;
137+
flex-wrap: wrap;
138+
}
139+
140+
#settings-table .slider-div > * {
141+
margin-top: 5px;
142+
margin-left: 5px;
137143
}
138144

139145
#settings-table .settings-row {
140146
width: 100%;
141147
border: 1px solid;
142-
white-space: nowrap;
143148
}
144149

145150
.mouse-highlight {

0 commit comments

Comments
 (0)