Files
iD/js/id/behavior/add_way.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

40 lines
1.0 KiB
JavaScript

iD.behavior.AddWay = function(context) {
var event = d3.dispatch('start', 'startFromWay', 'startFromNode', 'startFromMidpoint'),
draw = iD.behavior.Draw(context);
var addWay = function(surface) {
draw.on('click', event.start)
.on('clickWay', event.startFromWay)
.on('clickNode', event.startFromNode)
.on('clickMidpoint', event.startFromMidpoint)
.on('cancel', addWay.cancel)
.on('finish', addWay.cancel);
context.map()
.fastEnable(false)
.minzoom(16)
.dblclickEnable(false);
surface.call(draw);
};
addWay.off = function(surface) {
context.map()
.fastEnable(true)
.minzoom(0)
.tail(false);
window.setTimeout(function() {
context.map().dblclickEnable(true);
}, 1000);
surface.call(draw.off);
};
addWay.cancel = function() {
context.enter(iD.modes.Browse(context));
};
return d3.rebind(addWay, event, 'on');
};