Files
iD/js/id/modes/draw_area.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
832 B
JavaScript

iD.modes.DrawArea = function(context, wayId, baseGraph) {
var mode = {
button: 'area',
id: 'draw-area'
};
var behavior;
mode.enter = function() {
var way = context.entity(wayId),
headId = way.nodes[way.nodes.length - 2],
tailId = way.first();
behavior = iD.behavior.DrawWay(context, wayId, -1, mode, baseGraph);
var addNode = behavior.addNode;
behavior.addNode = function(node) {
if (node.id === headId || node.id === tailId) {
behavior.finish();
} else {
addNode(node);
}
};
context.install(behavior);
context.tail(t('modes.draw_area.tail'));
};
mode.exit = function() {
context.uninstall(behavior);
};
return mode;
};