From b18ba11a09834ac73570af774167f51586da0cfb Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Tue, 11 Dec 2012 15:58:17 -0500 Subject: [PATCH] Fixes #229 and road closing nodes. Order matters for history.replace --- js/id/modes/draw_area.js | 21 +++++++++++++-------- js/id/modes/draw_road.js | 2 +- js/id/renderer/map.js | 11 +++++------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/js/id/modes/draw_area.js b/js/id/modes/draw_area.js index 0d3fa7c9d..abf84ac4a 100644 --- a/js/id/modes/draw_area.js +++ b/js/id/modes/draw_area.js @@ -21,11 +21,11 @@ iD.modes.DrawArea = function(wayId) { iD.actions.AddNode(node), iD.actions.AddWayNode(way.id, node.id, -1)); - map.surface.on('mousemove.drawarea', function() { + function mousemove() { history.replace(iD.actions.Move(node.id, map.mouseCoordinates())); - }); + } - map.surface.on('click.drawarea', function() { + function click() { var datum = d3.select(d3.event.target).datum() || {}; if (datum.id === tailId) { @@ -52,16 +52,16 @@ iD.modes.DrawArea = function(wayId) { controller.enter(iD.modes.DrawArea(wayId)); } - }); + } - map.keybinding().on('⎋.drawarea', function() { + function esc() { history.replace( iD.actions.DeleteNode(node.id)); controller.enter(iD.modes.Browse()); - }); + } - map.keybinding().on('⌫.drawarea', function() { + function del() { d3.event.preventDefault(); history.replace( @@ -69,7 +69,12 @@ iD.modes.DrawArea = function(wayId) { iD.actions.DeleteNode(headId)); controller.enter(iD.modes.DrawArea(wayId)); - }); + } + + map.surface.on('mousemove.drawarea', mousemove); + map.surface.on('click.drawarea', click); + map.keybinding().on('⎋.drawarea', esc); + map.keybinding().on('⌫.drawarea', del); }; mode.exit = function() { diff --git a/js/id/modes/draw_road.js b/js/id/modes/draw_road.js index 81f00a0cf..5e61ddc96 100644 --- a/js/id/modes/draw_road.js +++ b/js/id/modes/draw_road.js @@ -57,7 +57,7 @@ iD.modes.DrawRoad = function(wayId, direction) { } else if (datum.type === 'way') { // connect the way to an existing way - var connectedIndex = iD.modes.chooseIndex(datum, d3.mouse(map.surface.node()), map); + var connectedIndex = iD.util.geo.chooseIndex(datum, d3.mouse(map.surface.node()), map); history.replace( iD.actions.AddWayNode(datum.id, node.id, connectedIndex), diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 61e9b7069..cbe7fcdb7 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -134,24 +134,23 @@ iD.Map = function() { var handles = g.hit.selectAll('image.handle') .filter(filter) .data(waynodes, key); - function olderOnTop(a, b) { - return a.osmId() - b.osmId(); - } + handles.exit().remove(); - handles.enter().append('image') + + handles.enter().insert('image', ':first-child') .attr({ width: 6, height: 6, 'class': 'handle', 'xlink:href': 'css/handle.png' }); + handles.attr('transform', function(entity) { var p = projection(entity.loc); return 'translate(' + [~~p[0], ~~p[1]] + ') translate(-3, -3) rotate(45, 3, 3)'; }) - .classed('active', classActive) - .sort(olderOnTop); + .classed('active', classActive); } function drawAccuracyHandles(waynodes, filter) {