mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-13 18:16:19 +02:00
ask for save location when exporting creations. fixes #200
This commit is contained in:
@ -1334,6 +1334,7 @@ globalConsoleContainerEl
|
||||
};
|
||||
|
||||
scope.exportItems = function exportItems(e) {
|
||||
handleDownloadsPermission().then(() => {
|
||||
fetchItems().then(function(items) {
|
||||
var d = new Date();
|
||||
var fileName = [
|
||||
@ -1349,6 +1350,16 @@ globalConsoleContainerEl
|
||||
var blob = new Blob([JSON.stringify(items, false, 2)], {
|
||||
type: 'application/json;charset=UTF-8'
|
||||
});
|
||||
|
||||
chrome.downloads.download(
|
||||
{
|
||||
url: window.URL.createObjectURL(blob),
|
||||
filename: fileName,
|
||||
saveAs: true
|
||||
},
|
||||
function() {
|
||||
// If there was an error, just download the file using ANCHOR method.
|
||||
if (chrome.runtime.lastError) {
|
||||
var a = document.createElement('a');
|
||||
a.href = window.URL.createObjectURL(blob);
|
||||
a.download = fileName;
|
||||
@ -1356,8 +1367,13 @@ globalConsoleContainerEl
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
trackEvent('ui', 'exportBtnClicked');
|
||||
});
|
||||
});
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user