From 87950fd47219bac085eda11f7e769c918525c6ff Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 4 Oct 2016 21:55:50 -0400 Subject: [PATCH] Fix lib export, flatten names in tests and docs --- API.md | 10 +- ARCHITECTURE.md | 34 ++-- CHANGELOG.md | 2 +- NOTES.md | 2 +- index.html | 8 +- modules/actions/circularize.js | 2 +- modules/index.js | 6 +- modules/ui/fields/index.js | 14 ++ test/rendering.html | 28 ++-- test/spec/actions/add_entity.js | 4 +- test/spec/actions/add_member.js | 14 +- test/spec/actions/add_midpoint.js | 10 +- test/spec/actions/change_member.js | 4 +- test/spec/actions/change_preset.js | 12 +- test/spec/actions/change_tags.js | 4 +- test/spec/actions/circularize.js | 30 ++-- test/spec/actions/connect.js | 18 +- test/spec/actions/copy_entities.js | 12 +- test/spec/actions/delete_member.js | 6 +- test/spec/actions/delete_multiple.js | 8 +- test/spec/actions/delete_node.js | 14 +- test/spec/actions/delete_relation.js | 24 +-- test/spec/actions/delete_way.js | 26 +-- test/spec/actions/discard_tags.js | 10 +- test/spec/actions/disconnect.js | 34 ++-- test/spec/actions/join.js | 58 +++---- test/spec/actions/merge.js | 6 +- test/spec/actions/merge_polygon.js | 32 ++-- test/spec/actions/merge_remote_changes.js | 56 +++---- test/spec/actions/move.js | 16 +- test/spec/actions/move_node.js | 4 +- test/spec/actions/noop.js | 4 +- test/spec/actions/orthogonalize.js | 20 +-- test/spec/actions/restrict_turn.js | 42 ++--- test/spec/actions/reverse.js | 56 +++---- test/spec/actions/revert.js | 28 ++-- test/spec/actions/split.js | 62 +++---- test/spec/actions/straighten.js | 14 +- test/spec/actions/unrestrict_turn.js | 4 +- test/spec/behavior/hash.js | 6 +- test/spec/behavior/hover.js | 20 +-- test/spec/behavior/lasso.js | 6 +- test/spec/behavior/select.js | 20 +-- test/spec/core/history.js | 10 +- test/spec/core/relation.js | 2 +- test/spec/core/tree.js | 36 ++-- test/spec/geo/extent.js | 148 ++++++++--------- test/spec/geo/geo.js | 190 +++++++++++----------- test/spec/geo/intersection.js | 56 +++---- test/spec/geo/multipolygon.js | 26 +-- test/spec/modes/add_point.js | 6 +- test/spec/presets/category.js | 8 +- test/spec/presets/collection.js | 30 ++-- test/spec/presets/preset.js | 58 +++---- test/spec/presets/presets.js | 8 +- test/spec/renderer/map.js | 2 +- test/spec/services/mapillary.js | 34 ++-- test/spec/services/nominatim.js | 10 +- test/spec/services/taginfo.js | 6 +- test/spec/svg/areas.js | 30 ++-- test/spec/svg/icon.js | 6 +- test/spec/svg/layers.js | 8 +- test/spec/svg/lines.js | 24 +-- test/spec/svg/midpoints.js | 22 +-- test/spec/svg/osm.js | 4 +- test/spec/svg/points.js | 4 +- test/spec/svg/svg.js | 6 +- test/spec/svg/tag_classes.js | 58 +++---- test/spec/svg/vertices.js | 4 +- test/spec/ui/cmd.js | 24 +-- test/spec/ui/confirm.js | 6 +- test/spec/ui/fields/access.js | 26 +-- test/spec/ui/fields/localized.js | 40 ++--- test/spec/ui/fields/wikipedia.js | 48 +++--- test/spec/ui/flash.js | 4 +- test/spec/ui/inspector.js | 2 +- test/spec/ui/modal.js | 4 +- test/spec/ui/raw_tag_editor.js | 6 +- test/spec/util/session_mutex.js | 30 ++-- test/spec/util/suggest_names.js | 4 +- test/spec/util/util.js | 48 +++--- 81 files changed, 923 insertions(+), 905 deletions(-) diff --git a/API.md b/API.md index ef19df429..f25d6c4e6 100644 --- a/API.md +++ b/API.md @@ -96,7 +96,7 @@ have `.area` and `.way` classes. Elements also receive classes according to certain of the OSM key-value tags that are assigned to them. -Tag classes are prefixed with `tag-` (see [`iD.svg.TagClasses`](https://github.com/openstreetmap/iD/blob/master/js/id/svg/tag_classes.js) for details). +Tag classes are prefixed with `tag-` (see [`iD.svgTagClasses`](https://github.com/openstreetmap/iD/blob/master/js/id/svg/tag_classes.js) for details). #### Primary @@ -150,8 +150,8 @@ iD can use external presets exclusively or along with the default OpenStreetMap var id = iD.Context(window) .presets(customPresets) - .taginfo(iD.services.taginfo()) - .imagery(iD.data.imagery); + .taginfo(iD.serviceTaginfo()) + .imagery(iD.dataImagery); ``` @@ -165,7 +165,7 @@ Just like Presets, Imagery can be configured using the `context.imagery` accesso var id = iD.Context(window) .presets(customPresets) - .taginfo(iD.services.taginfo()) + .taginfo(iD.serviceTaginfo()) .imagery(customImagery); ``` @@ -181,7 +181,7 @@ The Imagery object should follow the structure defined by [editor-layer-index](h var id = iD.Context(window) .presets(customPresets) - .taginfo(iD.services.taginfo().endpoint('url')) + .taginfo(iD.serviceTaginfo().endpoint('url')) .imagery(customImagery); ``` diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 56279ae3f..6de3f9a2a 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -129,21 +129,21 @@ var tree = iD.Tree(graph); // quickly pull all features that intersect with an extent var features = tree.intersects( - iD.geo.Extent([0, 0], [2, 2]), tree.graph()); + iD.geoExtent([0, 0], [2, 2]), tree.graph()); ``` ## Actions In iD, an _action_ is a function that accepts a graph as input and returns a new, modified graph as output. Actions typically need other inputs as well; for -example, `iD.actions.DeleteNode` also requires the ID of a node to delete. The +example, `iD.actionDeleteNode` also requires the ID of a node to delete. The additional input is passed to the action's constructor: ```js // construct the action: this returns a function that remembers the // value `n123456` in a closure so that when it's called, it runs // the specified action on the graph -var action = iD.actions.DeleteNode('n123456'); +var action = iD.actionDeleteNode('n123456'); // apply the action, yielding a new graph. oldGraph is untouched. newGraph = action(oldGraph); @@ -184,10 +184,10 @@ around the map and select and edit entities, and three geometrically-oriented drawing modes, which are accessible through the mode buttons in the upper toolbar: Point, Line, and Area. In the code, these are broken down a little bit more. There are separate modes for when an entity is selected -(`iD.modes.Select`) versus when nothing is selected (`iD.modes.Browse`), and +(`iD.modeSelect`) versus when nothing is selected (`iD.modeBrowse`), and each of the geometric modes is split into one mode for starting to draw an object and one mode for continuing an existing object (with the exception of -`iD.modes.AddPoint`, which is a single-step operation for obvious reasons). +`iD.modeAddPoint`, which is a single-step operation for obvious reasons). The code interface for each mode consists of a pair of methods: `enter` and `exit`. In the `enter` method, a mode sets up all the behavior that should be @@ -205,7 +205,7 @@ Certain behaviors are common to more than one mode. For example, iD indicates interactive map elements by drawing a halo around them when you hover over them, and this behavior is common to both the browse and draw modes. Instead of duplicating the code to implement this behavior in all these modes, we -extract it to `iD.behavior.Hover`. +extract it to `iD.behaviorHover`. _Behaviors_ take their inspiration from [d3's behaviors](https://github.com/mbostock/d3/wiki/Behaviors). Like d3's `zoom` @@ -247,8 +247,8 @@ conditions under which it is enabled. To execute an operation, call it as a function, with no arguments. The typical operation will perform the appropriate action, creating a new undo state in the history, and then enter the appropriate mode. For example, -`iD.operations.Split` performs `iD.actions.Split`, then enters -`iD.modes.Select` with the resulting ways selected. +`iD.operationSplit` performs `iD.actionSplit`, then enters +`iD.modeSelect` with the resulting ways selected. ## Map Rendering @@ -270,7 +270,7 @@ entity types of the OSM data model: or more ways grouped in a multipolygon relation. For each of these geometric types, `iD.svg` has a corresponding module: -`iD.svg.Points`, `iD.svg.Vertices`, `iD.svg.Lines`, and `iD.svg.Areas`. To +`iD.svgPoints`, `iD.svgVertices`, `iD.svgLines`, and `iD.svgAreas`. To render entities on screen, `iD.Map` delegates to these modules. Internally, they make heavy use of [d3 joins](http://bost.ocks.org/mike/join/) to manipulate the SVG elements that visually represent the map entities. When an @@ -282,7 +282,7 @@ are updated. And when an entity is deleted (or simply moves offscreen), the corresponding SVG element is in the _exit_ selection, and will be removed. The `iD.svg` modules apply classes to the SVG elements based on the entity -tags, via `iD.svg.TagClasses`. For example, an entity tagged with +tags, via `iD.svgTagClasses`. For example, an entity tagged with `highway=residential` gets two classes: `tag-highway` and `tag-highway-residential`. This allows distinct visual styles to be applied via CSS at either the key or key-value levels. SVG elements also receive a @@ -292,11 +292,11 @@ one corresponding to their geometry type (`point`, `line`, or `area`). The `iD.svg` namespace has a few other modules that don't have a one-to-one correspondence with entities: -* `iD.svg.Midpoints` renders the small "virtual node" at the midpoint between +* `iD.svgMidpoints` renders the small "virtual node" at the midpoint between two vertices. -* `iD.svg.Labels` renders the textual +* `iD.svgLabels` renders the textual [labels](http://mapbox.com/osmdev/2013/02/12/labeling-id/). -* `iD.svg.Layers` sets up a number of layers that ensure that map elements +* `iD.svgLayers` sets up a number of layers that ensure that map elements appear in an appropriate z-order. ## Other UI @@ -312,7 +312,7 @@ The implementations for all non-map UI components live in the `iD.ui` namespace. Many of the modules in this namespace follow a pattern for reusable d3 components [originally suggested](http://bost.ocks.org/mike/chart/) by Mike Bostock in the context of charts. The entry point to a UI element is a -constructor function, e.g. `iD.ui.Geocoder()`. The constructor function may +constructor function, e.g. `iD.uiGeocoder()`. The constructor function may require a set of mandatory arguments; for most UI components exactly one argument is required, a `context` object produced by the top-level `iD()` function. @@ -326,7 +326,7 @@ render itself: var container = d3.select('body').append('div') .attr('class', 'map-control geocode-control'); -var geocoder = iD.ui.Geocoder(context)(container); +var geocoder = iD.uiGeocoder(context)(container); ``` Alternatively, and more commonly, the same result is accomplished with @@ -335,7 +335,7 @@ Alternatively, and more commonly, the same result is accomplished with ``` d3.select('body').append('div') .attr('class', 'map-control geocode-control') - .call(iD.ui.Geocoder(context)); + .call(iD.uiGeocoder(context)); ``` Some components are reconfigurable, and some provide functionality beyond @@ -343,7 +343,7 @@ basic rendering. Both reconfiguration and extended functionality are exposed via module functions: ``` -var inspector = iD.ui.Inspector(); +var inspector = iD.uiInspector(); inspector(container); // render the inspector inspector.tags(); // retrieve the current tags inspector.on('change', callback); // get notified when a tag change is made diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d60de5b0..4a9c9b026 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,7 +124,7 @@ * Add ability to remove/disable Mapillary layers (#2722) * Add expansion arrows to category presets for better usability (#2972, thanks @kepta) * Refactor services into iD.services namespace - * :warning: This means that `iD.taginfo` is now `iD.services.taginfo` + * :warning: This means that `iD.taginfo` is now `iD.serviceTaginfo` * Disallow disconnecting that would damage relations (#1714, thanks @jfirebaugh) * Allow escape to cancel ⌘-V paste (#2889) * Enter should accept input and return to browse mode only on preset input fields (#2912, #2957, #2380) diff --git a/NOTES.md b/NOTES.md index 2a7494163..442aa606b 100644 --- a/NOTES.md +++ b/NOTES.md @@ -75,7 +75,7 @@ reverting to the previous version. The persistent data structure approach also takes advantage of the fact that the typical change modifies only a small portion of the graph. The unchanged majority of the graph is shared between revisions, -keeping memory use to a minimum. For example, the `iD.actions.RemoveWayNode` action removes a single +keeping memory use to a minimum. For example, the `iD.actionRemoveWayNode` action removes a single node from a way. It produces new versions of three objects: * The Array of nodes in the way. diff --git a/index.html b/index.html index 11f315d78..7e95fd5c3 100644 --- a/index.html +++ b/index.html @@ -18,16 +18,16 @@