From 33ddd283a806f5d4a995e2dba3aeeaac22069afa Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 26 Oct 2012 11:42:40 -0400 Subject: [PATCH] Add license, reduce underscore dep, update readme --- LICENSE | 13 +++++ README.md | 54 +++++++++++++------- index.html | 1 - js/iD/Relation.js | 6 +-- js/iD/Way.js | 6 +-- js/iD/controller/edit/EditBaseState.js | 71 -------------------------- 6 files changed, 54 insertions(+), 97 deletions(-) create mode 100644 LICENSE delete mode 100644 js/iD/controller/edit/EditBaseState.js diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..7d45cdc71 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2011 Richard Fairhurst + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/README.md b/README.md index 1fc4c14bf..b2b50dd98 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,24 @@ iD - friendly JavaScript editor for OpenStreetMap Basics ------ -* iD is a JavaScript-based OpenStreetMap editor with MapCSS rendering. -* iD is written with the Dojo framework. -* It's intentionally simple. iD is not a 90% editor. It's not even a 70% editor. It should let you do the most basic tasks while not breaking other people's data. Nothing more. (Same goes for the code, so go easy on the abstraction. :) ) +* iD is a JavaScript-based [OpenStreetMap](http://www.openstreetmap.us/) editor. +* It's intentionally simple. This is not a 90% editor - + not even a 70% editor. It should let you do the most basic tasks while + not breaking other people's data. Nothing more. (Same goes for the code, + so go easy on the abstraction. :) ) * Speaking of percentages, it's about 1% complete. -* We're initially targeting WebKit-based browsers and Firefox, using SVG. IE and non-SVG can come later! -* The licence of iD is WTFPL, though obviously, if you want to dual-license any contributions that's cool. +* The licence of iD is [WTFPL](http://sam.zoy.org/wtfpl/), though obviously, if you want to dual-license + any contributions that's cool. +Architecture +------------ + +* iD uses [d3js](http://d3js.org/) for graphics & managing databindings to the + map. There's a tiny tiled-map core, but the majority of the action is in + dynamic rendering of the editable map data. +* This project aims to create a usable object model of [OpenStreetMap data](http://wiki.openstreetmap.org/wiki/Tags) + in Javascript that can be transformed by actions and serialized back into + [changesets](http://wiki.openstreetmap.org/wiki/Changeset) Getting started --------------- @@ -20,34 +31,39 @@ Getting started How it works ------------ -The code works similarly to Potlatch 2, but with a bit less abstraction. So, we have: +The code works similarly to [Potlatch 2](http://wiki.openstreetmap.org/wiki/Potlatch_2), +but with a bit less abstraction. So, we have: * Connection: stores, fetches and saves data. (iD/Connection.js) * Entity (Node, Way, Relation): the data objects. (iD/Entity.js) * EntityUI (NodeUI, WayUI): the rendered graphic elements. (iD/renderer/...) * Map: the displayed map on which EntityUIs are rendered. (iD/renderer/Map.js) * Controller: the heart of the app, which does its work via... -* ControllerState: the current UI mode. ControllerStates decide what to do in response to mouse/keyboard events. (iD/controller/...) -* UndoableAction: the code to actually change the data, as fired by ControllerStates. (iD/actions/...) +* ControllerState: the current UI mode. ControllerStates decide what to do in + response to mouse/keyboard events. (iD/controller/...) +* UndoableAction: the code to actually change the data, as fired by + ControllerStates. (iD/actions/...) -The UI is much more modal than Potlatch 2. In particular there's a "draw shape" mode (the "Add road or shape" button) and an "edit object" mode. The directory structure of iD/controller reflects this. +The UI is much more modal than Potlatch 2. In particular there's a "draw shape" +mode (the "Add road or shape" button) and an "edit object" mode. The directory +structure of iD/controller reflects this. -Other relevant code includes the MapCSS parser in styleparser/ and custom widgets in ui/ . - -As well as the [live docs](http://www.geowiki.com/docs/), you'll find various notes and comments in the docs/ folder. Feel free to add to these. +As well as the [live docs](http://www.geowiki.com/docs/), you'll find +various notes and comments in the docs/ folder. Feel free to add to these. Getting started --------------- -Most of the interesting code is in the ControllerStates, which live in iD/controller/. Each one corresponds to a UI mode (e.g. "drawing a way"). Its EntityMouseEvent method takes the user's mouse event (e.g. "clicked on a node"), carries out any actions, and returns the new ControllerState (which might just be 'this', i.e. carry on with the current state). +Most of the interesting code is in the ControllerStates, which live in +iD/controller/. Each one corresponds to a UI mode (e.g. "drawing a way"). +Its EntityMouseEvent method takes the user's mouse event (e.g. "clicked on +a node"), carries out any actions, and returns the new ControllerState +(which might just be 'this', i.e. carry on with the current state). Coding tips ----------- -Scoping in JavaScript is famously broken: Dojo's lang.hitch method will save your life. Make sure you include dojo/_base/lang (in the 'declare' statement). Then, when you're passing an instance method as a function parameter, use lang.hitch(instance, instance.method) instead, and Dojo will magically set the right scope. You'll see lots of examples of this throughout the code. -Instance methods and variables _always_ need to be accessed with 'this.'. This is a fairly frequent gotcha if you're coming from another language. - -The [Dojo site](http://dojotoolkit.org/) has lots of documentation. iD currently uses Dojo 1.8 - this has a much better module architecture (AMD) than previously. - -Come on in, the water's lovely. More help? Ping RichardF on IRC (irc.oftc.net, in #osm-dev or #osm), on the OSM mailing lists or at richard@systemeD.net. +Come on in, the water's lovely. More help? Ping RichardF on IRC +(irc.oftc.net, in #osm-dev or #osm), on the OSM mailing lists or at +richard@systemeD.net. diff --git a/index.html b/index.html index f3f3bfc6a..8f52a4b63 100755 --- a/index.html +++ b/index.html @@ -18,7 +18,6 @@ - diff --git a/js/iD/Relation.js b/js/iD/Relation.js index e48c53c9f..b06402ce6 100644 --- a/js/iD/Relation.js +++ b/js/iD/Relation.js @@ -9,9 +9,9 @@ iD.Relation = function(connection, id, members, tags, loaded) { this.tags = tags; this.modified = this.id < 0; this.loaded = (loaded === undefined) ? true : loaded; - _.each(members, _.bind(function(member) { - member.entity.entity.addParent(this); - }, this)); + for (var i = 0; i < members.length; i++) { + members[i].entity.entity.addParent(this); + } }; iD.RelationMember = function(entity, role) { diff --git a/js/iD/Way.js b/js/iD/Way.js index 54230e8f1..02aa62c58 100644 --- a/js/iD/Way.js +++ b/js/iD/Way.js @@ -13,9 +13,9 @@ iD.Way = function(connection, id, nodes, tags, loaded) { this.modified = this.id < 0; this.nodes = nodes || []; this.extent = {}; - _.each(nodes, _.bind(function(node) { - node.entity.addParent(this); - }, this)); + for (var i = 0; i < nodes.length; i++) { + nodes[i].entity.addParent(this); + } }; iD.Way.prototype = { diff --git a/js/iD/controller/edit/EditBaseState.js b/js/iD/controller/edit/EditBaseState.js deleted file mode 100644 index 0af0e5fd3..000000000 --- a/js/iD/controller/edit/EditBaseState.js +++ /dev/null @@ -1,71 +0,0 @@ -// ---------------------------------------------------------------------- -// EditBaseState class - provides shared UI functions to edit mode states - -iD.controller.edit.EditBaseState = function() {}; -iD.controller.edit.EditBaseState.prototype = { - - editortooltip: null, - - constructor: function() { - // summary: Base state for the 'Edit object' states - where an - // object is selected and the user is making changes to it. - }, - - openEditorTooltip: function(entity) { - // summary: Open the initial 'Edit tags/Edit shape' tooltip. - // entity: iD.Entity The entity to be edited. - $('.edit-pane h2').text(iD.Util.friendlyName(entity)); - $('.edit-pane').show().addClass('active'); - /* - var $presets = $('.edit-pane .presets'); - // Build presets panel - iD.Util.presets(entity.entityType, function(presets) { - $presets.empty(); - _.each(presets, function(pre, category) { - $('

') - .text(category) - .appendTo($presets); - _.each(pre, function(set) { - var a = $('') - .text(set.name) - .attr({ - 'class': 'preset-option', - 'href': '#' - }) - .appendTo($presets); - $('') - .text(set.description) - .appendTo(a); - }); - }); - }); - */ - - // Build tag panel - $('.edit-pane .tags tbody').empty(); - _.each(entity.tags, function(value, key) { - var tr = $('').appendTo( - $('.edit-pane .tags tbody')); - var keyfield = $('') - .attr({ - type: 'text' - }) - .val(key); - var valuefield = $('') - .attr({ - type: 'text' - }) - .val(value); - $('').append(keyfield).appendTo(tr); - $('').append(valuefield).appendTo(tr); - }); - - $('.edit-pane a[href=#close]').click(this.closeEditorTooltip); - }, - - closeEditorTooltip: function(e) { - if (e) e.preventDefault(); - // summary: Close the tooltip. - $('.edit-pane').removeClass('active').hide(); - } -};