Files
iD/js/id/operations/circularize.js
2013-01-30 19:09:10 -05:00

40 lines
1.1 KiB
JavaScript

iD.operations.Circularize = function(entityId, mode) {
var history = mode.map.history(),
action = iD.actions.Circularize(entityId, mode.map);
var operation = function() {
var graph = history.graph(),
entity = graph.entity(entityId),
geometry = entity.geometry(graph);
if (geometry === 'line') {
history.perform(
action,
'Made a line circular.');
} else if (geometry === 'area') {
history.perform(
action,
'Made an area circular.');
}
};
operation.available = function() {
var graph = history.graph(),
entity = graph.entity(entityId);
return entity.geometry(graph) === 'area' || entity.geometry(graph) === 'line';
};
operation.enabled = function() {
var graph = history.graph();
return action.enabled(graph);
};
operation.id = "circularize";
operation.key = "O";
operation.title = "Circularize";
operation.description = "Make this round";
return operation;
};