diff --git a/js/id/behavior/select.js b/js/id/behavior/select.js index 6b955b343..f69a66bf9 100644 --- a/js/id/behavior/select.js +++ b/js/id/behavior/select.js @@ -22,19 +22,19 @@ iD.behavior.Select = function(context) { } else if (!d3.event.shiftKey && !lasso) { // Avoid re-entering Select mode with same entity. - if (context.selection().length !== 1 || context.selection()[0] !== datum.id) { + if (context.selectedIDs().length !== 1 || context.selectedIDs()[0] !== datum.id) { context.enter(iD.modes.Select(context, [datum.id])); } else { context.mode().reselect(); } - } else if (context.selection().indexOf(datum.id) >= 0) { - var selection = _.without(context.selection(), datum.id); - context.enter(selection.length ? - iD.modes.Select(context, selection) : + } else if (context.selectedIDs().indexOf(datum.id) >= 0) { + var selectedIDs = _.without(context.selectedIDs(), datum.id); + context.enter(selectedIDs.length ? + iD.modes.Select(context, selectedIDs) : iD.modes.Browse(context)); } else { - context.enter(iD.modes.Select(context, context.selection().concat([datum.id]))); + context.enter(iD.modes.Select(context, context.selectedIDs().concat([datum.id]))); } } diff --git a/js/id/id.js b/js/id/id.js index eb85ed275..bd0352495 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -100,7 +100,7 @@ window.iD = function () { /* Modes */ context.enter = function(newMode) { - var s0 = context.selection(); + var s0 = context.selectedIDs(); if (mode) { mode.exit(); @@ -111,7 +111,7 @@ window.iD = function () { mode.enter(); dispatch.enter(mode); - var s1 = context.selection(); + var s1 = context.selectedIDs(); dispatch.select(s1, s0); }; @@ -119,9 +119,9 @@ window.iD = function () { return mode; }; - context.selection = function() { - if (mode && mode.selection) { - return mode.selection(); + context.selectedIDs = function() { + if (mode && mode.selectedIDs) { + return mode.selectedIDs(); } else { return []; } diff --git a/js/id/modes/drag_node.js b/js/id/modes/drag_node.js index cb6ee6cda..fd9b29223 100644 --- a/js/id/modes/drag_node.js +++ b/js/id/modes/drag_node.js @@ -8,7 +8,7 @@ iD.modes.DragNode = function(context) { activeIDs, wasMidpoint, cancelled, - selection = [], + selectedIDs = [], hover = iD.behavior.Hover(context).altDisables(true); function edge(point, size) { @@ -136,7 +136,7 @@ iD.modes.DragNode = function(context) { moveAnnotation(entity)); } - var reselection = selection.filter(function(id) { + var reselection = selectedIDs.filter(function(id) { return context.graph().hasEntity(id); }); @@ -195,9 +195,9 @@ iD.modes.DragNode = function(context) { stopNudge(); }; - mode.selection = function(_) { - if (!arguments.length) return selection; - selection = _; + mode.selectedIDs = function(_) { + if (!arguments.length) return selectedIDs; + selectedIDs = _; return mode; }; diff --git a/js/id/modes/draw_area.js b/js/id/modes/draw_area.js index 66542ffc7..84382996f 100644 --- a/js/id/modes/draw_area.js +++ b/js/id/modes/draw_area.js @@ -31,7 +31,7 @@ iD.modes.DrawArea = function(context, wayId, baseGraph) { context.uninstall(behavior); }; - mode.selection = function() { + mode.selectedIDs = function() { return [wayId]; }; diff --git a/js/id/modes/draw_line.js b/js/id/modes/draw_line.js index f31ee2b78..beb29bba2 100644 --- a/js/id/modes/draw_line.js +++ b/js/id/modes/draw_line.js @@ -31,7 +31,7 @@ iD.modes.DrawLine = function(context, wayId, direction, baseGraph) { context.uninstall(behavior); }; - mode.selection = function() { + mode.selectedIDs = function() { return [wayId]; }; diff --git a/js/id/modes/select.js b/js/id/modes/select.js index 54841b646..918947857 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -1,4 +1,4 @@ -iD.modes.Select = function(context, selection) { +iD.modes.Select = function(context, selectedIDs) { var mode = { id: 'select', button: 'browse' @@ -11,7 +11,7 @@ iD.modes.Select = function(context, selection) { iD.behavior.Select(context), iD.behavior.Lasso(context), iD.modes.DragNode(context) - .selection(selection) + .selectedIDs(selectedIDs) .behavior], inspector, radialMenu, @@ -22,8 +22,8 @@ iD.modes.Select = function(context, selection) { .select('.inspector-wrap'); function singular() { - if (selection.length === 1) { - return context.entity(selection[0]); + if (selectedIDs.length === 1) { + return context.entity(selectedIDs[0]); } } @@ -43,8 +43,8 @@ iD.modes.Select = function(context, selection) { .call(radialMenu); } - mode.selection = function() { - return selection; + mode.selectedIDs = function() { + return selectedIDs; }; mode.reselect = function() { @@ -75,9 +75,9 @@ iD.modes.Select = function(context, selection) { }); var operations = _.without(d3.values(iD.operations), iD.operations.Delete) - .map(function(o) { return o(selection, context); }) + .map(function(o) { return o(selectedIDs, context); }) .filter(function(o) { return o.available(); }); - operations.unshift(iD.operations.Delete(selection, context)); + operations.unshift(iD.operations.Delete(selectedIDs, context)); keybinding.on('⎋', function() { context.enter(iD.modes.Browse(context)); @@ -93,7 +93,7 @@ iD.modes.Select = function(context, selection) { }); }); - var notNew = selection.filter(function(id) { + var notNew = selectedIDs.filter(function(id) { return !context.entity(id).isNew(); }); @@ -111,7 +111,7 @@ iD.modes.Select = function(context, selection) { function update() { context.surface().call(radialMenu.close); - if (_.any(selection, function(id) { return !context.hasEntity(id); })) { + if (_.any(selectedIDs, function(id) { return !context.hasEntity(id); })) { // Exit mode if selected entity gets undone context.enter(iD.modes.Browse(context)); } @@ -142,9 +142,9 @@ iD.modes.Select = function(context, selection) { } function selected() { - var s = iD.util.entitySelector(selection); + var s = iD.util.entitySelector(selectedIDs); - selection.forEach(function(id) { + selectedIDs.forEach(function(id) { var entity = context.hasEntity(id); if (entity && entity.type === 'relation') { entity.members.forEach(function(member) { diff --git a/js/id/operations/circularize.js b/js/id/operations/circularize.js index 00f0610f3..c8a00505c 100644 --- a/js/id/operations/circularize.js +++ b/js/id/operations/circularize.js @@ -1,5 +1,5 @@ -iD.operations.Circularize = function(selection, context) { - var entityId = selection[0], +iD.operations.Circularize = function(selectedIDs, context) { + var entityId = selectedIDs[0], geometry = context.geometry(entityId), action = iD.actions.Circularize(entityId, context.projection); @@ -9,7 +9,7 @@ iD.operations.Circularize = function(selection, context) { }; operation.available = function() { - return selection.length === 1 && + return selectedIDs.length === 1 && context.entity(entityId).type === 'way'; }; diff --git a/js/id/operations/delete.js b/js/id/operations/delete.js index 05f55d739..f5dafe835 100644 --- a/js/id/operations/delete.js +++ b/js/id/operations/delete.js @@ -1,15 +1,15 @@ -iD.operations.Delete = function(selection, context) { - var action = iD.actions.DeleteMultiple(selection); +iD.operations.Delete = function(selectedIDs, context) { + var action = iD.actions.DeleteMultiple(selectedIDs); var operation = function() { var annotation, mode; - if (selection.length > 1) { - annotation = t('operations.delete.annotation.multiple', {n: selection.length}); + if (selectedIDs.length > 1) { + annotation = t('operations.delete.annotation.multiple', {n: selectedIDs.length}); mode = iD.modes.Browse(context); } else { - var id = selection[0], + var id = selectedIDs[0], entity = context.entity(id), geometry = context.geometry(id), parents = context.graph().parentWays(entity), diff --git a/js/id/operations/disconnect.js b/js/id/operations/disconnect.js index 6ddd3dc00..067ba6205 100644 --- a/js/id/operations/disconnect.js +++ b/js/id/operations/disconnect.js @@ -1,13 +1,13 @@ -iD.operations.Disconnect = function(selection, context) { - var vertices = _.filter(selection, function vertex(entityId) { +iD.operations.Disconnect = function(selectedIDs, context) { + var vertices = _.filter(selectedIDs, function vertex(entityId) { return context.geometry(entityId) === 'vertex'; }); var entityId = vertices[0], action = iD.actions.Disconnect(entityId); - if (selection.length > 1) { - action.limitWays(_.without(selection, entityId)); + if (selectedIDs.length > 1) { + action.limitWays(_.without(selectedIDs, entityId)); } var operation = function() { diff --git a/js/id/operations/merge.js b/js/id/operations/merge.js index e7b2d5e43..05ceb6290 100644 --- a/js/id/operations/merge.js +++ b/js/id/operations/merge.js @@ -1,10 +1,10 @@ -iD.operations.Merge = function(selection, context) { - var join = iD.actions.Join(selection), - merge = iD.actions.Merge(selection), - mergePolygon = iD.actions.MergePolygon(selection); +iD.operations.Merge = function(selectedIDs, context) { + var join = iD.actions.Join(selectedIDs), + merge = iD.actions.Merge(selectedIDs), + mergePolygon = iD.actions.MergePolygon(selectedIDs); var operation = function() { - var annotation = t('operations.merge.annotation', {n: selection.length}), + var annotation = t('operations.merge.annotation', {n: selectedIDs.length}), action; if (!join.disabled(context.graph())) { @@ -20,7 +20,7 @@ iD.operations.Merge = function(selection, context) { }; operation.available = function() { - return selection.length >= 2; + return selectedIDs.length >= 2; }; operation.disabled = function() { diff --git a/js/id/operations/move.js b/js/id/operations/move.js index d2c892ccc..2a91ed32c 100644 --- a/js/id/operations/move.js +++ b/js/id/operations/move.js @@ -1,15 +1,15 @@ -iD.operations.Move = function(selection, context) { +iD.operations.Move = function(selectedIDs, context) { var operation = function() { - context.enter(iD.modes.Move(context, selection)); + context.enter(iD.modes.Move(context, selectedIDs)); }; operation.available = function() { - return selection.length > 1 || - context.entity(selection[0]).type !== 'node'; + return selectedIDs.length > 1 || + context.entity(selectedIDs[0]).type !== 'node'; }; operation.disabled = function() { - return iD.actions.Move(selection) + return iD.actions.Move(selectedIDs) .disabled(context.graph()); }; diff --git a/js/id/operations/orthogonalize.js b/js/id/operations/orthogonalize.js index 825347693..5f7d06564 100644 --- a/js/id/operations/orthogonalize.js +++ b/js/id/operations/orthogonalize.js @@ -1,5 +1,5 @@ -iD.operations.Orthogonalize = function(selection, context) { - var entityId = selection[0], +iD.operations.Orthogonalize = function(selectedIDs, context) { + var entityId = selectedIDs[0], action = iD.actions.Orthogonalize(entityId, context.projection); var operation = function() { @@ -8,7 +8,7 @@ iD.operations.Orthogonalize = function(selection, context) { }; operation.available = function() { - return selection.length === 1 && + return selectedIDs.length === 1 && context.entity(entityId).type === 'way' && _.uniq(context.entity(entityId).nodes).length > 2; }; diff --git a/js/id/operations/reverse.js b/js/id/operations/reverse.js index 3eca2d599..187e063cf 100644 --- a/js/id/operations/reverse.js +++ b/js/id/operations/reverse.js @@ -1,5 +1,5 @@ -iD.operations.Reverse = function(selection, context) { - var entityId = selection[0]; +iD.operations.Reverse = function(selectedIDs, context) { + var entityId = selectedIDs[0]; var operation = function() { context.perform( @@ -8,7 +8,7 @@ iD.operations.Reverse = function(selection, context) { }; operation.available = function() { - return selection.length === 1 && + return selectedIDs.length === 1 && context.geometry(entityId) === 'line'; }; diff --git a/js/id/operations/rotate.js b/js/id/operations/rotate.js index b9b3ed2c5..85bccd8ef 100644 --- a/js/id/operations/rotate.js +++ b/js/id/operations/rotate.js @@ -1,12 +1,12 @@ -iD.operations.Rotate = function(selection, context) { - var entityId = selection[0]; +iD.operations.Rotate = function(selectedIDs, context) { + var entityId = selectedIDs[0]; var operation = function() { context.enter(iD.modes.RotateWay(context, entityId)); }; operation.available = function() { - return selection.length === 1 && + return selectedIDs.length === 1 && context.entity(entityId).type === 'way' && context.geometry(entityId) === 'area'; }; diff --git a/js/id/operations/split.js b/js/id/operations/split.js index 78808137c..4f3804d71 100644 --- a/js/id/operations/split.js +++ b/js/id/operations/split.js @@ -1,13 +1,13 @@ -iD.operations.Split = function(selection, context) { - var vertices = _.filter(selection, function vertex(entityId) { +iD.operations.Split = function(selectedIDs, context) { + var vertices = _.filter(selectedIDs, function vertex(entityId) { return context.geometry(entityId) === 'vertex'; }); var entityId = vertices[0], action = iD.actions.Split(entityId); - if (selection.length > 1) { - action.limitWays(_.without(selection, entityId)); + if (selectedIDs.length > 1) { + action.limitWays(_.without(selectedIDs, entityId)); } var operation = function() { diff --git a/js/id/svg/midpoints.js b/js/id/svg/midpoints.js index 50caf61e0..892efd141 100644 --- a/js/id/svg/midpoints.js +++ b/js/id/svg/midpoints.js @@ -6,7 +6,7 @@ iD.svg.Midpoints = function(projection, context) { var entity = entities[i]; if (entity.type !== 'way') continue; - if (context.selection().indexOf(entity.id) < 0) continue; + if (context.selectedIDs().indexOf(entity.id) < 0) continue; var nodes = graph.childNodes(entity); diff --git a/js/id/svg/vertices.js b/js/id/svg/vertices.js index 64f8acf8e..bd9a109db 100644 --- a/js/id/svg/vertices.js +++ b/js/id/svg/vertices.js @@ -108,7 +108,7 @@ iD.svg.Vertices = function(projection, context) { } function drawVertices(surface, graph, entities, filter, extent, zoom) { - var selected = siblingAndChildVertices(context.selection(), graph, extent), + var selected = siblingAndChildVertices(context.selectedIDs(), graph, extent), vertices = []; for (var i = 0; i < entities.length; i++) { diff --git a/js/id/ui/intro/line.js b/js/id/ui/intro/line.js index 548a1bfbb..e05f6c241 100644 --- a/js/id/ui/intro/line.js +++ b/js/id/ui/intro/line.js @@ -64,7 +64,7 @@ iD.ui.intro.line = function(context, reveal) { var pointBox = iD.ui.intro.pad(context.projection(intersection), 30); reveal(pointBox, 'intro.lines.restart'); timeout(function() { - context.replace(iD.actions.DeleteMultiple(mode.selection())); + context.replace(iD.actions.DeleteMultiple(mode.selectedIDs())); step.exit(); step.enter(); }, 3000); diff --git a/js/id/ui/sidebar.js b/js/id/ui/sidebar.js index 59007d279..0488ad224 100644 --- a/js/id/ui/sidebar.js +++ b/js/id/ui/sidebar.js @@ -7,7 +7,7 @@ iD.ui.Sidebar = function(context) { .attr('class', 'inspector-hidden inspector-wrap fr'); context.on('hover.sidebar', function(entity) { - if (context.selection().length === 1) return; + if (context.selectedIDs().length === 1) return; if (!current && entity) { wrap.classed('inspector-hidden', false) @@ -25,15 +25,15 @@ iD.ui.Sidebar = function(context) { } }); - context.on('select.sidebar', function(selection) { - if (!current && selection.length === 1) { + context.on('select.sidebar', function(selectedIDs) { + if (!current && selectedIDs.length === 1) { wrap.classed('inspector-hidden', false) .classed('inspector-hover', false); - if (inspector.entityID() !== selection[0] || inspector.state() !== 'select') { + if (inspector.entityID() !== selectedIDs[0] || inspector.state() !== 'select') { inspector .state('select') - .entityID(selection[0]); + .entityID(selectedIDs[0]); wrap.call(inspector); } diff --git a/test/rendering.html b/test/rendering.html index f85ca834f..2740f11c6 100644 --- a/test/rendering.html +++ b/test/rendering.html @@ -103,7 +103,7 @@ return 'img/' + _; }; - context.selection = function() { + context.selectedIDs = function() { return []; }; diff --git a/test/spec/behavior/select.js b/test/spec/behavior/select.js index ecbb7e7b4..dabfaa4ce 100644 --- a/test/spec/behavior/select.js +++ b/test/spec/behavior/select.js @@ -34,7 +34,7 @@ describe("iD.behavior.Select", function() { specify("click on entity selects the entity", function() { happen.click(context.surface().select('.' + a.id).node()); - expect(context.selection()).to.eql([a.id]); + expect(context.selectedIDs()).to.eql([a.id]); }); specify("click on empty space clears the selection", function() { @@ -46,13 +46,13 @@ describe("iD.behavior.Select", function() { specify("shift-click on unselected entity adds it to the selection", function() { context.enter(iD.modes.Select(context, [a.id])); happen.click(context.surface().select('.' + b.id).node(), {shiftKey: true}); - expect(context.selection()).to.eql([a.id, b.id]); + expect(context.selectedIDs()).to.eql([a.id, b.id]); }); specify("shift-click on selected entity removes it from the selection", function() { context.enter(iD.modes.Select(context, [a.id, b.id])); happen.click(context.surface().select('.' + b.id).node(), {shiftKey: true}); - expect(context.selection()).to.eql([a.id]); + expect(context.selectedIDs()).to.eql([a.id]); }); specify("shift-click on last selected entity clears the selection", function() { @@ -64,6 +64,6 @@ describe("iD.behavior.Select", function() { specify("shift-click on empty space leaves the selection unchanged", function() { context.enter(iD.modes.Select(context, [a.id])); happen.click(context.surface().node(), {shiftKey: true}); - expect(context.selection()).to.eql([a.id]); + expect(context.selectedIDs()).to.eql([a.id]); }); }); diff --git a/test/spec/modes/add_point.js b/test/spec/modes/add_point.js index 080a86d3b..e45814740 100644 --- a/test/spec/modes/add_point.js +++ b/test/spec/modes/add_point.js @@ -27,7 +27,7 @@ describe("iD.modes.AddPoint", function() { happen.mousedown(context.surface().node(), {}); happen.mouseup(window, {}); expect(context.mode().id).to.equal('select'); - expect(context.mode().selection()).to.eql([context.changes().created[0].id]); + expect(context.mode().selectedIDs()).to.eql([context.changes().created[0].id]); context.mode().exit(); }); }); diff --git a/test/spec/svg/midpoints.js b/test/spec/svg/midpoints.js index 39b14e677..499e9405b 100644 --- a/test/spec/svg/midpoints.js +++ b/test/spec/svg/midpoints.js @@ -17,7 +17,7 @@ describe("iD.svg.Midpoints", function () { graph = iD.Graph([a, b, line]), extent = iD.geo.Extent([0, 0], [100, 100]); - context.selection = function() { return [line.id]; }; + context.selectedIDs = function() { return [line.id]; }; surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent); expect(surface.select('.midpoint').datum().loc).to.eql([25, 0]); @@ -30,7 +30,7 @@ describe("iD.svg.Midpoints", function () { graph = iD.Graph([a, b, line]), extent = iD.geo.Extent([0, 0], [100, 100]); - context.selection = function() { return [line.id]; }; + context.selectedIDs = function() { return [line.id]; }; surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent); expect(surface.selectAll('.midpoint')[0]).to.have.length(0);