From 01991bca6599e59ddacd0d3c4d021189177cde58 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Mon, 26 Nov 2012 16:56:27 -0500 Subject: [PATCH] Start on commit UI. This pulls together a modal window listing changes. --- index.html | 1 + js/iD/id.js | 46 ++++++++++++++++++++++------------------------ js/iD/ui/commit.js | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 js/iD/ui/commit.js diff --git a/index.html b/index.html index 02261e971..da63fc058 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,7 @@ + diff --git a/js/iD/id.js b/js/iD/id.js index b870ba419..ed2d79d53 100644 --- a/js/iD/id.js +++ b/js/iD/id.js @@ -11,21 +11,17 @@ var iD = function(container) { container = d3.select(container); var m = container.append('div') - .attr('id', 'map'); + .attr('id', 'map'), + connection = iD.Connection() + .url('http://api06.dev.openstreetmap.org'), + map = iD.Map(m.node(), connection), + controller = iD.Controller(map), + bar = container.append('div') + .attr('id', 'bar'); - var connection = iD.Connection() - .url('http://api06.dev.openstreetmap.org'); - - var map = iD.Map(m.node(), connection); - - var controller = iD.Controller(map); - - var bar = container.append('div') - .attr('id', 'bar'); - - var buttons = bar.selectAll('button') + var buttons = bar.selectAll('button.add-button') .data([iD.modes.AddPlace, iD.modes.AddRoad, iD.modes.AddArea]) - .enter().append('button') + .enter().append('button').attr('class', 'add-button') .text(function (mode) { return mode.title; }) .on('click', function (mode) { controller.enter(mode); }); @@ -34,30 +30,26 @@ var iD = function(container) { }); bar.append('button') - .attr('id', 'undo') - .attr('class', 'mini') + .attr({ id: 'undo', 'class': 'mini' }) .property('disabled', true) .html('←') .on('click', map.undo); bar.append('button') - .attr('id', 'redo') - .attr('class', 'mini') + .attr({ id: 'redo', 'class': 'mini' }) .property('disabled', true) .html('→') .on('click', map.redo); bar.append('input') - .attr('type', 'text') - .attr('placeholder', 'find a place') - .attr('id', 'geocode-location') + .attr({ type: 'text', placeholder: 'find a place', id: 'geocode-location' }) .on('keydown', function () { if (d3.event.keyCode !== 13) return; d3.event.preventDefault(); var val = d3.select('#geocode-location').node().value; - var scr = document.body.appendChild(document.createElement('script')); - scr.src = 'http://api.tiles.mapbox.com/v3/mapbox/geocode/' + - encodeURIComponent(val) + '.jsonp?callback=grid'; + d3.select(document.body).append('script') + .attr('src', 'http://api.tiles.mapbox.com/v3/mapbox/geocode/' + + encodeURIComponent(val) + '.jsonp?callback=grid'); }); window.grid = function(resp) { @@ -77,7 +69,13 @@ var iD = function(container) { .html("Save") .on('click', function() { connection.authenticate(function() { - map.commit(); + var shaded = d3.select(document.body) + .append('div').attr('class', 'shaded'); + var modal = shaded.append('div') + .attr('class', 'modal') + .datum(map.history.changes()); + modal.call(iD.Commit()); + // map.commit(); }); }); diff --git a/js/iD/ui/commit.js b/js/iD/ui/commit.js new file mode 100644 index 000000000..c7ce6a430 --- /dev/null +++ b/js/iD/ui/commit.js @@ -0,0 +1,32 @@ +iD.Commit = function() { + var event = d3.dispatch(); + + function commit(selection) { + var changes = selection.datum(); + var header = selection.append('div').attr('class', 'header'); + var body = selection.append('div').attr('class', 'body'); + + header.append('h2').text('Save Changes to OpenStreetMap'); + + var section = body.selectAll('div.section') + .data(['modify', 'delete', 'create']) + .enter() + .append('div').attr('class', 'section'); + section.append('h3').text(String); + section.append('ul') + .selectAll('li') + .data(function(d) { + return changes[d]; + }) + .enter() + .append('li') + .text(function(d) { + return d.type + iD.Util.friendlyName(d); + }); + + body.append('button').text('Save'); + body.append('button').text('Cancel'); + } + + return d3.rebind(commit, event, 'on'); +};