Add success page. Fixes #126

This commit is contained in:
Tom MacWright
2013-01-03 19:26:45 -05:00
parent 62efa1948e
commit 0cb5fbe227
3 changed files with 55 additions and 0 deletions

View File

@@ -39,6 +39,7 @@
<script src='js/id/ui/modal.js'></script>
<script src='js/id/ui/confirm.js'></script>
<script src='js/id/ui/commit.js'></script>
<script src='js/id/ui/success.js'></script>
<script src='js/id/ui/loading.js'></script>
<script src='js/id/ui/userpanel.js'></script>
<script src='js/id/ui/layerswitcher.js'></script>

View File

@@ -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();

43
js/id/ui/success.js Normal file
View File

@@ -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');
};