Files
iD/js/id/modes/draw_line.js
John Firebaugh a32ce33238 Add Way#affix
2013-08-30 13:59:29 -07:00

40 lines
924 B
JavaScript

iD.modes.DrawLine = function(context, wayId, baseGraph, affix) {
var mode = {
button: 'line',
id: 'draw-line'
};
var behavior;
mode.enter = function() {
var way = context.entity(wayId),
index = (affix === 'prefix') ? 0 : undefined,
headId = (affix === 'prefix') ? way.first() : way.last();
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.selectedIDs = function() {
return [wayId];
};
return mode;
};