addNodesWizard.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. var addNodesWizardStages = {
  2. /* The keys in 'stages' need to be kept in-sync with the <li> elements in
  3. * the markup.
  4. */
  5. stages : {
  6. 'addNodesStageId' : {
  7. divSelector : '#addNodesCoreDivId'
  8. },
  9. 'selectServicesStageId' : {
  10. divSelector : '#selectServicesCoreDivId'
  11. },
  12. },
  13. transitionToCachedStage :
  14. function (currentStageId, cachedStageId) {
  15. clearFormStatus();
  16. globalYui.log("In transitionToCachedStage: " + currentStageId + "->" + cachedStageId);
  17. swapStageVisibilities( this.stages[currentStageId].divSelector,
  18. this.stages[cachedStageId].divSelector );
  19. }
  20. };
  21. /* Setup the behavior for #installationWizardProgressBarListId */
  22. globalYui.one('#installationWizardProgressBarListId').delegate('click', function (e) {
  23. /* Important: When we specify CSS filters to delegate, we need to access
  24. * the filtered CSS element (which is what we really care to get at) via
  25. * 'this', not e.target.
  26. *
  27. * Only do anything with clicks on stages that have previously been visited.
  28. */
  29. if( this.hasClass('installationWizardVisitedStage') ) {
  30. var newCurrentStage = this;
  31. var nextStage = null;
  32. /* Mark the clicked-on stage as 'current'. */
  33. newCurrentStage.replaceClass( 'installationWizardVisitedStage', 'installationWizardCurrentStage' );
  34. globalYui.log("Marked " + newCurrentStage.get('id') + "from visited to current");
  35. var currentStage = newCurrentStage;
  36. while( nextStage = currentStage.next('.installationWizardVisitedStage') ) {
  37. /* Mark all the following 'visited' stages as 'unvisited'. */
  38. nextStage.replaceClass( 'installationWizardVisitedStage', 'installationWizardUnvisitedStage' );
  39. globalYui.log("Marked " + nextStage.get('id') + "from visited to unvisited");
  40. currentStage = nextStage;
  41. }
  42. var previouslyCurrentStage = currentStage.next();
  43. /* And finally, also mark the up-until-now 'current' stage as unvisited.
  44. * We know at this point that currentStage points to the last
  45. * previously-visited stage, and the last previously-visited stage is always
  46. * followed immediately by the up-until-now 'current' stage, so no fancier
  47. * checks are required - just depend on the invariants.
  48. */
  49. previouslyCurrentStage.replaceClass( 'installationWizardCurrentStage', 'installationWizardUnvisitedStage' );
  50. globalYui.log("Marked " + previouslyCurrentStage.get('id') + "from current to unvisited");
  51. /* Finally, flip to this newly 'current' stage, from the previously current one. */
  52. addNodesWizardStages.transitionToCachedStage( previouslyCurrentStage.get('id'), newCurrentStage.get('id') );
  53. }
  54. }, 'li' );