diff --git a/modules/ui/commit_changes.js b/modules/ui/commit_changes.js index 7d1295ef0..c33c1bddb 100644 --- a/modules/ui/commit_changes.js +++ b/modules/ui/commit_changes.js @@ -100,7 +100,8 @@ export function uiCommitChanges(context) { delete changeset.id; // Export without chnageset_id var data = JXON.stringify(changeset.osmChangeJXON(changes)), - uri = 'data:text/xml;charset=utf-8,' + encodeURIComponent(data); + blob = new Blob([data], {type: 'text/xml;charset=utf-8;'}), + fileName = 'changes.osc'; var linkEnter = container.selectAll('.download-changes') .data([0]) @@ -108,28 +109,24 @@ export function uiCommitChanges(context) { .append('a') .attr('class', 'download-changes'); - if (detected.download) { // all except IE11 and Edge - linkEnter // download the data uri as a file - .attr('href', uri) - .attr('download', 'changes.osc') - .call(svgIcon('#icon-load', 'inline')) - .append('span') - .text(t('commit.download_changes')); + if (detected.download) { // All except IE11 and Edge + linkEnter // download the data as a file + .attr('href', window.URL.createObjectURL(blob)) + .attr('download', fileName); } else { // IE11 and Edge linkEnter // open data uri in a new tab .attr('target', '_blank') - .call(svgIcon('#icon-load', 'inline')) - .append('span') - .text(t('commit.download_changes')); - - linkEnter .on('click.download', function() { - var win = window.open(uri, '_blank'); - win.focus(); + navigator.msSaveBlob(blob, fileName); }); } + linkEnter + .call(svgIcon('#icon-load', 'inline')) + .append('span') + .text(t('commit.download_changes')); + function mouseover(d) { if (d.entity) { diff --git a/modules/ui/conflicts.js b/modules/ui/conflicts.js index 1155953f7..ca89b9980 100644 --- a/modules/ui/conflicts.js +++ b/modules/ui/conflicts.js @@ -47,7 +47,8 @@ export function uiConflicts(context) { delete changeset.id; // Export without chnageset_id var data = JXON.stringify(changeset.osmChangeJXON(origChanges)), - uri = 'data:text/xml;charset=utf-8,' + encodeURIComponent(data); + blob = new Blob([data], {type: 'text/xml;charset=utf-8;'}), + fileName = 'changes.osc'; var linkEnter = conflictsHelp.selectAll('.download-changes') .data([0]) @@ -55,28 +56,24 @@ export function uiConflicts(context) { .append('a') .attr('class', 'download-changes'); - if (detected.download) { // all except IE11 and Edge - linkEnter // download the data uri as a file - .attr('href', uri) - .attr('download', 'changes.osc') - .call(svgIcon('#icon-load', 'inline')) - .append('span') - .text(t('save.conflict.download_changes')); + if (detected.download) { // All except IE11 and Edge + linkEnter // download the data as a file + .attr('href', window.URL.createObjectURL(blob)) + .attr('download', fileName); } else { // IE11 and Edge linkEnter // open data uri in a new tab .attr('target', '_blank') - .call(svgIcon('#icon-load', 'inline')) - .append('span') - .text(t('save.conflict.download_changes')); - - linkEnter .on('click.download', function() { - var win = window.open(uri, '_blank'); - win.focus(); + navigator.msSaveBlob(blob, fileName); }); } + linkEnter + .call(svgIcon('#icon-load', 'inline')) + .append('span') + .text(t('save.conflict.download_changes')); + body .append('div')