diff --git a/index.html b/index.html index 676463cfc..ae1d3570b 100644 --- a/index.html +++ b/index.html @@ -39,6 +39,7 @@ + diff --git a/js/id/id.js b/js/id/id.js index 914567cf2..005e508f4 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -121,6 +121,17 @@ window.iD = function(container) { l.remove(); history.reset(); map.flush().redraw(); + var modal = iD.modal(); + modal.select('.content') + .classed('success-modal', true) + .datum({ + id: changeset_id, + comment: e.comment + }) + .call(iD.success() + .on('cancel', function() { + modal.remove(); + })); }); } var changes = history.changes(); diff --git a/js/id/ui/success.js b/js/id/ui/success.js new file mode 100644 index 000000000..f81be1028 --- /dev/null +++ b/js/id/ui/success.js @@ -0,0 +1,43 @@ +iD.success = function() { + var event = d3.dispatch('cancel', 'save'); + + function success(selection) { + var changeset = selection.datum(), + header = selection.append('div').attr('class', 'header modal-section'), + body = selection.append('div').attr('class', 'body'); + + var section = body.append('div').attr('class','modal-section'); + + header.append('h2').text('You Just Edited OpenStreetMap!'); + header.append('p').text('You just improved the world\'s best free map'); + + var m = ''; + if (changeset.comment) { + m = '"' + changeset.comment.substring(0, 20) + '" '; + } + + var message = 'Edited OpenStreetMap! ' + m + + 'http://osm.org/browse/changeset/' + changeset.id; + + section.append('a') + .attr('href', function(d) { + return 'https://twitter.com/intent/tweet?source=webclient&text=' + + encodeURIComponent(message); + }) + .text('Tweet: ' + message); + + var buttonwrap = section.append('div') + .attr('class', 'buttons'); + + var okbutton = buttonwrap.append('button') + .attr('class', 'action wide') + .on('click.save', function() { + event.cancel(); + }); + + okbutton.append('span').attr('class','icon apply icon-pre-text'); + okbutton.append('span').attr('class','label').text('OK'); + } + + return d3.rebind(success, event, 'on'); +};