From 1455c5e551a20d9a49afc904c253cb03ee09a5ab Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sat, 11 May 2013 17:33:13 -0700 Subject: [PATCH] Use entity ID selectors in more places --- js/id/modes/drag_node.js | 3 +-- js/id/modes/select.js | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/js/id/modes/drag_node.js b/js/id/modes/drag_node.js index 6037f7738..9ac7be856 100644 --- a/js/id/modes/drag_node.js +++ b/js/id/modes/drag_node.js @@ -54,8 +54,7 @@ iD.modes.DragNode = function(context) { context.perform(iD.actions.AddMidpoint(midpoint, entity)); var vertex = context.surface() - .selectAll('.vertex') - .filter(function(d) { return d.id === entity.id; }); + .selectAll('.' + entity.id); behavior.target(vertex.node(), entity); } else { diff --git a/js/id/modes/select.js b/js/id/modes/select.js index 450256b54..65c0127fe 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -146,12 +146,19 @@ iD.modes.Select = function(context, selection) { } } - function selected(entity) { - if (!entity) return false; - if (selection.indexOf(entity.id) >= 0) return true; - return _.any(context.graph().parentRelations(entity), function(parent) { - return selection.indexOf(parent.id) >= 0; - }); + function selected() { + var s = iD.util.entitySelector(selection); + + selection.forEach(function(id) { + var entity = context.entity(id); + if (entity.type === 'relation') { + entity.members.forEach(function(member) { + s += ',.' + member.id + }); + } + }); + + return s; } d3.select(document) @@ -159,8 +166,7 @@ iD.modes.Select = function(context, selection) { function selectElements() { context.surface() - .selectAll("*") - .filter(selected) + .selectAll(selected()) .classed('selected', true); }