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
|
||||
$("#saveAsImageBtn").click(function () {
|
||||
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');
|
||||
a.href = imgData;
|
||||
a.download = 'whiteboard.png';
|
||||
document.body.appendChild(a);
|
||||
w.document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
w.document.body.removeChild(a);
|
||||
setTimeout(function () { w.close(); }, 100);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// save image to json containing steps
|
||||
$("#saveAsJSONBtn").click(function () {
|
||||
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.download = 'whiteboard.json';
|
||||
// Append anchor to body.
|
||||
document.body.appendChild(a);
|
||||
w.document.body.appendChild(a);
|
||||
a.click();
|
||||
// Remove anchor from body
|
||||
document.body.removeChild(a);
|
||||
w.document.body.removeChild(a);
|
||||
setTimeout(function () { w.close(); }, 100);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// upload json containing steps
|
||||
|
|
Loading…
Reference in New Issue