From 13c8be3d82350082093df8cd65771f09fcb83c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Tue, 15 Dec 2015 11:26:23 +0100 Subject: Fixed the bug about the loss of problem solving screen state when entering a navigation-bar state and getting back. Now every state carries with itself the publicly exposed jqScreen object and isModal boolean information, which is used by the globalStateMachine in the actualTransition method. --- js/codeq/navigation.js | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'js/codeq/navigation.js') diff --git a/js/codeq/navigation.js b/js/codeq/navigation.js index da2b04a..cfff71b 100644 --- a/js/codeq/navigation.js +++ b/js/codeq/navigation.js @@ -49,7 +49,8 @@ along with this program. If not, see . */ //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 . */ } }, '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; }, @@ -93,9 +97,39 @@ along with this program. If not, see . */ 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) 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])); + } } } }; -- cgit v1.2.1