mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-19 23:14:47 +02:00
external modules for modes
This commit is contained in:
@@ -44,7 +44,6 @@ $(BUILDJS_TARGETS): $(BUILDJS_SOURCES) build.js
|
||||
|
||||
MODULE_TARGETS = \
|
||||
js/lib/id/index.js \
|
||||
js/lib/id/modes.js \
|
||||
js/lib/id/operations.js \
|
||||
js/lib/id/presets.js \
|
||||
js/lib/id/renderer.js \
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
<script src='js/lib/id/index.js'></script>
|
||||
|
||||
<script src='js/lib/id/modes.js'></script>
|
||||
<script src='js/lib/id/operations.js'></script>
|
||||
<script src='js/lib/id/presets.js'></script>
|
||||
<script src='js/lib/id/renderer.js'></script>
|
||||
|
||||
+2315
-36
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -1,6 +1,7 @@
|
||||
import * as actions from './actions/index';
|
||||
import * as geo from './geo/index';
|
||||
import * as behavior from './behavior/index';
|
||||
import * as modes from './modes/index';
|
||||
|
||||
export { Connection } from './core/connection';
|
||||
export { Difference } from './core/difference';
|
||||
@@ -16,5 +17,6 @@ export { Way } from './core/way';
|
||||
export {
|
||||
actions,
|
||||
geo,
|
||||
behavior
|
||||
behavior,
|
||||
modes
|
||||
};
|
||||
|
||||
+25
-21
@@ -1,3 +1,7 @@
|
||||
import { AddWay } from '../behavior/index';
|
||||
import { Node, Way } from '../core/index';
|
||||
import { DrawArea } from './index';
|
||||
import { AddEntity, AddVertex, AddMidpoint } from '../actions/index';
|
||||
export function AddArea(context) {
|
||||
var mode = {
|
||||
id: 'add-area',
|
||||
@@ -7,7 +11,7 @@ export function AddArea(context) {
|
||||
key: '3'
|
||||
};
|
||||
|
||||
var behavior = iD.behavior.AddWay(context)
|
||||
var behavior = AddWay(context)
|
||||
.tail(t('modes.add_area.tail'))
|
||||
.on('start', start)
|
||||
.on('startFromWay', startFromWay)
|
||||
@@ -16,43 +20,43 @@ export function AddArea(context) {
|
||||
|
||||
function start(loc) {
|
||||
var graph = context.graph(),
|
||||
node = iD.Node({loc: loc}),
|
||||
way = iD.Way({tags: defaultTags});
|
||||
node = Node({loc: loc}),
|
||||
way = Way({tags: defaultTags});
|
||||
|
||||
context.perform(
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
AddEntity(node),
|
||||
AddEntity(way),
|
||||
AddVertex(way.id, node.id),
|
||||
AddVertex(way.id, node.id));
|
||||
|
||||
context.enter(iD.modes.DrawArea(context, way.id, graph));
|
||||
context.enter(DrawArea(context, way.id, graph));
|
||||
}
|
||||
|
||||
function startFromWay(loc, edge) {
|
||||
var graph = context.graph(),
|
||||
node = iD.Node({loc: loc}),
|
||||
way = iD.Way({tags: defaultTags});
|
||||
node = Node({loc: loc}),
|
||||
way = Way({tags: defaultTags});
|
||||
|
||||
context.perform(
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddMidpoint({ loc: loc, edge: edge }, node));
|
||||
AddEntity(node),
|
||||
AddEntity(way),
|
||||
AddVertex(way.id, node.id),
|
||||
AddVertex(way.id, node.id),
|
||||
AddMidpoint({ loc: loc, edge: edge }, node));
|
||||
|
||||
context.enter(iD.modes.DrawArea(context, way.id, graph));
|
||||
context.enter(DrawArea(context, way.id, graph));
|
||||
}
|
||||
|
||||
function startFromNode(node) {
|
||||
var graph = context.graph(),
|
||||
way = iD.Way({tags: defaultTags});
|
||||
way = Way({tags: defaultTags});
|
||||
|
||||
context.perform(
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
AddEntity(way),
|
||||
AddVertex(way.id, node.id),
|
||||
AddVertex(way.id, node.id));
|
||||
|
||||
context.enter(iD.modes.DrawArea(context, way.id, graph));
|
||||
context.enter(DrawArea(context, way.id, graph));
|
||||
}
|
||||
|
||||
mode.enter = function() {
|
||||
|
||||
+22
-18
@@ -1,3 +1,7 @@
|
||||
import { AddWay } from '../behavior/index';
|
||||
import { Node, Way } from '../core/index';
|
||||
import { DrawLine } from './index';
|
||||
import { AddEntity, AddVertex, AddMidpoint } from '../actions/index';
|
||||
export function AddLine(context) {
|
||||
var mode = {
|
||||
id: 'add-line',
|
||||
@@ -7,7 +11,7 @@ export function AddLine(context) {
|
||||
key: '2'
|
||||
};
|
||||
|
||||
var behavior = iD.behavior.AddWay(context)
|
||||
var behavior = AddWay(context)
|
||||
.tail(t('modes.add_line.tail'))
|
||||
.on('start', start)
|
||||
.on('startFromWay', startFromWay)
|
||||
@@ -15,40 +19,40 @@ export function AddLine(context) {
|
||||
|
||||
function start(loc) {
|
||||
var baseGraph = context.graph(),
|
||||
node = iD.Node({loc: loc}),
|
||||
way = iD.Way();
|
||||
node = Node({loc: loc}),
|
||||
way = Way();
|
||||
|
||||
context.perform(
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
AddEntity(node),
|
||||
AddEntity(way),
|
||||
AddVertex(way.id, node.id));
|
||||
|
||||
context.enter(iD.modes.DrawLine(context, way.id, baseGraph));
|
||||
context.enter(DrawLine(context, way.id, baseGraph));
|
||||
}
|
||||
|
||||
function startFromWay(loc, edge) {
|
||||
var baseGraph = context.graph(),
|
||||
node = iD.Node({loc: loc}),
|
||||
way = iD.Way();
|
||||
node = Node({loc: loc}),
|
||||
way = Way();
|
||||
|
||||
context.perform(
|
||||
iD.actions.AddEntity(node),
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id),
|
||||
iD.actions.AddMidpoint({ loc: loc, edge: edge }, node));
|
||||
AddEntity(node),
|
||||
AddEntity(way),
|
||||
AddVertex(way.id, node.id),
|
||||
AddMidpoint({ loc: loc, edge: edge }, node));
|
||||
|
||||
context.enter(iD.modes.DrawLine(context, way.id, baseGraph));
|
||||
context.enter(DrawLine(context, way.id, baseGraph));
|
||||
}
|
||||
|
||||
function startFromNode(node) {
|
||||
var baseGraph = context.graph(),
|
||||
way = iD.Way();
|
||||
way = Way();
|
||||
|
||||
context.perform(
|
||||
iD.actions.AddEntity(way),
|
||||
iD.actions.AddVertex(way.id, node.id));
|
||||
AddEntity(way),
|
||||
AddVertex(way.id, node.id));
|
||||
|
||||
context.enter(iD.modes.DrawLine(context, way.id, baseGraph));
|
||||
context.enter(DrawLine(context, way.id, baseGraph));
|
||||
}
|
||||
|
||||
mode.enter = function() {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { Draw } from '../behavior/index';
|
||||
import { Node } from '../core/index';
|
||||
import { Select, Browse } from './index';
|
||||
import { AddEntity } from '../actions/index';
|
||||
export function AddPoint(context) {
|
||||
var mode = {
|
||||
id: 'add-point',
|
||||
@@ -7,7 +11,7 @@ export function AddPoint(context) {
|
||||
key: '1'
|
||||
};
|
||||
|
||||
var behavior = iD.behavior.Draw(context)
|
||||
var behavior = Draw(context)
|
||||
.tail(t('modes.add_point.tail'))
|
||||
.on('click', add)
|
||||
.on('clickWay', addWay)
|
||||
@@ -16,14 +20,14 @@ export function AddPoint(context) {
|
||||
.on('finish', cancel);
|
||||
|
||||
function add(loc) {
|
||||
var node = iD.Node({loc: loc});
|
||||
var node = Node({loc: loc});
|
||||
|
||||
context.perform(
|
||||
iD.actions.AddEntity(node),
|
||||
AddEntity(node),
|
||||
t('operations.add.annotation.point'));
|
||||
|
||||
context.enter(
|
||||
iD.modes.Select(context, [node.id])
|
||||
Select(context, [node.id])
|
||||
.suppressMenu(true)
|
||||
.newFeature(true));
|
||||
}
|
||||
@@ -37,7 +41,7 @@ export function AddPoint(context) {
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
}
|
||||
|
||||
mode.enter = function() {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Paste, Hover, Select, Lasso } from '../behavior/index';
|
||||
import { DragNode } from './index';
|
||||
export function Browse(context) {
|
||||
var mode = {
|
||||
button: 'browse',
|
||||
@@ -7,12 +9,12 @@ export function Browse(context) {
|
||||
}, sidebar;
|
||||
|
||||
var behaviors = [
|
||||
iD.behavior.Paste(context),
|
||||
iD.behavior.Hover(context)
|
||||
Paste(context),
|
||||
Hover(context)
|
||||
.on('hover', context.ui().sidebar.hover),
|
||||
iD.behavior.Select(context),
|
||||
iD.behavior.Lasso(context),
|
||||
iD.modes.DragNode(context).behavior];
|
||||
Select(context),
|
||||
Lasso(context),
|
||||
DragNode(context).behavior];
|
||||
|
||||
mode.enter = function() {
|
||||
behaviors.forEach(function(behavior) {
|
||||
|
||||
+23
-17
@@ -1,3 +1,9 @@
|
||||
import { Hover, Edit, drag } from '../behavior/index';
|
||||
import { Node } from '../core/index';
|
||||
import { entitySelector } from '../util/index';
|
||||
import { Select, Browse } from './index';
|
||||
import { chooseEdge } from '../geo/index';
|
||||
import { AddMidpoint, Noop, MoveNode, Connect } from '../actions/index';
|
||||
export function DragNode(context) {
|
||||
var mode = {
|
||||
id: 'drag-node',
|
||||
@@ -9,10 +15,10 @@ export function DragNode(context) {
|
||||
wasMidpoint,
|
||||
cancelled,
|
||||
selectedIDs = [],
|
||||
hover = iD.behavior.Hover(context)
|
||||
hover = Hover(context)
|
||||
.altDisables(true)
|
||||
.on('hover', context.ui().sidebar.hover),
|
||||
edit = iD.behavior.Edit(context);
|
||||
edit = Edit(context);
|
||||
|
||||
function edge(point, size) {
|
||||
var pad = [30, 100, 30, 100];
|
||||
@@ -56,8 +62,8 @@ export function DragNode(context) {
|
||||
wasMidpoint = entity.type === 'midpoint';
|
||||
if (wasMidpoint) {
|
||||
var midpoint = entity;
|
||||
entity = iD.Node();
|
||||
context.perform(iD.actions.AddMidpoint(midpoint, entity));
|
||||
entity = Node();
|
||||
context.perform(AddMidpoint(midpoint, entity));
|
||||
|
||||
var vertex = context.surface()
|
||||
.selectAll('.' + entity.id);
|
||||
@@ -65,7 +71,7 @@ export function DragNode(context) {
|
||||
|
||||
} else {
|
||||
context.perform(
|
||||
iD.actions.Noop());
|
||||
Noop());
|
||||
}
|
||||
|
||||
activeIDs = _.map(context.graph().parentWays(entity), 'id');
|
||||
@@ -106,11 +112,11 @@ export function DragNode(context) {
|
||||
if (d.type === 'node' && d.id !== entity.id) {
|
||||
loc = d.loc;
|
||||
} else if (d.type === 'way' && !d3.select(d3.event.sourceEvent.target).classed('fill')) {
|
||||
loc = iD.geo.chooseEdge(context.childNodes(d), context.mouse(), context.projection).loc;
|
||||
loc = chooseEdge(context.childNodes(d), context.mouse(), context.projection).loc;
|
||||
}
|
||||
|
||||
context.replace(
|
||||
iD.actions.MoveNode(entity.id, loc),
|
||||
MoveNode(entity.id, loc),
|
||||
moveAnnotation(entity));
|
||||
}
|
||||
|
||||
@@ -120,24 +126,24 @@ export function DragNode(context) {
|
||||
var d = datum();
|
||||
|
||||
if (d.type === 'way') {
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(d), context.mouse(), context.projection);
|
||||
var choice = chooseEdge(context.childNodes(d), context.mouse(), context.projection);
|
||||
context.replace(
|
||||
iD.actions.AddMidpoint({ loc: choice.loc, edge: [d.nodes[choice.index - 1], d.nodes[choice.index]] }, entity),
|
||||
AddMidpoint({ loc: choice.loc, edge: [d.nodes[choice.index - 1], d.nodes[choice.index]] }, entity),
|
||||
connectAnnotation(d));
|
||||
|
||||
} else if (d.type === 'node' && d.id !== entity.id) {
|
||||
context.replace(
|
||||
iD.actions.Connect([d.id, entity.id]),
|
||||
Connect([d.id, entity.id]),
|
||||
connectAnnotation(d));
|
||||
|
||||
} else if (wasMidpoint) {
|
||||
context.replace(
|
||||
iD.actions.Noop(),
|
||||
Noop(),
|
||||
t('operations.add.annotation.vertex'));
|
||||
|
||||
} else {
|
||||
context.replace(
|
||||
iD.actions.Noop(),
|
||||
Noop(),
|
||||
moveAnnotation(entity));
|
||||
}
|
||||
|
||||
@@ -147,24 +153,24 @@ export function DragNode(context) {
|
||||
|
||||
if (reselection.length) {
|
||||
context.enter(
|
||||
iD.modes.Select(context, reselection)
|
||||
Select(context, reselection)
|
||||
.suppressMenu(true));
|
||||
} else {
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
}
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
behavior.cancel();
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
}
|
||||
|
||||
function setActiveElements() {
|
||||
context.surface().selectAll(iD.util.entitySelector(activeIDs))
|
||||
context.surface().selectAll(entitySelector(activeIDs))
|
||||
.classed('active', true);
|
||||
}
|
||||
|
||||
var behavior = iD.behavior.drag()
|
||||
var behavior = drag()
|
||||
.delegate('g.node, g.point, g.midpoint')
|
||||
.surface(context.surface().node())
|
||||
.origin(origin)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DrawWay } from '../behavior/index';
|
||||
export function DrawArea(context, wayId, baseGraph) {
|
||||
var mode = {
|
||||
button: 'area',
|
||||
@@ -11,7 +12,7 @@ export function DrawArea(context, wayId, baseGraph) {
|
||||
headId = way.nodes[way.nodes.length - 2],
|
||||
tailId = way.first();
|
||||
|
||||
behavior = iD.behavior.DrawWay(context, wayId, -1, mode, baseGraph)
|
||||
behavior = DrawWay(context, wayId, -1, mode, baseGraph)
|
||||
.tail(t('modes.draw_area.tail'));
|
||||
|
||||
var addNode = behavior.addNode;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DrawWay } from '../behavior/index';
|
||||
export function DrawLine(context, wayId, baseGraph, affix) {
|
||||
var mode = {
|
||||
button: 'line',
|
||||
@@ -11,7 +12,7 @@ export function DrawLine(context, wayId, baseGraph, affix) {
|
||||
index = (affix === 'prefix') ? 0 : undefined,
|
||||
headId = (affix === 'prefix') ? way.first() : way.last();
|
||||
|
||||
behavior = iD.behavior.DrawWay(context, wayId, index, mode, baseGraph)
|
||||
behavior = DrawWay(context, wayId, index, mode, baseGraph)
|
||||
.tail(t('modes.draw_line.tail'));
|
||||
|
||||
var addNode = behavior.addNode;
|
||||
|
||||
+11
-8
@@ -1,3 +1,6 @@
|
||||
import { Edit } from '../behavior/index';
|
||||
import { Select, Browse } from './index';
|
||||
import { Move as MoveAction, Noop } from '../actions/index';
|
||||
export function Move(context, entityIDs, baseGraph) {
|
||||
var mode = {
|
||||
id: 'move',
|
||||
@@ -5,7 +8,7 @@ export function Move(context, entityIDs, baseGraph) {
|
||||
};
|
||||
|
||||
var keybinding = d3.keybinding('move'),
|
||||
edit = iD.behavior.Edit(context),
|
||||
edit = Edit(context),
|
||||
annotation = entityIDs.length === 1 ?
|
||||
t('operations.move.annotation.' + context.geometry(entityIDs[0])) :
|
||||
t('operations.move.annotation.multiple'),
|
||||
@@ -32,7 +35,7 @@ export function Move(context, entityIDs, baseGraph) {
|
||||
var currMouse = context.mouse(),
|
||||
origMouse = context.projection(origin),
|
||||
delta = vecSub(vecSub(currMouse, origMouse), nudge),
|
||||
action = iD.actions.Move(entityIDs, delta, context.projection, cache);
|
||||
action = MoveAction(entityIDs, delta, context.projection, cache);
|
||||
|
||||
context.overwrite(action, annotation);
|
||||
|
||||
@@ -48,7 +51,7 @@ export function Move(context, entityIDs, baseGraph) {
|
||||
var currMouse = context.mouse(),
|
||||
origMouse = context.projection(origin),
|
||||
delta = vecSub(currMouse, origMouse),
|
||||
action = iD.actions.Move(entityIDs, delta, context.projection, cache);
|
||||
action = MoveAction(entityIDs, delta, context.projection, cache);
|
||||
|
||||
context.overwrite(action, annotation);
|
||||
|
||||
@@ -59,23 +62,23 @@ export function Move(context, entityIDs, baseGraph) {
|
||||
|
||||
function finish() {
|
||||
d3.event.stopPropagation();
|
||||
context.enter(iD.modes.Select(context, entityIDs).suppressMenu(true));
|
||||
context.enter(Select(context, entityIDs).suppressMenu(true));
|
||||
stopNudge();
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
if (baseGraph) {
|
||||
while (context.graph() !== baseGraph) context.pop();
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
} else {
|
||||
context.pop();
|
||||
context.enter(iD.modes.Select(context, entityIDs).suppressMenu(true));
|
||||
context.enter(Select(context, entityIDs).suppressMenu(true));
|
||||
}
|
||||
stopNudge();
|
||||
}
|
||||
|
||||
function undone() {
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
}
|
||||
|
||||
mode.enter = function() {
|
||||
@@ -85,7 +88,7 @@ export function Move(context, entityIDs, baseGraph) {
|
||||
context.install(edit);
|
||||
|
||||
context.perform(
|
||||
iD.actions.Noop(),
|
||||
Noop(),
|
||||
annotation);
|
||||
|
||||
context.surface()
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { Edit } from '../behavior/index';
|
||||
import { Select, Browse } from './index';
|
||||
import { Noop, RotateWay as RotateWayAction } from '../actions/index';
|
||||
export function RotateWay(context, wayId) {
|
||||
var mode = {
|
||||
id: 'rotate-way',
|
||||
@@ -5,7 +8,7 @@ export function RotateWay(context, wayId) {
|
||||
};
|
||||
|
||||
var keybinding = d3.keybinding('rotate-way'),
|
||||
edit = iD.behavior.Edit(context);
|
||||
edit = Edit(context);
|
||||
|
||||
mode.enter = function() {
|
||||
context.install(edit);
|
||||
@@ -18,7 +21,7 @@ export function RotateWay(context, wayId) {
|
||||
angle;
|
||||
|
||||
context.perform(
|
||||
iD.actions.Noop(),
|
||||
Noop(),
|
||||
annotation);
|
||||
|
||||
function rotate() {
|
||||
@@ -29,7 +32,7 @@ export function RotateWay(context, wayId) {
|
||||
if (typeof angle === 'undefined') angle = newAngle;
|
||||
|
||||
context.replace(
|
||||
iD.actions.RotateWay(wayId, pivot, newAngle - angle, context.projection),
|
||||
RotateWayAction(wayId, pivot, newAngle - angle, context.projection),
|
||||
annotation);
|
||||
|
||||
angle = newAngle;
|
||||
@@ -37,18 +40,18 @@ export function RotateWay(context, wayId) {
|
||||
|
||||
function finish() {
|
||||
d3.event.stopPropagation();
|
||||
context.enter(iD.modes.Select(context, [wayId])
|
||||
context.enter(Select(context, [wayId])
|
||||
.suppressMenu(true));
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
context.pop();
|
||||
context.enter(iD.modes.Select(context, [wayId])
|
||||
context.enter(Select(context, [wayId])
|
||||
.suppressMenu(true));
|
||||
}
|
||||
|
||||
function undone() {
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
}
|
||||
|
||||
context.surface()
|
||||
|
||||
+21
-15
@@ -1,10 +1,16 @@
|
||||
import { Graph } from '../core/index';
|
||||
import { displayName, displayType } from '../util/index';
|
||||
import { Browse } from './index';
|
||||
import { DiscardTags, Noop, MergeRemoteChanges, Revert } from '../actions/index';
|
||||
import { Commit, Loading, Success, Conflicts } from '../ui/core/index';
|
||||
|
||||
export function Save(context) {
|
||||
var ui = iD.ui.Commit(context)
|
||||
var ui = Commit(context)
|
||||
.on('cancel', cancel)
|
||||
.on('save', save);
|
||||
|
||||
function cancel() {
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
}
|
||||
|
||||
function save(e, tryAgain) {
|
||||
@@ -25,18 +31,18 @@ export function Save(context) {
|
||||
}, _.clone(ids)));
|
||||
}
|
||||
|
||||
var loading = iD.ui.Loading(context).message(t('save.uploading')).blocking(true),
|
||||
var loading = Loading(context).message(t('save.uploading')).blocking(true),
|
||||
history = context.history(),
|
||||
origChanges = history.changes(iD.actions.DiscardTags(history.difference())),
|
||||
origChanges = history.changes(DiscardTags(history.difference())),
|
||||
localGraph = context.graph(),
|
||||
remoteGraph = iD.Graph(history.base(), true),
|
||||
remoteGraph = Graph(history.base(), true),
|
||||
modified = _.filter(history.difference().summary(), {changeType: 'modified'}),
|
||||
toCheck = _.map(_.map(modified, 'entity'), 'id'),
|
||||
toLoad = withChildNodes(toCheck, localGraph),
|
||||
conflicts = [],
|
||||
errors = [];
|
||||
|
||||
if (!tryAgain) history.perform(iD.actions.Noop()); // checkpoint
|
||||
if (!tryAgain) history.perform(Noop()); // checkpoint
|
||||
context.container().call(loading);
|
||||
|
||||
if (toCheck.length) {
|
||||
@@ -95,7 +101,7 @@ export function Save(context) {
|
||||
return '<a href="' + context.connection().userURL(d) + '" target="_blank">' + d + '</a>';
|
||||
}
|
||||
function entityName(entity) {
|
||||
return iD.util.displayName(entity) || (iD.util.displayType(entity.id) + ' ' + entity.id);
|
||||
return displayName(entity) || (displayType(entity.id) + ' ' + entity.id);
|
||||
}
|
||||
|
||||
function compareVersions(local, remote) {
|
||||
@@ -121,7 +127,7 @@ export function Save(context) {
|
||||
|
||||
if (compareVersions(local, remote)) return;
|
||||
|
||||
var action = iD.actions.MergeRemoteChanges,
|
||||
var action = MergeRemoteChanges,
|
||||
merge = action(id, localGraph, remoteGraph, formatUser);
|
||||
|
||||
history.replace(merge);
|
||||
@@ -157,7 +163,7 @@ export function Save(context) {
|
||||
} else if (errors.length) {
|
||||
showErrors();
|
||||
} else {
|
||||
var changes = history.changes(iD.actions.DiscardTags(history.difference()));
|
||||
var changes = history.changes(DiscardTags(history.difference()));
|
||||
if (changes.modified.length || changes.created.length || changes.deleted.length) {
|
||||
context.connection().putChangeset(
|
||||
changes,
|
||||
@@ -197,7 +203,7 @@ export function Save(context) {
|
||||
|
||||
loading.close();
|
||||
|
||||
selection.call(iD.ui.Conflicts(context)
|
||||
selection.call(Conflicts(context)
|
||||
.list(conflicts)
|
||||
.on('download', function() {
|
||||
var data = JXON.stringify(context.connection().osmChangeJXON('CHANGEME', origChanges)),
|
||||
@@ -215,10 +221,10 @@ export function Save(context) {
|
||||
if (entity && entity.type === 'way') {
|
||||
var children = _.uniq(entity.nodes);
|
||||
for (var j = 0; j < children.length; j++) {
|
||||
history.replace(iD.actions.Revert(children[j]));
|
||||
history.replace(Revert(children[j]));
|
||||
}
|
||||
}
|
||||
history.replace(iD.actions.Revert(conflicts[i].id));
|
||||
history.replace(Revert(conflicts[i].id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +236,7 @@ export function Save(context) {
|
||||
|
||||
|
||||
function showErrors() {
|
||||
var selection = iD.ui.confirm(context.container());
|
||||
var selection = confirm(context.container());
|
||||
|
||||
history.pop();
|
||||
loading.close();
|
||||
@@ -297,8 +303,8 @@ export function Save(context) {
|
||||
|
||||
|
||||
function success(e, changeset_id) {
|
||||
context.enter(iD.modes.Browse(context)
|
||||
.sidebar(iD.ui.Success(context)
|
||||
context.enter(Browse(context)
|
||||
.sidebar(Success(context)
|
||||
.changeset({
|
||||
id: changeset_id,
|
||||
comment: e.comment
|
||||
|
||||
+30
-21
@@ -1,3 +1,12 @@
|
||||
import { Copy, Paste, Breathe, Hover, Select as SelectBehavior, Lasso } from '../behavior/index';
|
||||
import { Way, Node } from '../core/index';
|
||||
import { entityOrMemberSelector } from '../util/index';
|
||||
import { DragNode, Browse } from './index';
|
||||
import { Extent, pointInPolygon, chooseEdge } from '../geo/index';
|
||||
import { AddMidpoint } from '../actions/index';
|
||||
import * as Operations from '../operations/index';
|
||||
import { RadialMenu, SelectionList } from '../ui/core/index';
|
||||
|
||||
export function Select(context, selectedIDs) {
|
||||
var mode = {
|
||||
id: 'select',
|
||||
@@ -7,13 +16,13 @@ export function Select(context, selectedIDs) {
|
||||
var keybinding = d3.keybinding('select'),
|
||||
timeout = null,
|
||||
behaviors = [
|
||||
iD.behavior.Copy(context),
|
||||
iD.behavior.Paste(context),
|
||||
iD.behavior.Breathe(context),
|
||||
iD.behavior.Hover(context),
|
||||
iD.behavior.Select(context),
|
||||
iD.behavior.Lasso(context),
|
||||
iD.modes.DragNode(context)
|
||||
Copy(context),
|
||||
Paste(context),
|
||||
Breathe(context),
|
||||
Hover(context),
|
||||
SelectBehavior(context),
|
||||
Lasso(context),
|
||||
DragNode(context)
|
||||
.selectedIDs(selectedIDs)
|
||||
.behavior],
|
||||
inspector,
|
||||
@@ -47,8 +56,8 @@ export function Select(context, selectedIDs) {
|
||||
radialMenu.center(context.projection(entity.loc));
|
||||
} else {
|
||||
var point = context.mouse(),
|
||||
viewport = iD.geo.Extent(context.projection.clipExtent()).polygon();
|
||||
if (iD.geo.pointInPolygon(point, viewport)) {
|
||||
viewport = Extent(context.projection.clipExtent()).polygon();
|
||||
if (pointInPolygon(point, viewport)) {
|
||||
radialMenu.center(point);
|
||||
} else {
|
||||
suppressMenu = true;
|
||||
@@ -102,7 +111,7 @@ export function Select(context, selectedIDs) {
|
||||
closeMenu();
|
||||
if (_.some(selectedIDs, function(id) { return !context.hasEntity(id); })) {
|
||||
// Exit mode if selected entity gets undone
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,15 +119,15 @@ export function Select(context, selectedIDs) {
|
||||
var target = d3.select(d3.event.target),
|
||||
datum = target.datum();
|
||||
|
||||
if (datum instanceof iD.Way && !target.classed('fill')) {
|
||||
var choice = iD.geo.chooseEdge(context.childNodes(datum), context.mouse(), context.projection),
|
||||
node = iD.Node();
|
||||
if (datum instanceof Way && !target.classed('fill')) {
|
||||
var choice = chooseEdge(context.childNodes(datum), context.mouse(), context.projection),
|
||||
node = Node();
|
||||
|
||||
var prev = datum.nodes[choice.index - 1],
|
||||
next = datum.nodes[choice.index];
|
||||
|
||||
context.perform(
|
||||
iD.actions.AddMidpoint({loc: choice.loc, edge: [prev, next]}, node),
|
||||
AddMidpoint({loc: choice.loc, edge: [prev, next]}, node),
|
||||
t('operations.add.annotation.vertex'));
|
||||
|
||||
d3.event.preventDefault();
|
||||
@@ -134,11 +143,11 @@ export function Select(context, selectedIDs) {
|
||||
}
|
||||
|
||||
var selection = context.surface()
|
||||
.selectAll(iD.util.entityOrMemberSelector(selectedIDs, context.graph()));
|
||||
.selectAll(entityOrMemberSelector(selectedIDs, context.graph()));
|
||||
|
||||
if (selection.empty()) {
|
||||
if (drawn) { // Exit mode if selected DOM elements have disappeared..
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
}
|
||||
} else {
|
||||
selection
|
||||
@@ -148,7 +157,7 @@ export function Select(context, selectedIDs) {
|
||||
|
||||
function esc() {
|
||||
if (!context.inIntro()) {
|
||||
context.enter(iD.modes.Browse(context));
|
||||
context.enter(Browse(context));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,11 +166,11 @@ export function Select(context, selectedIDs) {
|
||||
context.install(behavior);
|
||||
});
|
||||
|
||||
var operations = _.without(d3.values(iD.operations), iD.operations.Delete)
|
||||
var operations = _.without(d3.values(Operations), Operations.Delete)
|
||||
.map(function(o) { return o(selectedIDs, context); })
|
||||
.filter(function(o) { return o.available(); });
|
||||
|
||||
operations.unshift(iD.operations.Delete(selectedIDs, context));
|
||||
operations.unshift(Operations.Delete(selectedIDs, context));
|
||||
|
||||
keybinding
|
||||
.on('⎋', esc, true)
|
||||
@@ -180,7 +189,7 @@ export function Select(context, selectedIDs) {
|
||||
d3.select(document)
|
||||
.call(keybinding);
|
||||
|
||||
radialMenu = iD.ui.RadialMenu(context, operations);
|
||||
radialMenu = RadialMenu(context, operations);
|
||||
|
||||
context.ui().sidebar
|
||||
.select(singular() ? singular().id : null, newFeature);
|
||||
@@ -211,7 +220,7 @@ export function Select(context, selectedIDs) {
|
||||
}, 200);
|
||||
|
||||
if (selectedIDs.length > 1) {
|
||||
var entities = iD.ui.SelectionList(context, selectedIDs);
|
||||
var entities = SelectionList(context, selectedIDs);
|
||||
context.ui().sidebar.show(entities);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
|
||||
<script src='../js/id/id.js'></script>
|
||||
<script src='../js/lib/id/index.js'></script>
|
||||
<script src='../js/lib/id/modes.js'></script>
|
||||
<script src='../js/lib/id/operations.js'></script>
|
||||
<script src='../js/lib/id/presets.js'></script>
|
||||
<script src='../js/lib/id/renderer.js'></script>
|
||||
|
||||
Reference in New Issue
Block a user