diff --git a/js/id/behavior/draw_way.js b/js/id/behavior/draw_way.js index a9f1f5c91..649d79e55 100644 --- a/js/id/behavior/draw_way.js +++ b/js/id/behavior/draw_way.js @@ -1,4 +1,4 @@ -iD.behavior.DrawWay = function(wayId, headId, tailId, index, mode) { +iD.behavior.DrawWay = function(wayId, headId, tailId, index, mode, baseGraph) { var map = mode.map, history = mode.history, controller = mode.controller, @@ -129,7 +129,7 @@ iD.behavior.DrawWay = function(wayId, headId, tailId, index, mode) { // Cancel the draw operation and return to browse, deleting everything drawn. drawWay.cancel = function() { - history.perform(iD.actions.DeleteWay(wayId), 'cancelled drawing'); + history.perform(d3.functor(baseGraph), 'cancelled drawing'); controller.enter(iD.modes.Browse()); }; diff --git a/js/id/modes/add_area.js b/js/id/modes/add_area.js index cbfdffbd0..d1a3efb08 100644 --- a/js/id/modes/add_area.js +++ b/js/id/modes/add_area.js @@ -16,18 +16,20 @@ iD.modes.AddArea = function() { controller = mode.controller; function startFromNode(node) { - var way = iD.Way({tags: defaultTags}); + var graph = history.graph(), + way = iD.Way({tags: defaultTags}); history.perform( iD.actions.AddWay(way), iD.actions.AddWayNode(way.id, node.id), iD.actions.AddWayNode(way.id, node.id)); - controller.enter(iD.modes.DrawArea(way.id)); + controller.enter(iD.modes.DrawArea(way.id, graph)); } function startFromWay(other, loc, index) { - var node = iD.Node({loc: loc}), + var graph = history.graph(), + node = iD.Node({loc: loc}), way = iD.Way({tags: defaultTags}); history.perform( @@ -37,11 +39,12 @@ iD.modes.AddArea = function() { iD.actions.AddWayNode(way.id, node.id), iD.actions.AddWayNode(other.id, node.id, index)); - controller.enter(iD.modes.DrawArea(way.id)); + controller.enter(iD.modes.DrawArea(way.id, graph)); } function start(loc) { - var node = iD.Node({loc: loc}), + var graph = history.graph(), + node = iD.Node({loc: loc}), way = iD.Way({tags: defaultTags}); history.perform( @@ -50,7 +53,7 @@ iD.modes.AddArea = function() { iD.actions.AddWayNode(way.id, node.id), iD.actions.AddWayNode(way.id, node.id)); - controller.enter(iD.modes.DrawArea(way.id)); + controller.enter(iD.modes.DrawArea(way.id, graph)); } behavior = iD.behavior.AddWay(mode) diff --git a/js/id/modes/add_line.js b/js/id/modes/add_line.js index f9d52a9a0..bf419d2bb 100644 --- a/js/id/modes/add_line.js +++ b/js/id/modes/add_line.js @@ -21,10 +21,10 @@ iD.modes.AddLine = function() { isLine = parent && parent.geometry(graph) === 'line'; if (isLine && parent.first() === node.id) { - controller.enter(iD.modes.DrawLine(parent.id, 'backward')); + controller.enter(iD.modes.DrawLine(parent.id, 'backward', graph)); } else if (isLine && parent.last() === node.id) { - controller.enter(iD.modes.DrawLine(parent.id, 'forward')); + controller.enter(iD.modes.DrawLine(parent.id, 'forward', graph)); } else { var way = iD.Way({tags: defaultTags}); @@ -33,12 +33,13 @@ iD.modes.AddLine = function() { iD.actions.AddWay(way), iD.actions.AddWayNode(way.id, node.id)); - controller.enter(iD.modes.DrawLine(way.id, 'forward')); + controller.enter(iD.modes.DrawLine(way.id, 'forward', graph)); } } function startFromWay(other, loc, index) { - var node = iD.Node({loc: loc}), + var graph = history.graph(), + node = iD.Node({loc: loc}), way = iD.Way({tags: defaultTags}); history.perform( @@ -47,11 +48,12 @@ iD.modes.AddLine = function() { iD.actions.AddWayNode(way.id, node.id), iD.actions.AddWayNode(other.id, node.id, index)); - controller.enter(iD.modes.DrawLine(way.id, 'forward')); + controller.enter(iD.modes.DrawLine(way.id, 'forward', graph)); } function start(loc) { - var node = iD.Node({loc: loc}), + var graph = history.graph(), + node = iD.Node({loc: loc}), way = iD.Way({tags: defaultTags}); history.perform( @@ -59,7 +61,7 @@ iD.modes.AddLine = function() { iD.actions.AddWay(way), iD.actions.AddWayNode(way.id, node.id)); - controller.enter(iD.modes.DrawLine(way.id, 'forward')); + controller.enter(iD.modes.DrawLine(way.id, 'forward', graph)); } behavior = iD.behavior.AddWay(mode) diff --git a/js/id/modes/draw_area.js b/js/id/modes/draw_area.js index 9e2bd6a32..721452bae 100644 --- a/js/id/modes/draw_area.js +++ b/js/id/modes/draw_area.js @@ -1,4 +1,4 @@ -iD.modes.DrawArea = function(wayId) { +iD.modes.DrawArea = function(wayId, baseGraph) { var mode = { button: 'area', id: 'draw-area' @@ -29,7 +29,7 @@ iD.modes.DrawArea = function(wayId) { behavior.add(loc, annotation); } - behavior = iD.behavior.DrawWay(wayId, headId, tailId, index, mode) + behavior = iD.behavior.DrawWay(wayId, headId, tailId, index, mode, baseGraph) .on('addHead', addHeadTail) .on('addTail', addHeadTail) .on('addNode', addNode) diff --git a/js/id/modes/draw_line.js b/js/id/modes/draw_line.js index 7980b0549..289d91c14 100644 --- a/js/id/modes/draw_line.js +++ b/js/id/modes/draw_line.js @@ -1,4 +1,4 @@ -iD.modes.DrawLine = function(wayId, direction) { +iD.modes.DrawLine = function(wayId, direction, baseGraph) { var mode = { button: 'line', id: 'draw-line' @@ -38,7 +38,7 @@ iD.modes.DrawLine = function(wayId, direction) { behavior.add(loc, annotation); } - behavior = iD.behavior.DrawWay(wayId, headId, tailId, index, mode) + behavior = iD.behavior.DrawWay(wayId, headId, tailId, index, mode, baseGraph) .on('addHead', addHead) .on('addTail', addTail) .on('addNode', addNode)