From f527a4f6fde9dd8469e52766a5bd7b4aed932615 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 12 Dec 2012 17:22:45 -0500 Subject: [PATCH] Complete bindings for roads and areas. Fixes #180 --- js/id/modes/draw_area.js | 27 +++++++++++++++++++++++---- js/id/modes/draw_road.js | 24 ++++++++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/js/id/modes/draw_area.js b/js/id/modes/draw_area.js index 3bfe5b947..ae5925ea0 100644 --- a/js/id/modes/draw_area.js +++ b/js/id/modes/draw_area.js @@ -63,7 +63,7 @@ iD.modes.DrawArea = function(wayId) { controller.enter(iD.modes.Browse()); } - function del() { + function backspace() { d3.event.preventDefault(); history.replace( @@ -80,10 +80,27 @@ iD.modes.DrawArea = function(wayId) { } } + function del() { + d3.event.preventDefault(); + history.replace(iD.actions.DeleteWay(wayId)); + controller.enter(iD.modes.Browse()); + } + + function ret() { + d3.event.preventDefault(); + history.replace( + iD.actions.DeleteNode(node.id), + iD.actions.AddWayNode(way.id, tailId, -1), + 'added to an area'); + controller.enter(iD.modes.Browse()); + } + map.surface.on('mousemove.drawarea', mousemove); map.surface.on('click.drawarea', click); - map.keybinding().on('⎋.drawarea', esc); - map.keybinding().on('⌫.drawarea', del); + map.keybinding().on('⎋.drawarea', esc) + .on('⌫.drawarea', backspace) + .on('delete.drawarea', del) + .on('↩.drawarea', ret); }; mode.exit = function() { @@ -93,7 +110,9 @@ iD.modes.DrawArea = function(wayId) { .on('mousemove.drawarea', null) .on('click.drawarea', null); mode.map.keybinding().on('⎋.drawarea', null) - .on('⌫.drawarea', null); + .on('⌫.drawarea', null) + .on('delete.drawarea', null) + .on('↩.drawarea', null); window.setTimeout(function() { mode.map.dblclickEnable(true); }, 1000); diff --git a/js/id/modes/draw_road.js b/js/id/modes/draw_road.js index c78ff913d..463e97f76 100644 --- a/js/id/modes/draw_road.js +++ b/js/id/modes/draw_road.js @@ -81,7 +81,7 @@ iD.modes.DrawRoad = function(wayId, direction) { controller.enter(iD.modes.Browse()); } - function del() { + function backspace() { d3.event.preventDefault(); history.replace( @@ -96,8 +96,22 @@ iD.modes.DrawRoad = function(wayId, direction) { } } - map.keybinding().on('⎋.drawroad', esc); - map.keybinding().on('⌫.drawroad', del); + function del() { + d3.event.preventDefault(); + history.replace(iD.actions.DeleteWay(wayId)); + controller.enter(iD.modes.Browse()); + } + + function ret() { + d3.event.preventDefault(); + history.replace(iD.actions.DeleteNode(node.id)); + controller.enter(iD.modes.Browse()); + } + + map.keybinding().on('⎋.drawroad', esc) + .on('⌫.drawroad', backspace) + .on('delete.drawroad', del) + .on('↩.drawroad', ret); }; mode.exit = function() { @@ -108,7 +122,9 @@ iD.modes.DrawRoad = function(wayId, direction) { .on('mousemove.drawroad', null) .on('click.drawroad', null); mode.map.keybinding().on('⎋.drawroad', null) - .on('⌫.drawroad', null); + .on('⌫.drawroad', null) + .on('delete.drawroad', null) + .on('↩.drawroad', null); window.setTimeout(function() { mode.map.dblclickEnable(true); }, 1000);