Commit fd8f89af authored by escudie escudie's avatar escudie escudie
Browse files

Fix bug when multiple clicks are done on export.

Export is became a download instead of a display with chrome.
The export adds a name and an extension to file.
parent 5b5c03c3
......@@ -2033,6 +2033,7 @@
$t = div;
var div_export = '<div id="module-export" style="position: relative; left:475px; top: -'+(415+extraheight)+'px; width: 25px; height: 20px;">';
div_export += '<a id="data-export" href="" download="" style="display:none;"></a>';
div_export += '<canvas id="canvasExport" style="border:1px solid white" width="25" height="20"></canvas>';
div_export += '<div id="menu" style="position: relative;width:150px; height:30px; display:none; right:123px; top:-4px;">';
div_export += '<div style="box-shadow: 3px 3px 10px rgb(136, 136, 136); border: 1px solid rgb(160, 160, 160); background: none repeat scroll 0% 0% rgb(255, 255, 255);padding: 5px 0px;">';
......@@ -2060,14 +2061,7 @@
var select_form = $("#menu");
var ceColorOri = $("#canvasExport").css('background');
$("#canvasExport").click(function (event) {
$(this).css('background', 'linear-gradient(to bottom, #AECEFF, white) repeat scroll 0 0 transparent');
$(this).css('border', '1px solid #6688AA');
$('#canvasExport').unbind('mouseenter mouseleave');
select_form.show();
if (select_form.is(":visible")){
$(document).mouseup(function (event){
if (select_form.has(event.target).length === 0){
$("#format-png").click(function(event) {
$("#canvasExport").css('background', ceColorOri);
$("#canvasExport").css('border-color', "white");
$("#canvasExport").hover(function() {
......@@ -2079,27 +2073,27 @@
$(this).css('border-color', "white");
});
select_form.hide();
}
});
}
var colorOrig=$("div[id^=format-]").css('background');
$("div[id^=format-]").hover(function() {
$(this).css('background', 'rgba(69,114,165,0.75)');
$(this).css('color', 'white');
}, function() {
$(this).css('background', colorOrig);
$(this).css('color', '');
});
$("#format-png").click(function(event) {
select_form.hide();
html2canvas($("#frame"), {
onrendered: function(canvas) {
var img = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
window.location.href = img;
var img = canvas.toDataURL("image/png");
$('#data-export').attr("href", img);
$('#data-export').attr("download", "jVenn_chart.png");
$('#data-export')[0].click();
}
});
});
$("#format-csv").click(function(event) {
$("#canvasExport").css('background', ceColorOri);
$("#canvasExport").css('border-color', "white");
$("#canvasExport").hover(function() {
$(this).css('background', 'linear-gradient(to bottom, white, #AECEFF) repeat scroll 0 0 transparent');
$(this).css('border', '1px solid #6688AA');
$(this).css('border-radius', '3px');
}, function() {
$(this).css('background', ceColorOri);
$(this).css('border-color', "white");
});
select_form.hide();
var rawData = new Array(),
comma = false;
$("*[id^=resultC]").each(function(){
......@@ -2133,7 +2127,39 @@
csvContent += index <= infoArray.length ? dataString+ "\n" : dataString;
});
var encodedUri = encodeURI(csvContent);
window.open(encodedUri);
$('#data-export').attr("href", encodedUri);
$('#data-export').attr("download", "jVenn.csv");
$('#data-export')[0].click();
});
$("#canvasExport").click(function (event) {
$(this).css('background', 'linear-gradient(to bottom, #AECEFF, white) repeat scroll 0 0 transparent');
$(this).css('border', '1px solid #6688AA');
$('#canvasExport').unbind('mouseenter mouseleave');
select_form.show();
if (select_form.is(":visible")){
$(document).mouseup(function (event){
if (select_form.has(event.target).length === 0){
$("#canvasExport").css('background', ceColorOri);
$("#canvasExport").css('border-color', "white");
$("#canvasExport").hover(function() {
$(this).css('background', 'linear-gradient(to bottom, white, #AECEFF) repeat scroll 0 0 transparent');
$(this).css('border', '1px solid #6688AA');
$(this).css('border-radius', '3px');
}, function() {
$(this).css('background', ceColorOri);
$(this).css('border-color', "white");
});
select_form.hide();
}
});
}
var colorOrig=$("div[id^=format-]").css('background');
$("div[id^=format-]").hover(function() {
$(this).css('background', 'rgba(69,114,165,0.75)');
$(this).css('color', 'white');
}, function() {
$(this).css('background', colorOrig);
$(this).css('color', '');
});
});
$("#canvasExport").hover(function() {
......
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