From 9eb455257341954669c7f1e370ef965f41a6edbd Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 13 Dec 2012 14:07:39 -0800 Subject: [PATCH] Revert unintended changes in c93cd4 --- js/id/modes/select.js | 45 +++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/js/id/modes/select.js b/js/id/modes/select.js index c0553ac61..a94e54103 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -1,7 +1,7 @@ iD.modes.Select = function (entity) { var mode = { id: 'select', - button: '', + button: 'browse', entity: entity }; @@ -17,8 +17,7 @@ iD.modes.Select = function (entity) { d3.event.sourceEvent.stopPropagation(); if (!dragging) { - dragging = iD.util.trueObj([entity.id].concat( - _.pluck(mode.history.graph().parentWays(entity.id), 'id'))); + dragging = true; mode.history.perform(iD.actions.Noop()); } @@ -31,19 +30,25 @@ iD.modes.Select = function (entity) { }); function remove() { - switch (entity.type) { - case 'way': - mode.history.perform(iD.actions.DeleteWay(entity.id)); - break; - case 'node': - mode.history.perform(iD.actions.DeleteNode(entity.id)); + if (entity.type === 'way') { + mode.history.perform( + iD.actions.DeleteWay(entity.id), + 'deleted a way'); + } else if (entity.type === 'node') { + var parents = mode.history.graph().parentWays(entity.id), + operations = [iD.actions.DeleteNode(entity.id)]; + parents.forEach(function(parent) { + if (_.uniq(parent.nodes).length === 1) operations.push(iD.actions.DeleteWay(parent.id)); + }); + mode.history.perform.apply(mode.history, + operations.concat(['deleted a node'])); } mode.controller.exit(); } mode.enter = function () { - target = mode.map.surface.selectAll("*") + target = mode.map.surface.selectAll('*') .filter(function (d) { return d === entity; }); iD.modes._dragFeatures(mode); @@ -55,11 +60,23 @@ iD.modes.Select = function (entity) { .call(inspector); inspector.on('changeTags', function(d, tags) { - mode.history.perform(iD.actions.ChangeEntityTags(d.id, tags)); + mode.history.perform( + iD.actions.ChangeEntityTags(d.id, tags), + 'changed tags'); + }).on('changeWayDirection', function(d) { - mode.history.perform(iD.actions.ReverseWay(d)); + mode.history.perform( + iD.actions.ReverseWay(d.id), + 'reversed a way'); + + }).on('splitWay', function(d) { + mode.history.perform( + iD.actions.SplitWay(d.id), + 'split a way on a node'); + }).on('remove', function() { remove(); + }).on('close', function() { mode.controller.exit(); }); @@ -68,7 +85,7 @@ iD.modes.Select = function (entity) { target.call(dragWay); } - mode.map.surface.on("click.browse", function () { + mode.map.surface.on('click.browse', function () { var datum = d3.select(d3.event.target).datum(); if (datum instanceof iD.Entity) { mode.controller.enter(iD.modes.Select(datum)); @@ -94,8 +111,8 @@ iD.modes.Select = function (entity) { .on('touchstart.drag', null); } - mode.map.surface.on('mousedown.latedrag', null); mode.map.surface.on("click.browse", null); + mode.map.surface.on('mousedown.latedrag', null); mode.map.keybinding().on('⌫.browse', null); mode.map.selection(null);