Files
iD/js/id/modes/add_point.js
T
Tom MacWright 811187620d jshint fixes
2012-12-18 10:47:32 -05:00

41 lines
1.1 KiB
JavaScript

iD.modes.AddPoint = function() {
var mode = {
id: 'add-point',
title: 'Point',
description: 'Restaurants, monuments, and postal boxes are points.'
};
mode.enter = function() {
d3.select('#map').attr('class', function() { return mode.id; });
var map = mode.map,
history = mode.history,
controller = mode.controller;
map.hint('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));
});
map.keybinding().on('⎋.addpoint', function() {
controller.exit();
});
};
mode.exit = function() {
mode.map.hint(false);
mode.map.surface.on('click.addpoint', null);
mode.map.keybinding().on('⎋.addpoint', null);
d3.select('#map').attr('class', null);
};
return mode;
};