Files
iD/js/id/operations/rotate.js
T
Bryan Housel 874a3e2ad6 disable Move and Rotate operations if area < 80% contained in the viewport
see #542.
Also included:
1. DRY up code for "% contained in" extent testing.
2. If action.disabled() returns a better reason, show that instead of the too_large one.
2014-07-11 17:11:50 -04:00

43 lines
1.2 KiB
JavaScript

iD.operations.Rotate = function(selectedIDs, context) {
var entityId = selectedIDs[0],
entity = context.entity(entityId),
extent = entity.extent(context.graph()),
geometry = context.geometry(entityId);
var operation = function() {
context.enter(iD.modes.RotateWay(context, entityId));
};
operation.available = function() {
if (selectedIDs.length !== 1 || entity.type !== 'way')
return false;
if (geometry === 'area')
return true;
if (entity.isClosed() &&
context.graph().parentRelations(entity).some(function(r) { return r.isMultipolygon(); }))
return true;
return false;
};
operation.disabled = function() {
if (extent.percentContainedIn(context.extent()) < 0.8) {
return 'too_large';
} else {
return false;
}
};
operation.tooltip = function() {
var disable = operation.disabled();
return disable ?
t('operations.rotate.' + disable) :
t('operations.rotate.description');
};
operation.id = 'rotate';
operation.keys = [t('operations.rotate.key')];
operation.title = t('operations.rotate.title');
return operation;
};