12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- var addNodesWizardStages = {
- /* The keys in 'stages' need to be kept in-sync with the <li> elements in
- * the markup.
- */
- stages : {
- 'addNodesStageId' : {
- divSelector : '#addNodesCoreDivId'
- },
- 'selectServicesStageId' : {
- divSelector : '#selectServicesCoreDivId'
- },
- },
- transitionToCachedStage :
- function (currentStageId, cachedStageId) {
- clearFormStatus();
- globalYui.log("In transitionToCachedStage: " + currentStageId + "->" + cachedStageId);
- swapStageVisibilities( this.stages[currentStageId].divSelector,
- this.stages[cachedStageId].divSelector );
- }
- };
- /* Setup the behavior for #installationWizardProgressBarListId */
- globalYui.one('#installationWizardProgressBarListId').delegate('click', function (e) {
- /* Important: When we specify CSS filters to delegate, we need to access
- * the filtered CSS element (which is what we really care to get at) via
- * 'this', not e.target.
- *
- * Only do anything with clicks on stages that have previously been visited.
- */
- if( this.hasClass('installationWizardVisitedStage') ) {
- var newCurrentStage = this;
- var nextStage = null;
- /* Mark the clicked-on stage as 'current'. */
- newCurrentStage.replaceClass( 'installationWizardVisitedStage', 'installationWizardCurrentStage' );
- globalYui.log("Marked " + newCurrentStage.get('id') + "from visited to current");
- var currentStage = newCurrentStage;
- while( nextStage = currentStage.next('.installationWizardVisitedStage') ) {
- /* Mark all the following 'visited' stages as 'unvisited'. */
- nextStage.replaceClass( 'installationWizardVisitedStage', 'installationWizardUnvisitedStage' );
- globalYui.log("Marked " + nextStage.get('id') + "from visited to unvisited");
- currentStage = nextStage;
- }
- var previouslyCurrentStage = currentStage.next();
- /* And finally, also mark the up-until-now 'current' stage as unvisited.
- * We know at this point that currentStage points to the last
- * previously-visited stage, and the last previously-visited stage is always
- * followed immediately by the up-until-now 'current' stage, so no fancier
- * checks are required - just depend on the invariants.
- */
- previouslyCurrentStage.replaceClass( 'installationWizardCurrentStage', 'installationWizardUnvisitedStage' );
- globalYui.log("Marked " + previouslyCurrentStage.get('id') + "from current to unvisited");
- /* Finally, flip to this newly 'current' stage, from the previously current one. */
- addNodesWizardStages.transitionToCachedStage( previouslyCurrentStage.get('id'), newCurrentStage.get('id') );
- }
- }, 'li' );
|