mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 13:38:26 +02:00
Rewrite some confusing nested ternaries (close #8117)
This commit is contained in:
@@ -238,8 +238,15 @@ export function behaviorDrawWay(context, wayID, mode, startGraph) {
|
||||
_drawNode = undefined;
|
||||
_didResolveTempEdit = false;
|
||||
_origWay = context.entity(wayID);
|
||||
_headNodeID = typeof _nodeIndex === 'number' ? _origWay.nodes[_nodeIndex] :
|
||||
(_origWay.isClosed() ? _origWay.nodes[_origWay.nodes.length - 2] : _origWay.nodes[_origWay.nodes.length - 1]);
|
||||
|
||||
if (typeof _nodeIndex === 'number') {
|
||||
_headNodeID = _origWay.nodes[_nodeIndex];
|
||||
} else if (_origWay.isClosed()) {
|
||||
_headNodeID = _origWay.nodes[_origWay.nodes.length - 2];
|
||||
} else {
|
||||
_headNodeID = _origWay.nodes[_origWay.nodes.length - 1];
|
||||
}
|
||||
|
||||
_wayGeometry = _origWay.geometry(context.graph());
|
||||
_annotation = t((_origWay.nodes.length === (_origWay.isClosed() ? 2 : 1) ?
|
||||
'operations.start.annotation.' :
|
||||
|
||||
@@ -109,7 +109,9 @@ function preventCoincident(loc, bumpUp) {
|
||||
let coincident = false;
|
||||
do {
|
||||
// first time, move marker up. after that, move marker right.
|
||||
let delta = coincident ? [0.00001, 0] : (bumpUp ? [0, 0.00001] : [0, 0]);
|
||||
let delta = coincident ? [0.00001, 0] :
|
||||
bumpUp ? [0, 0.00001] :
|
||||
[0, 0];
|
||||
loc = geoVecAdd(loc, delta);
|
||||
let bbox = geoExtent(loc).bbox();
|
||||
coincident = _cache.rtree.search(bbox).length;
|
||||
|
||||
@@ -153,7 +153,9 @@ export function svgNotes(projection, context, dispatch) {
|
||||
.attr('x', '-3px')
|
||||
.attr('y', '-19px')
|
||||
.attr('xlink:href', function(d) {
|
||||
return '#iD-icon-' + (d.id < 0 ? 'plus' : (d.status === 'open' ? 'close' : 'apply'));
|
||||
if (d.id < 0) return '#iD-icon-plus';
|
||||
if (d.status === 'open') return '#iD-icon-close';
|
||||
return '#iD-icon-apply';
|
||||
});
|
||||
|
||||
// update
|
||||
@@ -196,7 +198,9 @@ export function svgNotes(projection, context, dispatch) {
|
||||
|
||||
|
||||
function sortY(a, b) {
|
||||
return (a.id === selectedID) ? 1 : (b.id === selectedID) ? -1 : b.loc[1] - a.loc[1];
|
||||
if (a.id === selectedID) return 1;
|
||||
if (b.id === selectedID) return -1;
|
||||
return b.loc[1] - a.loc[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,14 @@ export function uiNoteHeader() {
|
||||
.call(svgIcon('#iD-icon-note', 'note-fill'));
|
||||
|
||||
iconEnter.each(function(d) {
|
||||
var statusIcon = '#iD-icon-' + (d.id < 0 ? 'plus' : (d.status === 'open' ? 'close' : 'apply'));
|
||||
var statusIcon;
|
||||
if (d.id < 0) {
|
||||
statusIcon = '#iD-icon-plus';
|
||||
} else if (d.status === 'open') {
|
||||
statusIcon = '#iD-icon-close';
|
||||
} else {
|
||||
statusIcon = '#iD-icon-apply';
|
||||
}
|
||||
iconEnter
|
||||
.append('div')
|
||||
.attr('class', 'note-icon-annotation')
|
||||
|
||||
Reference in New Issue
Block a user