Files
iD/js/id/behavior/select.js
John Firebaugh 3da0e70c0f Shift-selection
2013-02-01 14:31:47 -05:00

25 lines
722 B
JavaScript

iD.behavior.Select = function(context) {
function click() {
var datum = d3.select(d3.event.target).datum();
if (datum instanceof iD.Entity) {
if (d3.event.shiftKey) {
context.enter(iD.modes.Select(context, context.selection().concat([datum.id])));
} else {
context.enter(iD.modes.Select(context, [datum.id]));
}
} else if (!d3.event.shiftKey) {
context.enter(iD.modes.Browse(context));
}
}
var behavior = function(selection) {
selection.on('click.select', click);
};
behavior.off = function(selection) {
selection.on('click.select', null);
};
return behavior;
};