fix file downloads out of iframes like nextcloud
This commit is contained in:
parent
fac73b84ac
commit
b839fd66fa
@ -123,25 +123,33 @@ $(document).ready(function () {
|
|||||||
// save image to png
|
// save image to png
|
||||||
$("#saveAsImageBtn").click(function () {
|
$("#saveAsImageBtn").click(function () {
|
||||||
var imgData = whiteboard.getImageDataBase64();
|
var imgData = whiteboard.getImageDataBase64();
|
||||||
|
|
||||||
|
var w = window.open('about:blank'); //Firefox will not allow downloads without extra window
|
||||||
|
setTimeout(function () { //FireFox seems to require a setTimeout for this to work.
|
||||||
var a = document.createElement('a');
|
var a = document.createElement('a');
|
||||||
a.href = imgData;
|
a.href = imgData;
|
||||||
a.download = 'whiteboard.png';
|
a.download = 'whiteboard.png';
|
||||||
document.body.appendChild(a);
|
w.document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
w.document.body.removeChild(a);
|
||||||
|
setTimeout(function () { w.close(); }, 100);
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// save image to json containing steps
|
// save image to json containing steps
|
||||||
$("#saveAsJSONBtn").click(function () {
|
$("#saveAsJSONBtn").click(function () {
|
||||||
var imgData = whiteboard.getImageDataJson();
|
var imgData = whiteboard.getImageDataJson();
|
||||||
var a = window.document.createElement('a');
|
|
||||||
|
var w = window.open('about:blank'); //Firefox will not allow downloads without extra window
|
||||||
|
setTimeout(function () { //FireFox seems to require a setTimeout for this to work.
|
||||||
|
var a = document.createElement('a');
|
||||||
a.href = window.URL.createObjectURL(new Blob([imgData], { type: 'text/json' }));
|
a.href = window.URL.createObjectURL(new Blob([imgData], { type: 'text/json' }));
|
||||||
a.download = 'whiteboard.json';
|
a.download = 'whiteboard.json';
|
||||||
// Append anchor to body.
|
w.document.body.appendChild(a);
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
a.click();
|
||||||
// Remove anchor from body
|
w.document.body.removeChild(a);
|
||||||
document.body.removeChild(a);
|
setTimeout(function () { w.close(); }, 100);
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// upload json containing steps
|
// upload json containing steps
|
||||||
|
Loading…
x
Reference in New Issue
Block a user