From 1972711a66dbe9a2a897188e08b4dc1ab0391d84 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 3 Dec 2012 16:21:42 -0500 Subject: [PATCH] Exit indirectly via controller (fixes #147) --- js/id/actions/modes.js | 12 ++++++------ js/id/controller/controller.js | 6 +++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/js/id/actions/modes.js b/js/id/actions/modes.js index c06839888..3d630d1d4 100644 --- a/js/id/actions/modes.js +++ b/js/id/actions/modes.js @@ -36,11 +36,11 @@ iD.modes.AddPlace = { n._poi = true; this.map.perform(iD.actions.addNode(n)); this.map.selectEntity(n); - this.exit(); + this.controller.exit(); }.bind(this)); d3.select(document).on('keydown.addplace', function() { - if (d3.event.keyCode === 27) this.exit(); + if (d3.event.keyCode === 27) this.controller.exit(); }.bind(this)); }, exit: function() { @@ -140,7 +140,7 @@ iD.modes.AddRoad = { surface.on('click.addroad', addRoad.bind(this)); d3.select(document).on('keydown.addroad', function() { - if (d3.event.keyCode === 27) this.exit(); + if (d3.event.keyCode === 27) this.controller.exit(); }.bind(this)); }, exit: function() { @@ -204,7 +204,7 @@ iD.modes.DrawRoad = function(way_id, direction) { this.map.perform(iD.actions.changeTags(way, way.tags)); this.map.selectEntity(way); // End by clicking on own tail - return this.exit(); + return this.controller.exit(); } else { // connect a way to an existing way node = t.data()[0]; @@ -289,7 +289,7 @@ iD.modes.AddArea = { surface.on('click.addarea', addArea.bind(this)); d3.select(document).on('keydown.addarea', function() { - if (d3.event.keyCode === 27) this.exit(); + if (d3.event.keyCode === 27) this.controller.exit(); }.bind(this)); }, exit: function() { @@ -342,7 +342,7 @@ iD.modes.DrawArea = function(way_id) { delete way.tags.elastic; this.map.perform(iD.actions.changeTags(way, way.tags)); // End by clicking on own tail - return this.exit(); + return this.controller.exit(); } else { // connect a way to an existing way node = t.data()[0]; diff --git a/js/id/controller/controller.js b/js/id/controller/controller.js index bf5115900..c3721b4eb 100644 --- a/js/id/controller/controller.js +++ b/js/id/controller/controller.js @@ -16,7 +16,11 @@ iD.Controller = function(map) { event.enter(mode); }; - controller.enter(iD.modes.Move); + controller.exit = function() { + controller.enter(iD.modes.Move); + }; + + controller.exit(); return d3.rebind(controller, event, 'on'); };