Files
iD/js/id/operations/delete.js
John Firebaugh 7e68e8e114 Add iD.Context
This is a facade interface that ties together a bunch of
different internal objects and will make it easier to write
tests for behaviors, modes, and operations.
2013-02-01 12:40:15 -05:00

31 lines
922 B
JavaScript

iD.operations.Delete = function(selection, context) {
var entityId = selection[0];
var operation = function() {
var entity = context.entity(entityId),
action = {way: iD.actions.DeleteWay, node: iD.actions.DeleteNode}[entity.type],
annotation = t('operations.delete.annotation.' + context.geometry(entityId));
context.perform(
action(entityId),
annotation);
};
operation.available = function() {
var entity = context.entity(entityId);
return selection.length === 1 &&
(entity.type === 'way' || entity.type === 'node');
};
operation.enabled = function() {
return true;
};
operation.id = "delete";
operation.key = t('operations.delete.key');
operation.title = t('operations.delete.title');
operation.description = t('operations.delete.description');
return operation;
};