addNodesWizard.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. *
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. *
  20. */
  21. var addNodesWizardStages = {
  22. /* The keys in 'stages' need to be kept in-sync with the <li> elements in
  23. * the markup.
  24. */
  25. stages : {
  26. 'addNodesStageId' : {
  27. divSelector : '#addNodesCoreDivId'
  28. },
  29. 'selectServicesStageId' : {
  30. divSelector : '#selectServicesCoreDivId'
  31. },
  32. },
  33. transitionToCachedStage :
  34. function (currentStageId, cachedStageId) {
  35. clearFormStatus();
  36. globalYui.log("In transitionToCachedStage: " + currentStageId + "->" + cachedStageId);
  37. swapStageVisibilities( this.stages[currentStageId].divSelector,
  38. this.stages[cachedStageId].divSelector );
  39. }
  40. };
  41. /* Setup the behavior for #installationWizardProgressBarListId */
  42. globalYui.one('#installationWizardProgressBarListId').delegate('click', function (e) {
  43. /* Important: When we specify CSS filters to delegate, we need to access
  44. * the filtered CSS element (which is what we really care to get at) via
  45. * 'this', not e.target.
  46. *
  47. * Only do anything with clicks on stages that have previously been visited.
  48. */
  49. if( this.hasClass('installationWizardVisitedStage') ) {
  50. var newCurrentStage = this;
  51. var nextStage = null;
  52. /* Mark the clicked-on stage as 'current'. */
  53. newCurrentStage.replaceClass( 'installationWizardVisitedStage', 'installationWizardCurrentStage' );
  54. globalYui.log("Marked " + newCurrentStage.get('id') + "from visited to current");
  55. var currentStage = newCurrentStage;
  56. while( nextStage = currentStage.next('.installationWizardVisitedStage') ) {
  57. /* Mark all the following 'visited' stages as 'unvisited'. */
  58. nextStage.replaceClass( 'installationWizardVisitedStage', 'installationWizardUnvisitedStage' );
  59. globalYui.log("Marked " + nextStage.get('id') + "from visited to unvisited");
  60. currentStage = nextStage;
  61. }
  62. var previouslyCurrentStage = currentStage.next();
  63. /* And finally, also mark the up-until-now 'current' stage as unvisited.
  64. * We know at this point that currentStage points to the last
  65. * previously-visited stage, and the last previously-visited stage is always
  66. * followed immediately by the up-until-now 'current' stage, so no fancier
  67. * checks are required - just depend on the invariants.
  68. */
  69. previouslyCurrentStage.replaceClass( 'installationWizardCurrentStage', 'installationWizardUnvisitedStage' );
  70. globalYui.log("Marked " + previouslyCurrentStage.get('id') + "from current to unvisited");
  71. /* Finally, flip to this newly 'current' stage, from the previously current one. */
  72. addNodesWizardStages.transitionToCachedStage( previouslyCurrentStage.get('id'), newCurrentStage.get('id') );
  73. }
  74. }, 'li' );