diff options
Diffstat (limited to 'js/codeq/navigation.js')
-rw-r--r-- | js/codeq/navigation.js | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/js/codeq/navigation.js b/js/codeq/navigation.js index 62344e5..d806eea 100644 --- a/js/codeq/navigation.js +++ b/js/codeq/navigation.js @@ -49,7 +49,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ //the global state machine is a bit different - so it'll be implemented here var makeGlobalStateMachine = function (def) { - var currState = null; + var currState = null, + waitingState = null; // state hidden with a modal form var stateChangeFun = function historyStateChangeHandler() { var historyState = History.getState(); codeq.globalStateMachine.actualTransition.apply(codeq.globalStateMachine, $.merge([historyState.data.state] ,historyState.data.params)); @@ -77,11 +78,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ } }, 'destroy': function () { + var i; if (currState) currState.exit(); currState = null; + if (waitingState) waitingState.exit(); + waitingState = null; History.Adapter.unbind(window, 'statechange', stateChangeFun); }, - 'register': function (name, state) { + 'register': function (name, state, props) { if (name in def) codeq.log.error('The state ' + name + ' is already registered, overriding'); def[name] = state; }, @@ -92,10 +96,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ } var newState = def[name];//if the newState is not the same as the old or if it doesn't exist at all is already checked at this point - if (currState) currState.exit(); - - currState = newState; - currState.enter.apply(currState, Array.prototype.slice.apply(arguments, [1])); + if (currState) { + if (newState.isModal) { + if (currState.isModal) currState.exit(); + else { + waitingState = currState; + waitingState.jqScreen.css('display', 'none'); + } + currState = newState; + currState.enter.apply(currState, Array.prototype.slice.apply(arguments, [1])); + } + else { + currState.exit(); + currState = newState; + if (waitingState === newState) { + waitingState.jqScreen.css('display', ''); + waitingState = null; + } + else { + if (waitingState) { + waitingState.exit(); + waitingState = null; + } + currState.enter.apply(currState, Array.prototype.slice.apply(arguments, [1])); + } + } + } + else { + currState = newState; + currState.enter.apply(currState, Array.prototype.slice.apply(arguments, [1])); + } } } }; |