mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-24 09:04:02 +02:00
69d95a6082
They're something distinct from actions. Actions are independent of UI, operations are actions + UI (title, keybinding, modality, etc.)
35 lines
929 B
JavaScript
35 lines
929 B
JavaScript
iD.operations.Circular = function(entityId, mode) {
|
|
var action = iD.actions.Circular(entityId, mode.map);
|
|
|
|
var operation = function(history) {
|
|
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(graph) {
|
|
var entity = graph.entity(entityId);
|
|
return entity.geometry(graph) === 'area' || entity.geometry(graph) === 'line';
|
|
};
|
|
|
|
operation.enabled = function(graph) {
|
|
return action.enabled(graph);
|
|
};
|
|
|
|
operation.id = "circular";
|
|
operation.title = "Circular";
|
|
|
|
return operation;
|
|
};
|