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