summaryrefslogtreecommitdiff
path: root/js/codeq
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
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')
-rw-r--r--js/codeq/aaiLogin.js2
-rw-r--r--js/codeq/about.js3
-rw-r--r--js/codeq/change_password.js3
-rw-r--r--js/codeq/language.js2
-rw-r--r--js/codeq/login.js2
-rw-r--r--js/codeq/navigation.js44
-rw-r--r--js/codeq/problem_list.js2
-rw-r--r--js/codeq/profile.js10
-rw-r--r--js/codeq/prolog.js3
-rw-r--r--js/codeq/python.js2
-rw-r--r--js/codeq/robot.js2
-rw-r--r--js/codeq/settings.js3
-rw-r--r--js/codeq/signup.js2
-rw-r--r--js/codeq/upgrade_to_aai.js2
14 files changed, 74 insertions, 8 deletions
diff --git a/js/codeq/aaiLogin.js b/js/codeq/aaiLogin.js
index a0a8e68..abe7283 100644
--- a/js/codeq/aaiLogin.js
+++ b/js/codeq/aaiLogin.js
@@ -29,6 +29,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
samlLoginUrl = '';
codeq.globalStateMachine.register('aailogin',{
+ 'jqScreen': jqScreen,
+
'enter': function(){
jqDisabledOverlay.css('display', '');
codeq.samlLogin = true;//set the flag
diff --git a/js/codeq/about.js b/js/codeq/about.js
index 25fa829..f56d9fd 100644
--- a/js/codeq/about.js
+++ b/js/codeq/about.js
@@ -23,6 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqBtnGoBack = $("#btnAboutGoBack");
codeq.globalStateMachine.register('about',{
+ 'jqScreen': jqScreen,
+ 'isModal': true,
+
'enter': function(){
jqBtnGoBack.on('click',function(){
history.back();//forces a transition to the previous state
diff --git a/js/codeq/change_password.js b/js/codeq/change_password.js
index dc5db39..6ebd6dd 100644
--- a/js/codeq/change_password.js
+++ b/js/codeq/change_password.js
@@ -26,6 +26,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqChangePassForm = $('#formChangePassword');
codeq.globalStateMachine.register('changePassword',{
+ 'jqScreen': jqScreen,
+ 'isModal': true,
+
'enter': function(){
jqCancelBtn.on('click',function(){
history.back();//forces a transition to the previous state
diff --git a/js/codeq/language.js b/js/codeq/language.js
index 5433c84..cacdb32 100644
--- a/js/codeq/language.js
+++ b/js/codeq/language.js
@@ -28,6 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
};
codeq.globalStateMachine.register('language',{
+ 'jqScreen': jqScreen,
+
'enter': function(){
jqScreen.css('display', '');
jqProlog.on('click', function (e) { e.preventDefault(); choose('prolog') });
diff --git a/js/codeq/login.js b/js/codeq/login.js
index 162e336..f7ddeb3 100644
--- a/js/codeq/login.js
+++ b/js/codeq/login.js
@@ -78,6 +78,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
formInputs = $('#username, #password');
codeq.globalStateMachine.register('login',{
+ 'jqScreen': jqScreen,
+
'enter': function(){
jqNavigationHomeBtn.off('click');//remove the click listener of this element here
jqNavBarRight.css('display','none');//hide settings etc.
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]));
+ }
}
}
};
diff --git a/js/codeq/problem_list.js b/js/codeq/problem_list.js
index 8c3808e..e3ce255 100644
--- a/js/codeq/problem_list.js
+++ b/js/codeq/problem_list.js
@@ -382,6 +382,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
// ================================================================================
codeq.globalStateMachine.register('problem_list', {
+ 'jqScreen': jqScreen,
+
'enter': function(language){
var data = languageCache[language]; // language data
diff --git a/js/codeq/profile.js b/js/codeq/profile.js
index 09a0e05..f863140 100644
--- a/js/codeq/profile.js
+++ b/js/codeq/profile.js
@@ -20,13 +20,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
(function(){
- var jqBtnChangePass = $("#change_pass_profile"),
+ var jqScreen = $("#screen_profile"),
+ jqBtnChangePass = $("#change_pass_profile"),
jqBtnGoBack = $("#btnProfileGoBack");
codeq.profile = {
};
codeq.globalStateMachine.register('profile',{
+ 'jqScreen': jqScreen,
+ 'isModal': true,
+
'enter': function(){
jqBtnChangePass.on('click',function(){
codeq.globalStateMachine.transition('changePassword');
@@ -35,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
history.back();//forces a transition to the previous state
});
if(codeq.samlLogin) $('#loggedInViaSamlSpan').css("display","");//show the span if we actually logged in with SAML
- $("#screen_profile").css('display', '');
+ jqScreen.css('display', '');
$('#disabled').css('display', 'none');
codeq.comms.getUserStat()
.then(function (data) {
@@ -78,7 +82,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
'exit' : function(){
jqBtnChangePass.off('click');
jqBtnGoBack.off('click');
- $("#screen_profile").css('display', 'none');
+ jqScreen.css('display', 'none');
$('#loggedInViaSamlSpan').css("display","none");
}
});
diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js
index 7f74aaf..8a6cddc 100644
--- a/js/codeq/prolog.js
+++ b/js/codeq/prolog.js
@@ -82,6 +82,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
};
var prologHandler; //created when we enter the prolog state and destroyed once we leave it
codeq.globalStateMachine.register('prolog', {
+ 'jqScreen': jqScreen,
+
'enter': function (problemDef, commonDef, currentSolution) {
$('#navigation-problem_list').css('display', '');
$("#navigation-prolog").addClass("active");
@@ -103,6 +105,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
});
},
'exit': function () {
+ codeq.log.info('prolog exit()');
jqAllButtons.off(); // unregister all event handlers
jqAllQuadrants.off();
jqScreen.css('display', 'none');
diff --git a/js/codeq/python.js b/js/codeq/python.js
index 4033a63..b1f46f5 100644
--- a/js/codeq/python.js
+++ b/js/codeq/python.js
@@ -87,6 +87,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
};
var pythonHandler; //created when we enter the python state and destroyed once we leave it
codeq.globalStateMachine.register('python', {
+ 'jqScreen': jqScreen,
+
'enter': function (problemDef, commonDef, currentSolution) {
$('#navigation-problem_list').css('display', '');
$("#navigation-python").addClass("active");
diff --git a/js/codeq/robot.js b/js/codeq/robot.js
index 0dca6f3..cfff13d 100644
--- a/js/codeq/robot.js
+++ b/js/codeq/robot.js
@@ -82,6 +82,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
};
var robotHandler; //created when we enter the robot state and destroyed once we leave it
codeq.globalStateMachine.register('robot', {
+ 'jqScreen': jqScreen,
+
'enter': function (problemDef, commonDef, currentSolution) {
$('#navigation-problem_list').css('display', '');
$("#navigation-robot").addClass("active");
diff --git a/js/codeq/settings.js b/js/codeq/settings.js
index 3e72cbd..6fec614 100644
--- a/js/codeq/settings.js
+++ b/js/codeq/settings.js
@@ -34,6 +34,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
});
codeq.globalStateMachine.register('settings',{
+ 'jqScreen': jqScreenSettings,
+ 'isModal': true,
+
'enter':function(){
jqDisabledOverlay.css('display', '');
robotAddressInput.val(codeq.settings['robot_address']);//set the robot address once we enter the state
diff --git a/js/codeq/signup.js b/js/codeq/signup.js
index 2667fe4..5f3f2be 100644
--- a/js/codeq/signup.js
+++ b/js/codeq/signup.js
@@ -32,6 +32,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqNavigationHomeBtn = $('#navigation-home');
codeq.globalStateMachine.register('signup',{
+ 'jqScreen': jqScreen,
+
'enter': function(){
jqNavigationHomeBtn.off('click');//remove the click listener of this element here
jqNavBarRight.css('display','none');//hide settings etc.
diff --git a/js/codeq/upgrade_to_aai.js b/js/codeq/upgrade_to_aai.js
index 6ea5855..5357a29 100644
--- a/js/codeq/upgrade_to_aai.js
+++ b/js/codeq/upgrade_to_aai.js
@@ -26,6 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqLangSelect = jqScreen.find('.lang-select');
codeq.globalStateMachine.register('upgradeToAAI',{
+ 'jqScreen': jqScreen,
+
'enter': function(){
jqNoBtn.on('click',function(){
codeq.comms.samlLogin(false)