Rearrange code

This commit is contained in:
John Firebaugh
2013-01-30 16:17:30 -05:00
parent 168a3b5e26
commit 363cd53af1
3 changed files with 55 additions and 55 deletions
+11 -11
View File
@@ -85,10 +85,13 @@ iD.behavior.DrawWay = function(wayId, index, mode, baseGraph) {
}
}
// Connect the way to an existing node and continue drawing.
drawWay.addNode = function(node) {
history.perform(
ReplaceTemporaryNode(node),
// Accept the current position of the temporary node and continue drawing.
drawWay.add = function(loc) {
var newNode = iD.Node({loc: loc});
history.replace(
iD.actions.AddNode(newNode),
ReplaceTemporaryNode(newNode),
annotation);
finished = true;
@@ -109,13 +112,10 @@ iD.behavior.DrawWay = function(wayId, index, mode, baseGraph) {
controller.enter(mode);
};
// Accept the current position of the temporary node and continue drawing.
drawWay.add = function(loc) {
var newNode = iD.Node({loc: loc});
history.replace(
iD.actions.AddNode(newNode),
ReplaceTemporaryNode(newNode),
// Connect the way to an existing node and continue drawing.
drawWay.addNode = function(node) {
history.perform(
ReplaceTemporaryNode(node),
annotation);
finished = true;
+21 -21
View File
@@ -15,25 +15,13 @@ iD.modes.AddArea = function() {
history = mode.history,
controller = mode.controller;
function startFromMidpoint(midpoint) {
var graph = history.graph(),
node = iD.Node(),
way = iD.Way({tags: defaultTags});
history.perform(
iD.actions.AddMidpoint(midpoint, node),
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, graph));
}
function startFromNode(node) {
function start(loc) {
var graph = history.graph(),
node = iD.Node({loc: loc}),
way = iD.Way({tags: defaultTags});
history.perform(
iD.actions.AddNode(node),
iD.actions.AddWay(way),
iD.actions.AddWayNode(way.id, node.id),
iD.actions.AddWayNode(way.id, node.id));
@@ -56,13 +44,25 @@ iD.modes.AddArea = function() {
controller.enter(iD.modes.DrawArea(way.id, graph));
}
function start(loc) {
function startFromNode(node) {
var graph = history.graph(),
node = iD.Node({loc: loc}),
way = iD.Way({tags: defaultTags});
history.perform(
iD.actions.AddNode(node),
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, graph));
}
function startFromMidpoint(midpoint) {
var graph = history.graph(),
node = iD.Node(),
way = iD.Way({tags: defaultTags});
history.perform(
iD.actions.AddMidpoint(midpoint, node),
iD.actions.AddWay(way),
iD.actions.AddWayNode(way.id, node.id),
iD.actions.AddWayNode(way.id, node.id));
@@ -71,10 +71,10 @@ iD.modes.AddArea = function() {
}
behavior = iD.behavior.AddWay(mode)
.on('startFromMidpoint', startFromMidpoint)
.on('startFromNode', startFromNode)
.on('start', start)
.on('startFromWay', startFromWay)
.on('start', start);
.on('startFromNode', startFromNode)
.on('startFromMidpoint', startFromMidpoint);
mode.map.surface.call(behavior);
mode.map.tail('Click on the map to start drawing an area, like a park, lake, or building.', true);
+23 -23
View File
@@ -15,19 +15,33 @@ iD.modes.AddLine = function() {
history = mode.history,
controller = mode.controller;
function startFromMidpoint(midpoint) {
function start(loc) {
var graph = history.graph(),
node = iD.Node(),
node = iD.Node({loc: loc}),
way = iD.Way({tags: defaultTags});
history.perform(
iD.actions.AddMidpoint(midpoint, node),
iD.actions.AddNode(node),
iD.actions.AddWay(way),
iD.actions.AddWayNode(way.id, node.id));
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
}
function startFromWay(other, loc, index) {
var graph = history.graph(),
node = iD.Node({loc: loc}),
way = iD.Way({tags: defaultTags});
history.perform(
iD.actions.AddNode(node),
iD.actions.AddWay(way),
iD.actions.AddWayNode(way.id, node.id),
iD.actions.AddWayNode(other.id, node.id, index));
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
}
function startFromNode(node) {
var graph = history.graph(),
parent = graph.parentWays(node)[0],
@@ -50,27 +64,13 @@ iD.modes.AddLine = function() {
}
}
function startFromWay(other, loc, index) {
function startFromMidpoint(midpoint) {
var graph = history.graph(),
node = iD.Node({loc: loc}),
node = iD.Node(),
way = iD.Way({tags: defaultTags});
history.perform(
iD.actions.AddNode(node),
iD.actions.AddWay(way),
iD.actions.AddWayNode(way.id, node.id),
iD.actions.AddWayNode(other.id, node.id, index));
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
}
function start(loc) {
var graph = history.graph(),
node = iD.Node({loc: loc}),
way = iD.Way({tags: defaultTags});
history.perform(
iD.actions.AddNode(node),
iD.actions.AddMidpoint(midpoint, node),
iD.actions.AddWay(way),
iD.actions.AddWayNode(way.id, node.id));
@@ -78,10 +78,10 @@ iD.modes.AddLine = function() {
}
behavior = iD.behavior.AddWay(mode)
.on('startFromMidpoint', startFromMidpoint)
.on('startFromNode', startFromNode)
.on('start', start)
.on('startFromWay', startFromWay)
.on('start', start);
.on('startFromNode', startFromNode)
.on('startFromMidpoint', startFromMidpoint);
mode.map.surface.call(behavior);
mode.map.tail('Click on the map to start drawing an road, path, or route.', true);