diff --git a/js/id/ui/loading.js b/js/id/ui/loading.js index 6a98a917a..23d5b7c2d 100644 --- a/js/id/ui/loading.js +++ b/js/id/ui/loading.js @@ -1,5 +1,5 @@ -iD.ui.loading = function(message) { - var modal = iD.ui.modal(); +iD.ui.loading = function(message, blocking) { + var modal = iD.ui.modal(blocking); var loadertext = modal.select('.content') .classed('loading-modal', true) diff --git a/js/id/ui/modal.js b/js/id/ui/modal.js index fed97a0a1..498f1e241 100644 --- a/js/id/ui/modal.js +++ b/js/id/ui/modal.js @@ -1,4 +1,4 @@ -iD.ui.modal = function() { +iD.ui.modal = function(blocking) { var animate = d3.select('div.modal').empty(); d3.select('div.modal').transition() @@ -9,7 +9,7 @@ iD.ui.modal = function() { .attr('class', 'shaded') .style('opacity', 0) .on('click.remove-modal', function() { - if (d3.event.target == this) d3.select(this).remove(); + if (d3.event.target == this && !blocking) d3.select(this).remove(); }); var modal = shaded.append('div') @@ -18,7 +18,7 @@ iD.ui.modal = function() { modal.append('button') .attr('class', 'icon remove close-modal') .on('click', function() { - shaded.remove(); + if (!blocking) shaded.remove(); }); modal.append('div') diff --git a/js/id/ui/save.js b/js/id/ui/save.js index afaab5023..c0036d334 100644 --- a/js/id/ui/save.js +++ b/js/id/ui/save.js @@ -14,60 +14,61 @@ iD.ui.save = function() { .placement('bottom')) .on('click', function() { - function commit(e) { - d3.select('.shaded').remove(); - var l = iD.ui.loading('Uploading changes to OpenStreetMap.'); - connection.putChangeset(history.changes(), e.comment, history.imagery_used(), function(err, changeset_id) { - l.remove(); - history.reset(); - map.flush().redraw(); - if (err) { - var desc = iD.ui.confirm() - .select('.description'); - desc.append('h2') - .text('An error occurred while trying to save'); - desc.append('p').text(err.responseText); - } else { - var modal = iD.ui.modal(); - modal.select('.content') - .classed('success-modal', true) - .datum({ - id: changeset_id, - comment: e.comment - }) - .call(iD.ui.success() - .on('cancel', function() { - modal.remove(); - })); - } - }); - } - - if (history.hasChanges()) { - connection.authenticate(function(err) { + function commit(e) { + d3.select('.shaded').remove(); + var l = iD.ui.loading('Uploading changes to OpenStreetMap.', true); + connection.putChangeset(history.changes(), e.comment, history.imagery_used(), function(err, changeset_id) { + l.remove(); + history.reset(); + map.flush().redraw(); + if (err) { + var desc = iD.ui.confirm() + .select('.description'); + desc.append('h2') + .text('An error occurred while trying to save'); + desc.append('p').text(err.responseText); + } else { var modal = iD.ui.modal(); - var changes = history.changes(); - changes.connection = connection; modal.select('.content') - .classed('commit-modal', true) - .datum(changes) - .call(iD.ui.commit() + .classed('success-modal', true) + .datum({ + id: changeset_id, + comment: e.comment + }) + .call(iD.ui.success() .on('cancel', function() { modal.remove(); - }) - .on('fix', function(d) { - map.extent(d.entity.extent(map.history().graph())); - if (map.zoom() > 19) map.zoom(19); - controller.enter(iD.modes.Select(d.entity)); - modal.remove(); - }) - .on('save', commit)); - }); - } else { - iD.ui.confirm().select('.description') - .append('h3').text('You don\'t have any changes to save.'); - } - }); + })); + } + }); + } + + if (history.hasChanges()) { + connection.authenticate(function(err) { + var modal = iD.ui.modal(); + var changes = history.changes(); + changes.connection = connection; + modal.select('.content') + .classed('commit-modal', true) + .datum(changes) + .call(iD.ui.commit() + .on('cancel', function() { + modal.remove(); + }) + .on('fix', function(d) { + map.extent(d.entity.extent(map.history().graph())); + if (map.zoom() > 19) map.zoom(19); + controller.enter(iD.modes.Select(d.entity)); + modal.remove(); + }) + .on('save', commit)); + }); + } else { + iD.ui.confirm().select('.description') + .append('h3').text('You don\'t have any changes to save.'); + } + + }); selection.append('span') .attr('class', 'count'); diff --git a/test/spec/renderer/map.js b/test/spec/renderer/map.js index 894451299..5070bdffa 100644 --- a/test/spec/renderer/map.js +++ b/test/spec/renderer/map.js @@ -66,7 +66,7 @@ describe('iD.Map', function() { expect(map.center()[0]).to.be.closeTo(20, 0.5); expect(map.center()[1]).to.be.closeTo(20, 0.5); done(); - }, 500); + }, 1000); }); });