Permalink
Browse files

Split actions into separate files

  • Loading branch information...
1 parent 4a3169b commit 33beb3d2f0cf90215ef47c8c95f3512ca8d6d6f8 @jfirebaugh jfirebaugh committed Dec 5, 2012
View
@@ -26,6 +26,7 @@ all: \
js/id/oauth.js \
js/id/taginfo.js \
js/id/util.js \
+ js/id/actions.js \
js/id/actions/*.js \
js/id/modes.js \
js/id/modes/*.js \
View
@@ -40,7 +40,17 @@
<script src='js/id/ui/loading.js'></script>
<script src='js/id/ui/userpanel.js'></script>
- <script src='js/id/actions/actions.js'></script>
+ <script src='js/id/actions.js'></script>
+ <script src='js/id/actions/add_node.js'></script>
+ <script src='js/id/actions/add_way_node.js'></script>
+ <script src='js/id/actions/change_tags.js'></script>
+ <script src='js/id/actions/change_way_direction.js'></script>
+ <script src='js/id/actions/move.js'></script>
+ <script src='js/id/actions/noop.js'></script>
+ <script src='js/id/actions/remove.js'></script>
+ <script src='js/id/actions/remove_relation_entity.js'></script>
+ <script src='js/id/actions/remove_way_node.js'></script>
+ <script src='js/id/actions/start_way.js'></script>
<script src='js/id/modes.js'></script>
<script src='js/id/modes/add_area.js'></script>
View
@@ -0,0 +1 @@
+iD.actions = {};
View
@@ -1,97 +0,0 @@
-iD.actions = {};
-
-iD.actions.noop = function() {
- return function(graph) {
- return graph;
- };
-};
-
-// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/command/AddCommand.java
-iD.actions.addNode = function(node) {
- return function(graph) {
- return graph.replace(node, 'added a place');
- };
-};
-
-iD.actions.startWay = function(way) {
- return function(graph) {
- return graph.replace(way, 'started a road');
- };
-};
-
-// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteWayAction.as
-iD.actions.remove = function(entity) {
- return function(graph) {
- graph.parentWays(entity.id)
- .forEach(function(parent) {
- graph = iD.actions.removeWayNode(parent, entity)(graph);
- });
-
- graph.parentRelations(entity.id)
- .forEach(function(parent) {
- graph = iD.actions.removeRelationEntity(parent, entity)(graph);
- });
-
- return graph.remove(entity, 'removed a feature');
- };
-};
-
-// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/AddNodeToWayAction.as
-iD.actions.addWayNode = function(way, node, index) {
- return function(graph) {
- var nodes = way.nodes.slice();
- nodes.splice(index || nodes.length, 0, node.id);
- return graph.replace(way.update({nodes: nodes})).replace(node, 'added to a road');
- };
-};
-
-iD.actions.removeWayNode = function(way, node) {
- return function(graph) {
- var nodes = _.without(way.nodes, node.id);
- return graph.replace(way.update({nodes: nodes}), 'removed from a road');
- };
-};
-
-iD.actions.removeRelationEntity = function(relation, entity) {
- return function(graph) {
- var members = _.without(relation.members, entity.id);
- return graph.replace(relation.update({members: members}), 'removed from a relation');
- };
-};
-
-// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/AddNodeToWayAction.as
-iD.actions.changeWayDirection = function(way) {
- return function(graph) {
- return graph.replace(way.update({
- nodes: way.nodes.slice()
- }), 'changed way direction');
- };
-};
-
-iD.actions.changeTags = function(node, tags) {
- return function(graph) {
- return graph.replace(node.update({
- tags: tags
- }), 'changed tags');
- };
-};
-
-// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/command/MoveCommand.java
-// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/MoveNodeAction.as
-iD.actions.move = function(entity, loc) {
- return function(graph) {
- return graph.replace(entity.update({loc: loc}), 'moved an element');
- };
-};
-
-iD.actions.addTemporary = function(node) {
- return function(graph) {
- return graph.replace(node);
- };
-};
-
-iD.actions.removeTemporary = function(node) {
- return function(graph) {
- return graph.remove(node);
- };
-};
@@ -0,0 +1,6 @@
+// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/command/AddCommand.java
+iD.actions.addNode = function(node) {
+ return function(graph) {
+ return graph.replace(node, 'added a place');
+ };
+};
@@ -0,0 +1,8 @@
+// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/AddNodeToWayAction.as
+iD.actions.addWayNode = function(way, node, index) {
+ return function(graph) {
+ var nodes = way.nodes.slice();
+ nodes.splice(index || nodes.length, 0, node.id);
+ return graph.replace(way.update({nodes: nodes})).replace(node, 'added to a road');
+ };
+};
@@ -0,0 +1,7 @@
+iD.actions.changeTags = function(node, tags) {
+ return function(graph) {
+ return graph.replace(node.update({
+ tags: tags
+ }), 'changed tags');
+ };
+};
@@ -0,0 +1,8 @@
+// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/AddNodeToWayAction.as
+iD.actions.changeWayDirection = function(way) {
+ return function(graph) {
+ return graph.replace(way.update({
+ nodes: way.nodes.slice()
+ }), 'changed way direction');
+ };
+};
View
@@ -0,0 +1,7 @@
+// https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/command/MoveCommand.java
+// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/MoveNodeAction.as
+iD.actions.move = function(entity, loc) {
+ return function(graph) {
+ return graph.replace(entity.update({loc: loc}), 'moved an element');
+ };
+};
View
@@ -0,0 +1,5 @@
+iD.actions.noop = function() {
+ return function(graph) {
+ return graph;
+ };
+};
View
@@ -0,0 +1,16 @@
+// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteWayAction.as
+iD.actions.remove = function(entity) {
+ return function(graph) {
+ graph.parentWays(entity.id)
+ .forEach(function(parent) {
+ graph = iD.actions.removeWayNode(parent, entity)(graph);
+ });
+
+ graph.parentRelations(entity.id)
+ .forEach(function(parent) {
+ graph = iD.actions.removeRelationEntity(parent, entity)(graph);
+ });
+
+ return graph.remove(entity, 'removed a feature');
+ };
+};
@@ -0,0 +1,6 @@
+iD.actions.removeRelationEntity = function(relation, entity) {
+ return function(graph) {
+ var members = _.without(relation.members, entity.id);
+ return graph.replace(relation.update({members: members}), 'removed from a relation');
+ };
+};
@@ -0,0 +1,6 @@
+iD.actions.removeWayNode = function(way, node) {
+ return function(graph) {
+ var nodes = _.without(way.nodes, node.id);
+ return graph.replace(way.update({nodes: nodes}), 'removed from a road');
+ };
+};
@@ -0,0 +1,5 @@
+iD.actions.startWay = function(way) {
+ return function(graph) {
+ return graph.replace(way, 'started a road');
+ };
+};
View
@@ -42,7 +42,17 @@
<script src='../js/id/ui/loading.js'></script>
<script src='../js/id/ui/userpanel.js'></script>
- <script src='../js/id/actions/actions.js'></script>
+ <script src='../js/id/actions.js'></script>
+ <script src='../js/id/actions/add_node.js'></script>
+ <script src='../js/id/actions/add_way_node.js'></script>
+ <script src='../js/id/actions/change_tags.js'></script>
+ <script src='../js/id/actions/change_way_direction.js'></script>
+ <script src='../js/id/actions/move.js'></script>
+ <script src='../js/id/actions/noop.js'></script>
+ <script src='../js/id/actions/remove.js'></script>
+ <script src='../js/id/actions/remove_relation_entity.js'></script>
+ <script src='../js/id/actions/remove_way_node.js'></script>
+ <script src='../js/id/actions/start_way.js'></script>
<script src='../js/id/modes.js'></script>
<script src='../js/id/modes/add_area.js'></script>

0 comments on commit 33beb3d

Please sign in to comment.