From 266504d4e2480e63cafce38a35841f8719d08c03 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Mon, 6 Jun 2016 16:40:21 -0400 Subject: [PATCH] Baby steps mode --- Makefile | 39 +++---------------- dist/modules/.gitkeep | 0 index.html | 34 +--------------- js/id/actions.js | 1 - {js/id => modules}/actions/add_entity.js | 2 +- {js/id => modules}/actions/add_member.js | 2 +- {js/id => modules}/actions/add_midpoint.js | 2 +- {js/id => modules}/actions/add_vertex.js | 2 +- {js/id => modules}/actions/change_member.js | 2 +- {js/id => modules}/actions/change_preset.js | 2 +- {js/id => modules}/actions/change_tags.js | 2 +- {js/id => modules}/actions/circularize.js | 2 +- {js/id => modules}/actions/connect.js | 2 +- {js/id => modules}/actions/copy_entities.js | 2 +- {js/id => modules}/actions/delete_member.js | 2 +- {js/id => modules}/actions/delete_multiple.js | 2 +- {js/id => modules}/actions/delete_node.js | 2 +- {js/id => modules}/actions/delete_relation.js | 2 +- {js/id => modules}/actions/delete_way.js | 2 +- {js/id => modules}/actions/deprecate_tags.js | 2 +- {js/id => modules}/actions/discard_tags.js | 2 +- {js/id => modules}/actions/disconnect.js | 2 +- modules/actions/index.js | 33 ++++++++++++++++ {js/id => modules}/actions/join.js | 2 +- {js/id => modules}/actions/merge.js | 2 +- {js/id => modules}/actions/merge_polygon.js | 2 +- .../actions/merge_remote_changes.js | 2 +- {js/id => modules}/actions/move.js | 2 +- {js/id => modules}/actions/move_node.js | 2 +- {js/id => modules}/actions/noop.js | 2 +- {js/id => modules}/actions/orthogonalize.js | 2 +- {js/id => modules}/actions/restrict_turn.js | 2 +- {js/id => modules}/actions/reverse.js | 2 +- {js/id => modules}/actions/revert.js | 2 +- {js/id => modules}/actions/rotate_way.js | 2 +- {js/id => modules}/actions/split.js | 2 +- {js/id => modules}/actions/straighten.js | 2 +- {js/id => modules}/actions/unrestrict_turn.js | 2 +- package.json | 1 + test/index.html | 34 +--------------- 40 files changed, 74 insertions(+), 134 deletions(-) create mode 100644 dist/modules/.gitkeep delete mode 100644 js/id/actions.js rename {js/id => modules}/actions/add_entity.js (65%) rename {js/id => modules}/actions/add_member.js (93%) rename {js/id => modules}/actions/add_midpoint.js (93%) rename {js/id => modules}/actions/add_vertex.js (80%) rename {js/id => modules}/actions/change_member.js (64%) rename {js/id => modules}/actions/change_preset.js (83%) rename {js/id => modules}/actions/change_tags.js (73%) rename {js/id => modules}/actions/circularize.js (99%) rename {js/id => modules}/actions/connect.js (97%) rename {js/id => modules}/actions/copy_entities.js (87%) rename {js/id => modules}/actions/delete_member.js (82%) rename {js/id => modules}/actions/delete_multiple.js (94%) rename {js/id => modules}/actions/delete_node.js (95%) rename {js/id => modules}/actions/delete_relation.js (96%) rename {js/id => modules}/actions/delete_way.js (97%) rename {js/id => modules}/actions/deprecate_tags.js (95%) rename {js/id => modules}/actions/discard_tags.js (91%) rename {js/id => modules}/actions/disconnect.js (98%) create mode 100644 modules/actions/index.js rename {js/id => modules}/actions/join.js (98%) rename {js/id => modules}/actions/merge.js (97%) rename {js/id => modules}/actions/merge_polygon.js (98%) rename {js/id => modules}/actions/merge_remote_changes.js (99%) rename {js/id => modules}/actions/move.js (99%) rename {js/id => modules}/actions/move_node.js (87%) rename {js/id => modules}/actions/noop.js (66%) rename {js/id => modules}/actions/orthogonalize.js (98%) rename {js/id => modules}/actions/restrict_turn.js (97%) rename {js/id => modules}/actions/reverse.js (98%) rename {js/id => modules}/actions/revert.js (96%) rename {js/id => modules}/actions/rotate_way.js (91%) rename {js/id => modules}/actions/split.js (99%) rename {js/id => modules}/actions/straighten.js (98%) rename {js/id => modules}/actions/unrestrict_turn.js (94%) diff --git a/Makefile b/Makefile index c22d5a80a..b54bd1083 100644 --- a/Makefile +++ b/Makefile @@ -77,40 +77,7 @@ dist/iD.js: \ js/id/geo/intersection.js \ js/id/geo/multipolygon.js \ js/id/geo/raw_mercator.js \ - js/id/actions.js \ - js/id/actions/add_entity.js \ - js/id/actions/add_member.js \ - js/id/actions/add_midpoint.js \ - js/id/actions/add_vertex.js \ - js/id/actions/change_member.js \ - js/id/actions/change_preset.js \ - js/id/actions/change_tags.js \ - js/id/actions/circularize.js \ - js/id/actions/connect.js \ - js/id/actions/copy_entities.js \ - js/id/actions/delete_member.js \ - js/id/actions/delete_multiple.js \ - js/id/actions/delete_node.js \ - js/id/actions/delete_relation.js \ - js/id/actions/delete_way.js \ - js/id/actions/deprecate_tags.js \ - js/id/actions/discard_tags.js \ - js/id/actions/disconnect.js \ - js/id/actions/join.js \ - js/id/actions/merge.js \ - js/id/actions/merge_polygon.js \ - js/id/actions/merge_remote_changes.js \ - js/id/actions/move.js \ - js/id/actions/move_node.js \ - js/id/actions/noop.js \ - js/id/actions/orthogonalize.js \ - js/id/actions/restrict_turn.js \ - js/id/actions/reverse.js \ - js/id/actions/revert.js \ - js/id/actions/rotate_way.js \ - js/id/actions/split.js \ - js/id/actions/straighten.js \ - js/id/actions/unrestrict_turn.js \ + dist/modules/actions.js \ js/id/behavior.js \ js/id/behavior/add_way.js \ js/id/behavior/breathe.js \ @@ -317,5 +284,9 @@ d3: node_modules/.bin/smash $(D3_FILES) > js/lib/d3.v3.js @echo 'd3 rebuilt. Please reapply 7e2485d, 4da529f, and 223974d' +ACTIONS = $(shell ./node_modules/.bin/browserify --list modules/actions/index.js) +dist/modules/actions.js: $(ACTIONS) + node_modules/.bin/browserify modules/actions/index.js -s iD.actions > dist/modules/actions.js + lodash: node_modules/.bin/lodash --development --output js/lib/lodash.js include="includes,toPairs,assign,bind,chunk,clone,compact,debounce,difference,each,every,extend,filter,find,first,forEach,forOwn,groupBy,indexOf,intersection,isEmpty,isEqual,isFunction,keys,last,map,omit,reject,some,throttle,union,uniq,values,without,flatten,value,chain,cloneDeep,merge,pick,reduce" exports="global,node" diff --git a/dist/modules/.gitkeep b/dist/modules/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/index.html b/index.html index d7eb05479..0f425101c 100644 --- a/index.html +++ b/index.html @@ -145,39 +145,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/js/id/actions.js b/js/id/actions.js deleted file mode 100644 index 481fa8285..000000000 --- a/js/id/actions.js +++ /dev/null @@ -1 +0,0 @@ -iD.actions = {}; diff --git a/js/id/actions/add_entity.js b/modules/actions/add_entity.js similarity index 65% rename from js/id/actions/add_entity.js rename to modules/actions/add_entity.js index 0011d0fe5..38a1e5f7d 100644 --- a/js/id/actions/add_entity.js +++ b/modules/actions/add_entity.js @@ -1,4 +1,4 @@ -iD.actions.AddEntity = function(way) { +module.exports = function(way) { return function(graph) { return graph.replace(way); }; diff --git a/js/id/actions/add_member.js b/modules/actions/add_member.js similarity index 93% rename from js/id/actions/add_member.js rename to modules/actions/add_member.js index 7617cf386..e8a4a7be8 100644 --- a/js/id/actions/add_member.js +++ b/modules/actions/add_member.js @@ -1,4 +1,4 @@ -iD.actions.AddMember = function(relationId, member, memberIndex) { +module.exports = function(relationId, member, memberIndex) { return function(graph) { var relation = graph.entity(relationId); diff --git a/js/id/actions/add_midpoint.js b/modules/actions/add_midpoint.js similarity index 93% rename from js/id/actions/add_midpoint.js rename to modules/actions/add_midpoint.js index b89a87f5b..be7c49453 100644 --- a/js/id/actions/add_midpoint.js +++ b/modules/actions/add_midpoint.js @@ -1,4 +1,4 @@ -iD.actions.AddMidpoint = function(midpoint, node) { +module.exports = function(midpoint, node) { return function(graph) { graph = graph.replace(node.move(midpoint.loc)); diff --git a/js/id/actions/add_vertex.js b/modules/actions/add_vertex.js similarity index 80% rename from js/id/actions/add_vertex.js rename to modules/actions/add_vertex.js index 279737c05..ac7a9997e 100644 --- a/js/id/actions/add_vertex.js +++ b/modules/actions/add_vertex.js @@ -1,5 +1,5 @@ // https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/AddNodeToWayAction.as -iD.actions.AddVertex = function(wayId, nodeId, index) { +module.exports = function(wayId, nodeId, index) { return function(graph) { return graph.replace(graph.entity(wayId).addNode(nodeId, index)); }; diff --git a/js/id/actions/change_member.js b/modules/actions/change_member.js similarity index 64% rename from js/id/actions/change_member.js rename to modules/actions/change_member.js index a84b30487..8b374fc12 100644 --- a/js/id/actions/change_member.js +++ b/modules/actions/change_member.js @@ -1,4 +1,4 @@ -iD.actions.ChangeMember = function(relationId, member, memberIndex) { +module.exports = function(relationId, member, memberIndex) { return function(graph) { return graph.replace(graph.entity(relationId).updateMember(member, memberIndex)); }; diff --git a/js/id/actions/change_preset.js b/modules/actions/change_preset.js similarity index 83% rename from js/id/actions/change_preset.js rename to modules/actions/change_preset.js index 7688b8c10..79715cfc6 100644 --- a/js/id/actions/change_preset.js +++ b/modules/actions/change_preset.js @@ -1,4 +1,4 @@ -iD.actions.ChangePreset = function(entityId, oldPreset, newPreset) { +module.exports = function(entityId, oldPreset, newPreset) { return function(graph) { var entity = graph.entity(entityId), geometry = entity.geometry(graph), diff --git a/js/id/actions/change_tags.js b/modules/actions/change_tags.js similarity index 73% rename from js/id/actions/change_tags.js rename to modules/actions/change_tags.js index c5972644e..c054a99a6 100644 --- a/js/id/actions/change_tags.js +++ b/modules/actions/change_tags.js @@ -1,4 +1,4 @@ -iD.actions.ChangeTags = function(entityId, tags) { +module.exports = function(entityId, tags) { return function(graph) { var entity = graph.entity(entityId); return graph.replace(entity.update({tags: tags})); diff --git a/js/id/actions/circularize.js b/modules/actions/circularize.js similarity index 99% rename from js/id/actions/circularize.js rename to modules/actions/circularize.js index de720c4e5..d662d4875 100644 --- a/js/id/actions/circularize.js +++ b/modules/actions/circularize.js @@ -1,4 +1,4 @@ -iD.actions.Circularize = function(wayId, projection, maxAngle) { +module.exports = function(wayId, projection, maxAngle) { maxAngle = (maxAngle || 20) * Math.PI / 180; var action = function(graph) { diff --git a/js/id/actions/connect.js b/modules/actions/connect.js similarity index 97% rename from js/id/actions/connect.js rename to modules/actions/connect.js index d82cedd60..6395d9509 100644 --- a/js/id/actions/connect.js +++ b/modules/actions/connect.js @@ -12,7 +12,7 @@ // https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/MergeNodesAction.as // https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/actions/MergeNodesAction.java // -iD.actions.Connect = function(nodeIds) { +module.exports = function(nodeIds) { return function(graph) { var survivor = graph.entity(_.last(nodeIds)); diff --git a/js/id/actions/copy_entities.js b/modules/actions/copy_entities.js similarity index 87% rename from js/id/actions/copy_entities.js rename to modules/actions/copy_entities.js index 5c6a02850..1f168fdf9 100644 --- a/js/id/actions/copy_entities.js +++ b/modules/actions/copy_entities.js @@ -1,4 +1,4 @@ -iD.actions.CopyEntities = function(ids, fromGraph) { +module.exports = function(ids, fromGraph) { var copies = {}; var action = function(graph) { diff --git a/js/id/actions/delete_member.js b/modules/actions/delete_member.js similarity index 82% rename from js/id/actions/delete_member.js rename to modules/actions/delete_member.js index ffed567ca..23842f613 100644 --- a/js/id/actions/delete_member.js +++ b/modules/actions/delete_member.js @@ -1,4 +1,4 @@ -iD.actions.DeleteMember = function(relationId, memberIndex) { +module.exports = function(relationId, memberIndex) { return function(graph) { var relation = graph.entity(relationId) .removeMember(memberIndex); diff --git a/js/id/actions/delete_multiple.js b/modules/actions/delete_multiple.js similarity index 94% rename from js/id/actions/delete_multiple.js rename to modules/actions/delete_multiple.js index f91cc0fdb..a9c50f88a 100644 --- a/js/id/actions/delete_multiple.js +++ b/modules/actions/delete_multiple.js @@ -1,4 +1,4 @@ -iD.actions.DeleteMultiple = function(ids) { +module.exports = function(ids) { var actions = { way: iD.actions.DeleteWay, node: iD.actions.DeleteNode, diff --git a/js/id/actions/delete_node.js b/modules/actions/delete_node.js similarity index 95% rename from js/id/actions/delete_node.js rename to modules/actions/delete_node.js index bd131de68..95ebd824c 100644 --- a/js/id/actions/delete_node.js +++ b/modules/actions/delete_node.js @@ -1,5 +1,5 @@ // https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteNodeAction.as -iD.actions.DeleteNode = function(nodeId) { +module.exports = function(nodeId) { var action = function(graph) { var node = graph.entity(nodeId); diff --git a/js/id/actions/delete_relation.js b/modules/actions/delete_relation.js similarity index 96% rename from js/id/actions/delete_relation.js rename to modules/actions/delete_relation.js index 2ba4b389d..f656fca95 100644 --- a/js/id/actions/delete_relation.js +++ b/modules/actions/delete_relation.js @@ -1,5 +1,5 @@ // https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteRelationAction.as -iD.actions.DeleteRelation = function(relationId) { +module.exports = function(relationId) { function deleteEntity(entity, graph) { return !graph.parentWays(entity).length && !graph.parentRelations(entity).length && diff --git a/js/id/actions/delete_way.js b/modules/actions/delete_way.js similarity index 97% rename from js/id/actions/delete_way.js rename to modules/actions/delete_way.js index 4ec50a4b3..1ca876d5c 100644 --- a/js/id/actions/delete_way.js +++ b/modules/actions/delete_way.js @@ -1,5 +1,5 @@ // https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteWayAction.as -iD.actions.DeleteWay = function(wayId) { +module.exports = function(wayId) { function deleteNode(node, graph) { return !graph.parentWays(node).length && !graph.parentRelations(node).length && diff --git a/js/id/actions/deprecate_tags.js b/modules/actions/deprecate_tags.js similarity index 95% rename from js/id/actions/deprecate_tags.js rename to modules/actions/deprecate_tags.js index 5be03840f..228227567 100644 --- a/js/id/actions/deprecate_tags.js +++ b/modules/actions/deprecate_tags.js @@ -1,4 +1,4 @@ -iD.actions.DeprecateTags = function(entityId) { +module.exports = function(entityId) { return function(graph) { var entity = graph.entity(entityId), newtags = _.clone(entity.tags), diff --git a/js/id/actions/discard_tags.js b/modules/actions/discard_tags.js similarity index 91% rename from js/id/actions/discard_tags.js rename to modules/actions/discard_tags.js index a626c7323..662d79c07 100644 --- a/js/id/actions/discard_tags.js +++ b/modules/actions/discard_tags.js @@ -1,4 +1,4 @@ -iD.actions.DiscardTags = function(difference) { +module.exports = function(difference) { return function(graph) { function discardTags(entity) { if (!_.isEmpty(entity.tags)) { diff --git a/js/id/actions/disconnect.js b/modules/actions/disconnect.js similarity index 98% rename from js/id/actions/disconnect.js rename to modules/actions/disconnect.js index d038faeba..888877db1 100644 --- a/js/id/actions/disconnect.js +++ b/modules/actions/disconnect.js @@ -12,7 +12,7 @@ // https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/UnjoinNodeAction.as // https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/actions/UnGlueAction.java // -iD.actions.Disconnect = function(nodeId, newNodeId) { +module.exports = function(nodeId, newNodeId) { var wayIds; var action = function(graph) { diff --git a/modules/actions/index.js b/modules/actions/index.js new file mode 100644 index 000000000..943a836df --- /dev/null +++ b/modules/actions/index.js @@ -0,0 +1,33 @@ +module.exports.AddEntity = require('./add_entity'); +module.exports.AddMember = require('./add_member'); +module.exports.AddMidpoint = require('./add_midpoint'); +module.exports.AddVertex = require('./add_vertex'); +module.exports.ChangeMember = require('./change_member'); +module.exports.ChangePreset = require('./change_preset'); +module.exports.ChangeTags = require('./change_tags'); +module.exports.Circularize = require('./circularize'); +module.exports.Connect = require('./connect'); +module.exports.CopyEntities = require('./copy_entities'); +module.exports.DeleteMember = require('./delete_member'); +module.exports.DeleteMultiple = require('./delete_multiple'); +module.exports.DeleteNode = require('./delete_node'); +module.exports.DeleteRelation = require('./delete_relation'); +module.exports.DeleteWay = require('./delete_way'); +module.exports.DeprecateTags = require('./deprecate_tags'); +module.exports.DiscardTags = require('./discard_tags'); +module.exports.Disconnect = require('./disconnect'); +module.exports.Join = require('./join'); +module.exports.Merge = require('./merge'); +module.exports.MergePolygon = require('./merge_polygon'); +module.exports.MergeRemoteChanges = require('./merge_remote_changes'); +module.exports.Move = require('./move'); +module.exports.MoveNode = require('./move_node'); +module.exports.Noop = require('./noop'); +module.exports.Orthogonalize = require('./orthogonalize'); +module.exports.RestrictTurn = require('./restrict_turn'); +module.exports.Reverse = require('./reverse'); +module.exports.Revert = require('./revert'); +module.exports.RotateWay = require('./rotate_way'); +module.exports.Split = require('./split'); +module.exports.Straighten = require('./straighten'); +module.exports.UnrestrictTurn = require('./unrestrict_turn'); diff --git a/js/id/actions/join.js b/modules/actions/join.js similarity index 98% rename from js/id/actions/join.js rename to modules/actions/join.js index 250ad76f7..101d5ac0e 100644 --- a/js/id/actions/join.js +++ b/modules/actions/join.js @@ -6,7 +6,7 @@ // https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/MergeWaysAction.as // https://github.com/openstreetmap/josm/blob/mirror/src/org/openstreetmap/josm/actions/CombineWayAction.java // -iD.actions.Join = function(ids) { +module.exports = function(ids) { function groupEntitiesByGeometry(graph) { var entities = ids.map(function(id) { return graph.entity(id); }); diff --git a/js/id/actions/merge.js b/modules/actions/merge.js similarity index 97% rename from js/id/actions/merge.js rename to modules/actions/merge.js index 8d0880c15..2ac02c76e 100644 --- a/js/id/actions/merge.js +++ b/modules/actions/merge.js @@ -1,4 +1,4 @@ -iD.actions.Merge = function(ids) { +module.exports = function(ids) { function groupEntitiesByGeometry(graph) { var entities = ids.map(function(id) { return graph.entity(id); }); return _.extend({point: [], area: [], line: [], relation: []}, diff --git a/js/id/actions/merge_polygon.js b/modules/actions/merge_polygon.js similarity index 98% rename from js/id/actions/merge_polygon.js rename to modules/actions/merge_polygon.js index 66eda6e40..aaccb99cf 100644 --- a/js/id/actions/merge_polygon.js +++ b/modules/actions/merge_polygon.js @@ -1,4 +1,4 @@ -iD.actions.MergePolygon = function(ids, newRelationId) { +module.exports = function(ids, newRelationId) { function groupEntities(graph) { var entities = ids.map(function (id) { return graph.entity(id); }); diff --git a/js/id/actions/merge_remote_changes.js b/modules/actions/merge_remote_changes.js similarity index 99% rename from js/id/actions/merge_remote_changes.js rename to modules/actions/merge_remote_changes.js index f9cdab627..adb685fdc 100644 --- a/js/id/actions/merge_remote_changes.js +++ b/modules/actions/merge_remote_changes.js @@ -1,4 +1,4 @@ -iD.actions.MergeRemoteChanges = function(id, localGraph, remoteGraph, formatUser) { +module.exports = function(id, localGraph, remoteGraph, formatUser) { var option = 'safe', // 'safe', 'force_local', 'force_remote' conflicts = []; diff --git a/js/id/actions/move.js b/modules/actions/move.js similarity index 99% rename from js/id/actions/move.js rename to modules/actions/move.js index 9bb8477cf..48c311c44 100644 --- a/js/id/actions/move.js +++ b/modules/actions/move.js @@ -1,6 +1,6 @@ // 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(moveIds, tryDelta, projection, cache) { +module.exports = function(moveIds, tryDelta, projection, cache) { var delta = tryDelta; function vecAdd(a, b) { return [a[0] + b[0], a[1] + b[1]]; } diff --git a/js/id/actions/move_node.js b/modules/actions/move_node.js similarity index 87% rename from js/id/actions/move_node.js rename to modules/actions/move_node.js index 433242ff6..44b2a664a 100644 --- a/js/id/actions/move_node.js +++ b/modules/actions/move_node.js @@ -1,6 +1,6 @@ // 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.MoveNode = function(nodeId, loc) { +module.exports = function(nodeId, loc) { return function(graph) { return graph.replace(graph.entity(nodeId).move(loc)); }; diff --git a/js/id/actions/noop.js b/modules/actions/noop.js similarity index 66% rename from js/id/actions/noop.js rename to modules/actions/noop.js index b729fe0c0..cf0f1cb3f 100644 --- a/js/id/actions/noop.js +++ b/modules/actions/noop.js @@ -1,4 +1,4 @@ -iD.actions.Noop = function() { +module.exports = function() { return function(graph) { return graph; }; diff --git a/js/id/actions/orthogonalize.js b/modules/actions/orthogonalize.js similarity index 98% rename from js/id/actions/orthogonalize.js rename to modules/actions/orthogonalize.js index 7a13885a5..1e8a9bc1a 100644 --- a/js/id/actions/orthogonalize.js +++ b/modules/actions/orthogonalize.js @@ -2,7 +2,7 @@ * Based on https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/potlatch2/tools/Quadrilateralise.as */ -iD.actions.Orthogonalize = function(wayId, projection) { +module.exports = function(wayId, projection) { var threshold = 12, // degrees within right or straight to alter lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180), upperThreshold = Math.cos(threshold * Math.PI / 180); diff --git a/js/id/actions/restrict_turn.js b/modules/actions/restrict_turn.js similarity index 97% rename from js/id/actions/restrict_turn.js rename to modules/actions/restrict_turn.js index 67236c964..6d9260d99 100644 --- a/js/id/actions/restrict_turn.js +++ b/modules/actions/restrict_turn.js @@ -22,7 +22,7 @@ // Normally, this will be undefined and the relation will automatically // be assigned a new ID. // -iD.actions.RestrictTurn = function(turn, projection, restrictionId) { +module.exports = function(turn, projection, restrictionId) { return function(graph) { var from = graph.entity(turn.from.way), via = graph.entity(turn.via.node), diff --git a/js/id/actions/reverse.js b/modules/actions/reverse.js similarity index 98% rename from js/id/actions/reverse.js rename to modules/actions/reverse.js index 461b5d9ac..b811fb2d3 100644 --- a/js/id/actions/reverse.js +++ b/modules/actions/reverse.js @@ -29,7 +29,7 @@ http://wiki.openstreetmap.org/wiki/Route#Members http://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java */ -iD.actions.Reverse = function(wayId, options) { +module.exports = function(wayId, options) { var replacements = [ [/:right$/, ':left'], [/:left$/, ':right'], [/:forward$/, ':backward'], [/:backward$/, ':forward'] diff --git a/js/id/actions/revert.js b/modules/actions/revert.js similarity index 96% rename from js/id/actions/revert.js rename to modules/actions/revert.js index 3dbdca96c..3667a6582 100644 --- a/js/id/actions/revert.js +++ b/modules/actions/revert.js @@ -1,4 +1,4 @@ -iD.actions.Revert = function(id) { +module.exports = function(id) { var action = function(graph) { var entity = graph.hasEntity(id), diff --git a/js/id/actions/rotate_way.js b/modules/actions/rotate_way.js similarity index 91% rename from js/id/actions/rotate_way.js rename to modules/actions/rotate_way.js index 6a9548306..6738913db 100644 --- a/js/id/actions/rotate_way.js +++ b/modules/actions/rotate_way.js @@ -1,4 +1,4 @@ -iD.actions.RotateWay = function(wayId, pivot, angle, projection) { +module.exports = function(wayId, pivot, angle, projection) { return function(graph) { return graph.update(function(graph) { var way = graph.entity(wayId); diff --git a/js/id/actions/split.js b/modules/actions/split.js similarity index 99% rename from js/id/actions/split.js rename to modules/actions/split.js index 2e739a7b5..25829fcd4 100644 --- a/js/id/actions/split.js +++ b/modules/actions/split.js @@ -12,7 +12,7 @@ // Reference: // https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/SplitWayAction.as // -iD.actions.Split = function(nodeId, newWayIds) { +module.exports = function(nodeId, newWayIds) { var wayIds; // if the way is closed, we need to search for a partner node diff --git a/js/id/actions/straighten.js b/modules/actions/straighten.js similarity index 98% rename from js/id/actions/straighten.js rename to modules/actions/straighten.js index ea0190cb0..9a898fa11 100644 --- a/js/id/actions/straighten.js +++ b/modules/actions/straighten.js @@ -2,7 +2,7 @@ * Based on https://github.com/openstreetmap/potlatch2/net/systemeD/potlatch2/tools/Straighten.as */ -iD.actions.Straighten = function(wayId, projection) { +module.exports = function(wayId, projection) { function positionAlongWay(n, s, e) { return ((n[0] - s[0]) * (e[0] - s[0]) + (n[1] - s[1]) * (e[1] - s[1]))/ (Math.pow(e[0] - s[0], 2) + Math.pow(e[1] - s[1], 2)); diff --git a/js/id/actions/unrestrict_turn.js b/modules/actions/unrestrict_turn.js similarity index 94% rename from js/id/actions/unrestrict_turn.js rename to modules/actions/unrestrict_turn.js index f57186d7a..0809e4336 100644 --- a/js/id/actions/unrestrict_turn.js +++ b/modules/actions/unrestrict_turn.js @@ -16,7 +16,7 @@ // that restriction is also deleted, but at the same time restrictions on // the turns other than the first two are created. // -iD.actions.UnrestrictTurn = function(turn) { +module.exports = function(turn) { return function(graph) { return iD.actions.DeleteRelation(turn.restriction)(graph); }; diff --git a/package.json b/package.json index fb05d88cc..4149035a5 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ ], "license": "ISC", "devDependencies": { + "browserify": "13.0.1", "chai": "~1.9.2", "d3": "3.5.5", "editor-layer-index": "git://github.com/osmlab/editor-layer-index.git#gh-pages", diff --git a/test/index.html b/test/index.html index 24aa35963..eddd756ca 100644 --- a/test/index.html +++ b/test/index.html @@ -131,39 +131,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +