Use entity ID selectors in more places

This commit is contained in:
John Firebaugh
2013-05-11 17:33:13 -07:00
parent 07fb94fee2
commit 1455c5e551
2 changed files with 15 additions and 10 deletions
+1 -2
View File
@@ -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 {
+14 -8
View File
@@ -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);
}