@@ -635,32 +635,22 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
635635 }
636636
637637 // Check if callback is a function
638- if ( angular . isFunction ( callback ) ) {
639- if ( callback ( $scope . selectedStep ) ) {
640- if ( index <= enabledSteps . length - 1 ) {
641- // Go to the next step
642- if ( enabledSteps [ index + 1 ] . substeps ) {
643- enabledSteps [ index + 1 ] . resetNav ( ) ;
644- }
645- } else {
646- this . finish ( ) ;
647- return ;
648- }
638+ if ( ! angular . isFunction ( callback ) || callback ( $scope . selectedStep ) ) {
639+ // Completed property set on scope which is used to add class/remove class from progress bar
640+ $scope . selectedStep . completed = true ;
641+
642+ // Check to see if this is the last step. If it is next behaves the same as finish()
643+ if ( index === enabledSteps . length - 1 ) {
644+ this . finish ( ) ;
649645 } else {
650- return ;
646+ // Go to the next step
647+ if ( enabledSteps [ index + 1 ] . substeps ) {
648+ enabledSteps [ index + 1 ] . resetNav ( ) ;
649+ }
650+ // Go to the next step
651+ $scope . goTo ( enabledSteps [ index + 1 ] ) ;
651652 }
652653 }
653-
654- // Completed property set on scope which is used to add class/remove class from progress bar
655- $scope . selectedStep . completed = true ;
656-
657- // Check to see if this is the last step. If it is next behaves the same as finish()
658- if ( index === enabledSteps . length - 1 ) {
659- this . finish ( ) ;
660- } else {
661- // Go to the next step
662- $scope . goTo ( enabledSteps [ index + 1 ] ) ;
663- }
664654 } ;
665655
666656 this . previous = function ( callback ) {
@@ -673,15 +663,7 @@ angular.module('patternfly.wizard').directive('pfWizard', function ($window) {
673663 }
674664
675665 // Check if callback is a function
676- if ( angular . isFunction ( callback ) ) {
677- if ( callback ( $scope . selectedStep ) ) {
678- if ( index === 0 ) {
679- throw new Error ( "Can't go back. It's already in step 0" ) ;
680- } else {
681- $scope . goTo ( $scope . getEnabledSteps ( ) [ index - 1 ] ) ;
682- }
683- }
684- } else {
666+ if ( ! angular . isFunction ( callback ) || callback ( $scope . selectedStep ) ) {
685667 if ( index === 0 ) {
686668 throw new Error ( "Can't go back. It's already in step 0" ) ;
687669 } else {
0 commit comments