Commit 84798ebc authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Disable all on loading + fix some loadings

parent 130f3759
......@@ -15,6 +15,7 @@ d3.boxplot.y_len = null;
d3.boxplot.x_zones = null;
d3.boxplot.y_zones = null;
d3.boxplot.zoom_enabled = true;
d3.boxplot.all_disabled = false;
d3.boxplot.min_idy = 0;
d3.boxplot.max_idy = 0;
d3.boxplot.zone_selected = false;
......@@ -722,15 +723,17 @@ d3.boxplot.__draw_idy_lines = function (idy, lines, x_len, y_len) {
};
d3.boxplot.switch_color_theme = function () {
let current_theme = d3.boxplot.color_idy_theme;
let idx = d3.boxplot.color_idy_themes.indexOf(current_theme)
if (idx < d3.boxplot.color_idy_themes.length -1) {
idx ++;
}
else {
idx = 0;
if (!d3.boxplot.all_disabled) {
let current_theme = d3.boxplot.color_idy_theme;
let idx = d3.boxplot.color_idy_themes.indexOf(current_theme)
if (idx < d3.boxplot.color_idy_themes.length - 1) {
idx++;
}
else {
idx = 0;
}
d3.boxplot.change_color_theme(d3.boxplot.color_idy_themes[idx]);
}
d3.boxplot.change_color_theme(d3.boxplot.color_idy_themes[idx]);
};
d3.boxplot.change_color_theme = function (theme) {
......@@ -888,14 +891,16 @@ d3.boxplot.draw = function (x_contigs, x_order, y_contigs, y_order) {
d3.boxplot.draw_lines();
$("#restore-all").click(function () {
d3.boxplot.zoom.reset_scale();
$(this).hide();
if (d3.boxplot.zoom.reset_scale(false, null, false)) {
$(this).hide();
}
});
$(document).on("keyup", function(e) {
if (e.keyCode === 27) {
d3.boxplot.zoom.reset_scale();
$("#restore-all").hide();
if(d3.boxplot.zoom.reset_scale(false, null, false)) {
$("#restore-all").hide();
}
}
});
......
......@@ -73,7 +73,7 @@ d3.boxplot.zoom.init = function() {
// };
d3.boxplot.zoom.click = function () {
if (!d3.event.ctrlKey) {
if (!d3.event.ctrlKey && !d3.boxplot.all_disabled) {
let event = d3.event;
let rect = $("g.container")[0].getBoundingClientRect();
let posX = rect.left + window.scrollX,
......@@ -236,40 +236,44 @@ d3.boxplot.zoom.restore_scale = function(transform) {
}
};
d3.boxplot.zoom.reset_scale = function (temp=false, after=null) {
dgenies.show_loading();
window.setTimeout(() => {
//Reset scale:
d3.boxplot.container.attr("transform", "scale(1,1)translate(0,0)");
d3.boxplot.zoom_scale_lines = 1;
d3.boxplot.zoom.reset_scale = function (temp=false, after=null, force=true) {
if (!d3.boxplot.all_disabled || force) {
dgenies.show_loading();
window.setTimeout(() => {
//Reset scale:
d3.boxplot.container.attr("transform", "scale(1,1)translate(0,0)");
d3.boxplot.zoom_scale_lines = 1;
//Restore lines stroke width:
d3.selectAll("path.content-lines").attr("stroke-width", d3.boxplot.content_lines_width);
if (d3.boxplot.break_lines_show) {
d3.selectAll("line.break-lines").style("visibility", "visible");
d3.selectAll("line.break-lines").attr("stroke-width", d3.boxplot.break_lines_width);
}
//Restore lines stroke width:
d3.selectAll("path.content-lines").attr("stroke-width", d3.boxplot.content_lines_width);
if (d3.boxplot.break_lines_show) {
d3.selectAll("line.break-lines").style("visibility", "visible");
d3.selectAll("line.break-lines").attr("stroke-width", d3.boxplot.break_lines_width);
}
//Update left and bottom axis:
d3.boxplot.draw_left_axis(d3.boxplot.y_len);
d3.boxplot.draw_bottom_axis(d3.boxplot.x_len);
//Update left and bottom axis:
d3.boxplot.draw_left_axis(d3.boxplot.y_len);
d3.boxplot.draw_bottom_axis(d3.boxplot.x_len);
//Update top and right axis:
d3.boxplot.draw_top_axis();
d3.boxplot.draw_right_axis();
//Update top and right axis:
d3.boxplot.draw_top_axis();
d3.boxplot.draw_right_axis();
if (!temp)
d3.boxplot.zone_selected = false;
if (!temp)
d3.boxplot.zone_selected = false;
dgenies.hide_loading();
dgenies.hide_loading();
//Re-enable zoom:
d3.boxplot.zoom_enabled = true;
//Re-enable zoom:
d3.boxplot.zoom_enabled = true;
if (after !== null) {
after();
}
}, 0);
if (after !== null) {
after();
}
}, 0);
return true
}
return false
//
// //Restore axis:
// d3.boxplot.draw_left_axis(d3.boxplot.y_len);
......
......@@ -22,6 +22,8 @@ dgenies.notify = function (text, type="warning", delay=5000) {
};
dgenies.show_loading = function (message="Loading...", width=118) {
$("input,select").prop("disabled", true);
d3.boxplot.all_disabled = true;
$(dgenies.loading).find(".mylabel").html(message);
$(dgenies.loading).find(".label").width(width);
$(dgenies.loading).show();
......@@ -34,6 +36,8 @@ dgenies.show_loading = function (message="Loading...", width=118) {
};
dgenies.hide_loading = function () {
$("input,select").prop("disabled", false);
d3.boxplot.all_disabled = false;
$(dgenies.loading).hide();
dgenies.reset_loading_message();
};
......
......@@ -14,30 +14,33 @@ dgenies.result.export.save_file = function(blob, format) {
};
dgenies.result.export.export_png = function() {
dgenies.show_loading("Building files...", 180);
let export_div = $("div#export-pict");
export_div.html("").append($("<canvas>"));
canvg(export_div.find("canvas")[0], dgenies.result.export.get_svg());
let canvas = export_div.find("canvas")[0];
canvas.toBlob(function(blob) {
dgenies.result.export.save_file(blob, "png");
export_div.html("");
}, "image/png");
dgenies.show_loading("Building picture...", 210);
window.setTimeout(() => {
let export_div = $("div#export-pict");
export_div.html("").append($("<canvas>"));
canvg(export_div.find("canvas")[0], dgenies.result.export.get_svg());
let canvas = export_div.find("canvas")[0];
canvas.toBlob(function (blob) {
dgenies.result.export.save_file(blob, "png");
export_div.html("");
}, "image/png");
}, 0);
};
dgenies.result.export.export_svg = function () {
dgenies.show_loading("Building files...", 180);
let transform = d3.boxplot.container.attr("transform");
let after = function() {
let blob = new Blob([dgenies.result.export.get_svg()], {type: "image/svg+xml"});
d3.boxplot.zoom.restore_scale(transform);
dgenies.result.export.save_file(blob, "svg");
};
d3.boxplot.zoom.reset_scale(true, after);
dgenies.show_loading("Building picture...", 180);
window.setTimeout(() => {
let transform = d3.boxplot.container.attr("transform");
let after = function () {
let blob = new Blob([dgenies.result.export.get_svg()], {type: "image/svg+xml"});
d3.boxplot.zoom.restore_scale(transform);
dgenies.result.export.save_file(blob, "svg");
};
d3.boxplot.zoom.reset_scale(true, after);
}, 0);
};
dgenies.result.export.export_paf = function () {
dgenies.show_loading("Building files...", 180);
let export_div = $("div#export-pict");
export_div.html("");
export_div.append($("<a>").attr("href", `/paf/${dgenies.result.id_res}`)
......@@ -181,10 +184,14 @@ dgenies.result.export.export = function () {
window.setTimeout(() => {
if (selection > 0) {
let async = false;
if (selection === 1)
if (selection === 1) {
dgenies.result.export.export_svg();
else if (selection === 2)
async = true;
}
else if (selection === 2) {
dgenies.result.export.export_png();
async = true;
}
else if (selection === 3)
dgenies.result.export.export_paf();
else if (selection === 4) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment