diff --git a/modules/ui/commit_changes.js b/modules/ui/commit_changes.js index 7e7dac177..b2dac7111 100644 --- a/modules/ui/commit_changes.js +++ b/modules/ui/commit_changes.js @@ -97,30 +97,35 @@ export function uiCommitChanges(context) { var changeset = new osmChangeset({ id: 'CHANGEME' }), changes = history.changes(actionDiscardTags(history.difference())), data = JXON.stringify(changeset.osmChangeJXON(changes)), - uri = 'data:text/xml,' + encodeURIComponent(data); + uri = 'data:text/xml;charset=utf-8,' + encodeURIComponent(data); - var downloadLink = container.selectAll('.download-changes') - .data([0]); - - var enter = downloadLink.enter() + var linkEnter = container.selectAll('.download-changes') + .data([0]) + .enter() .append('a') - .attr('class', 'download-changes') - .attr('href', uri) // no IE11 ? - .attr('download', 'changes.osc') // no IE11 ? - // .attr('target', '_blank') // maybe IE11 ? - .call(svgIcon('#icon-load', 'inline')); + .attr('class', 'download-changes'); - enter - .append('span') - .text(t('commit.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')); - downloadLink - .merge(enter) - .on('click.download', function() { - if (!detected.ie) return; // yes IE11 ? - var win = window.open(uri, '_blank'); - win.focus(); - }); + } 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(); + }); + } function mouseover(d) { diff --git a/modules/ui/conflicts.js b/modules/ui/conflicts.js index 5b09fd6e4..726cc3e17 100644 --- a/modules/ui/conflicts.js +++ b/modules/ui/conflicts.js @@ -34,28 +34,46 @@ export function uiConflicts(context) { .append('div') .attr('class', 'body fillL'); + var conflictsHelp = body + .append('div') + .attr('class', 'conflicts-help') + .text(t('save.conflict.help')); + // Download changes link var detected = utilDetect(), changeset = new osmChangeset({ id: 'CHANGEME' }), data = JXON.stringify(changeset.osmChangeJXON(origChanges)), - uri = 'data:text/xml,' + encodeURIComponent(data); + uri = 'data:text/xml;charset=utf-8,' + encodeURIComponent(data); - body - .append('div') - .attr('class', 'conflicts-help') - .text(t('save.conflict.help')) + var linkEnter = conflictsHelp.selectAll('.download-changes') + .data([0]) + .enter() .append('a') - .attr('class', 'conflicts-download') - .attr('href', uri) // no IE11 ? - .attr('download', 'changes.osc') // no IE11 ? - // .attr('target', '_blank') // maybe IE11 ? - .text(t('save.conflict.download_changes')) - .on('click.download', function() { - if (!detected.ie) return; // yes IE11 ? - var win = window.open(uri, '_blank'); - win.focus(); - }); + .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')); + + } 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(); + }); + } + body .append('div') diff --git a/modules/util/detect.js b/modules/util/detect.js index ed8f3ad2e..92a9691a5 100644 --- a/modules/util/detect.js +++ b/modules/util/detect.js @@ -110,6 +110,8 @@ export function utilDetect(force) { detected.filedrop = (window.FileReader && 'ondrop' in window); + detected.download = !(detected.ie || detected.browser.toLowerCase() === 'edge'); + function nav(x) { return navigator.userAgent.indexOf(x) !== -1; }