mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 01:33:03 +00:00
Move multiple elements
This commit is contained in:
@@ -132,7 +132,7 @@
|
||||
<script src='js/id/modes/browse.js'></script>
|
||||
<script src='js/id/modes/draw_area.js'></script>
|
||||
<script src='js/id/modes/draw_line.js'></script>
|
||||
<script src='js/id/modes/move_way.js'></script>
|
||||
<script src='js/id/modes/move.js'></script>
|
||||
<script src='js/id/modes/select.js'></script>
|
||||
|
||||
<script src='js/id/operations.js'></script>
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
iD.modes.MoveWay = function(context, wayId) {
|
||||
iD.modes.Move = function(context, entityIDs) {
|
||||
var mode = {
|
||||
id: 'move-way',
|
||||
id: 'move',
|
||||
button: 'browse'
|
||||
};
|
||||
|
||||
var keybinding = d3.keybinding('move-way');
|
||||
var keybinding = d3.keybinding('move'),
|
||||
entities = entityIDs.map(context.entity);
|
||||
|
||||
mode.enter = function() {
|
||||
var origin,
|
||||
nudgeInterval,
|
||||
annotation = t('operations.move.annotation.' + context.geometry(wayId));
|
||||
annotation = entities.length === 1 ?
|
||||
t('operations.move.annotation.' + context.geometry(entities[0].id)) :
|
||||
t('operations.move.annotation.multiple');
|
||||
|
||||
context.perform(
|
||||
iD.actions.Noop(),
|
||||
@@ -54,19 +57,29 @@ iD.modes.MoveWay = function(context, wayId) {
|
||||
|
||||
origin = context.map().mouseCoordinates();
|
||||
|
||||
context.replace(
|
||||
iD.actions.MoveWay(wayId, delta, context.projection),
|
||||
annotation);
|
||||
entities.forEach(function(entity) {
|
||||
if (entity.type === 'way') {
|
||||
context.replace(
|
||||
iD.actions.MoveWay(entity.id, delta, context.projection));
|
||||
} else if (entity.type === 'node') {
|
||||
var start = context.projection(context.entity(entity.id).loc),
|
||||
end = [start[0] + delta[0], start[1] + delta[1]],
|
||||
loc = context.projection.invert(end);
|
||||
context.replace(iD.actions.MoveNode(entity.id, loc));
|
||||
}
|
||||
});
|
||||
|
||||
context.replace(iD.actions.Noop(), annotation);
|
||||
}
|
||||
|
||||
function finish() {
|
||||
d3.event.stopPropagation();
|
||||
context.enter(iD.modes.Select(context, [wayId], true));
|
||||
context.enter(iD.modes.Select(context, entityIDs, true));
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
context.pop();
|
||||
context.enter(iD.modes.Select(context, [wayId], true));
|
||||
context.enter(iD.modes.Select(context, entityIDs, true));
|
||||
}
|
||||
|
||||
function undone() {
|
||||
@@ -74,11 +87,11 @@ iD.modes.MoveWay = function(context, wayId) {
|
||||
}
|
||||
|
||||
context.surface()
|
||||
.on('mousemove.move-way', move)
|
||||
.on('click.move-way', finish);
|
||||
.on('mousemove.move', move)
|
||||
.on('click.move', finish);
|
||||
|
||||
context.history()
|
||||
.on('undone.move-way', undone);
|
||||
.on('undone.move', undone);
|
||||
|
||||
keybinding
|
||||
.on('⎋', cancel)
|
||||
@@ -90,11 +103,11 @@ iD.modes.MoveWay = function(context, wayId) {
|
||||
|
||||
mode.exit = function() {
|
||||
context.surface()
|
||||
.on('mousemove.move-way', null)
|
||||
.on('click.move-way', null);
|
||||
.on('mousemove.move', null)
|
||||
.on('click.move', null);
|
||||
|
||||
context.history()
|
||||
.on('undone.move-way', null);
|
||||
.on('undone.move', null);
|
||||
|
||||
keybinding.off();
|
||||
};
|
||||
@@ -1,13 +1,12 @@
|
||||
iD.operations.Move = function(selection, context) {
|
||||
var entityId = selection[0];
|
||||
|
||||
var operation = function() {
|
||||
context.enter(iD.modes.MoveWay(context, entityId));
|
||||
context.enter(iD.modes.Move(context, selection));
|
||||
};
|
||||
|
||||
operation.available = function() {
|
||||
return selection.length === 1 &&
|
||||
context.entity(entityId).type === 'way';
|
||||
return selection.length > 1 ||
|
||||
context.entity(selection[0]).type === 'way';
|
||||
};
|
||||
|
||||
operation.enabled = function() {
|
||||
|
||||
@@ -111,7 +111,8 @@ locale.en = {
|
||||
point: "Moved a point.",
|
||||
vertex: "Moved a node in a way.",
|
||||
line: "Moved a line.",
|
||||
area: "Moved an area."
|
||||
area: "Moved an area.",
|
||||
multiple: "Moved multiple objects"
|
||||
}
|
||||
},
|
||||
reverse: {
|
||||
@@ -221,7 +222,7 @@ locale.en = {
|
||||
},
|
||||
|
||||
zoom: {
|
||||
in: "Zoom In",
|
||||
'in': "Zoom In",
|
||||
out: "Zoom Out"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
<script src='../js/id/modes/browse.js'></script>
|
||||
<script src='../js/id/modes/draw_area.js'></script>
|
||||
<script src='../js/id/modes/draw_line.js'></script>
|
||||
<script src='../js/id/modes/move_way.js'></script>
|
||||
<script src='../js/id/modes/move.js'></script>
|
||||
<script src='../js/id/modes/select.js'></script>
|
||||
|
||||
<script src='../js/id/operations.js'></script>
|
||||
|
||||
Reference in New Issue
Block a user