diff --git a/bower.json b/bower.json index 8f9cf22..757c728 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "ionic-wizard", "description": "A set of Angular/Ionic directives to create a wizard using Ionic's slide box component", - "version": "1.0.0", + "version": "1.0.1", "homepage": "https://github.com/arielfaur/ionic-wizard", "license": "MIT", "devDependencies": { diff --git a/dist/ion-wizard.js b/dist/ion-wizard.js index 9f67864..6cb66e8 100644 --- a/dist/ion-wizard.js +++ b/dist/ion-wizard.js @@ -16,22 +16,26 @@ angular.module('ionic.wizard', []) }], link: function (scope, element, attrs, controller) { + var currentIndex = 0; + + $ionicSlideBoxDelegate.enableSlide(false); + element.css('height', '100%'); scope.$on("wizard:Previous", function() { $ionicSlideBoxDelegate.previous(); - $rootScope.$broadcast("wizard:IndexChanged"); }); scope.$on("wizard:Next", function() { - var index = $ionicSlideBoxDelegate.currentIndex(); - - if (controller.isStepValid(index)) { + if (controller.isStepValid(currentIndex)) { $ionicSlideBoxDelegate.next(); - $rootScope.$broadcast("wizard:IndexChanged"); } else { - $rootScope.$broadcast("wizard:StepFailed", {index: index}); + $rootScope.$broadcast("wizard:StepFailed", {index: currentIndex}); } }); + + scope.$on("slideBox.slideChanged", function(e, index) { + currentIndex = index; + }); } } @@ -57,11 +61,12 @@ angular.module('ionic.wizard', []) element.addClass('ng-hide'); element.on('click', function() { + //$ionicSlideBoxDelegate.previous(); $rootScope.$broadcast("wizard:Previous"); }); - scope.$on("wizard:IndexChanged", function() { - element.toggleClass('ng-hide', $ionicSlideBoxDelegate.currentIndex() == 0); + scope.$on("slideBox.slideChanged", function(e, index) { + element.toggleClass('ng-hide', index == 0); }); } } @@ -75,8 +80,8 @@ angular.module('ionic.wizard', []) $rootScope.$broadcast("wizard:Next"); }); - scope.$on("wizard:IndexChanged", function() { - element.toggleClass('ng-hide', $ionicSlideBoxDelegate.currentIndex() == $ionicSlideBoxDelegate.slidesCount() - 1); + scope.$on("slideBox.slideChanged", function(e, index) { + element.toggleClass('ng-hide', index == $ionicSlideBoxDelegate.slidesCount() - 1); }); } } @@ -94,8 +99,8 @@ angular.module('ionic.wizard', []) scope.startFn(); }); - scope.$on("wizard:IndexChanged", function() { - element.toggleClass('ng-hide', $ionicSlideBoxDelegate.currentIndex() < $ionicSlideBoxDelegate.slidesCount() - 1); + scope.$on("slideBox.slideChanged", function(e, index) { + element.toggleClass('ng-hide', index < $ionicSlideBoxDelegate.slidesCount() - 1); }); } } diff --git a/example/www/js/ion-wizard.js b/example/www/js/ion-wizard.js index 7f94794..6cb66e8 100644 --- a/example/www/js/ion-wizard.js +++ b/example/www/js/ion-wizard.js @@ -16,22 +16,26 @@ angular.module('ionic.wizard', []) }], link: function (scope, element, attrs, controller) { + var currentIndex = 0; + + $ionicSlideBoxDelegate.enableSlide(false); + element.css('height', '100%'); scope.$on("wizard:Previous", function() { $ionicSlideBoxDelegate.previous(); - $rootScope.$broadcast("wizard:IndexChanged"); }); scope.$on("wizard:Next", function() { - var index = $ionicSlideBoxDelegate.currentIndex(); - - if (controller.isStepValid(index)) { + if (controller.isStepValid(currentIndex)) { $ionicSlideBoxDelegate.next(); - $rootScope.$broadcast("wizard:IndexChanged"); } else { - $rootScope.$broadcast("wizard:StepFailed", {index: index}); + $rootScope.$broadcast("wizard:StepFailed", {index: currentIndex}); } }); + + scope.$on("slideBox.slideChanged", function(e, index) { + currentIndex = index; + }); } } @@ -61,8 +65,8 @@ angular.module('ionic.wizard', []) $rootScope.$broadcast("wizard:Previous"); }); - scope.$on("wizard:IndexChanged", function() { - element.toggleClass('ng-hide', $ionicSlideBoxDelegate.currentIndex() == 0); + scope.$on("slideBox.slideChanged", function(e, index) { + element.toggleClass('ng-hide', index == 0); }); } } @@ -76,8 +80,8 @@ angular.module('ionic.wizard', []) $rootScope.$broadcast("wizard:Next"); }); - scope.$on("wizard:IndexChanged", function() { - element.toggleClass('ng-hide', $ionicSlideBoxDelegate.currentIndex() == $ionicSlideBoxDelegate.slidesCount() - 1); + scope.$on("slideBox.slideChanged", function(e, index) { + element.toggleClass('ng-hide', index == $ionicSlideBoxDelegate.slidesCount() - 1); }); } } @@ -95,8 +99,8 @@ angular.module('ionic.wizard', []) scope.startFn(); }); - scope.$on("wizard:IndexChanged", function() { - element.toggleClass('ng-hide', $ionicSlideBoxDelegate.currentIndex() < $ionicSlideBoxDelegate.slidesCount() - 1); + scope.$on("slideBox.slideChanged", function(e, index) { + element.toggleClass('ng-hide', index < $ionicSlideBoxDelegate.slidesCount() - 1); }); } } diff --git a/package.json b/package.json index e01798a..4aa66fa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ionic-wizard", - "version": "1.0.0", - "description": "A set of Angular/Ionic directives to create a wizard using Ionic's slide box component", + "version": "1.0.1", + "description": "A set of Angular/Ionic directives to create a wizard using Ionic slide box component", "repository": "https://github.com/arielfaur/ionic-wizard", "license": "MIT", "devDependencies": { @@ -19,6 +19,6 @@ "pretest": "npm install", "test": "node node_modules/karma/bin/karma start karma.conf.js", - "test-single-run": "karma start karma.conf.js --single-run", + "test-single-run": "karma start karma.conf.js --single-run" } }