mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 13:38:26 +02:00
ff15aa8e7b
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.
43 lines
1.0 KiB
JavaScript
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;
|
|
};
|