@@ -323,14 +323,14 @@ Questions.resultMap = undefined;
323
323
// This data won't be used until after several questions, so this is tolerable.
324
324
325
325
jQuery . getJSON ( jQuery ( "script[src*='/termination-of-transfer/js/questions.js']" )
326
- . attr ( 'src' ) . replace ( / q u e s t i o n s \. j s .* $ / , '' )
327
- + 'results.json' )
326
+ . attr ( 'src' ) . replace ( / q u e s t i o n s \. j s .* $ / , '' )
327
+ + 'results.json' )
328
328
. done ( function ( result ) {
329
329
resultMap = result ;
330
330
} )
331
331
. fail ( function ( jqxhr , textStatus , error ) {
332
- var err = textStatus + ", " + error ;
333
- console . log ( "Request Failed: " + err ) ;
332
+ var err = textStatus + ", " + error ;
333
+ console . log ( "Request Failed: " + err ) ;
334
334
} ) ;
335
335
336
336
Questions . getConclusionDetails = function ( specifier ) {
@@ -346,11 +346,9 @@ Questions.getConclusionDetails = function (specifier) {
346
346
Questions . first_question = 's1q1a' ;
347
347
Questions . last_question = 's2q2fii' ;
348
348
349
- Questions . progress_stack = [ ] ;
350
-
351
349
Questions . start = function ( ) {
352
350
jQuery ( '.questionnaire-section, .question-progress-buttons' )
353
- . removeClass ( 'hidden' ) ;
351
+ . removeClass ( 'hidden' ) ;
354
352
jQuery ( '.no-javascript-alert' ) . addClass ( 'hidden' ) ;
355
353
//Navigation.disablePrevious();
356
354
Rendering . transitionTo ( Questions . first_question ) ;
@@ -389,12 +387,13 @@ Questions.nextQuestionID = function () {
389
387
Questions . nextQuestion = function ( ) {
390
388
// If the answer was OK, move on
391
389
if ( Questions . processAnswer ( ) ) {
390
+ ValuesStack . push ( ) ;
392
391
var id = Questions . nextQuestionID ( ) ;
393
- Questions . progress_stack . push ( id ) ;
392
+ Values . question_id = id ;
394
393
if ( id == 'finish' ) {
395
394
Questions . finish ( ) ;
396
395
} else {
397
- Questions . transitionQuestion ( id ) ;
396
+ Questions . transitionQuestion ( Values . question_id ) ;
398
397
// Scroll down to make sure the input UI is visible
399
398
jQuery ( 'html,body' ) . animate ( {
400
399
scrollTop : jQuery ( '#button-question-next' ) . offset ( ) . top } , 'slow' ) ;
@@ -404,22 +403,18 @@ Questions.nextQuestion = function () {
404
403
405
404
Questions . previousQuestion = function ( ) {
406
405
// If we are going back from *after* the last question, re-enable UI
407
- if ( Questions . progress_stack [ Questions . progress_stack . length - 1 ]
408
- == 'finish' ) {
406
+ if ( Values . question_id == 'finish' ) {
409
407
Navigation . unfinishQuestions ( ) ;
410
408
}
411
409
// Don't pop past the very first item
412
- if ( Questions . progress_stack . length > 0 ) {
413
- // Clear current answer
414
- var current_question = Questions [ Questions . current_question ] ;
415
- delete Values [ current_question . variable ] ;
416
- Answers . removeAnswer ( current_question . variable ) ;
410
+ if ( ValuesStack . height ( ) > 0 ) {
417
411
// Go back
418
- var previous_question =
419
- Questions . progress_stack [ Questions . progress_stack . length - 2 ] ;
420
- Questions . transitionQuestion ( previous_question ) ;
421
- Questions . progress_stack . pop ( ) ;
412
+ ValuesStack . pop ( ) ;
413
+ Questions . transitionQuestion ( Values . question_id ) ;
422
414
Notifications . clearAlerts ( ) ;
415
+ // Clear previous answer
416
+ var previous_question = Questions [ Values . question_id ] ;
417
+ Answers . removeAnswer ( previous_question . variable ) ;
423
418
// Scroll down to make sure the input UI is visible
424
419
jQuery ( 'html,body' ) . animate ( {
425
420
scrollTop : jQuery ( '#button-question-next' ) . offset ( ) . top } , 'slow' ) ;
@@ -442,7 +437,7 @@ Questions.start = function () {
442
437
Navigation . showAnswersTable ( ) ;
443
438
Navigation . showNextPrevious ( ) ;
444
439
jQuery ( '#button-question-next' ) . click ( Questions . nextQuestion ) ;
445
- // jQuery('#button-question-back').click(Questions.previousQuestion);
440
+ jQuery ( '#button-question-back' ) . click ( Questions . previousQuestion ) ;
446
441
// When the user presses "return" in a text area, move to next question
447
442
jQuery ( '#question-rendering-area' ) . on ( 'submit' , function ( ) {
448
443
if ( jQuery ( '#button-question-next' ) . is ( ':enabled' ) ) {
@@ -451,5 +446,5 @@ Questions.start = function () {
451
446
return false ;
452
447
} ) ;
453
448
Questions . transitionQuestion ( Questions . first_question ) ;
454
- Questions . progress_stack . push ( Questions . first_question ) ;
449
+ Values . question_id = Questions . first_question ;
455
450
} ;
0 commit comments