installationWizard.js 3.1 KB

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