Skip to content

Commit

Permalink
disabled swiping because it does not play well with conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariel Faur committed Apr 3, 2015
1 parent 3ff4ff6 commit 5cc5e8f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
29 changes: 17 additions & 12 deletions dist/ion-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
}

Expand All @@ -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);
});
}
}
Expand All @@ -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);
});
}
}
Expand All @@ -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);
});
}
}
Expand Down
28 changes: 16 additions & 12 deletions example/www/js/ion-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
}

Expand Down Expand Up @@ -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);
});
}
}
Expand All @@ -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);
});
}
}
Expand All @@ -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);
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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"
}
}

0 comments on commit 5cc5e8f

Please sign in to comment.