summaryrefslogtreecommitdiff
path: root/js/codeq/navigation.js
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-12-15 11:26:23 +0100
committerAleš Smodiš <aless@guru.si>2015-12-15 11:26:23 +0100
commit13c8be3d82350082093df8cd65771f09fcb83c54 (patch)
tree3df49dfdff29a1d57cb30857c323187d50852a5e /js/codeq/navigation.js
parent8b223c8ad6e096105703776a59937da62d8cb3d5 (diff)
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.
Diffstat (limited to 'js/codeq/navigation.js')
-rw-r--r--js/codeq/navigation.js44
1 files changed, 39 insertions, 5 deletions
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 <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;
},
@@ -93,9 +97,39 @@ 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) 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]));
+ }
}
}
};