mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 22:03:37 +02:00
20 lines
542 B
JavaScript
Executable File
20 lines
542 B
JavaScript
Executable File
if (typeof iD === 'undefined') iD = {};
|
|
|
|
iD.Controller = function() {
|
|
var controller = {},
|
|
state = null;
|
|
|
|
controller.undoStack = new iD.UndoStack();
|
|
|
|
controller.setState = function(newState) {
|
|
// summary: Enter a new ControllerState, firing exitState on the old one, and enterState on the new one.
|
|
if (newState === state) { return; }
|
|
if (state) state.exitState();
|
|
newState.controller = controller;
|
|
state = newState;
|
|
newState.enterState();
|
|
};
|
|
|
|
return controller;
|
|
};
|