Files
iD/js/id/modes/add_point.js
T
John Firebaugh ff15aa8e7b Rewrite d3.keybinding
A keybinding now represents a set of key commands that can
be unbound as a set. Multiple keybindings are possible, and,
providing a namespace is provided to the constructor, will
not conflict with each other.

Also, key combination strings such as ⌘+A are now supported.
2013-01-22 14:55:08 -05:00

43 lines
1.0 KiB
JavaScript

iD.modes.AddPoint = function() {
var mode = {
id: 'add-point',
title: 'Point',
description: 'Restaurants, monuments, and postal boxes are points.'
};
var keybinding = d3.keybinding('add-point');
mode.enter = function() {
var map = mode.map,
history = mode.history,
controller = mode.controller;
map.tail('Click on the map to add a point.');
map.surface.on('click.addpoint', function() {
var node = iD.Node({loc: map.mouseCoordinates(), _poi: true});
history.perform(
iD.actions.AddNode(node),
'added a point');
controller.enter(iD.modes.Select(node, true));
});
keybinding.on('⎋', function() {
controller.exit();
});
d3.select(document)
.call(keybinding);
};
mode.exit = function() {
mode.map.tail(false);
mode.map.surface.on('click.addpoint', null);
keybinding.off();
};
return mode;
};