Files
iD/js/id/modes/draw_line.js
John Firebaugh 7e68e8e114 Add iD.Context
This is a facade interface that ties together a bunch of
different internal objects and will make it easier to write
tests for behaviors, modes, and operations.
2013-02-01 12:40:15 -05:00

36 lines
874 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);
var addNode = behavior.addNode;
behavior.addNode = function(node) {
if (node.id === headId) {
behavior.finish();
} else {
addNode(node);
}
};
context.install(behavior);
context.tail(t('modes.draw_line.tail'));
};
mode.exit = function() {
context.uninstall(behavior);
};
return mode;
};