Files
iD/js/id/modes/draw_line.js
John Firebaugh d238e4eaeb Convert Tail to a behavior
This avoids an extra mousemove listener in base modes.
2013-05-14 17:51:24 -07:00

40 lines
936 B
JavaScript

iD.modes.DrawLine = function(context, wayId, direction, baseGraph) {
var mode = {
button: 'line',
id: 'draw-line'
};
var behavior;
mode.enter = function() {
var way = context.entity(wayId),
index = (direction === 'forward') ? undefined : 0,
headId = (direction === 'forward') ? way.last() : way.first();
behavior = iD.behavior.DrawWay(context, wayId, index, mode, baseGraph)
.tail(t('modes.draw_line.tail'));
var addNode = behavior.addNode;
behavior.addNode = function(node) {
if (node.id === headId) {
behavior.finish();
} else {
addNode(node);
}
};
context.install(behavior);
};
mode.exit = function() {
context.uninstall(behavior);
};
mode.selection = function() {
return [wayId];
};
return mode;
};