mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-20 18:13:30 +00:00
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.
20 lines
521 B
JavaScript
20 lines
521 B
JavaScript
// A controller holds a single action at a time and calls `.enter` and `.exit`
|
|
// to bind and unbind actions.
|
|
iD.Controller = function() {
|
|
var event = d3.dispatch('enter', 'exit');
|
|
var controller = { mode: null };
|
|
|
|
controller.enter = function(mode) {
|
|
if (controller.mode) {
|
|
controller.mode.exit();
|
|
event.exit(controller.mode);
|
|
}
|
|
|
|
mode.enter();
|
|
controller.mode = mode;
|
|
event.enter(mode);
|
|
};
|
|
|
|
return d3.rebind(controller, event, 'on');
|
|
};
|