From b79811cb0519e246f1d9dccafe30f1d6aaa2f74f Mon Sep 17 00:00:00 2001 From: Tane Piper Date: Fri, 31 Jan 2014 01:49:42 +0000 Subject: [PATCH 001/185] Method signature changed from deleteWizard to removeWizard as per function call --- dist/angular-wizard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 113c150..bb78152 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -183,7 +183,7 @@ angular.module('mgo-angular-wizard').factory('WizardHandler', function() { wizards[name] = wizard; } - service.deleteWizard = function(name) { + service.removeWizard = function(name) { delete wizards[name]; } From 1e7481362059719ec3a9718188c4e5acaa3734f6 Mon Sep 17 00:00:00 2001 From: Tane Piper Date: Fri, 31 Jan 2014 11:31:31 +0000 Subject: [PATCH 002/185] Fixed sig method in source, also replaced with .eval to fix issue of methods not being called --- dist/angular-wizard.js | 4 ++-- dist/angular-wizard.min.js | 4 ++-- src/wizardButtons.js | 6 +++--- src/wizardHandler.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index bb78152..be61b4b 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.0 - 2014-01-30 * @link https://github.com/mgonto/angular-wizard + * @version v0.2.0 - 2014-01-31 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -156,7 +156,7 @@ function wizardButtonDirective(action) { $element.on("click", function(e) { e.preventDefault(); $scope.$apply(function() { - var fn = $parse($attrs[action]); + var fn = $scope.$eval($attrs[action]); fn && fn(); wizard[action.replace("wz", "").toLowerCase()](); }); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 4082019..a78f23a 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.0 - 2014-01-30 * @link https://github.com/mgonto/angular-wizard + * @version v0.2.0 - 2014-01-31 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,["$parse",function(b){return{restrict:"A",replace:!1,require:"^wizard",link:function(c,d,e,f){d.on("click",function(d){d.preventDefault(),c.$apply(function(){var c=b(e[a]);c&&c(),f[a.replace("wz","").toLowerCase()]()})})}}}])}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.deleteWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,["$parse",function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){var c=b.$eval(d[a]);c&&c(),e[a.replace("wz","").toLowerCase()]()})})}}}])}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/wizardButtons.js b/src/wizardButtons.js index 7e46170..f26a035 100644 --- a/src/wizardButtons.js +++ b/src/wizardButtons.js @@ -1,6 +1,6 @@ function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') - .directive(action, ['$parse', function($parse) { + .directive(action, function() { return { restrict: 'A', replace: false, @@ -10,14 +10,14 @@ function wizardButtonDirective(action) { $element.on("click", function(e) { e.preventDefault(); $scope.$apply(function() { - var fn = $parse($attrs[action]); + var fn = $scope.$eval($attrs[action]); fn && fn(); wizard[action.replace("wz", "").toLowerCase()](); }); }); } } - }]); + }); } wizardButtonDirective('wzNext'); diff --git a/src/wizardHandler.js b/src/wizardHandler.js index 771b757..217d02c 100644 --- a/src/wizardHandler.js +++ b/src/wizardHandler.js @@ -9,7 +9,7 @@ angular.module('mgo-angular-wizard').factory('WizardHandler', function() { wizards[name] = wizard; } - service.deleteWizard = function(name) { + service.removeWizard = function(name) { delete wizards[name]; } From 6a4084386d3c62f1e89eb1347b5dbbaee4017b56 Mon Sep 17 00:00:00 2001 From: Tane Piper Date: Fri, 31 Jan 2014 11:34:53 +0000 Subject: [PATCH 003/185] Added dist build --- dist/angular-wizard.js | 4 ++-- dist/angular-wizard.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index be61b4b..09c3716 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -146,7 +146,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }); function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') - .directive(action, ['$parse', function($parse) { + .directive(action, function() { return { restrict: 'A', replace: false, @@ -163,7 +163,7 @@ function wizardButtonDirective(action) { }); } } - }]); + }); } wizardButtonDirective('wzNext'); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index a78f23a..f66849e 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -4,4 +4,4 @@ * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,["$parse",function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){var c=b.$eval(d[a]);c&&c(),e[a.replace("wz","").toLowerCase()]()})})}}}])}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){var c=b.$eval(d[a]);c&&c(),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 4f65bf17a1975ea9e41c86b044bb093c39dccaeb Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Fri, 31 Jan 2014 11:23:45 -0300 Subject: [PATCH 004/185] already runs the code. Removed function calling --- dist/angular-wizard.js | 3 +-- dist/angular-wizard.min.js | 2 +- src/wizardButtons.js | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 09c3716..ebaee4d 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -156,8 +156,7 @@ function wizardButtonDirective(action) { $element.on("click", function(e) { e.preventDefault(); $scope.$apply(function() { - var fn = $scope.$eval($attrs[action]); - fn && fn(); + $scope.$eval($attrs[action]); wizard[action.replace("wz", "").toLowerCase()](); }); }); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index f66849e..036b8ed 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -4,4 +4,4 @@ * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){var c=b.$eval(d[a]);c&&c(),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/wizardButtons.js b/src/wizardButtons.js index f26a035..1529fc4 100644 --- a/src/wizardButtons.js +++ b/src/wizardButtons.js @@ -10,8 +10,7 @@ function wizardButtonDirective(action) { $element.on("click", function(e) { e.preventDefault(); $scope.$apply(function() { - var fn = $scope.$eval($attrs[action]); - fn && fn(); + $scope.$eval($attrs[action]); wizard[action.replace("wz", "").toLowerCase()](); }); }); From 1a2ba1a22250c485d449b5576fafaab9b2c0bd1b Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Fri, 31 Jan 2014 11:25:13 -0300 Subject: [PATCH 005/185] 0.2.1 --- bower.json | 2 +- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 7f95dc3..83472a6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.2.0", + "version": "0.2.1", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index ebaee4d..7635025 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.0 - 2014-01-31 * @link https://github.com/mgonto/angular-wizard + * @version v0.2.1 - 2014-01-31 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 036b8ed..7639fe7 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.0 - 2014-01-31 * @link https://github.com/mgonto/angular-wizard + * @version v0.2.1 - 2014-01-31 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/package.json b/package.json index eae9ced..ddf04a5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.2.0", + "version": "0.2.1", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 87edcc9a4e36cdf5eafe25809f728490e1f611fc Mon Sep 17 00:00:00 2001 From: Mason Date: Tue, 11 Feb 2014 11:18:26 -0500 Subject: [PATCH 006/185] Adding ability to use attribute declaration with Angular-Wizard directive package. --- dist/angular-wizard.js | 82 +++++++++++++++++++------------------- dist/angular-wizard.min.js | 14 +++---- src/angularModule.js | 2 +- src/step.js | 4 +- src/wizard.js | 14 +++---- src/wizardButtons.js | 1 - src/wizardHandler.js | 8 ++-- 7 files changed, 63 insertions(+), 62 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 7635025..98ed7f9 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,33 +1,34 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.2.1 - 2014-01-31 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
\n" + - "
"); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
\n" + - "
\n" + - " \n" + - "
"); -}]); - -angular.module('mgo-angular-wizard', ['templates-angularwizard']); +/** + * Easy to use Wizard library for AngularJS + * @version v0.2.1 - 2014-02-11 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
\n" + + "
"); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
\n" + + "
\n" + + " \n" + + "
"); +}]); + +angular.module('mgo-angular-wizard', ['templates-angularwizard']); + angular.module('mgo-angular-wizard').directive('step', function() { return { - restrict: 'E', + restrict: 'EA', replace: true, transclude: true, scope: { @@ -40,9 +41,10 @@ angular.module('mgo-angular-wizard').directive('step', function() { } } }); + angular.module('mgo-angular-wizard').directive('wizard', function() { return { - restrict: 'E', + restrict: 'EA', replace: true, transclude: true, scope: { @@ -87,7 +89,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if ($scope.steps.length === 1) { $scope.goTo($scope.steps[0]); } - } + }; $scope.goTo = function(step) { unselectAll(); @@ -96,7 +98,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.currentStep = step.title; } step.selected = true; - } + }; function unselectAll() { _.each($scope.steps, function (step) { @@ -115,7 +117,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } else { $scope.goTo($scope.steps[index + 1]); } - } + }; this.goTo = function(step) { var stepTo; @@ -125,11 +127,11 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { stepTo = _.find($scope.steps, {title: step}); } $scope.goTo(stepTo); - } + }; this.finish = function() { $scope.onFinish && $scope.onFinish(); - } + }; this.cancel = this.previous = function() { var index = _.indexOf($scope.steps , $scope.selectedStep); @@ -144,6 +146,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }] } }); + function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') .directive(action, function() { @@ -169,8 +172,7 @@ wizardButtonDirective('wzNext'); wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); - - + angular.module('mgo-angular-wizard').factory('WizardHandler', function() { var service = {}; @@ -180,11 +182,11 @@ angular.module('mgo-angular-wizard').factory('WizardHandler', function() { service.addWizard = function(name, wizard) { wizards[name] = wizard; - } + }; service.removeWizard = function(name) { delete wizards[name]; - } + }; service.wizard = function(name) { var nameToUse = name; @@ -193,7 +195,7 @@ angular.module('mgo-angular-wizard').factory('WizardHandler', function() { } return wizards[nameToUse]; - } + }; return service; -}); \ No newline at end of file +}); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 7639fe7..2b536a7 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.2.1 - 2014-01-31 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +/** + * Easy to use Wizard library for AngularJS + * @version v0.2.1 - 2014-02-11 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/angularModule.js b/src/angularModule.js index 81c64dc..816d5be 100644 --- a/src/angularModule.js +++ b/src/angularModule.js @@ -1 +1 @@ -angular.module('mgo-angular-wizard', ['templates-angularwizard']); \ No newline at end of file +angular.module('mgo-angular-wizard', ['templates-angularwizard']); diff --git a/src/step.js b/src/step.js index 5b2273c..99d1f1f 100644 --- a/src/step.js +++ b/src/step.js @@ -1,6 +1,6 @@ angular.module('mgo-angular-wizard').directive('step', function() { return { - restrict: 'E', + restrict: 'EA', replace: true, transclude: true, scope: { @@ -12,4 +12,4 @@ angular.module('mgo-angular-wizard').directive('step', function() { wizard.addStep($scope); } } -}); \ No newline at end of file +}); diff --git a/src/wizard.js b/src/wizard.js index c2ae691..9ebe3f9 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -1,6 +1,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return { - restrict: 'E', + restrict: 'EA', replace: true, transclude: true, scope: { @@ -45,7 +45,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if ($scope.steps.length === 1) { $scope.goTo($scope.steps[0]); } - } + }; $scope.goTo = function(step) { unselectAll(); @@ -54,7 +54,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.currentStep = step.title; } step.selected = true; - } + }; function unselectAll() { _.each($scope.steps, function (step) { @@ -73,7 +73,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } else { $scope.goTo($scope.steps[index + 1]); } - } + }; this.goTo = function(step) { var stepTo; @@ -83,11 +83,11 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { stepTo = _.find($scope.steps, {title: step}); } $scope.goTo(stepTo); - } + }; this.finish = function() { $scope.onFinish && $scope.onFinish(); - } + }; this.cancel = this.previous = function() { var index = _.indexOf($scope.steps , $scope.selectedStep); @@ -101,4 +101,4 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }] } -}); \ No newline at end of file +}); diff --git a/src/wizardButtons.js b/src/wizardButtons.js index 1529fc4..f40a96d 100644 --- a/src/wizardButtons.js +++ b/src/wizardButtons.js @@ -23,4 +23,3 @@ wizardButtonDirective('wzNext'); wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); - diff --git a/src/wizardHandler.js b/src/wizardHandler.js index 217d02c..8957c94 100644 --- a/src/wizardHandler.js +++ b/src/wizardHandler.js @@ -7,11 +7,11 @@ angular.module('mgo-angular-wizard').factory('WizardHandler', function() { service.addWizard = function(name, wizard) { wizards[name] = wizard; - } + }; service.removeWizard = function(name) { delete wizards[name]; - } + }; service.wizard = function(name) { var nameToUse = name; @@ -20,7 +20,7 @@ angular.module('mgo-angular-wizard').factory('WizardHandler', function() { } return wizards[nameToUse]; - } + }; return service; -}); \ No newline at end of file +}); From 8653a78fdbd8fe85be8b4370c17b5dd37f4d7e7e Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Tue, 11 Feb 2014 20:18:52 -0200 Subject: [PATCH 007/185] Update README.md Donations --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0bd9ad2..f5c252e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Angular-Wizard +[![PayPayl donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using Paypal") +[![Donate on Gittip](http://badgr.co/gittip/mgonto.png)](https://www.gittip.com/mgonto/) + + Angular-wizard is a component that will make it easy for you to create wizards in your app. You can check a running example of the wizard [by clicking here](http://mgonto.github.io/angular-wizard/) # How do I add this to my project? From 18d5017cbf8d2c3e8d08693eab22048049ff881f Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Thu, 13 Feb 2014 16:44:02 -0300 Subject: [PATCH 008/185] Added step class It allows for animations to be added with angular-animate. Fixes #4 --- src/step.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/step.html b/src/step.html index 49148d9..59f13f2 100644 --- a/src/step.html +++ b/src/step.html @@ -1,2 +1,2 @@ -
+
\ No newline at end of file From 08ccd4c3da7440a2ff504a46abdb8782ec35242d Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Thu, 13 Feb 2014 16:45:18 -0300 Subject: [PATCH 009/185] Added new dist --- dist/angular-wizard.js | 30 ++++++++++++++++++++++++++++++ dist/angular-wizard.min.js | 12 +++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 98ed7f9..b7fede7 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,3 +1,4 @@ +<<<<<<< HEAD /** * Easy to use Wizard library for AngularJS * @version v0.2.1 - 2014-02-11 * @link https://github.com/mgonto/angular-wizard @@ -26,6 +27,35 @@ angular.module("wizard.html", []).run(["$templateCache", function($templateCache angular.module('mgo-angular-wizard', ['templates-angularwizard']); +======= +/** + * Easy to use Wizard library for AngularJS + * @version v0.2.1 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
\n" + + "
"); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
\n" + + "
\n" + + " \n" + + "
"); +}]); + +angular.module('mgo-angular-wizard', ['templates-angularwizard']); +>>>>>>> Added new dist angular.module('mgo-angular-wizard').directive('step', function() { return { restrict: 'EA', diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 2b536a7..e05990e 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,17 @@ +<<<<<<< HEAD /** * Easy to use Wizard library for AngularJS * @version v0.2.1 - 2014-02-11 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); +======= +/** + * Easy to use Wizard library for AngularJS + * @version v0.2.1 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); +>>>>>>> Added new dist From 46c390c10c38c4f4b04ebcdabcffa5c899e69518 Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Thu, 13 Feb 2014 16:47:10 -0300 Subject: [PATCH 010/185] Dist done --- dist/angular-wizard.js | 40 +++++--------------------------------- dist/angular-wizard.min.js | 12 +----------- 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index b7fede7..4d15509 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,33 +1,3 @@ -<<<<<<< HEAD -/** - * Easy to use Wizard library for AngularJS - * @version v0.2.1 - 2014-02-11 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
\n" + - "
"); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
\n" + - "
\n" + - " \n" + - "
"); -}]); - -angular.module('mgo-angular-wizard', ['templates-angularwizard']); - -======= /** * Easy to use Wizard library for AngularJS * @version v0.2.1 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard @@ -54,8 +24,8 @@ angular.module("wizard.html", []).run(["$templateCache", function($templateCache ""); }]); -angular.module('mgo-angular-wizard', ['templates-angularwizard']); ->>>>>>> Added new dist +angular.module('mgo-angular-wizard', ['templates-angularwizard']); + angular.module('mgo-angular-wizard').directive('step', function() { return { restrict: 'EA', @@ -71,7 +41,7 @@ angular.module('mgo-angular-wizard').directive('step', function() { } } }); - + angular.module('mgo-angular-wizard').directive('wizard', function() { return { restrict: 'EA', @@ -176,7 +146,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }] } }); - + function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') .directive(action, function() { @@ -202,7 +172,7 @@ wizardButtonDirective('wzNext'); wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); - + angular.module('mgo-angular-wizard').factory('WizardHandler', function() { var service = {}; diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index e05990e..5bfaed7 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,17 +1,7 @@ -<<<<<<< HEAD -/** - * Easy to use Wizard library for AngularJS - * @version v0.2.1 - 2014-02-11 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); -======= /** * Easy to use Wizard library for AngularJS * @version v0.2.1 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"E",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); ->>>>>>> Added new dist +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 4b1ab07db62289088a3c6aee2fe950b8a71f43d9 Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Thu, 13 Feb 2014 16:48:59 -0300 Subject: [PATCH 011/185] Only undefined properties get not set Fixes #8 --- src/wizard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wizard.js b/src/wizard.js index 9ebe3f9..21a9736 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -50,7 +50,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo = function(step) { unselectAll(); $scope.selectedStep = step; - if ($scope.currentStep) { + if (!_.isUndefined($scope.currentStep)) { $scope.currentStep = step.title; } step.selected = true; From 1f8b52248417d163a3ddd5125fc1028192996335 Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Thu, 13 Feb 2014 16:49:36 -0300 Subject: [PATCH 012/185] Grunted --- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 4d15509..53a8f9b 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -94,7 +94,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo = function(step) { unselectAll(); $scope.selectedStep = step; - if ($scope.currentStep) { + if (!_.isUndefined($scope.currentStep)) { $scope.currentStep = step.title; } step.selected = true; diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 5bfaed7..efc782d 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -4,4 +4,4 @@ * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,a.currentStep&&(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From bea7f0512818bf7d9b29294f972fdf5c2ae1f6a8 Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Thu, 13 Feb 2014 16:50:10 -0300 Subject: [PATCH 013/185] 0.2.2 --- bower.json | 2 +- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 83472a6..8b68e3e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.2.1", + "version": "0.2.2", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 53a8f9b..9a83242 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.1 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard + * @version v0.2.2 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index efc782d..438b375 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.1 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard + * @version v0.2.2 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/package.json b/package.json index ddf04a5..4765b17 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.2.1", + "version": "0.2.2", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 00ed1f97c9818029b243b3214f0605d587f0431a Mon Sep 17 00:00:00 2001 From: Ryan Tucker Date: Mon, 24 Feb 2014 10:50:14 -0500 Subject: [PATCH 014/185] Fixes issue #11. --- README.md | 16 ++++++++-------- dist/angular-wizard.js | 6 ++++-- dist/angular-wizard.min.js | 4 ++-- src/step.js | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f5c252e..091cadc 100644 --- a/README.md +++ b/README.md @@ -49,20 +49,20 @@ Now, in some HTML for a controller, you can just add a wizard as follows: ````html - +

This is the first step

Here you can use whatever you want. You can use other directives, binding, etc.

-
- + +

Continuing

You have continued here!

-
- + +

Even more steps!!

-
+
```` @@ -102,9 +102,9 @@ For those cases, we can inject the `WizardHandler` to our controller. The main function of this service is the `wizard(name)` which will let you get the wizard to manipulate it. If you have just one wizard in the screen and you didn't set a name to it, you can just call it as `wizard()`. Let's see an example: ````html - + - + ```` ````js diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 9a83242..5aee2d4 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.2 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard + * @version v0.2.2 - 2014-02-24 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -26,7 +26,7 @@ angular.module("wizard.html", []).run(["$templateCache", function($templateCache angular.module('mgo-angular-wizard', ['templates-angularwizard']); -angular.module('mgo-angular-wizard').directive('step', function() { +angular.module('mgo-angular-wizard').directive('wzStep', function() { return { restrict: 'EA', replace: true, @@ -37,6 +37,7 @@ angular.module('mgo-angular-wizard').directive('step', function() { require: '^wizard', templateUrl: 'step.html', link: function($scope, $element, $attrs, wizard) { + console.log('found scope step', $scope); wizard.addStep($scope); } } @@ -85,6 +86,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }, true); this.addStep = function(step) { + console.log('adding step', step); $scope.steps.push(step); if ($scope.steps.length === 1) { $scope.goTo($scope.steps[0]); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 438b375..e5ce45c 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.2 - 2014-02-13 * @link https://github.com/mgonto/angular-wizard + * @version v0.2.2 - 2014-02-24 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("step",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){console.log("found scope step",a),d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){console.log("adding step",b),a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/step.js b/src/step.js index 99d1f1f..0d6fb6d 100644 --- a/src/step.js +++ b/src/step.js @@ -1,4 +1,4 @@ -angular.module('mgo-angular-wizard').directive('step', function() { +angular.module('mgo-angular-wizard').directive('wzStep', function() { return { restrict: 'EA', replace: true, From 1949776b674179bf277bcea74a7e4c21c621c9d2 Mon Sep 17 00:00:00 2001 From: Ryan Tucker Date: Mon, 24 Feb 2014 10:52:10 -0500 Subject: [PATCH 015/185] Fixes issue #11. (Removed console.log I added). --- dist/angular-wizard.js | 2 -- dist/angular-wizard.min.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 5aee2d4..30488c4 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -37,7 +37,6 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { require: '^wizard', templateUrl: 'step.html', link: function($scope, $element, $attrs, wizard) { - console.log('found scope step', $scope); wizard.addStep($scope); } } @@ -86,7 +85,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }, true); this.addStep = function(step) { - console.log('adding step', step); $scope.steps.push(step); if ($scope.steps.length === 1) { $scope.goTo($scope.steps[0]); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index e5ce45c..980e7ef 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -4,4 +4,4 @@ * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){console.log("found scope step",a),d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){console.log("adding step",b),a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 36b67144088cfadc652120d4b59fd2b82670e9b0 Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Mon, 24 Feb 2014 13:07:51 -0300 Subject: [PATCH 016/185] v0.3.0 --- bower.json | 2 +- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 8b68e3e..ff1591f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.2.2", + "version": "0.3.0", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 30488c4..d6b939d 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.2 - 2014-02-24 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-02-24 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 980e7ef..bebb89a 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.2.2 - 2014-02-24 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-02-24 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/package.json b/package.json index 4765b17..e5116cb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.2.2", + "version": "0.3.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 3054e7ae74af12485e9b6fcb2c2d8a3c813b333e Mon Sep 17 00:00:00 2001 From: Victor Goya Date: Thu, 27 Feb 2014 15:08:35 +0100 Subject: [PATCH 017/185] add a attribute to select a custom template --- README.md | 1 + dist/angular-wizard.js | 10 +++++++--- dist/angular-wizard.min.js | 4 ++-- src/step.js | 4 +++- src/wizard.js | 4 +++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 091cadc..6c7f421 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Let's go step by step to see how this works. * **edit-mode**: If set to true, this will set the wizard as edit mode. Edit mode means that all steps have been completed byt he can modify any of them now. Defaults to false. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. * **current-step**: You need to set here a property from your scope (similar to `ng-model`) and that property will always have the name of the current step being shown on the screen. +* **templatel**: Path to a custom template. 2) Inside the wizard, we can have as many steps as we want. Each step MUST have a title which is going to be used to identify it. Inside each step, we can put whatever we want. Other directives, bindings, controls, forms, etc. diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index d6b939d..f8555ca 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-02-24 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.1 - 2014-02-27 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -35,7 +35,9 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { title: '@' }, require: '^wizard', - templateUrl: 'step.html', + templateUrl: function(element, attributes) { + return attributes.template || "step.html"; + }, link: function($scope, $element, $attrs, wizard) { wizard.addStep($scope); } @@ -54,7 +56,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { editMode: '=', name: '@' }, - templateUrl: 'wizard.html', + templateUrl: function(element, attributes) { + return attributes.template || "wizard.html"; + }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index bebb89a..96e5b6a 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-02-24 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-02-27 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:"step.html",link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:"wizard.html",controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/step.js b/src/step.js index 0d6fb6d..aa69d18 100644 --- a/src/step.js +++ b/src/step.js @@ -7,7 +7,9 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { title: '@' }, require: '^wizard', - templateUrl: 'step.html', + templateUrl: function(element, attributes) { + return attributes.template || "step.html"; + }, link: function($scope, $element, $attrs, wizard) { wizard.addStep($scope); } diff --git a/src/wizard.js b/src/wizard.js index 21a9736..34b66f7 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -10,7 +10,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { editMode: '=', name: '@' }, - templateUrl: 'wizard.html', + templateUrl: function(element, attributes) { + return attributes.template || "wizard.html"; + }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); From 962b3ea8cc0ab8aadd8789a7841ba9b20b57efec Mon Sep 17 00:00:00 2001 From: Victor Goya Date: Thu, 27 Feb 2014 15:10:26 +0100 Subject: [PATCH 018/185] fix typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c7f421..d74f02b 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Let's go step by step to see how this works. * **edit-mode**: If set to true, this will set the wizard as edit mode. Edit mode means that all steps have been completed byt he can modify any of them now. Defaults to false. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. * **current-step**: You need to set here a property from your scope (similar to `ng-model`) and that property will always have the name of the current step being shown on the screen. -* **templatel**: Path to a custom template. +* **template**: Path to a custom template. 2) Inside the wizard, we can have as many steps as we want. Each step MUST have a title which is going to be used to identify it. Inside each step, we can put whatever we want. Other directives, bindings, controls, forms, etc. From 3a74ed53bfc020584744a6b2abad08407eeafcc0 Mon Sep 17 00:00:00 2001 From: raykin Date: Fri, 21 Mar 2014 13:44:44 +0800 Subject: [PATCH 019/185] replace _.find with _.findWhere to make it compatible with underscore --- src/wizard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index 34b66f7..9df45fc 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -26,7 +26,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if (!step) return; if ($scope.selectedStep && $scope.selectedStep.title !== $scope.currentStep) { - $scope.goTo(_.find($scope.steps, {title: $scope.currentStep})); + $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); } }); @@ -82,7 +82,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if (_.isNumber(step)) { stepTo = $scope.steps[step]; } else { - stepTo = _.find($scope.steps, {title: step}); + stepTo = _.findWhere($scope.steps, {title: step}); } $scope.goTo(stepTo); }; From a22beb25967b380b73ac78a67f2206439d593c4c Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 21 Mar 2014 03:35:56 -0400 Subject: [PATCH 020/185] add optional attr wz-title --- src/step.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/step.js b/src/step.js index aa69d18..c9efe31 100644 --- a/src/step.js +++ b/src/step.js @@ -4,6 +4,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { replace: true, transclude: true, scope: { + wzTitle: '@', title: '@' }, require: '^wizard', @@ -11,6 +12,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { return attributes.template || "step.html"; }, link: function($scope, $element, $attrs, wizard) { + $scope.title = $scope.title || $scope.wzTitle; wizard.addStep($scope); } } From 99645b22c68eccd61a47b8ca9b0d7fd82ae6eeee Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 21 Mar 2014 04:00:35 -0400 Subject: [PATCH 021/185] fix indicator for wz-title --- src/wizard.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wizard.html b/src/wizard.html index 9c521e8..06e9e4c 100644 --- a/src/wizard.html +++ b/src/wizard.html @@ -2,7 +2,7 @@
- \ No newline at end of file + From 6ee6e605acbd10f99711004451c6eef15af8d3b2 Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 22 Mar 2014 00:09:43 -0400 Subject: [PATCH 022/185] rebuilt angular-wizard --- dist/angular-wizard.js | 9 ++++++--- dist/angular-wizard.min.js | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index f8555ca..1a5bc73 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.1 - 2014-02-27 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-03-22 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -18,10 +18,11 @@ angular.module("wizard.html", []).run(["$templateCache", function($templateCache "
\n" + " \n" + - ""); + "\n" + + ""); }]); angular.module('mgo-angular-wizard', ['templates-angularwizard']); @@ -32,6 +33,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { replace: true, transclude: true, scope: { + wzTitle: '@', title: '@' }, require: '^wizard', @@ -39,6 +41,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { return attributes.template || "step.html"; }, link: function($scope, $element, $attrs, wizard) { + $scope.title = $scope.title || $scope.wzTitle; wizard.addStep($scope); } } diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 96e5b6a..18ebade 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-02-27 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-03-22 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 6e797218b5d06cc8b105a2d093f68f388b795c5d Mon Sep 17 00:00:00 2001 From: Eric Steinborn Date: Fri, 28 Mar 2014 10:43:10 -0400 Subject: [PATCH 023/185] fixed missing semicolons, passes JSHint now. Wizard.js - Line 91 was failing JSHint, it passes now. --- src/wizard.js | 40 ++++++++++++++++++++-------------------- src/wizardButtons.js | 6 +++--- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index 34b66f7..7c071f0 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -14,57 +14,57 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return attributes.template || "wizard.html"; }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { - + WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); $scope.$on('$destroy', function() { WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); }); - + $scope.steps = []; - + $scope.$watch('currentStep', function(step) { if (!step) return; - + if ($scope.selectedStep && $scope.selectedStep.title !== $scope.currentStep) { $scope.goTo(_.find($scope.steps, {title: $scope.currentStep})); } - + }); - + $scope.$watch('[editMode, steps.length]', function() { var editMode = $scope.editMode; if (_.isUndefined(editMode) || _.isNull(editMode)) return; - + if (editMode) { _.each($scope.steps, function(step) { step.completed = true; }); } }, true); - + this.addStep = function(step) { $scope.steps.push(step); if ($scope.steps.length === 1) { $scope.goTo($scope.steps[0]); } }; - + $scope.goTo = function(step) { unselectAll(); $scope.selectedStep = step; if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title; + $scope.currentStep = step.title; } step.selected = true; }; - + function unselectAll() { _.each($scope.steps, function (step) { step.selected = false; }); $scope.selectedStep = null; } - + this.next = function(draft) { var index = _.indexOf($scope.steps , $scope.selectedStep); if (!draft) { @@ -76,7 +76,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo($scope.steps[index + 1]); } }; - + this.goTo = function(step) { var stepTo; if (_.isNumber(step)) { @@ -86,11 +86,13 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } $scope.goTo(stepTo); }; - + this.finish = function() { - $scope.onFinish && $scope.onFinish(); + if ($scope.onFinish) { + $scope.onFinish(); + } }; - + this.cancel = this.previous = function() { var index = _.indexOf($scope.steps , $scope.selectedStep); if (index === 0) { @@ -98,9 +100,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } else { $scope.goTo($scope.steps[index - 1]); } - } - - + }; }] - } + }; }); diff --git a/src/wizardButtons.js b/src/wizardButtons.js index f40a96d..dd596d5 100644 --- a/src/wizardButtons.js +++ b/src/wizardButtons.js @@ -6,7 +6,7 @@ function wizardButtonDirective(action) { replace: false, require: '^wizard', link: function($scope, $element, $attrs, wizard) { - + $element.on("click", function(e) { e.preventDefault(); $scope.$apply(function() { @@ -15,8 +15,8 @@ function wizardButtonDirective(action) { }); }); } - } - }); + }; + }); } wizardButtonDirective('wzNext'); From a43653731f7c15c011c2a8cbe067ee0e3bead14c Mon Sep 17 00:00:00 2001 From: Cristian Spinetta Date: Wed, 2 Apr 2014 19:18:11 -0300 Subject: [PATCH 024/185] add main unit tests --- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- karma.conf.js | 1 + package.json | 2 +- test/validationSpec.js | 60 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 test/validationSpec.js diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index f8555ca..1037be6 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.1 - 2014-02-27 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-04-02 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 96e5b6a..f133974 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-02-27 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-04-02 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/karma.conf.js b/karma.conf.js index 3a1f1a5..dd01cff 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -11,6 +11,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ + 'http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js', 'http://code.angularjs.org/1.1.4/angular.js', 'http://code.angularjs.org/1.1.4/angular-resource.js', 'http://code.angularjs.org/1.1.4/angular-mocks.js', diff --git a/package.json b/package.json index e5116cb..b2be0d7 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "grunt-contrib-copy": "~0.4.1", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-uglify": "~0.2.0", - "grunt-karma": "~0.5.0", + "grunt-karma": "~0.8", "grunt-ngmin": "0.0.2", "grunt-html2js": "~0.1.3", "grunt-conventional-changelog": "~0.1.1", diff --git a/test/validationSpec.js b/test/validationSpec.js new file mode 100644 index 0000000..34956dd --- /dev/null +++ b/test/validationSpec.js @@ -0,0 +1,60 @@ +describe( 'Validations for the step changes', function() { + var $compile, $rootScope, scope, view, WizardHandler; + + beforeEach(module('mgo-angular-wizard')); + beforeEach(inject(function(_$compile_, _$rootScope_, _WizardHandler_) { + $compile = _$compile_; + $rootScope = _$rootScope_; + WizardHandler = _WizardHandler_; + scope = $rootScope.$new(); + createView(scope); + $rootScope.$digest(); + })); + + function createView(scope) { + scope.finishedWizard = function() { + /** + * It's Ok to do nothing + */ + } + scope.referenceCurrentStep = null; + var element = angular.element('' + + ' ' + + '

This is the first step

' + + '

Here you can use whatever you want. You can use other directives, binding, etc.

' + + ' ' + + '
' + + ' ' + + '

Continuing

' + + '

You have continued here!

' + + ' ' + + '
' + + ' ' + + '

Even more steps!!

' + + ' ' + + '
' + + '
'); + view = $compile(element)(scope); + } + + it('should correctly create the wizard', function() { + expect(WizardHandler).toBeTruthy(); + expect(view.find('section').length).toEqual(3); + // expect the currect step to be desirable one + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().goTo('Continuing'); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + }) + + //TODO: implement the rest of the unit tests + it( 'should allow to go to the next step when the current step is valid', function() { + expect( true ).toBeTruthy(); + }); + it( 'should allow to return to a previous step although the current step is not valid', function() { + expect( true ).toBeTruthy(); + }); + it( 'should not allow to return to a previous step if the current step is not valid and the attribute validateOnlyToAdvance is false', function() { + expect( true ).toBeTruthy(); + }); +}); \ No newline at end of file From e130b8df13483a938b86bc1999a9b7d335e569f4 Mon Sep 17 00:00:00 2001 From: Cristian Spinetta Date: Thu, 3 Apr 2014 23:49:00 -0300 Subject: [PATCH 025/185] Add validation for step and the validateOnlyToAdvance attribute --- dist/angular-wizard.js | 28 +++++++++++++++++++++++++--- dist/angular-wizard.min.js | 4 ++-- src/step.js | 6 +++++- src/wizard.js | 20 +++++++++++++++++++- 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 1037be6..6c45b3e 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-04-02 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-04-03 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -32,13 +32,17 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { replace: true, transclude: true, scope: { - title: '@' + title: '@', + validateStep: '&' }, require: '^wizard', templateUrl: function(element, attributes) { return attributes.template || "step.html"; }, link: function($scope, $element, $attrs, wizard) { + // If the validateStep isn't passed, the validate function must return true + if (_.isUndefined($attrs['validateStep'])) + $scope.validateStep = function() { return true; }; wizard.addStep($scope); } } @@ -53,6 +57,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { currentStep: '=', onFinish: '&', hideIndicators: '=', + validateOnlyToAdvance: '@', editMode: '=', name: '@' }, @@ -60,6 +65,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return attributes.template || "wizard.html"; }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { + + var validateOnlyToAdvance = _.isUndefined($scope.validateOnlyToAdvance) ? true : $scope.validateOnlyToAdvance === 'true'; WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); $scope.$on('$destroy', function() { @@ -96,13 +103,28 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; $scope.goTo = function(step) { + if (!$scope.validateGoTo(step)) return; unselectAll(); $scope.selectedStep = step; if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title; + $scope.currentStep = step.title; } step.selected = true; }; + + $scope.validateGoTo = function(nextStep) { + var indexNextStep = _.indexOf($scope.steps , nextStep); + var indexCurrentStep = _.indexOf($scope.steps, $scope.selectedStep); + if (indexNextStep == -1 || indexCurrentStep == -1) { + // if the next step is invalid, it won't change the step + // if the current step is invalid, there is nothing to validate. + return true; + } + if (validateOnlyToAdvance && indexNextStep < indexCurrentStep) + return true; + else + return $scope.selectedStep.validateStep(); + }; function unselectAll() { _.each($scope.steps, function (step) { diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index f133974..9e6ac30 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-04-02 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-04-03 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{title:"@",validateStep:"&"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){_.isUndefined(c.validateStep)&&(a.validateStep=function(){return!0}),d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",validateOnlyToAdvance:"@",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var e=_.isUndefined(a.validateOnlyToAdvance)?!0:"true"===a.validateOnlyToAdvance;c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){a.validateGoTo(b)&&(d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0)},a.validateGoTo=function(b){var c=_.indexOf(a.steps,b),d=_.indexOf(a.steps,a.selectedStep);return-1==c||-1==d?!0:e&&d>c?!0:a.selectedStep.validateStep()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/step.js b/src/step.js index aa69d18..aa4df1a 100644 --- a/src/step.js +++ b/src/step.js @@ -4,13 +4,17 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { replace: true, transclude: true, scope: { - title: '@' + title: '@', + validateStep: '&' }, require: '^wizard', templateUrl: function(element, attributes) { return attributes.template || "step.html"; }, link: function($scope, $element, $attrs, wizard) { + // If the validateStep isn't passed, the validate function must return true + if (_.isUndefined($attrs['validateStep'])) + $scope.validateStep = function() { return true; }; wizard.addStep($scope); } } diff --git a/src/wizard.js b/src/wizard.js index 34b66f7..c4d2663 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -7,6 +7,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { currentStep: '=', onFinish: '&', hideIndicators: '=', + validateOnlyToAdvance: '@', editMode: '=', name: '@' }, @@ -14,6 +15,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return attributes.template || "wizard.html"; }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { + + var validateOnlyToAdvance = _.isUndefined($scope.validateOnlyToAdvance) ? true : $scope.validateOnlyToAdvance === 'true'; WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); $scope.$on('$destroy', function() { @@ -50,13 +53,28 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; $scope.goTo = function(step) { + if (!$scope.validateGoTo(step)) return; unselectAll(); $scope.selectedStep = step; if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title; + $scope.currentStep = step.title; } step.selected = true; }; + + $scope.validateGoTo = function(nextStep) { + var indexNextStep = _.indexOf($scope.steps , nextStep); + var indexCurrentStep = _.indexOf($scope.steps, $scope.selectedStep); + if (indexNextStep == -1 || indexCurrentStep == -1) { + // if the next step is invalid, it won't change the step + // if the current step is invalid, there is nothing to validate. + return true; + } + if (validateOnlyToAdvance && indexNextStep < indexCurrentStep) + return true; + else + return $scope.selectedStep.validateStep(); + }; function unselectAll() { _.each($scope.steps, function (step) { From 8dd16eba010954c3d13f48480dca82f074271f73 Mon Sep 17 00:00:00 2001 From: Cristian Spinetta Date: Thu, 3 Apr 2014 23:50:50 -0300 Subject: [PATCH 026/185] Unit tests for validation --- test/validationSpec.js | 97 +++++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 20 deletions(-) diff --git a/test/validationSpec.js b/test/validationSpec.js index 34956dd..4cdc685 100644 --- a/test/validationSpec.js +++ b/test/validationSpec.js @@ -1,60 +1,117 @@ describe( 'Validations for the step changes', function() { - var $compile, $rootScope, scope, view, WizardHandler; + var $compile, $rootScope, WizardHandler; beforeEach(module('mgo-angular-wizard')); beforeEach(inject(function(_$compile_, _$rootScope_, _WizardHandler_) { $compile = _$compile_; $rootScope = _$rootScope_; WizardHandler = _WizardHandler_; - scope = $rootScope.$new(); - createView(scope); - $rootScope.$digest(); })); - function createView(scope) { - scope.finishedWizard = function() { - /** - * It's Ok to do nothing - */ + /** + * Create the view with wizard to test + * @param {Scope} scope A scope to bind to + * @param {String} validators Name of validators for each step + * @param {Boolean} validateOnlyToAdvance Boolean value to set validate-only-to-advance + * @return {[DOM element]} A DOM element compiled + */ + function createView(scope, validators, validateOnlyToAdvance) { + + // Check the name of validators and generate attributes + var attrValidators = []; + if (!_.isArray(validators)) { + validators = []; } + validators.length = 3; + _.each(validators, function (name, index) { + attrValidators[index] = _.isUndefined(name) ? '' : 'validate-step="' + name + '"'; + }); + + if (_.isBoolean(validateOnlyToAdvance)) + attrValidateOnlyToAdvance = 'validate-only-to-advance="' + validateOnlyToAdvance.toString() + '"'; + else + attrValidateOnlyToAdvance = ''; + scope.referenceCurrentStep = null; - var element = angular.element('' - + ' ' + + var element = angular.element('' + + ' ' + '

This is the first step

' + '

Here you can use whatever you want. You can use other directives, binding, etc.

' + ' ' + '
' - + ' ' + + ' ' + '

Continuing

' + '

You have continued here!

' + ' ' + '
' - + ' ' + + ' ' + '

Even more steps!!

' + ' ' + '
' + '
'); - view = $compile(element)(scope); + var elementCompiled = $compile(element)(scope); + $rootScope.$digest(); + return elementCompiled; } it('should correctly create the wizard', function() { + var scope = $rootScope.$new(); + var view = createView(scope); expect(WizardHandler).toBeTruthy(); expect(view.find('section').length).toEqual(3); // expect the currect step to be desirable one expect(scope.referenceCurrentStep).toEqual('Starting'); + }); + + it( 'should allow to go to the next step when there is not passed a function to validate', function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo('Continuing'); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); - }) - - //TODO: implement the rest of the unit tests + }); it( 'should allow to go to the next step when the current step is valid', function() { - expect( true ).toBeTruthy(); + var scope = $rootScope.$new(); + scope.validateSuccessfully = function() { return true; }; + var view = createView(scope, ['validateSuccessfully()']); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().goTo('Continuing'); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + }); + it( 'should not allow to go to the next step if the current step is not valid', function() { + var scope = $rootScope.$new(); + scope.validateUnsuccessfully = function() { return false; }; + var view = createView(scope, ['validateUnsuccessfully()']); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().goTo('Continuing'); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Starting'); }); it( 'should allow to return to a previous step although the current step is not valid', function() { - expect( true ).toBeTruthy(); + var scope = $rootScope.$new(); + scope.validateUnsuccessfully = function() { return false; }; + var view = createView(scope, [undefined, 'validateUnsuccessfully()']); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().goTo('Continuing'); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().goTo('Starting'); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Starting'); }); it( 'should not allow to return to a previous step if the current step is not valid and the attribute validateOnlyToAdvance is false', function() { - expect( true ).toBeTruthy(); + var scope = $rootScope.$new(); + scope.validateUnsuccessfully = function() { return false; }; + var view = createView(scope, [undefined, 'validateUnsuccessfully()'], false); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().goTo('Continuing'); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().goTo('Starting'); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); }); }); \ No newline at end of file From 23049616d0a6bdd1a862c6887ae0697476439f04 Mon Sep 17 00:00:00 2001 From: Prem Prakash Date: Fri, 4 Apr 2014 15:34:55 -0300 Subject: [PATCH 027/185] adding lodash dependency to bower.json --- bower.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index ff1591f..aa48003 100644 --- a/bower.json +++ b/bower.json @@ -8,6 +8,7 @@ "url": "git://github.com/mgonto/angular-wizard.git" }, "dependencies": { + "lodash": ">=1.3.0 <2.5.0", "angular": "*" }, "ignore": [ @@ -15,4 +16,4 @@ "components", "lib" ] -} \ No newline at end of file +} From bcd2f5c0518e13f361616a4d2a16794a4fa17f63 Mon Sep 17 00:00:00 2001 From: Tyler Hughes Date: Mon, 14 Apr 2014 22:51:14 -0700 Subject: [PATCH 028/185] Fixing title references in currentStep attribute to account for wz-step addition --- dist/angular-wizard.js | 54 +++++++++++++++++++------------------- dist/angular-wizard.min.js | 4 +-- src/wizard.js | 6 ++--- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 1a5bc73..a525bc1 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-03-22 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-04-14 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -63,57 +63,57 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return attributes.template || "wizard.html"; }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { - + WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); $scope.$on('$destroy', function() { WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); }); - + $scope.steps = []; - + $scope.$watch('currentStep', function(step) { if (!step) return; - - if ($scope.selectedStep && $scope.selectedStep.title !== $scope.currentStep) { - $scope.goTo(_.find($scope.steps, {title: $scope.currentStep})); + var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; + if ($scope.selectedStep && stepTitle !== $scope.currentStep) { + $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); } - + }); - + $scope.$watch('[editMode, steps.length]', function() { var editMode = $scope.editMode; if (_.isUndefined(editMode) || _.isNull(editMode)) return; - + if (editMode) { _.each($scope.steps, function(step) { step.completed = true; }); } }, true); - + this.addStep = function(step) { $scope.steps.push(step); if ($scope.steps.length === 1) { $scope.goTo($scope.steps[0]); } }; - + $scope.goTo = function(step) { unselectAll(); $scope.selectedStep = step; if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title; + $scope.currentStep = step.title || step.wzTitle; } step.selected = true; }; - + function unselectAll() { _.each($scope.steps, function (step) { step.selected = false; }); $scope.selectedStep = null; } - + this.next = function(draft) { var index = _.indexOf($scope.steps , $scope.selectedStep); if (!draft) { @@ -125,21 +125,23 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo($scope.steps[index + 1]); } }; - + this.goTo = function(step) { var stepTo; if (_.isNumber(step)) { stepTo = $scope.steps[step]; } else { - stepTo = _.find($scope.steps, {title: step}); + stepTo = _.findWhere($scope.steps, {title: step}); } $scope.goTo(stepTo); }; - + this.finish = function() { - $scope.onFinish && $scope.onFinish(); + if ($scope.onFinish) { + $scope.onFinish(); + } }; - + this.cancel = this.previous = function() { var index = _.indexOf($scope.steps , $scope.selectedStep); if (index === 0) { @@ -147,11 +149,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } else { $scope.goTo($scope.steps[index - 1]); } - } - - + }; }] - } + }; }); function wizardButtonDirective(action) { @@ -162,7 +162,7 @@ function wizardButtonDirective(action) { replace: false, require: '^wizard', link: function($scope, $element, $attrs, wizard) { - + $element.on("click", function(e) { e.preventDefault(); $scope.$apply(function() { @@ -171,8 +171,8 @@ function wizardButtonDirective(action) { }); }); } - } - }); + }; + }); } wizardButtonDirective('wzNext'); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 18ebade..a5523c6 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-03-22 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-04-14 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/wizard.js b/src/wizard.js index 6127055..264a20c 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -24,8 +24,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.$watch('currentStep', function(step) { if (!step) return; - - if ($scope.selectedStep && $scope.selectedStep.title !== $scope.currentStep) { + var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; + if ($scope.selectedStep && stepTitle !== $scope.currentStep) { $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); } @@ -53,7 +53,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { unselectAll(); $scope.selectedStep = step; if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title; + $scope.currentStep = step.title || step.wzTitle; } step.selected = true; }; From 7959b5ec879bde4c3c3b54df18f795a85414cb2c Mon Sep 17 00:00:00 2001 From: Cristian Spinetta Date: Thu, 17 Apr 2014 02:57:23 -0300 Subject: [PATCH 029/185] refactory for validation --- dist/angular-wizard.js | 34 ++++++++++------------- dist/angular-wizard.min.js | 4 +-- src/step.js | 7 ++--- src/wizard.js | 26 ++++++++--------- test/validationSpec.js | 57 ++++++++++++++++++++++++-------------- 5 files changed, 67 insertions(+), 61 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 1be43c7..7c48476 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-04-16 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-04-17 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -35,7 +35,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { scope: { wzTitle: '@', title: '@', - validateStep: '&' + validate: '&validateStep' }, require: '^wizard', templateUrl: function(element, attributes) { @@ -44,11 +44,9 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { link: function($scope, $element, $attrs, wizard) { $scope.title = $scope.title || $scope.wzTitle; // If the validateStep isn't passed, the validate function must return true - if (_.isUndefined($attrs['validateStep'])) - $scope.validateStep = function() { return true; }; wizard.addStep($scope); } - } + }; }); angular.module('mgo-angular-wizard').directive('wizard', function() { @@ -69,7 +67,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { - var validateOnlyToAdvance = _.isUndefined($scope.validateOnlyToAdvance) ? true : $scope.validateOnlyToAdvance === 'true'; + this.validateOnlyToAdvance = _.isUndefined($scope.validateOnlyToAdvance) ? true : $scope.$eval($scope.validateOnlyToAdvance); WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); $scope.$on('$destroy', function() { @@ -106,7 +104,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; $scope.goTo = function(step) { - if (!$scope.validateGoTo(step)) return; unselectAll(); $scope.selectedStep = step; if (!_.isUndefined($scope.currentStep)) { @@ -115,18 +112,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { step.selected = true; }; - $scope.validateGoTo = function(nextStep) { - var indexNextStep = _.indexOf($scope.steps , nextStep); - var indexCurrentStep = _.indexOf($scope.steps, $scope.selectedStep); - if (indexNextStep == -1 || indexCurrentStep == -1) { - // if the next step is invalid, it won't change the step - // if the current step is invalid, there is nothing to validate. - return true; - } - if (validateOnlyToAdvance && indexNextStep < indexCurrentStep) - return true; - else - return $scope.selectedStep.validateStep(); + $scope.validStep = function(nextStep) { + var validation = $scope.selectedStep.validate(); + return _.isUndefined(validation) || validation; }; function unselectAll() { @@ -137,6 +125,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } this.next = function(draft) { + if (!$scope.validStep($scope.selectedStep)) + return; var index = _.indexOf($scope.steps , $scope.selectedStep); if (!draft) { $scope.selectedStep.completed = true; @@ -150,6 +140,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.goTo = function(step) { var stepTo; + if ($scope.selectedStep.completed && !$scope.validStep($scope.selectedStep)) + return; if (_.isNumber(step)) { stepTo = $scope.steps[step]; } else { @@ -159,12 +151,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; this.finish = function() { + if (!$scope.validStep($scope.selectedStep)) + return; if ($scope.onFinish) { $scope.onFinish(); } }; this.cancel = this.previous = function() { + if ((!this.validateOnlyToAdvance || $scope.selectedStep.completed) && !$scope.validStep($scope.selectedStep)) + return; var index = _.indexOf($scope.steps , $scope.selectedStep); if (index === 0) { throw new Error("Can't go back. It's already in step 0"); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 90bd1cb..417a2f3 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-04-16 * @link https://github.com/mgonto/angular-wizard + * @version v0.3.0 - 2014-04-17 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",validateStep:"&"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,_.isUndefined(c.validateStep)&&(a.validateStep=function(){return!0}),d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",validateOnlyToAdvance:"@",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var e=_.isUndefined(a.validateOnlyToAdvance)?!0:"true"===a.validateOnlyToAdvance;c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){a.validateGoTo(b)&&(d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0)},a.validateGoTo=function(b){var c=_.indexOf(a.steps,b),d=_.indexOf(a.steps,a.selectedStep);return-1==c||-1==d?!0:e&&d>c?!0:a.selectedStep.validateStep()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",validate:"&validateStep"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",validateOnlyToAdvance:"@",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}this.validateOnlyToAdvance=_.isUndefined(a.validateOnlyToAdvance)?!0:a.$eval(a.validateOnlyToAdvance),c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},a.validStep=function(){var b=a.selectedStep.validate();return _.isUndefined(b)||b},this.next=function(b){if(a.validStep(a.selectedStep)){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}},this.goTo=function(b){var c;(!a.selectedStep.completed||a.validStep(a.selectedStep))&&(c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c))},this.finish=function(){a.validStep(a.selectedStep)&&a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){if(this.validateOnlyToAdvance&&!a.selectedStep.completed||a.validStep(a.selectedStep)){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/step.js b/src/step.js index 9f48fcf..516c965 100644 --- a/src/step.js +++ b/src/step.js @@ -6,7 +6,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { scope: { wzTitle: '@', title: '@', - validateStep: '&' + validate: '&validateStep' }, require: '^wizard', templateUrl: function(element, attributes) { @@ -14,10 +14,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { }, link: function($scope, $element, $attrs, wizard) { $scope.title = $scope.title || $scope.wzTitle; - // If the validateStep isn't passed, the validate function must return true - if (_.isUndefined($attrs['validateStep'])) - $scope.validateStep = function() { return true; }; wizard.addStep($scope); } - } + }; }); diff --git a/src/wizard.js b/src/wizard.js index 2390aa8..d9bdb53 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -16,7 +16,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { - var validateOnlyToAdvance = _.isUndefined($scope.validateOnlyToAdvance) ? true : $scope.validateOnlyToAdvance === 'true'; + this.validateOnlyToAdvance = _.isUndefined($scope.validateOnlyToAdvance) ? true : $scope.$eval($scope.validateOnlyToAdvance); WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); $scope.$on('$destroy', function() { @@ -53,7 +53,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; $scope.goTo = function(step) { - if (!$scope.validateGoTo(step)) return; unselectAll(); $scope.selectedStep = step; if (!_.isUndefined($scope.currentStep)) { @@ -62,18 +61,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { step.selected = true; }; - $scope.validateGoTo = function(nextStep) { - var indexNextStep = _.indexOf($scope.steps , nextStep); - var indexCurrentStep = _.indexOf($scope.steps, $scope.selectedStep); - if (indexNextStep == -1 || indexCurrentStep == -1) { - // if the next step is invalid, it won't change the step - // if the current step is invalid, there is nothing to validate. - return true; - } - if (validateOnlyToAdvance && indexNextStep < indexCurrentStep) - return true; - else - return $scope.selectedStep.validateStep(); + $scope.validStep = function(nextStep) { + var validation = $scope.selectedStep.validate(); + return _.isUndefined(validation) || validation; }; function unselectAll() { @@ -84,6 +74,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } this.next = function(draft) { + if (!$scope.validStep($scope.selectedStep)) + return; var index = _.indexOf($scope.steps , $scope.selectedStep); if (!draft) { $scope.selectedStep.completed = true; @@ -97,6 +89,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.goTo = function(step) { var stepTo; + if ($scope.selectedStep.completed && !$scope.validStep($scope.selectedStep)) + return; if (_.isNumber(step)) { stepTo = $scope.steps[step]; } else { @@ -106,12 +100,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; this.finish = function() { + if (!$scope.validStep($scope.selectedStep)) + return; if ($scope.onFinish) { $scope.onFinish(); } }; this.cancel = this.previous = function() { + if ((!this.validateOnlyToAdvance || $scope.selectedStep.completed) && !$scope.validStep($scope.selectedStep)) + return; var index = _.indexOf($scope.steps , $scope.selectedStep); if (index === 0) { throw new Error("Can't go back. It's already in step 0"); diff --git a/test/validationSpec.js b/test/validationSpec.js index 4cdc685..59e9aaa 100644 --- a/test/validationSpec.js +++ b/test/validationSpec.js @@ -55,7 +55,7 @@ describe( 'Validations for the step changes', function() { return elementCompiled; } - it('should correctly create the wizard', function() { + it("should correctly create the wizard", function() { var scope = $rootScope.$new(); var view = createView(scope); expect(WizardHandler).toBeTruthy(); @@ -64,53 +64,68 @@ describe( 'Validations for the step changes', function() { expect(scope.referenceCurrentStep).toEqual('Starting'); }); - it( 'should allow to go to the next step when there is not passed a function to validate', function() { + it( "should allow to go to the next step when there isn't a function passed to validate", function() { var scope = $rootScope.$new(); var view = createView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().goTo('Continuing'); + WizardHandler.wizard().next(); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); }); - it( 'should allow to go to the next step when the current step is valid', function() { + it( "should allow to go to the next step when the current step is valid", function() { var scope = $rootScope.$new(); - scope.validateSuccessfully = function() { return true; }; - var view = createView(scope, ['validateSuccessfully()']); + var view = createView(scope, ['true']); expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().goTo('Continuing'); + WizardHandler.wizard().next(); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); }); - it( 'should not allow to go to the next step if the current step is not valid', function() { + it( "should not allow to go to the next step if the current step isn't valid", function() { var scope = $rootScope.$new(); - scope.validateUnsuccessfully = function() { return false; }; - var view = createView(scope, ['validateUnsuccessfully()']); + var view = createView(scope, ['false']); expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().goTo('Continuing'); + WizardHandler.wizard().next(); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Starting'); }); - it( 'should allow to return to a previous step although the current step is not valid', function() { + it( "should allow to return to a previous step if the current step isn't valid and isn't complete", function() { var scope = $rootScope.$new(); - scope.validateUnsuccessfully = function() { return false; }; - var view = createView(scope, [undefined, 'validateUnsuccessfully()']); + var view = createView(scope, [undefined, 'false']); expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().goTo('Continuing'); + WizardHandler.wizard().next(); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); - WizardHandler.wizard().goTo('Starting'); + WizardHandler.wizard().previous(); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Starting'); }); - it( 'should not allow to return to a previous step if the current step is not valid and the attribute validateOnlyToAdvance is false', function() { + it( "should not allow to return to a previous step if the current step isn't valid and the attribute validateOnlyToAdvance is false", function() { var scope = $rootScope.$new(); - scope.validateUnsuccessfully = function() { return false; }; - var view = createView(scope, [undefined, 'validateUnsuccessfully()'], false); + var view = createView(scope, [undefined, 'false'], false); expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().goTo('Continuing'); + WizardHandler.wizard().next(); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); - WizardHandler.wizard().goTo('Starting'); + WizardHandler.wizard().previous(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + }); + it( "should not allow to return to a previous step if the current step is completed and isn't valid", function() { + var scope = $rootScope.$new(); + scope.validateSecondStep = true; + var view = createView(scope, [undefined, 'validateSecondStep', undefined]); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + WizardHandler.wizard().previous(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + scope.validateSecondStep = false; + WizardHandler.wizard().previous(); $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); }); From 6a8c544f066482e06d2eb02b2f234c886e5dc47f Mon Sep 17 00:00:00 2001 From: Cristian Spinetta Date: Thu, 17 Apr 2014 04:32:07 -0300 Subject: [PATCH 030/185] undo steps when go to a previous step and attribute validate-only-to-advance renamed to validate-always --- dist/angular-wizard.js | 42 ++++++++++++++++++++++++++------------ dist/angular-wizard.min.js | 2 +- src/wizard.js | 41 ++++++++++++++++++++++++++----------- test/validationSpec.js | 40 ++++++++++++++++++++++++++++-------- 4 files changed, 91 insertions(+), 34 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 7c48476..847792c 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -43,7 +43,6 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { }, link: function($scope, $element, $attrs, wizard) { $scope.title = $scope.title || $scope.wzTitle; - // If the validateStep isn't passed, the validate function must return true wizard.addStep($scope); } }; @@ -58,7 +57,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { currentStep: '=', onFinish: '&', hideIndicators: '=', - validateOnlyToAdvance: '@', + validateAlways: '@', + undoSteps: '@', editMode: '=', name: '@' }, @@ -67,7 +67,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { - this.validateOnlyToAdvance = _.isUndefined($scope.validateOnlyToAdvance) ? true : $scope.$eval($scope.validateOnlyToAdvance); + this.validateAlways = _.isUndefined($scope.validateAlways) ? false : $scope.$eval($scope.validateAlways); + this.undoSteps = _.isUndefined($scope.undoSteps) ? false : $scope.$eval($scope.undoSteps); WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); $scope.$on('$destroy', function() { @@ -111,11 +112,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } step.selected = true; }; - - $scope.validStep = function(nextStep) { - var validation = $scope.selectedStep.validate(); - return _.isUndefined(validation) || validation; - }; function unselectAll() { _.each($scope.steps, function (step) { @@ -124,8 +120,25 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.selectedStep = null; } + this.validStep = function(nextStep) { + var validation = nextStep.validate(); + return _.isUndefined(validation) || validation; + }; + + this.doUndoSteps = function(nextStep) { + if (!this.undoSteps) + return; + var indexNextStep = _.indexOf($scope.steps , nextStep); + var indexCurrentStep = _.indexOf($scope.steps, $scope.selectedStep); + if (indexCurrentStep != -1 && indexNextStep != -1 && (indexNextStep < indexCurrentStep)) { + for (var i = indexNextStep; i <= indexCurrentStep; i++) { + $scope.steps[i].completed = false; + } + } + }; + this.next = function(draft) { - if (!$scope.validStep($scope.selectedStep)) + if (!this.validStep($scope.selectedStep)) return; var index = _.indexOf($scope.steps , $scope.selectedStep); if (!draft) { @@ -140,18 +153,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.goTo = function(step) { var stepTo; - if ($scope.selectedStep.completed && !$scope.validStep($scope.selectedStep)) + if ((this.validateAlways || $scope.selectedStep.completed) && !this.validStep($scope.selectedStep)) return; if (_.isNumber(step)) { stepTo = $scope.steps[step]; } else { stepTo = _.find($scope.steps, {title: step}); } + this.doUndoSteps(stepTo); $scope.goTo(stepTo); }; this.finish = function() { - if (!$scope.validStep($scope.selectedStep)) + if (!this.validStep($scope.selectedStep)) return; if ($scope.onFinish) { $scope.onFinish(); @@ -159,13 +173,15 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; this.cancel = this.previous = function() { - if ((!this.validateOnlyToAdvance || $scope.selectedStep.completed) && !$scope.validStep($scope.selectedStep)) + if ((this.validateAlways || $scope.selectedStep.completed) && !this.validStep($scope.selectedStep)) return; var index = _.indexOf($scope.steps , $scope.selectedStep); if (index === 0) { throw new Error("Can't go back. It's already in step 0"); } else { - $scope.goTo($scope.steps[index - 1]); + var stepTo = $scope.steps[index - 1]; + this.doUndoSteps(stepTo); + $scope.goTo(stepTo); } }; }] diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 417a2f3..5267a23 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -4,4 +4,4 @@ * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",validate:"&validateStep"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",validateOnlyToAdvance:"@",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}this.validateOnlyToAdvance=_.isUndefined(a.validateOnlyToAdvance)?!0:a.$eval(a.validateOnlyToAdvance),c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},a.validStep=function(){var b=a.selectedStep.validate();return _.isUndefined(b)||b},this.next=function(b){if(a.validStep(a.selectedStep)){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}},this.goTo=function(b){var c;(!a.selectedStep.completed||a.validStep(a.selectedStep))&&(c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),a.goTo(c))},this.finish=function(){a.validStep(a.selectedStep)&&a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){if(this.validateOnlyToAdvance&&!a.selectedStep.completed||a.validStep(a.selectedStep)){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",validate:"&validateStep"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",validateAlways:"@",undoSteps:"@",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}this.validateAlways=_.isUndefined(a.validateAlways)?!1:a.$eval(a.validateAlways),this.undoSteps=_.isUndefined(a.undoSteps)?!1:a.$eval(a.undoSteps),c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){b&&a.selectedStep&&a.selectedStep.title!==a.currentStep&&a.goTo(_.find(a.steps,{title:a.currentStep}))}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title),b.selected=!0},this.validStep=function(a){var b=a.validate();return _.isUndefined(b)||b},this.doUndoSteps=function(b){if(this.undoSteps){var c=_.indexOf(a.steps,b),d=_.indexOf(a.steps,a.selectedStep);if(-1!=d&&-1!=c&&d>c)for(var e=c;d>=e;e++)a.steps[e].completed=!1}},this.next=function(b){if(this.validStep(a.selectedStep)){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}},this.goTo=function(b){var c;(!this.validateAlways&&!a.selectedStep.completed||this.validStep(a.selectedStep))&&(c=_.isNumber(b)?a.steps[b]:_.find(a.steps,{title:b}),this.doUndoSteps(c),a.goTo(c))},this.finish=function(){this.validStep(a.selectedStep)&&a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){if(!this.validateAlways&&!a.selectedStep.completed||this.validStep(a.selectedStep)){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");var c=a.steps[b-1];this.doUndoSteps(c),a.goTo(c)}}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/wizard.js b/src/wizard.js index d9bdb53..cc2cd55 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -7,7 +7,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { currentStep: '=', onFinish: '&', hideIndicators: '=', - validateOnlyToAdvance: '@', + validateAlways: '@', + undoSteps: '@', editMode: '=', name: '@' }, @@ -16,7 +17,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }, controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { - this.validateOnlyToAdvance = _.isUndefined($scope.validateOnlyToAdvance) ? true : $scope.$eval($scope.validateOnlyToAdvance); + this.validateAlways = _.isUndefined($scope.validateAlways) ? false : $scope.$eval($scope.validateAlways); + this.undoSteps = _.isUndefined($scope.undoSteps) ? false : $scope.$eval($scope.undoSteps); WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); $scope.$on('$destroy', function() { @@ -60,11 +62,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } step.selected = true; }; - - $scope.validStep = function(nextStep) { - var validation = $scope.selectedStep.validate(); - return _.isUndefined(validation) || validation; - }; function unselectAll() { _.each($scope.steps, function (step) { @@ -73,8 +70,25 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.selectedStep = null; } + this.validStep = function(nextStep) { + var validation = nextStep.validate(); + return _.isUndefined(validation) || validation; + }; + + this.doUndoSteps = function(nextStep) { + if (!this.undoSteps) + return; + var indexNextStep = _.indexOf($scope.steps , nextStep); + var indexCurrentStep = _.indexOf($scope.steps, $scope.selectedStep); + if (indexCurrentStep != -1 && indexNextStep != -1 && (indexNextStep < indexCurrentStep)) { + for (var i = indexNextStep; i <= indexCurrentStep; i++) { + $scope.steps[i].completed = false; + } + } + }; + this.next = function(draft) { - if (!$scope.validStep($scope.selectedStep)) + if (!this.validStep($scope.selectedStep)) return; var index = _.indexOf($scope.steps , $scope.selectedStep); if (!draft) { @@ -89,18 +103,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.goTo = function(step) { var stepTo; - if ($scope.selectedStep.completed && !$scope.validStep($scope.selectedStep)) + if ((this.validateAlways || $scope.selectedStep.completed) && !this.validStep($scope.selectedStep)) return; if (_.isNumber(step)) { stepTo = $scope.steps[step]; } else { stepTo = _.find($scope.steps, {title: step}); } + this.doUndoSteps(stepTo); $scope.goTo(stepTo); }; this.finish = function() { - if (!$scope.validStep($scope.selectedStep)) + if (!this.validStep($scope.selectedStep)) return; if ($scope.onFinish) { $scope.onFinish(); @@ -108,13 +123,15 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; this.cancel = this.previous = function() { - if ((!this.validateOnlyToAdvance || $scope.selectedStep.completed) && !$scope.validStep($scope.selectedStep)) + if ((this.validateAlways || $scope.selectedStep.completed) && !this.validStep($scope.selectedStep)) return; var index = _.indexOf($scope.steps , $scope.selectedStep); if (index === 0) { throw new Error("Can't go back. It's already in step 0"); } else { - $scope.goTo($scope.steps[index - 1]); + var stepTo = $scope.steps[index - 1]; + this.doUndoSteps(stepTo); + $scope.goTo(stepTo); } }; }] diff --git a/test/validationSpec.js b/test/validationSpec.js index 59e9aaa..b4d100e 100644 --- a/test/validationSpec.js +++ b/test/validationSpec.js @@ -12,10 +12,11 @@ describe( 'Validations for the step changes', function() { * Create the view with wizard to test * @param {Scope} scope A scope to bind to * @param {String} validators Name of validators for each step - * @param {Boolean} validateOnlyToAdvance Boolean value to set validate-only-to-advance + * @param {Boolean} validateAlways Boolean value to set validate-always + * @param {Boolean} undoSteps Boolean value to set undo-steps * @return {[DOM element]} A DOM element compiled */ - function createView(scope, validators, validateOnlyToAdvance) { + function createView(scope, validators, validateAlways, undoSteps) { // Check the name of validators and generate attributes var attrValidators = []; @@ -27,14 +28,19 @@ describe( 'Validations for the step changes', function() { attrValidators[index] = _.isUndefined(name) ? '' : 'validate-step="' + name + '"'; }); - if (_.isBoolean(validateOnlyToAdvance)) - attrValidateOnlyToAdvance = 'validate-only-to-advance="' + validateOnlyToAdvance.toString() + '"'; + if (_.isBoolean(validateAlways)) + attrValidateAlways = 'validate-always="' + validateAlways.toString() + '"'; else - attrValidateOnlyToAdvance = ''; + attrValidateAlways = ''; + + if (_.isBoolean(undoSteps)) + attrUndoSteps = 'undo-steps="' + undoSteps.toString() + '"'; + else + attrUndoSteps = ''; scope.referenceCurrentStep = null; - var element = angular.element('' + var element = angular.element('' + ' ' + '

This is the first step

' + '

Here you can use whatever you want. You can use other directives, binding, etc.

' @@ -99,9 +105,9 @@ describe( 'Validations for the step changes', function() { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Starting'); }); - it( "should not allow to return to a previous step if the current step isn't valid and the attribute validateOnlyToAdvance is false", function() { + it( "should not allow to return to a previous step if the current step isn't valid and the attribute validateAlways is true", function() { var scope = $rootScope.$new(); - var view = createView(scope, [undefined, 'false'], false); + var view = createView(scope, [undefined, 'false'], true); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); $rootScope.$digest(); @@ -129,4 +135,22 @@ describe( 'Validations for the step changes', function() { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); }); + it( "should undo the completed steps if the attribute 'undo-steps' is defined", function() { + var scope = $rootScope.$new(); + scope.validateSecondStep = true; + var view = createView(scope, [undefined, undefined, undefined], undefined, true); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + WizardHandler.wizard().goTo(0); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Starting'); + expect(angular.element(view).find('ul.steps-indicator li:eq(0)').hasClass('current')).toBeTruthy(); + expect(angular.element(view).find('ul.steps-indicator li:eq(1)').hasClass('default')).toBeTruthy(); + expect(angular.element(view).find('ul.steps-indicator li:eq(2)').hasClass('default')).toBeTruthy(); + }); }); \ No newline at end of file From f2ab73806fb5de21345110781c4351276096314f Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Fri, 25 Apr 2014 15:59:42 -0300 Subject: [PATCH 031/185] 0.4.0 --- bower.json | 4 +- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- karma.conf.js | 7 ++-- karma.underscore.conf.js | 75 -------------------------------------- package.json | 2 +- 6 files changed, 8 insertions(+), 84 deletions(-) delete mode 100644 karma.underscore.conf.js diff --git a/bower.json b/bower.json index aa48003..b18294d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.3.0", + "version": "0.4.0", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { @@ -16,4 +16,4 @@ "components", "lib" ] -} +} \ No newline at end of file diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index a525bc1..6853477 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-04-14 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-04-25 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index a5523c6..8ded258 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.3.0 - 2014-04-14 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-04-25 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/karma.conf.js b/karma.conf.js index 3a1f1a5..fd79f1b 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -11,10 +11,9 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'http://code.angularjs.org/1.1.4/angular.js', - 'http://code.angularjs.org/1.1.4/angular-resource.js', - 'http://code.angularjs.org/1.1.4/angular-mocks.js', - 'http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.0/lodash.min.js', + 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.6/angular.js', + 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.6/angular-mocks.js', + 'http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js', 'dist/*.js', 'test/*.js' ], diff --git a/karma.underscore.conf.js b/karma.underscore.conf.js deleted file mode 100644 index ab1d824..0000000 --- a/karma.underscore.conf.js +++ /dev/null @@ -1,75 +0,0 @@ -// Karma configuration -// Generated on Fri Aug 09 2013 14:14:35 GMT-0500 (CDT) - -module.exports = function(config) { - config.set({ - - // base path, that will be used to resolve files and exclude - basePath: '', - - frameworks: ["jasmine"], - - // list of files / patterns to load in the browser - files: [ - 'http://code.angularjs.org/1.1.4/angular.js', - 'http://code.angularjs.org/1.1.4/angular-resource.js', - 'http://code.angularjs.org/1.1.4/angular-mocks.js', - 'http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js', - 'src/restangular.js', - 'test/*.js' - ], - - - // list of files to exclude - exclude: [ - - ], - - - // test results reporter to use - // possible values: 'dots', 'progress', 'junit' - reporters: ['progress'], - - - // web server port - port: 9877, - - - // cli runner port - runnerPort: 9101, - - - // enable / disable colors in the output (reporters and logs) - colors: true, - - - // level of logging - // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG - logLevel: config.LOG_INFO, - - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, - - - // Start these browsers, currently available: - // - Chrome - // - ChromeCanary - // - Firefox - // - Opera - // - Safari (only Mac) - // - PhantomJS - // - IE (only Windows) - browsers: ['PhantomJS'], - - - // If browser does not capture in given timeout [ms], kill it - captureTimeout: 60000, - - - // Continuous Integration mode - // if true, it capture browsers, run tests and exit - singleRun: false - - }); -}; diff --git a/package.json b/package.json index e5116cb..e0936a7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.3.0", + "version": "0.4.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 7eddbd26bea7a6f86790b7bdd31a87a26ea7f6e0 Mon Sep 17 00:00:00 2001 From: Brendan Stennett Date: Wed, 7 May 2014 15:41:36 -0400 Subject: [PATCH 032/185] now emits a wizard:stepChange event when the step changes --- dist/angular-wizard.js | 3 ++- dist/angular-wizard.min.js | 4 ++-- src/wizard.js | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 6853477..c2978dc 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-04-25 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-05-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -105,6 +105,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.currentStep = step.title || step.wzTitle; } step.selected = true; + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); }; function unselectAll() { diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 8ded258..8a8249e 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-04-25 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-05-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/wizard.js b/src/wizard.js index 264a20c..955f09a 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -56,6 +56,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.currentStep = step.title || step.wzTitle; } step.selected = true; + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); }; function unselectAll() { From 9a5d4eaf564142ee486b4b6285691400ce90a21b Mon Sep 17 00:00:00 2001 From: Cristian Spinetta Date: Sat, 17 May 2014 00:59:44 -0300 Subject: [PATCH 033/185] add some tests for basic functionality --- dist/angular-wizard.js | 6 +- dist/angular-wizard.min.js | 2 +- src/step.js | 3 +- test/angularWizardSpec.js | 94 +++++++++++++++++++++- test/validationSpec.js | 156 ------------------------------------- 5 files changed, 95 insertions(+), 166 deletions(-) delete mode 100644 test/validationSpec.js diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index cd48eac..45a8d8c 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-05-07 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-05-17 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -25,7 +25,7 @@ angular.module("wizard.html", []).run(["$templateCache", function($templateCache ""); }]); -angular.module('mgo-angular-wizard', ['templates-angularwizard']); +angular.module('mgo-angular-wizard', ['templates-angularwizard']); angular.module('mgo-angular-wizard').directive('wzStep', function() { return { @@ -44,7 +44,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { $scope.title = $scope.title || $scope.wzTitle; wizard.addStep($scope); } - } + }; }); angular.module('mgo-angular-wizard').directive('wizard', function() { diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 8a8249e..f78e3b0 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-05-07 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-05-17 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/src/step.js b/src/step.js index 516c965..118252a 100644 --- a/src/step.js +++ b/src/step.js @@ -5,8 +5,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { transclude: true, scope: { wzTitle: '@', - title: '@', - validate: '&validateStep' + title: '@' }, require: '^wizard', templateUrl: function(element, attributes) { diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index f988840..b7176fe 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -1,7 +1,93 @@ describe( 'AngularWizard', function() { - beforeEach( module( 'mgo-angular-wizard' ) ); + var $compile, $rootScope, WizardHandler; - it( 'should have a dummy test', inject( function() { - expect( true ).toBeTruthy(); - })); + beforeEach(module('mgo-angular-wizard')); + beforeEach(inject(function(_$compile_, _$rootScope_, _WizardHandler_) { + $compile = _$compile_; + $rootScope = _$rootScope_; + WizardHandler = _WizardHandler_; + })); + + /** + * Create the view with wizard to test + * @param {Scope} scope A scope to bind to + * @return {[DOM element]} A DOM element compiled + */ + function createView(scope) { + scope.referenceCurrentStep = null; + var element = angular.element('' + + ' ' + + '

This is the first step

' + + '

Here you can use whatever you want. You can use other directives, binding, etc.

' + + ' ' + + '
' + + ' ' + + '

Continuing

' + + '

You have continued here!

' + + ' ' + + '
' + + ' ' + + '

Even more steps!!

' + + ' ' + + '
' + + '
'); + var elementCompiled = $compile(element)(scope); + $rootScope.$digest(); + return elementCompiled; + } + + it("should correctly create the wizard", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(WizardHandler).toBeTruthy(); + expect(view.find('section').length).toEqual(3); + // expect the currect step to be desirable one + expect(scope.referenceCurrentStep).toEqual('Starting'); + }); + + it( "should go to the next step", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + }); + it( "should return to a previous step", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().previous(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Starting'); + }); + it( "should go to a step specified by name", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().goTo('More steps'); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); + it( "should go to a step specified by index", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().goTo(2); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); + it( "should finish", function() { + var scope = $rootScope.$new(); + var flag = false; + scope.finishedWizard = function() { flag = true; }; + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().finish(); + expect(flag).toBeTruthy(); + $rootScope.$digest(); + }); }); \ No newline at end of file diff --git a/test/validationSpec.js b/test/validationSpec.js deleted file mode 100644 index b4d100e..0000000 --- a/test/validationSpec.js +++ /dev/null @@ -1,156 +0,0 @@ -describe( 'Validations for the step changes', function() { - var $compile, $rootScope, WizardHandler; - - beforeEach(module('mgo-angular-wizard')); - beforeEach(inject(function(_$compile_, _$rootScope_, _WizardHandler_) { - $compile = _$compile_; - $rootScope = _$rootScope_; - WizardHandler = _WizardHandler_; - })); - - /** - * Create the view with wizard to test - * @param {Scope} scope A scope to bind to - * @param {String} validators Name of validators for each step - * @param {Boolean} validateAlways Boolean value to set validate-always - * @param {Boolean} undoSteps Boolean value to set undo-steps - * @return {[DOM element]} A DOM element compiled - */ - function createView(scope, validators, validateAlways, undoSteps) { - - // Check the name of validators and generate attributes - var attrValidators = []; - if (!_.isArray(validators)) { - validators = []; - } - validators.length = 3; - _.each(validators, function (name, index) { - attrValidators[index] = _.isUndefined(name) ? '' : 'validate-step="' + name + '"'; - }); - - if (_.isBoolean(validateAlways)) - attrValidateAlways = 'validate-always="' + validateAlways.toString() + '"'; - else - attrValidateAlways = ''; - - if (_.isBoolean(undoSteps)) - attrUndoSteps = 'undo-steps="' + undoSteps.toString() + '"'; - else - attrUndoSteps = ''; - - scope.referenceCurrentStep = null; - - var element = angular.element('' - + ' ' - + '

This is the first step

' - + '

Here you can use whatever you want. You can use other directives, binding, etc.

' - + ' ' - + '
' - + ' ' - + '

Continuing

' - + '

You have continued here!

' - + ' ' - + '
' - + ' ' - + '

Even more steps!!

' - + ' ' - + '
' - + '
'); - var elementCompiled = $compile(element)(scope); - $rootScope.$digest(); - return elementCompiled; - } - - it("should correctly create the wizard", function() { - var scope = $rootScope.$new(); - var view = createView(scope); - expect(WizardHandler).toBeTruthy(); - expect(view.find('section').length).toEqual(3); - // expect the currect step to be desirable one - expect(scope.referenceCurrentStep).toEqual('Starting'); - }); - - it( "should allow to go to the next step when there isn't a function passed to validate", function() { - var scope = $rootScope.$new(); - var view = createView(scope); - expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().next(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Continuing'); - }); - it( "should allow to go to the next step when the current step is valid", function() { - var scope = $rootScope.$new(); - var view = createView(scope, ['true']); - expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().next(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Continuing'); - }); - it( "should not allow to go to the next step if the current step isn't valid", function() { - var scope = $rootScope.$new(); - var view = createView(scope, ['false']); - expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().next(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Starting'); - }); - it( "should allow to return to a previous step if the current step isn't valid and isn't complete", function() { - var scope = $rootScope.$new(); - var view = createView(scope, [undefined, 'false']); - expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().next(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Continuing'); - WizardHandler.wizard().previous(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Starting'); - }); - it( "should not allow to return to a previous step if the current step isn't valid and the attribute validateAlways is true", function() { - var scope = $rootScope.$new(); - var view = createView(scope, [undefined, 'false'], true); - expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().next(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Continuing'); - WizardHandler.wizard().previous(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Continuing'); - }); - it( "should not allow to return to a previous step if the current step is completed and isn't valid", function() { - var scope = $rootScope.$new(); - scope.validateSecondStep = true; - var view = createView(scope, [undefined, 'validateSecondStep', undefined]); - expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().next(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Continuing'); - WizardHandler.wizard().next(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('More steps'); - WizardHandler.wizard().previous(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Continuing'); - scope.validateSecondStep = false; - WizardHandler.wizard().previous(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Continuing'); - }); - it( "should undo the completed steps if the attribute 'undo-steps' is defined", function() { - var scope = $rootScope.$new(); - scope.validateSecondStep = true; - var view = createView(scope, [undefined, undefined, undefined], undefined, true); - expect(scope.referenceCurrentStep).toEqual('Starting'); - WizardHandler.wizard().next(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Continuing'); - WizardHandler.wizard().next(); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('More steps'); - WizardHandler.wizard().goTo(0); - $rootScope.$digest(); - expect(scope.referenceCurrentStep).toEqual('Starting'); - expect(angular.element(view).find('ul.steps-indicator li:eq(0)').hasClass('current')).toBeTruthy(); - expect(angular.element(view).find('ul.steps-indicator li:eq(1)').hasClass('default')).toBeTruthy(); - expect(angular.element(view).find('ul.steps-indicator li:eq(2)').hasClass('default')).toBeTruthy(); - }); -}); \ No newline at end of file From bdd026811fa60941356439777624476e6153bd3c Mon Sep 17 00:00:00 2001 From: Kamshak Date: Thu, 10 Jul 2014 11:09:09 +0200 Subject: [PATCH 034/185] Add currentStepNumber() Useful for things like progress bars as step indicator, where you show e.g. Step 1 / 5 --- src/wizard.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wizard.js b/src/wizard.js index 955f09a..2b9c129 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -58,6 +58,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { step.selected = true; $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); }; + + $scope.currentStepNumber = function() { + return _.indexOf($scope.steps , $scope.selectedStep) + 1; + } function unselectAll() { _.each($scope.steps, function (step) { From 0a7259250f9e9d2c87880ca054491a5dd44e0412 Mon Sep 17 00:00:00 2001 From: Valentin Funk Date: Thu, 10 Jul 2014 09:34:43 +0000 Subject: [PATCH 035/185] Performed build --- dist/angular-wizard.js | 6 +++++- dist/angular-wizard.min.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 45a8d8c..9276045 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-05-17 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-07-10 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -107,6 +107,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { step.selected = true; $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); }; + + $scope.currentStepNumber = function() { + return _.indexOf($scope.steps , $scope.selectedStep) + 1; + } function unselectAll() { _.each($scope.steps, function (step) { diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index f78e3b0..43c3d38 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-05-17 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-07-10 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 1521c35353b36426138e4e734a3f025b241f34bf Mon Sep 17 00:00:00 2001 From: Harry Moreno Date: Fri, 19 Sep 2014 02:28:19 -0700 Subject: [PATCH 036/185] Update README.md typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d74f02b..4f98129 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Let's go step by step to see how this works. 1) You need to declare a master `wizard` directive. This wizard directive, has the following options as attributes: * **on-finish**: Here you can put a function to be called when the wizard is finished. The syntaxis here is very similar to `ng-click` * **name**: The name of the wizard. By default, it's called "Default wizard". It's used for the `WizardHandler` which we'll explain later. -* **edit-mode**: If set to true, this will set the wizard as edit mode. Edit mode means that all steps have been completed byt he can modify any of them now. Defaults to false. +* **edit-mode**: If set to true, this will set the wizard as edit mode. Edit mode means that all steps have been completed but he can modify any of them now. Defaults to false. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. * **current-step**: You need to set here a property from your scope (similar to `ng-model`) and that property will always have the name of the current step being shown on the screen. * **template**: Path to a custom template. From af8debb889d3765c7e2d981515d50215f3e98b39 Mon Sep 17 00:00:00 2001 From: Harry Moreno Date: Fri, 19 Sep 2014 04:05:07 -0700 Subject: [PATCH 037/185] made navigation relative to the wizard. I think this is better than just placing the navbar at the bottom of the window. Also updated dev-dependencies --- dist/angular-wizard.css | 3 +-- dist/angular-wizard.js | 2 +- dist/angular-wizard.less | 5 ++--- dist/angular-wizard.min.css | 2 +- dist/angular-wizard.min.js | 2 +- package.json | 6 ++++-- src/angular-wizard.less | 5 ++--- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/dist/angular-wizard.css b/dist/angular-wizard.css index af6b962..a11bcf1 100644 --- a/dist/angular-wizard.css +++ b/dist/angular-wizard.css @@ -1,10 +1,9 @@ .steps-indicator { - position: absolute; right: 0; bottom: 0; left: 0; height: 30px; - padding: 0; + padding: 20px 0 0 0; margin: 0; list-style: none; } diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 9276045..51ae9ad 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-07-10 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-09-19 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.less b/dist/angular-wizard.less index 6b2306f..9556344 100644 --- a/dist/angular-wizard.less +++ b/dist/angular-wizard.less @@ -6,12 +6,11 @@ @color-done: #339933; @color-editing: #FF0000; - position: absolute; right: 0; bottom: 0; left: 0; margin: 0; - padding: 0; + padding: 20px 0 0 0; height: 30px; list-style: none; @@ -176,4 +175,4 @@ li.editing a:before { background-color: @color-editing; } -} \ No newline at end of file +} diff --git a/dist/angular-wizard.min.css b/dist/angular-wizard.min.css index 7b055fe..52636f3 100644 --- a/dist/angular-wizard.min.css +++ b/dist/angular-wizard.min.css @@ -1 +1 @@ -.steps-indicator{position:absolute;right:0;bottom:0;left:0;height:30px;padding:0;margin:0;list-style:none}.steps-indicator:before{position:absolute;height:1px;background-color:#e6e6e6;content:''}.steps-indicator.steps-2:before{right:calc(25%);left:calc(25%)}.steps-indicator.steps-3:before{right:calc(16.666666666666668%);left:calc(16.666666666666668%)}.steps-indicator.steps-4:before{right:calc(12.5%);left:calc(12.5%)}.steps-indicator.steps-5:before{right:calc(10%);left:calc(10%)}.steps-indicator.steps-6:before{right:calc(8.333333333333334%);left:calc(8.333333333333334%)}.steps-indicator.steps-7:before{right:calc(7.142857142857143%);left:calc(7.142857142857143%)}.steps-indicator.steps-8:before{right:calc(6.25%);left:calc(6.25%)}.steps-indicator.steps-9:before{right:calc(5.555555555555555%);left:calc(5.555555555555555%)}.steps-indicator.steps-10:before{right:calc(5%);left:calc(5%)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;padding:0;padding-top:10px;margin:0;line-height:15px;text-align:center}.steps-indicator li a{font-weight:bold;color:#808080;text-decoration:none;text-transform:uppercase;cursor:pointer;transition:.25s}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(43%);width:14px;height:14px;background-color:#e6e6e6;border-radius:100%;content:'';transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(50%)}.steps-indicator.steps-3 li{width:calc(33.333333333333336%)}.steps-indicator.steps-4 li{width:calc(25%)}.steps-indicator.steps-5 li{width:calc(20%)}.steps-indicator.steps-6 li{width:calc(16.666666666666668%)}.steps-indicator.steps-7 li{width:calc(14.285714285714286%)}.steps-indicator.steps-8 li{width:calc(12.5%)}.steps-indicator.steps-9 li{width:calc(11.11111111111111%)}.steps-indicator.steps-10 li{width:calc(10%)}.steps-indicator.steps-11 li{width:calc(9.090909090909092%)}.steps-indicator li.default{pointer-events:none}.steps-indicator li.default a:hover{color:#808080}.steps-indicator li.current,.steps-indicator li.editing{pointer-events:none}.steps-indicator li.current a:before{background-color:#808080}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:#f00} \ No newline at end of file +.steps-indicator{right:0;bottom:0;left:0;height:30px;padding:20px 0 0 0;margin:0;list-style:none}.steps-indicator:before{position:absolute;height:1px;background-color:#e6e6e6;content:''}.steps-indicator.steps-2:before{right:calc(25%);left:calc(25%)}.steps-indicator.steps-3:before{right:calc(16.666666666666668%);left:calc(16.666666666666668%)}.steps-indicator.steps-4:before{right:calc(12.5%);left:calc(12.5%)}.steps-indicator.steps-5:before{right:calc(10%);left:calc(10%)}.steps-indicator.steps-6:before{right:calc(8.333333333333334%);left:calc(8.333333333333334%)}.steps-indicator.steps-7:before{right:calc(7.142857142857143%);left:calc(7.142857142857143%)}.steps-indicator.steps-8:before{right:calc(6.25%);left:calc(6.25%)}.steps-indicator.steps-9:before{right:calc(5.555555555555555%);left:calc(5.555555555555555%)}.steps-indicator.steps-10:before{right:calc(5%);left:calc(5%)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;padding:0;padding-top:10px;margin:0;line-height:15px;text-align:center}.steps-indicator li a{font-weight:bold;color:#808080;text-decoration:none;text-transform:uppercase;cursor:pointer;transition:.25s}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(43%);width:14px;height:14px;background-color:#e6e6e6;border-radius:100%;content:'';transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(50%)}.steps-indicator.steps-3 li{width:calc(33.333333333333336%)}.steps-indicator.steps-4 li{width:calc(25%)}.steps-indicator.steps-5 li{width:calc(20%)}.steps-indicator.steps-6 li{width:calc(16.666666666666668%)}.steps-indicator.steps-7 li{width:calc(14.285714285714286%)}.steps-indicator.steps-8 li{width:calc(12.5%)}.steps-indicator.steps-9 li{width:calc(11.11111111111111%)}.steps-indicator.steps-10 li{width:calc(10%)}.steps-indicator.steps-11 li{width:calc(9.090909090909092%)}.steps-indicator li.default{pointer-events:none}.steps-indicator li.default a:hover{color:#808080}.steps-indicator li.current,.steps-indicator li.editing{pointer-events:none}.steps-indicator li.current a:before{background-color:#808080}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:#f00} \ No newline at end of file diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 43c3d38..337bc47 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-07-10 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-09-19 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/package.json b/package.json index 809315f..b94a885 100644 --- a/package.json +++ b/package.json @@ -42,10 +42,12 @@ "grunt-ngmin": "0.0.2", "grunt-html2js": "~0.1.3", "grunt-conventional-changelog": "~0.1.1", - "grunt-bump": "0.0.6" + "grunt-bump": "0.0.6", + "karma-jasmine": "^0.1.5", + "karma-phantomjs-launcher": "^0.1.4" }, "scripts": { "test": "grunt travis --verbose" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/src/angular-wizard.less b/src/angular-wizard.less index 6b2306f..9556344 100644 --- a/src/angular-wizard.less +++ b/src/angular-wizard.less @@ -6,12 +6,11 @@ @color-done: #339933; @color-editing: #FF0000; - position: absolute; right: 0; bottom: 0; left: 0; margin: 0; - padding: 0; + padding: 20px 0 0 0; height: 30px; list-style: none; @@ -176,4 +175,4 @@ li.editing a:before { background-color: @color-editing; } -} \ No newline at end of file +} From 07b9c4d6b4e391c3f55f2690dd3f93b84fb992a7 Mon Sep 17 00:00:00 2001 From: mprent99 Date: Mon, 17 Nov 2014 14:31:41 -0500 Subject: [PATCH 038/185] Remove deprecated grunt-ngmin and replace it with grunt-ng-annotate. Add missing karma-jasmine and karma-phantomjs-launcher dependencies. --- Gruntfile.js | 4 ++-- karma.conf.js | 4 ++-- package.json | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 8ed8696..944b6dd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -79,7 +79,7 @@ module.exports = function(grunt) { }, src: [ 'src/*.html' ], dest: 'src/<%= pkg.name %>.tpls.js' - }, + } }, uglify: { options: { @@ -132,7 +132,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-recess'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-ngmin'); + grunt.loadNpmTasks('grunt-ng-annotate'); grunt.loadNpmTasks('grunt-html2js'); diff --git a/karma.conf.js b/karma.conf.js index fd79f1b..9bdf995 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -11,8 +11,8 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.6/angular.js', - 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.6/angular-mocks.js', + 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.js', + 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular-mocks.js', 'http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js', 'dist/*.js', 'test/*.js' diff --git a/package.json b/package.json index 809315f..61fc58a 100644 --- a/package.json +++ b/package.json @@ -29,23 +29,25 @@ ], "dependencies": {}, "devDependencies": { + "grunt": "~0.4.1", "grunt-bower": "*", "grunt-bower-task": "*", - "grunt-zip": "*", - "grunt": "~0.4.1", - "grunt-recess": "~0.3.0", + "grunt-bump": "0.0.6", "grunt-contrib-clean": "~0.4.1", - "grunt-contrib-copy": "~0.4.1", "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-copy": "~0.4.1", "grunt-contrib-uglify": "~0.2.0", - "grunt-karma": "~0.8", - "grunt-ngmin": "0.0.2", - "grunt-html2js": "~0.1.3", "grunt-conventional-changelog": "~0.1.1", - "grunt-bump": "0.0.6" + "grunt-html2js": "~0.1.3", + "grunt-karma": "~0.9.x", + "grunt-ng-annotate": "^0.6.0", + "grunt-recess": "~0.3.0", + "grunt-zip": "*", + "karma-jasmine": "~0.2.x", + "karma-phantomjs-launcher": "~0.1.x" }, "scripts": { "test": "grunt travis --verbose" }, "license": "MIT" -} \ No newline at end of file +} From f413a32db81f5558cb0cb14a21f2dc62d338743f Mon Sep 17 00:00:00 2001 From: mprent99 Date: Mon, 17 Nov 2014 14:51:38 -0500 Subject: [PATCH 039/185] Update README to fix broken img link, typos, etc. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d74f02b..652018f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Angular-Wizard -[![PayPayl donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using Paypal") -[![Donate on Gittip](http://badgr.co/gittip/mgonto.png)](https://www.gittip.com/mgonto/) +[![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using PayPal") +[![Donate on Gratipay](http://img.shields.io/gratipay/mgonto.svg?style=flat)](https://gratipay.com/mgonto/) Angular-wizard is a component that will make it easy for you to create wizards in your app. You can check a running example of the wizard [by clicking here](http://mgonto.github.io/angular-wizard/) @@ -73,7 +73,7 @@ This will look like the following when you're in the second step: Let's go step by step to see how this works. 1) You need to declare a master `wizard` directive. This wizard directive, has the following options as attributes: -* **on-finish**: Here you can put a function to be called when the wizard is finished. The syntaxis here is very similar to `ng-click` +* **on-finish**: Here you can put a function to be called when the wizard is finished. The syntax here is very similar to `ng-click` * **name**: The name of the wizard. By default, it's called "Default wizard". It's used for the `WizardHandler` which we'll explain later. * **edit-mode**: If set to true, this will set the wizard as edit mode. Edit mode means that all steps have been completed byt he can modify any of them now. Defaults to false. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. @@ -96,7 +96,7 @@ All of this attributes can receive an optional function to be called before chan In this case, the `setMode` function will be called before going to the next step. ## Manipulating the wizard from a service -There're some times where we actually want to manipulate the wizard from the controller instead of from the HTML. +There are some times where we actually want to manipulate the wizard from the controller instead of from the HTML. For those cases, we can inject the `WizardHandler` to our controller. From 11bd0c8f5177e5f512594e88aa608917d37e8965 Mon Sep 17 00:00:00 2001 From: mprent99 Date: Mon, 17 Nov 2014 14:52:32 -0500 Subject: [PATCH 040/185] Make both badges use the flat style. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 652018f..f9f0dc4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Angular-Wizard -[![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using PayPal") +[![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellow&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using PayPal") [![Donate on Gratipay](http://img.shields.io/gratipay/mgonto.svg?style=flat)](https://gratipay.com/mgonto/) From 167ecdad8c7743197f042f4f56d22d3b276e7bf2 Mon Sep 17 00:00:00 2001 From: mprent99 Date: Mon, 17 Nov 2014 14:55:33 -0500 Subject: [PATCH 041/185] Remove flat style so that buttons look similar. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f9f0dc4..5c2efe9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Angular-Wizard -[![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellow&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using PayPal") -[![Donate on Gratipay](http://img.shields.io/gratipay/mgonto.svg?style=flat)](https://gratipay.com/mgonto/) +[![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using PayPal") +[![Donate on Gratipay](http://img.shields.io/gratipay/mgonto.svg)](https://gratipay.com/mgonto/) Angular-wizard is a component that will make it easy for you to create wizards in your app. You can check a running example of the wizard [by clicking here](http://mgonto.github.io/angular-wizard/) From c258b9a049e23a26500c8e2dc3f1756c25f9206d Mon Sep 17 00:00:00 2001 From: mprent99 Date: Mon, 17 Nov 2014 15:46:55 -0500 Subject: [PATCH 042/185] Fix missing semi-colon and typo in test. --- src/wizard.js | 2 +- test/angularWizardSpec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index 2b9c129..9aaa529 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -61,7 +61,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.currentStepNumber = function() { return _.indexOf($scope.steps , $scope.selectedStep) + 1; - } + }; function unselectAll() { _.each($scope.steps, function (step) { diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index b7176fe..d1d05b3 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -41,7 +41,7 @@ describe( 'AngularWizard', function() { var view = createView(scope); expect(WizardHandler).toBeTruthy(); expect(view.find('section').length).toEqual(3); - // expect the currect step to be desirable one + // expect the correct step to be desirable one expect(scope.referenceCurrentStep).toEqual('Starting'); }); @@ -90,4 +90,4 @@ describe( 'AngularWizard', function() { expect(flag).toBeTruthy(); $rootScope.$digest(); }); -}); \ No newline at end of file +}); From f3ca42399eaef884bc98cb7f9b4309d3c831c753 Mon Sep 17 00:00:00 2001 From: Kai Henzler Date: Tue, 18 Nov 2014 10:10:49 +0100 Subject: [PATCH 043/185] prefixes variables and makes them overridable --- README.md | 8 +++++++- src/angular-wizard.less | 25 +++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d74f02b..ba52d00 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,13 @@ The navigation bar shown below works in the following way: * Editing step (Modifying a step already completed in the past) is painted as red * You can click in any completed step to go back to that step. You can't click in the current step nor in the future ones unless you've already completed a future step before (for example in EditMode all steps are completed by default) -All of those colors are variables in the `angular-wizard.less`. You can easily change them by changing the colors in that file +### Color Definitions +All of those colors are variables in the `angular-wizard.less`. You can easily change them by importing the `angular-wizard.less` file into your own less file(s) and change the variables. +The available variables are: +* @wz-color-default +* @wz-color-done +* @wz-color-current +* @wz-color-editing # Contributors diff --git a/src/angular-wizard.less b/src/angular-wizard.less index 6b2306f..bc29696 100644 --- a/src/angular-wizard.less +++ b/src/angular-wizard.less @@ -1,10 +1,11 @@ +@wz-color-default: #E6E6E6; +@wz-color-current: #808080; +@wz-color-done: #339933; +@wz-color-editing: #FF0000; + .steps-indicator { /* ---- steps quantity ---- */ - @color-default: #E6E6E6; - @color-current: #808080; - @color-done: #339933; - @color-editing: #FF0000; position: absolute; right: 0; @@ -18,7 +19,7 @@ &:before { - background-color: @color-default; + background-color: @wz-color-default; content: ''; position: absolute; height: 1px; @@ -87,7 +88,7 @@ line-height: 15px; a { - color: @color-current; + color: @wz-color-current; text-decoration: none; text-transform: uppercase; font-weight: bold; @@ -101,13 +102,13 @@ width: 14px; height: 14px; border-radius: 100%; - background-color: @color-default; + background-color: @wz-color-default; content: ''; transition: 0.25s; } &:hover { - color: darken(@color-current, 20%); + color: darken(@wz-color-current, 20%); } } } @@ -156,7 +157,7 @@ pointer-events: none; a:hover { - color: @color-current; + color: @wz-color-current; } } @@ -166,14 +167,14 @@ } li.current a:before { - background-color: @color-current; + background-color: @wz-color-current; } li.done a:before { - background-color: @color-done; + background-color: @wz-color-done; } li.editing a:before { - background-color: @color-editing; + background-color: @wz-color-editing; } } \ No newline at end of file From 49d7f323e74dc58553632e87006fb81a2391a48a Mon Sep 17 00:00:00 2001 From: mprent99 Date: Fri, 21 Nov 2014 09:44:01 -0500 Subject: [PATCH 044/185] Fix typos and update Copyright years. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5c2efe9..1621818 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Let's go step by step to see how this works. 1) You need to declare a master `wizard` directive. This wizard directive, has the following options as attributes: * **on-finish**: Here you can put a function to be called when the wizard is finished. The syntax here is very similar to `ng-click` * **name**: The name of the wizard. By default, it's called "Default wizard". It's used for the `WizardHandler` which we'll explain later. -* **edit-mode**: If set to true, this will set the wizard as edit mode. Edit mode means that all steps have been completed byt he can modify any of them now. Defaults to false. +* **edit-mode**: If set to true, this will set the wizard as edit mode. Edit mode means that all steps have been completed and the user can now navigate to and modify any step. Defaults to false. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. * **current-step**: You need to set here a property from your scope (similar to `ng-model`) and that property will always have the name of the current step being shown on the screen. * **template**: Path to a custom template. @@ -137,7 +137,7 @@ All of those colors are variables in the `angular-wizard.less`. You can easily c # Contributors -@sebazelonka helped me with all fo the styles of the Wizard. +@sebazelonka helped me with all of the styles in the Wizard. # Live sample @@ -150,7 +150,7 @@ Releases notes are together with releases in GitHub at: https://github.com/mgont # License The MIT License -Copyright (c) 2013 Martin Gontovnikas http://www.gon.to/ +Copyright (c) 2013-2014 Martin Gontovnikas http://www.gon.to/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: From 5ce6f2058670f5aaa6d6294ab1428c46b7fc39a6 Mon Sep 17 00:00:00 2001 From: mprent99 Date: Fri, 21 Nov 2014 09:51:40 -0500 Subject: [PATCH 045/185] Update Karma config to load Angular 1.3.3. --- karma.conf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 9bdf995..c5767b1 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -11,8 +11,8 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ - 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.js', - 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular-mocks.js', + 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js', + 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular-mocks.js', 'http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js', 'dist/*.js', 'test/*.js' From a76778437b6d0083a9bc038a50bd468fb17579c9 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 5 Dec 2014 16:04:41 -0700 Subject: [PATCH 046/185] created a callback function check for this.next() is wizard.js, if callback function is present it will only move on to next step if it returns truthy --- .gitignore | 1 + dist/angular-wizard.css | 0 dist/angular-wizard.js | 143 +++++++++++++++++++++++++----------- dist/angular-wizard.less | 0 dist/angular-wizard.min.css | 0 dist/angular-wizard.min.js | 14 ++-- src/wizard.js | 82 ++++++++++++++++++--- 7 files changed, 180 insertions(+), 60 deletions(-) mode change 100644 => 100755 dist/angular-wizard.css mode change 100644 => 100755 dist/angular-wizard.js mode change 100644 => 100755 dist/angular-wizard.less mode change 100644 => 100755 dist/angular-wizard.min.css mode change 100644 => 100755 dist/angular-wizard.min.js mode change 100644 => 100755 src/wizard.js diff --git a/.gitignore b/.gitignore index 895766b..346cb48 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ components bower_components npm-debug.log src/*.tpls.js +.idea/ diff --git a/dist/angular-wizard.css b/dist/angular-wizard.css old mode 100644 new mode 100755 diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js old mode 100644 new mode 100755 index 9276045..d752971 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,32 +1,32 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-07-10 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
\n" + - "
"); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
\n" + - "
\n" + - " \n" + - "
\n" + - ""); -}]); - +/** + * Easy to use Wizard library for AngularJS + * @version v0.4.0 - 2014-12-05 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
\n" + + "
"); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
\n" + + "
\n" + + " \n" + + "
\n" + + ""); +}]); + angular.module('mgo-angular-wizard', ['templates-angularwizard']); - + angular.module('mgo-angular-wizard').directive('wzStep', function() { return { restrict: 'EA', @@ -46,7 +46,8 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { } }; }); - + +//wizard directive angular.module('mgo-angular-wizard').directive('wizard', function() { return { restrict: 'EA', @@ -60,26 +61,37 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { name: '@' }, templateUrl: function(element, attributes) { - return attributes.template || "wizard.html"; + return attributes.template || "wizardDirective.html"; }, - controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { + //controller for wizard directive, treat this just like an angular controller + controller: ['$scope', '$element', '$log', 'WizardHandler', function($scope, $element, $log, WizardHandler) { + + //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); + $scope.$on('$destroy', function() { WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); }); + //steps array where all the scopes of each step are added $scope.steps = []; + //watching changes to currentStep $scope.$watch('currentStep', function(step) { + //checking to make sure currentStep is truthy value if (!step) return; + //setting stepTitle equal to current step title or default title var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; if ($scope.selectedStep && stepTitle !== $scope.currentStep) { + //invoking goTo() with step title as argument $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); } }); + //watching steps array length and editMode value, if edit module is undefined or null the nothing is done + //if edit mode is truthy, then all steps are marked as completed $scope.$watch('[editMode, steps.length]', function() { var editMode = $scope.editMode; if (_.isUndefined(editMode) || _.isNull(editMode)) return; @@ -91,74 +103,121 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } }, true); + //called each time step directive is loaded this.addStep = function(step) { + //pushing the scope of directive onto step array $scope.steps.push(step); + //if this is first step being pushed then goTo that first step if ($scope.steps.length === 1) { + //goTo first step $scope.goTo($scope.steps[0]); } }; $scope.goTo = function(step) { + //deselect all steps so you can set fresh below unselectAll(); + //set the selected step to $scope of directive of that step $scope.selectedStep = step; + //making sure current step is not undefined if (!_.isUndefined($scope.currentStep)) { $scope.currentStep = step.title || step.wzTitle; } + //setting selected step to argument passed into goTo() step.selected = true; + //emit event upwards with data on goTo() invoktion $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); }; - + $scope.currentStepNumber = function() { + //retreive current step number return _.indexOf($scope.steps , $scope.selectedStep) + 1; - } + }; + //unSelect All Steps function unselectAll() { + //traverse steps array and set each "selected" property to false _.each($scope.steps, function (step) { step.selected = false; }); + //set selectedStep variable to null $scope.selectedStep = null; } - this.next = function(draft) { + //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + + //Access to current step number from outside + this.currentStepNumber = function(){ + return $scope.currentStepNumber(); + }; + //method used for next button within step + //TODO How is the callback in the directive, i.e. wz-next="callback()" get called! + this.next = function(callback) { + $log.log('wizard.next invoked, ', callback, $scope.steps, $scope.selectedStep); + //setting variable equal to step you were on when next() was invoked var index = _.indexOf($scope.steps , $scope.selectedStep); - if (!draft) { + //checking to see if callback is a function + if(angular.isFunction(callback)){ + if(callback()){ + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + } + }else if (!callback) { + $log.log('no callback function called!'); + //completed property set on scope which is used to add class/remove class from progress bar $scope.selectedStep.completed = true; - } - if (index === $scope.steps.length - 1) { - this.finish(); } else { - $scope.goTo($scope.steps[index + 1]); + //checking to see if this is the last step. If it is next behaves the same as finish() + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } } + }; + //used to traverse to any step, step number placed as argument this.goTo = function(step) { var stepTo; + //checking that step is a Number if (_.isNumber(step)) { stepTo = $scope.steps[step]; } else { + //finding the step associated with the title entered as goTo argument stepTo = _.findWhere($scope.steps, {title: step}); } + //going to step $scope.goTo(stepTo); }; + //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. this.finish = function() { if ($scope.onFinish) { $scope.onFinish(); } }; + //cancel is alias for previous. this.cancel = this.previous = function() { + //getting index of current step var index = _.indexOf($scope.steps , $scope.selectedStep); + //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); } else { + //go back one step from current step $scope.goTo($scope.steps[index - 1]); } }; }] }; -}); - +}); function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') .directive(action, function() { @@ -184,7 +243,7 @@ wizardButtonDirective('wzNext'); wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); - + angular.module('mgo-angular-wizard').factory('WizardHandler', function() { var service = {}; diff --git a/dist/angular-wizard.less b/dist/angular-wizard.less old mode 100644 new mode 100755 diff --git a/dist/angular-wizard.min.css b/dist/angular-wizard.min.css old mode 100644 new mode 100755 diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js old mode 100644 new mode 100755 index 43c3d38..cd7ca3d --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-07-10 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","WizardHandler",function(a,b,c){function d(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}c.addWizard(a.name||c.defaultName,this),a.$on("$destroy",function(){c.removeWizard(a.name||c.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){d(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +/** + * Easy to use Wizard library for AngularJS + * @version v0.4.0 - 2014-12-05 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizardDirective.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){c.log("wizard.next invoked, ",b,a.steps,a.selectedStep);var d=_.indexOf(a.steps,a.selectedStep);angular.isFunction(b)?b()&&(d===a.steps.length-1?this.finish():a.goTo(a.steps[d+1])):b?d===a.steps.length-1?this.finish():a.goTo(a.steps[d+1]):(c.log("no callback function called!"),a.selectedStep.completed=!0)},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/wizard.js b/src/wizard.js old mode 100644 new mode 100755 index 2b9c129..cdeefb3 --- a/src/wizard.js +++ b/src/wizard.js @@ -1,3 +1,4 @@ +//wizard directive angular.module('mgo-angular-wizard').directive('wizard', function() { return { restrict: 'EA', @@ -11,26 +12,37 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { name: '@' }, templateUrl: function(element, attributes) { - return attributes.template || "wizard.html"; + return attributes.template || "wizardDirective.html"; }, - controller: ['$scope', '$element', 'WizardHandler', function($scope, $element, WizardHandler) { + //controller for wizard directive, treat this just like an angular controller + controller: ['$scope', '$element', '$log', 'WizardHandler', function($scope, $element, $log, WizardHandler) { + + //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); + $scope.$on('$destroy', function() { WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); }); + //steps array where all the scopes of each step are added $scope.steps = []; + //watching changes to currentStep $scope.$watch('currentStep', function(step) { + //checking to make sure currentStep is truthy value if (!step) return; + //setting stepTitle equal to current step title or default title var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; if ($scope.selectedStep && stepTitle !== $scope.currentStep) { + //invoking goTo() with step title as argument $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); } }); + //watching steps array length and editMode value, if edit module is undefined or null the nothing is done + //if edit mode is truthy, then all steps are marked as completed $scope.$watch('[editMode, steps.length]', function() { var editMode = $scope.editMode; if (_.isUndefined(editMode) || _.isNull(editMode)) return; @@ -42,70 +54,118 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } }, true); + //called each time step directive is loaded this.addStep = function(step) { + //pushing the scope of directive onto step array $scope.steps.push(step); + //if this is first step being pushed then goTo that first step if ($scope.steps.length === 1) { + //goTo first step $scope.goTo($scope.steps[0]); } }; $scope.goTo = function(step) { + //deselect all steps so you can set fresh below unselectAll(); + //set the selected step to $scope of directive of that step $scope.selectedStep = step; + //making sure current step is not undefined if (!_.isUndefined($scope.currentStep)) { $scope.currentStep = step.title || step.wzTitle; } + //setting selected step to argument passed into goTo() step.selected = true; + //emit event upwards with data on goTo() invoktion $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); }; - + $scope.currentStepNumber = function() { + //retreive current step number return _.indexOf($scope.steps , $scope.selectedStep) + 1; - } + }; + //unSelect All Steps function unselectAll() { + //traverse steps array and set each "selected" property to false _.each($scope.steps, function (step) { step.selected = false; }); + //set selectedStep variable to null $scope.selectedStep = null; } - this.next = function(draft) { + //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + + //Access to current step number from outside + this.currentStepNumber = function(){ + return $scope.currentStepNumber(); + }; + //method used for next button within step + //TODO How is the callback in the directive, i.e. wz-next="callback()" get called! + this.next = function(callback) { + $log.log('wizard.next invoked, ', callback, $scope.steps, $scope.selectedStep); + //setting variable equal to step you were on when next() was invoked var index = _.indexOf($scope.steps , $scope.selectedStep); - if (!draft) { + //checking to see if callback is a function + if(angular.isFunction(callback)){ + if(callback()){ + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + } + }else if (!callback) { + $log.log('no callback function called!'); + //completed property set on scope which is used to add class/remove class from progress bar $scope.selectedStep.completed = true; - } - if (index === $scope.steps.length - 1) { - this.finish(); } else { - $scope.goTo($scope.steps[index + 1]); + //checking to see if this is the last step. If it is next behaves the same as finish() + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } } + }; + //used to traverse to any step, step number placed as argument this.goTo = function(step) { var stepTo; + //checking that step is a Number if (_.isNumber(step)) { stepTo = $scope.steps[step]; } else { + //finding the step associated with the title entered as goTo argument stepTo = _.findWhere($scope.steps, {title: step}); } + //going to step $scope.goTo(stepTo); }; + //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. this.finish = function() { if ($scope.onFinish) { $scope.onFinish(); } }; + //cancel is alias for previous. this.cancel = this.previous = function() { + //getting index of current step var index = _.indexOf($scope.steps , $scope.selectedStep); + //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); } else { + //go back one step from current step $scope.goTo($scope.steps[index - 1]); } }; }] }; -}); +}); \ No newline at end of file From 9f81cb628488039275daa0ad8a4f5adb79beb799 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 5 Dec 2014 16:38:21 -0700 Subject: [PATCH 047/185] updated karma config to include Chrome, added Chrome and PhantomJS launcher to package.json dev dependencies --- karma.conf.js | 2 +- package.json | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index fd79f1b..a040cb0 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -59,7 +59,7 @@ module.exports = function(config) { // - Safari (only Mac) // - PhantomJS // - IE (only Windows) - browsers: ['PhantomJS'], + browsers: ['PhantomJS', 'Chrome'], // If browser does not capture in given timeout [ms], kill it diff --git a/package.json b/package.json index 809315f..6851d26 100644 --- a/package.json +++ b/package.json @@ -29,23 +29,27 @@ ], "dependencies": {}, "devDependencies": { + "grunt": "~0.4.1", "grunt-bower": "*", "grunt-bower-task": "*", - "grunt-zip": "*", - "grunt": "~0.4.1", - "grunt-recess": "~0.3.0", + "grunt-bump": "0.0.6", "grunt-contrib-clean": "~0.4.1", - "grunt-contrib-copy": "~0.4.1", "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-copy": "~0.4.1", "grunt-contrib-uglify": "~0.2.0", + "grunt-conventional-changelog": "~0.1.1", + "grunt-html2js": "~0.1.3", "grunt-karma": "~0.8", "grunt-ngmin": "0.0.2", - "grunt-html2js": "~0.1.3", - "grunt-conventional-changelog": "~0.1.1", - "grunt-bump": "0.0.6" + "grunt-recess": "~0.3.0", + "grunt-zip": "*", + "jasmine-core": "^2.1.3", + "karma-chrome-launcher": "^0.1.7", + "karma-jasmine": "^0.3.2", + "karma-phantomjs-launcher": "^0.1.4" }, "scripts": { "test": "grunt travis --verbose" }, "license": "MIT" -} \ No newline at end of file +} From 20039a4b82b36f1e5c7d89c8b518d39e9c302046 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 5 Dec 2014 16:40:39 -0700 Subject: [PATCH 048/185] created test for new next() functionality, previously added comments to code for understanding, removed logs --- src/wizard.js | 22 +++++++++++----------- test/angularWizardSpec.js | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index cdeefb3..7104760 100755 --- a/src/wizard.js +++ b/src/wizard.js @@ -12,7 +12,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { name: '@' }, templateUrl: function(element, attributes) { - return attributes.template || "wizardDirective.html"; + return attributes.template || "wizard.html"; }, //controller for wizard directive, treat this just like an angular controller @@ -104,7 +104,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //method used for next button within step //TODO How is the callback in the directive, i.e. wz-next="callback()" get called! this.next = function(callback) { - $log.log('wizard.next invoked, ', callback, $scope.steps, $scope.selectedStep); //setting variable equal to step you were on when next() was invoked var index = _.indexOf($scope.steps , $scope.selectedStep); //checking to see if callback is a function @@ -116,19 +115,20 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //invoking goTo() with step number next in line $scope.goTo($scope.steps[index + 1]); } + } else { + return; } - }else if (!callback) { - $log.log('no callback function called!'); + } + if (!callback) { //completed property set on scope which is used to add class/remove class from progress bar $scope.selectedStep.completed = true; + } + //checking to see if this is the last step. If it is next behaves the same as finish() + if (index === $scope.steps.length - 1) { + this.finish(); } else { - //checking to see if this is the last step. If it is next behaves the same as finish() - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); } }; diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index b7176fe..721aaaa 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -80,6 +80,26 @@ describe( 'AngularWizard', function() { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('More steps'); }); + it( "should go to next step becasue callback is truthy", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(function(){ + return true + }); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + }); + it( "should NOT go to next step becasue callback is falsey", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(function(){ + return false + }); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Starting'); + }); it( "should finish", function() { var scope = $rootScope.$new(); var flag = false; From e2efecc8586c5ed7ab7a2698599d8bcc79d2bd9a Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 5 Dec 2014 16:41:38 -0700 Subject: [PATCH 049/185] project build --- dist/angular-wizard.js | 22 +++++++++++----------- dist/angular-wizard.min.js | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index d752971..d5178c1 100755 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -61,7 +61,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { name: '@' }, templateUrl: function(element, attributes) { - return attributes.template || "wizardDirective.html"; + return attributes.template || "wizard.html"; }, //controller for wizard directive, treat this just like an angular controller @@ -153,7 +153,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //method used for next button within step //TODO How is the callback in the directive, i.e. wz-next="callback()" get called! this.next = function(callback) { - $log.log('wizard.next invoked, ', callback, $scope.steps, $scope.selectedStep); //setting variable equal to step you were on when next() was invoked var index = _.indexOf($scope.steps , $scope.selectedStep); //checking to see if callback is a function @@ -165,19 +164,20 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //invoking goTo() with step number next in line $scope.goTo($scope.steps[index + 1]); } + } else { + return; } - }else if (!callback) { - $log.log('no callback function called!'); + } + if (!callback) { //completed property set on scope which is used to add class/remove class from progress bar $scope.selectedStep.completed = true; + } + //checking to see if this is the last step. If it is next behaves the same as finish() + if (index === $scope.steps.length - 1) { + this.finish(); } else { - //checking to see if this is the last step. If it is next behaves the same as finish() - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); } }; diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index cd7ca3d..13aac3f 100755 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -4,4 +4,4 @@ * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizardDirective.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){c.log("wizard.next invoked, ",b,a.steps,a.selectedStep);var d=_.indexOf(a.steps,a.selectedStep);angular.isFunction(b)?b()&&(d===a.steps.length-1?this.finish():a.goTo(a.steps[d+1])):b?d===a.steps.length-1?this.finish():a.goTo(a.steps[d+1]):(c.log("no callback function called!"),a.selectedStep.completed=!0)},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 495a577cc6e62fc26ccc71e571af8b98a261c04f Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 8 Dec 2014 16:29:22 -0700 Subject: [PATCH 050/185] added enter and exit validation for traversing steps that depend on information from other steps through context object --- src/step.js | 4 ++- src/wizard.js | 69 ++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 13 deletions(-) mode change 100644 => 100755 src/step.js diff --git a/src/step.js b/src/step.js old mode 100644 new mode 100755 index 118252a..bbe5d05 --- a/src/step.js +++ b/src/step.js @@ -5,7 +5,9 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { transclude: true, scope: { wzTitle: '@', - title: '@' + title: '@', + canenter : '=', + canexit : '=' }, require: '^wizard', templateUrl: function(element, attributes) { diff --git a/src/wizard.js b/src/wizard.js index 7104760..58c16a2 100755 --- a/src/wizard.js +++ b/src/wizard.js @@ -17,7 +17,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //controller for wizard directive, treat this just like an angular controller controller: ['$scope', '$element', '$log', 'WizardHandler', function($scope, $element, $log, WizardHandler) { - + //this variable allows directive to load without having to pass any step validation + var firstRun = true; //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); @@ -28,6 +29,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //steps array where all the scopes of each step are added $scope.steps = []; + //access to context object for step validation + $scope.context = {}; + //watching changes to currentStep $scope.$watch('currentStep', function(step) { //checking to make sure currentStep is truthy value @@ -66,18 +70,59 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; $scope.goTo = function(step) { - //deselect all steps so you can set fresh below - unselectAll(); - //set the selected step to $scope of directive of that step - $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; + //if this is the first time the wizard is loading it bi-passes step validation + if(firstRun){ + //deselect all steps so you can set fresh below + unselectAll(); + $scope.selectedStep = step; + //making sure current step is not undefined + if (!_.isUndefined($scope.currentStep)) { + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + //setting variable to false so all other step changes must pass validation + firstRun = false; + } else { + //createing variables to capture current state that goTo() was invoked from and allow booleans + var thisStep; + var exitallowed = false; + var enterallowed = false; + //getting data for step you are transitioning out of + if($scope.currentStepNumber() > 0){ + thisStep = $scope.currentStepNumber() - 1; + } else if ($scope.currentStepNumber() === 0){ + thisStep = 0; + } + console.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); + if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ + exitallowed = true; + } + if(exitallowed && step.canenter === undefined || exitallowed && step.canenter($scope.context) === true){ + enterallowed = true; + } + + if(exitallowed && enterallowed){ + //deselect all steps so you can set fresh below + unselectAll(); + + //console.log('value for canExit argument: ', $scope.currentStep.canexit); + $scope.selectedStep = step; + //making sure current step is not undefined + if (!_.isUndefined($scope.currentStep)) { + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + console.log('current step number: ', $scope.currentStepNumber()); + } else { + return; + } } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); }; $scope.currentStepNumber = function() { From 1fab89e820510a37cf4d4dd8ff00453e756c630d Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 9 Dec 2014 08:47:07 -0700 Subject: [PATCH 051/185] added testing for enter and exit validation --- test/angularWizardSpec.js | 72 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 3 deletions(-) mode change 100644 => 100755 test/angularWizardSpec.js diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js old mode 100644 new mode 100755 index 721aaaa..c28f26c --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -2,6 +2,8 @@ describe( 'AngularWizard', function() { var $compile, $rootScope, WizardHandler; beforeEach(module('mgo-angular-wizard')); + + beforeEach(inject(function(_$compile_, _$rootScope_, _WizardHandler_) { $compile = _$compile_; $rootScope = _$rootScope_; @@ -21,12 +23,12 @@ describe( 'AngularWizard', function() { + '

Here you can use whatever you want. You can use other directives, binding, etc.

' + ' ' + '
' - + ' ' + + ' ' + '

Continuing

' + '

You have continued here!

' + ' ' + '
' - + ' ' + + ' ' + '

Even more steps!!

' + ' ' + '
' @@ -90,7 +92,7 @@ describe( 'AngularWizard', function() { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); }); - it( "should NOT go to next step becasue callback is falsey", function() { + it( "should NOT go to next step because callback is falsey", function() { var scope = $rootScope.$new(); var view = createView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); @@ -100,6 +102,70 @@ describe( 'AngularWizard', function() { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Starting'); }); + it( "should go to next step because CANEXIT is UNDEFINED", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + }); + it( "should go to next step because CANEXIT is TRUE", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + scope.stepValidation = function(){ + return true; + }; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); + it( "should NOT go to next step because CANEXIT is FALSE", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + scope.stepValidation = function(){ + return false; + }; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + }); + it( "should go to next step because CANENTER is TRUE", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + scope.enterValidation = function(){ + return true; + }; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); + it( "should NOT go to next step because CANENTER is TRUE", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + scope.enterValidation = function(){ + return false; + }; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + }); it( "should finish", function() { var scope = $rootScope.$new(); var flag = false; From 8a58a567a1ac989c0d8b782471f05a1029d73da6 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 9 Dec 2014 08:47:34 -0700 Subject: [PATCH 052/185] Project build --- dist/angular-wizard.js | 75 +++++++++++++++++++++++++++++++------- dist/angular-wizard.min.js | 4 +- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index d5178c1..b2a38da 100755 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-12-05 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-12-09 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -34,7 +34,9 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { transclude: true, scope: { wzTitle: '@', - title: '@' + title: '@', + canenter : '=', + canexit : '=' }, require: '^wizard', templateUrl: function(element, attributes) { @@ -66,7 +68,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //controller for wizard directive, treat this just like an angular controller controller: ['$scope', '$element', '$log', 'WizardHandler', function($scope, $element, $log, WizardHandler) { - + //this variable allows directive to load without having to pass any step validation + var firstRun = true; //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); @@ -77,6 +80,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //steps array where all the scopes of each step are added $scope.steps = []; + //access to context object for step validation + $scope.context = {}; + //watching changes to currentStep $scope.$watch('currentStep', function(step) { //checking to make sure currentStep is truthy value @@ -115,18 +121,59 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; $scope.goTo = function(step) { - //deselect all steps so you can set fresh below - unselectAll(); - //set the selected step to $scope of directive of that step - $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; + //if this is the first time the wizard is loading it bi-passes step validation + if(firstRun){ + //deselect all steps so you can set fresh below + unselectAll(); + $scope.selectedStep = step; + //making sure current step is not undefined + if (!_.isUndefined($scope.currentStep)) { + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + //setting variable to false so all other step changes must pass validation + firstRun = false; + } else { + //createing variables to capture current state that goTo() was invoked from and allow booleans + var thisStep; + var exitallowed = false; + var enterallowed = false; + //getting data for step you are transitioning out of + if($scope.currentStepNumber() > 0){ + thisStep = $scope.currentStepNumber() - 1; + } else if ($scope.currentStepNumber() === 0){ + thisStep = 0; + } + console.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); + if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ + exitallowed = true; + } + if(exitallowed && step.canenter === undefined || exitallowed && step.canenter($scope.context) === true){ + enterallowed = true; + } + + if(exitallowed && enterallowed){ + //deselect all steps so you can set fresh below + unselectAll(); + + //console.log('value for canExit argument: ', $scope.currentStep.canexit); + $scope.selectedStep = step; + //making sure current step is not undefined + if (!_.isUndefined($scope.currentStep)) { + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + console.log('current step number: ', $scope.currentStepNumber()); + } else { + return; + } } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); }; $scope.currentStepNumber = function() { diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 13aac3f..f681d6b 100755 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-12-05 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-12-09 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var f=!0;d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.context={},a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){if(f)e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),f=!1;else{var c,d=!1,g=!1;if(a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),console.log("steps[thisStep] Data: ",a.steps[c].canexit),("undefined"==typeof a.steps[c].canexit||a.steps[c].canexit(a.context)===!0)&&(d=!0),(d&&void 0===b.canenter||d&&b.canenter(a.context)===!0)&&(g=!0),!d||!g)return;e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),console.log("current step number: ",a.currentStepNumber())}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 58bba777596622b0572d5bcf59ff7b9449b81714 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Dec 2014 09:03:31 -0700 Subject: [PATCH 053/185] added context object --- src/step.js | 0 src/wizard.js | 2 ++ test/angularWizardSpec.js | 0 3 files changed, 2 insertions(+) mode change 100755 => 100644 src/step.js mode change 100755 => 100644 src/wizard.js mode change 100755 => 100644 test/angularWizardSpec.js diff --git a/src/step.js b/src/step.js old mode 100755 new mode 100644 diff --git a/src/wizard.js b/src/wizard.js old mode 100755 new mode 100644 index 58c16a2..1e5125b --- a/src/wizard.js +++ b/src/wizard.js @@ -69,6 +69,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } }; + this.context = $scope.context; + $scope.goTo = function(step) { //if this is the first time the wizard is loading it bi-passes step validation if(firstRun){ diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js old mode 100755 new mode 100644 From 27035215cda231d9e2adba6c73674689fa267709 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 9 Dec 2014 09:11:37 -0700 Subject: [PATCH 054/185] Added new step functionality and all controbuters to README.md --- README.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d74f02b..fa10aea 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,44 @@ All of this attributes can receive an optional function to be called before chan In this case, the `setMode` function will be called before going to the next step. +## Wizard Step Validation +The wzStep directive has the following options as attributes: +* **canexit**: Here you can reference a function from your controller. If this attribute is listed the funtion must return true in order for the wizard to move to the next step. If it is ommitted no validation will be required. +* **canenter**: Here you can reference a function from your controller. If this attribute is listed the funtion must return true in order for the wizard to move into this step. If it is ommitted no validation will be required. + + **Example** + +HTML +````html + + +

This is the first step

+

Here you can use whatever you want. You can use other directives, binding, etc.

+ +
+ +

Continuing

+

You have continued here!

+ +
+ +

Even more steps!!

+ +
+
+```` +Controller +````javascript +$scope.enterValidation = function(){ + return true; +}; + +$scope.exitValidation = function(){ + return true; +}; +```` +If a step requires information from a previous step to populate itself you can access this information through the `context` object. The context object is automatically passed in as an argument into your canexit and canenter methods. You can access the context objext from your controller via: `WizardHandler.wizard().context` + ## Manipulating the wizard from a service There're some times where we actually want to manipulate the wizard from the controller instead of from the HTML. @@ -122,6 +160,7 @@ The functions available in the `wizard()` are: * **previous**: Goes to the previous step * **finish**: Finishes the wizard. * **goTo(number|title)**: This goes to the indicated step. It can receive either the number of the step (starting from 0) or the title of the step to go to. +* **currentStepNumber()**: This returns a Number which is the current step number you are on. ## Navigation bar @@ -137,7 +176,20 @@ All of those colors are variables in the `angular-wizard.less`. You can easily c # Contributors -@sebazelonka helped me with all fo the styles of the Wizard. +* [@sebazelonka](https://github.com/sebazelonka) helped me with all fo the styles of the Wizard. +* [@cristianspinetta](https://github.com/cristianspinetta) +* [@tanepiper](https://github.com/tanepiper) +* [@stevecd](https://github.com/stevecd) +* [@kamshak](https://github.com/Kamshak) +* [@rtucker88](https://github.com/rtucker88) +* [@starr0stealer](https://github.com/starr0stealer) +* [@bitdeli-chef](https://github.com/bitdeli-chef) +* [@brendan6](https://github.com/brendan6) +* [@raykin](https://github.com/raykin) +* [@TylerLH](https://github.com/TylerLH) +* [@prem-prakash](https://github.com/prem-prakash) +* [@esteinborn](https://github.com/esteinborn) +* [@jacobscarter](https://github.com/jacobscarter) # Live sample From 310ba495302ac0e647c3af199c84415eee8c78a2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Dec 2014 09:13:01 -0700 Subject: [PATCH 055/185] Project build --- dist/angular-wizard.css | 0 dist/angular-wizard.js | 2 ++ dist/angular-wizard.less | 0 dist/angular-wizard.min.css | 0 dist/angular-wizard.min.js | 2 +- 5 files changed, 3 insertions(+), 1 deletion(-) mode change 100755 => 100644 dist/angular-wizard.css mode change 100755 => 100644 dist/angular-wizard.js mode change 100755 => 100644 dist/angular-wizard.less mode change 100755 => 100644 dist/angular-wizard.min.css mode change 100755 => 100644 dist/angular-wizard.min.js diff --git a/dist/angular-wizard.css b/dist/angular-wizard.css old mode 100755 new mode 100644 diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js old mode 100755 new mode 100644 index b2a38da..05c338b --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -120,6 +120,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } }; + this.context = $scope.context; + $scope.goTo = function(step) { //if this is the first time the wizard is loading it bi-passes step validation if(firstRun){ diff --git a/dist/angular-wizard.less b/dist/angular-wizard.less old mode 100755 new mode 100644 diff --git a/dist/angular-wizard.min.css b/dist/angular-wizard.min.css old mode 100755 new mode 100644 diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js old mode 100755 new mode 100644 index f681d6b..06503d5 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -4,4 +4,4 @@ * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var f=!0;d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.context={},a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},a.goTo=function(b){if(f)e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),f=!1;else{var c,d=!1,g=!1;if(a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),console.log("steps[thisStep] Data: ",a.steps[c].canexit),("undefined"==typeof a.steps[c].canexit||a.steps[c].canexit(a.context)===!0)&&(d=!0),(d&&void 0===b.canenter||d&&b.canenter(a.context)===!0)&&(g=!0),!d||!g)return;e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),console.log("current step number: ",a.currentStepNumber())}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var f=!0;d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.context={},a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},this.context=a.context,a.goTo=function(b){if(f)e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),f=!1;else{var c,d=!1,g=!1;if(a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),console.log("steps[thisStep] Data: ",a.steps[c].canexit),("undefined"==typeof a.steps[c].canexit||a.steps[c].canexit(a.context)===!0)&&(d=!0),(d&&void 0===b.canenter||d&&b.canenter(a.context)===!0)&&(g=!0),!d||!g)return;e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),console.log("current step number: ",a.currentStepNumber())}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 45fad165f923078722fab39a289e1b4db513523c Mon Sep 17 00:00:00 2001 From: Martin Gontovnikas Date: Sat, 13 Dec 2014 14:30:06 -0300 Subject: [PATCH 056/185] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d74f02b..9f72510 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,8 @@ All of those colors are variables in the `angular-wizard.less`. You can easily c # Contributors -@sebazelonka helped me with all fo the styles of the Wizard. +* @sebazelonka helped me with all fo the styles of the Wizard. +* [@jacobscarter](https://github.com/jacobscarter) is helping with manteinance, PRS merging and adding new features # Live sample From d159f40914d92a66fc64c7be114ec86a90c7d50d Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Sat, 13 Dec 2014 10:30:32 -0700 Subject: [PATCH 057/185] removed contributors --- README.md | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/README.md b/README.md index fa10aea..8a030f1 100644 --- a/README.md +++ b/README.md @@ -177,19 +177,6 @@ All of those colors are variables in the `angular-wizard.less`. You can easily c # Contributors * [@sebazelonka](https://github.com/sebazelonka) helped me with all fo the styles of the Wizard. -* [@cristianspinetta](https://github.com/cristianspinetta) -* [@tanepiper](https://github.com/tanepiper) -* [@stevecd](https://github.com/stevecd) -* [@kamshak](https://github.com/Kamshak) -* [@rtucker88](https://github.com/rtucker88) -* [@starr0stealer](https://github.com/starr0stealer) -* [@bitdeli-chef](https://github.com/bitdeli-chef) -* [@brendan6](https://github.com/brendan6) -* [@raykin](https://github.com/raykin) -* [@TylerLH](https://github.com/TylerLH) -* [@prem-prakash](https://github.com/prem-prakash) -* [@esteinborn](https://github.com/esteinborn) -* [@jacobscarter](https://github.com/jacobscarter) # Live sample From 17070f2a9147d3082b0a642c4496cc60dfdf3b71 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 16 Dec 2014 08:33:22 -0700 Subject: [PATCH 058/185] Removed merge conflict --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 097ab68..3459a51 100644 --- a/README.md +++ b/README.md @@ -176,12 +176,9 @@ All of those colors are variables in the `angular-wizard.less`. You can easily c # Contributors -<<<<<<< HEAD -* [@sebazelonka](https://github.com/sebazelonka) helped me with all fo the styles of the Wizard. -======= * @sebazelonka helped me with all fo the styles of the Wizard. * [@jacobscarter](https://github.com/jacobscarter) is helping with manteinance, PRS merging and adding new features ->>>>>>> upstream/master + # Live sample From f6d27d69d75fda5cc48ce60309678ee1e1c1abe7 Mon Sep 17 00:00:00 2001 From: mprent99 Date: Tue, 16 Dec 2014 15:27:49 -0500 Subject: [PATCH 059/185] Add Travis-CI support. Add Firefox runner for Karma. Add grunt-cli. --- README.md | 1 - karma.conf.js | 12 +++++++++--- package.json | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c08586f..7c44db9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using PayPal") [![Donate on Gratipay](http://img.shields.io/gratipay/mgonto.svg)](https://gratipay.com/mgonto/) - Angular-wizard is a component that will make it easy for you to create wizards in your app. You can check a running example of the wizard [by clicking here](http://mgonto.github.io/angular-wizard/) # How do I add this to my project? diff --git a/karma.conf.js b/karma.conf.js index f73feb8..9f422ec 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -2,7 +2,7 @@ // Generated on Fri Aug 09 2013 14:14:35 GMT-0500 (CDT) module.exports = function(config) { - config.set({ + var configuration = { // base path, that will be used to resolve files and exclude basePath: '', @@ -59,7 +59,7 @@ module.exports = function(config) { // - Safari (only Mac) // - PhantomJS // - IE (only Windows) - browsers: ['PhantomJS', 'Chrome'], + browsers: ['Chrome', 'Firefox', 'PhantomJS'], // If browser does not capture in given timeout [ms], kill it @@ -70,5 +70,11 @@ module.exports = function(config) { // if true, it capture browsers, run tests and exit singleRun: false - }); + }; + + if (process.env.TRAVIS) { + configuration.browsers = ['Firefox', 'PhantomJS']; + } + + config.set(configuration); }; diff --git a/package.json b/package.json index cde7295..48d4365 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "grunt-bower": "*", "grunt-bower-task": "*", "grunt-bump": "0.0.6", + "grunt-cli": "^0.1.x", "grunt-contrib-clean": "~0.4.1", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.4.1", @@ -45,6 +46,7 @@ "grunt-zip": "*", "jasmine-core": "^2.1.3", "karma-chrome-launcher": "^0.1.7", + "karma-firefox-launcher": "~0.1.x", "karma-jasmine": "~0.3.x", "karma-phantomjs-launcher": "~0.1.x" }, From a648fea2fad4bd24ffae355b8c7bf244d256cabf Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 30 Dec 2014 10:06:57 -0700 Subject: [PATCH 060/185] Fixed test decription --- test/angularWizardSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index c28f26c..19c2b33 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -152,7 +152,7 @@ describe( 'AngularWizard', function() { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('More steps'); }); - it( "should NOT go to next step because CANENTER is TRUE", function() { + it( "should NOT go to next step because CANENTER is FALSE", function() { var scope = $rootScope.$new(); var view = createView(scope); scope.enterValidation = function(){ From 335bbaa33708406ea9b23ca1284f9e6a3847c620 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 30 Dec 2014 10:21:54 -0700 Subject: [PATCH 061/185] updated comment notes, changes console.log to .log, commented out all --- src/wizard.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index 1e5125b..5e86d67 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -98,7 +98,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } else if ($scope.currentStepNumber() === 0){ thisStep = 0; } - console.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); + //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ exitallowed = true; } @@ -110,7 +110,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //deselect all steps so you can set fresh below unselectAll(); - //console.log('value for canExit argument: ', $scope.currentStep.canexit); + //$log.log('value for canExit argument: ', $scope.currentStep.canexit); $scope.selectedStep = step; //making sure current step is not undefined if (!_.isUndefined($scope.currentStep)) { @@ -120,7 +120,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { step.selected = true; //emit event upwards with data on goTo() invoktion $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); - console.log('current step number: ', $scope.currentStepNumber()); + //$log.log('current step number: ', $scope.currentStepNumber()); } else { return; } @@ -149,7 +149,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return $scope.currentStepNumber(); }; //method used for next button within step - //TODO How is the callback in the directive, i.e. wz-next="callback()" get called! this.next = function(callback) { //setting variable equal to step you were on when next() was invoked var index = _.indexOf($scope.steps , $scope.selectedStep); From 956a40cdeb031e01760a0dbe3b4efd1c6f96e612 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 30 Dec 2014 10:23:00 -0700 Subject: [PATCH 062/185] Updated project build --- dist/angular-wizard.js | 12 ++++++------ dist/angular-wizard.min.js | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 5dad855..ec336cb 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-12-09 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.0 - 2014-12-30 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -25,7 +25,7 @@ angular.module("wizard.html", []).run(["$templateCache", function($templateCache ""); }]); -angular.module('mgo-angular-wizard', ['templates-angularwizard']); +angular.module('mgo-angular-wizard', ['templates-angularwizard']); angular.module('mgo-angular-wizard').directive('wzStep', function() { return { @@ -149,7 +149,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } else if ($scope.currentStepNumber() === 0){ thisStep = 0; } - console.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); + //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ exitallowed = true; } @@ -161,7 +161,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //deselect all steps so you can set fresh below unselectAll(); - //console.log('value for canExit argument: ', $scope.currentStep.canexit); + //$log.log('value for canExit argument: ', $scope.currentStep.canexit); $scope.selectedStep = step; //making sure current step is not undefined if (!_.isUndefined($scope.currentStep)) { @@ -171,7 +171,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { step.selected = true; //emit event upwards with data on goTo() invoktion $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); - console.log('current step number: ', $scope.currentStepNumber()); + //$log.log('current step number: ', $scope.currentStepNumber()); } else { return; } @@ -200,7 +200,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return $scope.currentStepNumber(); }; //method used for next button within step - //TODO How is the callback in the directive, i.e. wz-next="callback()" get called! this.next = function(callback) { //setting variable equal to step you were on when next() was invoked var index = _.indexOf($scope.steps , $scope.selectedStep); @@ -228,6 +227,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //invoking goTo() with step number next in line $scope.goTo($scope.steps[index + 1]); } + }; //used to traverse to any step, step number placed as argument diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index ab4ca6e..b582e3b 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-12-09 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var f=!0;d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.context={},a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},this.context=a.context,a.goTo=function(b){if(f)e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),f=!1;else{var c,d=!1,g=!1;if(a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),console.log("steps[thisStep] Data: ",a.steps[c].canexit),("undefined"==typeof a.steps[c].canexit||a.steps[c].canexit(a.context)===!0)&&(d=!0),(d&&void 0===b.canenter||d&&b.canenter(a.context)===!0)&&(g=!0),!d||!g)return;e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),console.log("current step number: ",a.currentStepNumber())}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); +/** + * Easy to use Wizard library for AngularJS + * @version v0.4.0 - 2014-12-30 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var f=!0;d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.context={},a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},this.context=a.context,a.goTo=function(b){if(f)e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),f=!1;else{var c,d=!1,g=!1;if(a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),("undefined"==typeof a.steps[c].canexit||a.steps[c].canexit(a.context)===!0)&&(d=!0),(d&&void 0===b.canenter||d&&b.canenter(a.context)===!0)&&(g=!0),!d||!g)return;e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From bedb5093c40896f009df2349caea60b439bc0cce Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 30 Dec 2014 10:48:50 -0700 Subject: [PATCH 063/185] Project Build --- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index ec336cb..448db31 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-12-30 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.1 - 2014-12-30 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index b582e3b..59de58f 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.0 - 2014-12-30 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.1 - 2014-12-30 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ From 3e96b68548b90306ebf083382585db38bbff46b6 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 30 Dec 2014 10:49:07 -0700 Subject: [PATCH 064/185] 0.4.1 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index b18294d..e566308 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.4.0", + "version": "0.4.1", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { diff --git a/package.json b/package.json index 6851d26..124e305 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.4.0", + "version": "0.4.1", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 5351f42ee02b98d3ae8dea357fbd36476ac6cd47 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 1 Jan 2015 15:57:10 -0700 Subject: [PATCH 065/185] added functionality to allow moving back in steps even if current step canexit is false, you would use canenter validation to stop this from being allowed --- src/wizard.js | 7 +++++++ test/angularWizardSpec.js | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/wizard.js b/src/wizard.js index 5e86d67..79d9535 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -71,6 +71,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.context = $scope.context; + $scope.getStepNumber = function(step) { + return _.indexOf($scope.steps, step) + 1; + }; + $scope.goTo = function(step) { //if this is the first time the wizard is loading it bi-passes step validation if(firstRun){ @@ -102,6 +106,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ exitallowed = true; } + if($scope.getStepNumber(step) < $scope.currentStepNumber()){ + exitallowed = true; + } if(exitallowed && step.canenter === undefined || exitallowed && step.canenter($scope.context) === true){ enterallowed = true; } diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index 19c2b33..4ecd983 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -18,7 +18,7 @@ describe( 'AngularWizard', function() { function createView(scope) { scope.referenceCurrentStep = null; var element = angular.element('' - + ' ' + + ' ' + '

This is the first step

' + '

Here you can use whatever you want. You can use other directives, binding, etc.

' + ' ' @@ -166,6 +166,37 @@ describe( 'AngularWizard', function() { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); }); + it( "should NOT return to a previous step. Although CANEXIT is false and we are heading to a previous state, the can enter validation is false", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + scope.stepValidation = function(){ + return false; + }; + scope.enterValidation = function(){ + return false; + }; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().previous(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + }); + it( "should return to a previous step even though CANEXIT is false", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + scope.stepValidation = function(){ + return false; + }; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().previous(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Starting'); + }); it( "should finish", function() { var scope = $rootScope.$new(); var flag = false; From a0c960039cecb5e358fa3724966e985e144288e5 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 1 Jan 2015 15:59:25 -0700 Subject: [PATCH 066/185] Project Build --- dist/angular-wizard.js | 9 ++++++++- dist/angular-wizard.min.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 448db31..dd7c148 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.1 - 2014-12-30 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.2 - 2015-01-01 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -122,6 +122,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.context = $scope.context; + $scope.getStepNumber = function(step) { + return _.indexOf($scope.steps, step) + 1; + }; + $scope.goTo = function(step) { //if this is the first time the wizard is loading it bi-passes step validation if(firstRun){ @@ -153,6 +157,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ exitallowed = true; } + if($scope.getStepNumber(step) < $scope.currentStepNumber()){ + exitallowed = true; + } if(exitallowed && step.canenter === undefined || exitallowed && step.canenter($scope.context) === true){ enterallowed = true; } diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 59de58f..24557d7 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.1 - 2014-12-30 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.2 - 2015-01-01 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var f=!0;d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.context={},a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},this.context=a.context,a.goTo=function(b){if(f)e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),f=!1;else{var c,d=!1,g=!1;if(a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),("undefined"==typeof a.steps[c].canexit||a.steps[c].canexit(a.context)===!0)&&(d=!0),(d&&void 0===b.canenter||d&&b.canenter(a.context)===!0)&&(g=!0),!d||!g)return;e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)})}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var f=!0;d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.context={},a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},this.context=a.context,a.getStepNumber=function(b){return _.indexOf(a.steps,b)+1},a.goTo=function(b){if(f)e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),f=!1;else{var c,d=!1,g=!1;if(a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),("undefined"==typeof a.steps[c].canexit||a.steps[c].canexit(a.context)===!0)&&(d=!0),a.getStepNumber(b) Date: Thu, 1 Jan 2015 16:00:37 -0700 Subject: [PATCH 067/185] update bower package --- bower.json | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index e566308..fe681bc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.4.1", + "version": "0.4.2", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { diff --git a/package.json b/package.json index 124e305..0ff1816 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.4.1", + "version": "0.4.2", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", @@ -52,4 +52,4 @@ "test": "grunt travis --verbose" }, "license": "MIT" -} +} \ No newline at end of file From 011f970f69543caad85e3d0dceef1219dc77a9c4 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 3 Apr 2015 16:03:40 -0700 Subject: [PATCH 068/185] Project Build --- dist/angular-wizard.css | 115 +++---- dist/angular-wizard.js | 653 ++++++++++++++++++------------------ dist/angular-wizard.less | 2 +- dist/angular-wizard.min.css | 2 +- dist/angular-wizard.min.js | 2 +- 5 files changed, 373 insertions(+), 401 deletions(-) mode change 100644 => 100755 dist/angular-wizard.css mode change 100644 => 100755 dist/angular-wizard.js mode change 100644 => 100755 dist/angular-wizard.less mode change 100644 => 100755 dist/angular-wizard.min.css mode change 100644 => 100755 dist/angular-wizard.min.js diff --git a/dist/angular-wizard.css b/dist/angular-wizard.css old mode 100644 new mode 100755 index a11bcf1..97efc9d --- a/dist/angular-wizard.css +++ b/dist/angular-wizard.css @@ -1,167 +1,138 @@ .steps-indicator { + /* ---- steps quantity ---- */ right: 0; bottom: 0; left: 0; - height: 30px; - padding: 20px 0 0 0; margin: 0; + padding: 20px 0 0 0; + height: 30px; list-style: none; + /* --- http://www.paulirish.com/2012/box-sizing-border-box-ftw/ ---- */ } - .steps-indicator:before { - position: absolute; - height: 1px; background-color: #e6e6e6; content: ''; + position: absolute; + height: 1px; } - .steps-indicator.steps-2:before { - right: calc(25%); - left: calc(25%); + left: calc(100% / 2 / 2); + right: calc(100% / 2 / 2); } - .steps-indicator.steps-3:before { - right: calc(16.666666666666668%); - left: calc(16.666666666666668%); + left: calc(100% / 3 / 2); + right: calc(100% / 3 / 2); } - .steps-indicator.steps-4:before { - right: calc(12.5%); - left: calc(12.5%); + left: calc(100% / 4 / 2); + right: calc(100% / 4 / 2); } - .steps-indicator.steps-5:before { - right: calc(10%); - left: calc(10%); + left: calc(100% / 5 / 2); + right: calc(100% / 5 / 2); } - .steps-indicator.steps-6:before { - right: calc(8.333333333333334%); - left: calc(8.333333333333334%); + left: calc(100% / 6 / 2); + right: calc(100% / 6 / 2); } - .steps-indicator.steps-7:before { - right: calc(7.142857142857143%); - left: calc(7.142857142857143%); + left: calc(100% / 7 / 2); + right: calc(100% / 7 / 2); } - .steps-indicator.steps-8:before { - right: calc(6.25%); - left: calc(6.25%); + left: calc(100% / 8 / 2); + right: calc(100% / 8 / 2); } - .steps-indicator.steps-9:before { - right: calc(5.555555555555555%); - left: calc(5.555555555555555%); + left: calc(100% / 9 / 2); + right: calc(100% / 9 / 2); } - .steps-indicator.steps-10:before { - right: calc(5%); - left: calc(5%); + left: calc(100% / 10 / 2); + right: calc(100% / 10 / 2); } - .steps-indicator * { -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } - .steps-indicator li { position: relative; float: left; + margin: 0; padding: 0; padding-top: 10px; - margin: 0; - line-height: 15px; text-align: center; + line-height: 15px; } - .steps-indicator li a { - font-weight: bold; color: #808080; text-decoration: none; text-transform: uppercase; - cursor: pointer; + font-weight: bold; transition: 0.25s; + cursor: pointer; } - .steps-indicator li a:before { position: absolute; top: -7px; - left: calc(43%); + left: calc(50% - 7px); width: 14px; height: 14px; - background-color: #e6e6e6; border-radius: 100%; + background-color: #e6e6e6; content: ''; transition: 0.25s; } - .steps-indicator li a:hover { color: #4d4d4d; } - .steps-indicator.steps-2 li { - width: calc(50%); + width: calc(100% / 2); } - .steps-indicator.steps-3 li { - width: calc(33.333333333333336%); + width: calc(100% / 3); } - .steps-indicator.steps-4 li { - width: calc(25%); + width: calc(100% / 4); } - .steps-indicator.steps-5 li { - width: calc(20%); + width: calc(100% / 5); } - .steps-indicator.steps-6 li { - width: calc(16.666666666666668%); + width: calc(100% / 6); } - .steps-indicator.steps-7 li { - width: calc(14.285714285714286%); + width: calc(100% / 7); } - .steps-indicator.steps-8 li { - width: calc(12.5%); + width: calc(100% / 8); } - .steps-indicator.steps-9 li { - width: calc(11.11111111111111%); + width: calc(100% / 9); } - .steps-indicator.steps-10 li { - width: calc(10%); + width: calc(100% / 10); } - .steps-indicator.steps-11 li { - width: calc(9.090909090909092%); + width: calc(100% / 11); } - .steps-indicator li.default { pointer-events: none; } - .steps-indicator li.default a:hover { color: #808080; } - .steps-indicator li.current, .steps-indicator li.editing { pointer-events: none; } - .steps-indicator li.current a:before { background-color: #808080; } - .steps-indicator li.done a:before { background-color: #339933; } - .steps-indicator li.editing a:before { background-color: #ff0000; -} \ No newline at end of file +} diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js old mode 100644 new mode 100755 index dd7c148..79f69d4 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,327 +1,328 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.4.2 - 2015-01-01 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
\n" + - "
"); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
\n" + - "
\n" + - " \n" + - "
\n" + - ""); -}]); - +/** + * Easy to use Wizard library for AngularJS + * @version v0.4.2 - 2015-04-03 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
\n" + + "
"); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
\n" + + "
\n" + + " \n" + + "
\n" + + ""); +}]); + angular.module('mgo-angular-wizard', ['templates-angularwizard']); - -angular.module('mgo-angular-wizard').directive('wzStep', function() { - return { - restrict: 'EA', - replace: true, - transclude: true, - scope: { - wzTitle: '@', - title: '@', - canenter : '=', - canexit : '=' - }, - require: '^wizard', - templateUrl: function(element, attributes) { - return attributes.template || "step.html"; - }, - link: function($scope, $element, $attrs, wizard) { - $scope.title = $scope.title || $scope.wzTitle; - wizard.addStep($scope); - } - }; -}); - -//wizard directive -angular.module('mgo-angular-wizard').directive('wizard', function() { - return { - restrict: 'EA', - replace: true, - transclude: true, - scope: { - currentStep: '=', - onFinish: '&', - hideIndicators: '=', - editMode: '=', - name: '@' - }, - templateUrl: function(element, attributes) { - return attributes.template || "wizard.html"; - }, - - //controller for wizard directive, treat this just like an angular controller - controller: ['$scope', '$element', '$log', 'WizardHandler', function($scope, $element, $log, WizardHandler) { - //this variable allows directive to load without having to pass any step validation - var firstRun = true; - //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service - WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); - - $scope.$on('$destroy', function() { - WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); - }); - - //steps array where all the scopes of each step are added - $scope.steps = []; - - //access to context object for step validation - $scope.context = {}; - - //watching changes to currentStep - $scope.$watch('currentStep', function(step) { - //checking to make sure currentStep is truthy value - if (!step) return; - //setting stepTitle equal to current step title or default title - var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; - if ($scope.selectedStep && stepTitle !== $scope.currentStep) { - //invoking goTo() with step title as argument - $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); - } - - }); - - //watching steps array length and editMode value, if edit module is undefined or null the nothing is done - //if edit mode is truthy, then all steps are marked as completed - $scope.$watch('[editMode, steps.length]', function() { - var editMode = $scope.editMode; - if (_.isUndefined(editMode) || _.isNull(editMode)) return; - - if (editMode) { - _.each($scope.steps, function(step) { - step.completed = true; - }); - } - }, true); - - //called each time step directive is loaded - this.addStep = function(step) { - //pushing the scope of directive onto step array - $scope.steps.push(step); - //if this is first step being pushed then goTo that first step - if ($scope.steps.length === 1) { - //goTo first step - $scope.goTo($scope.steps[0]); - } - }; - - this.context = $scope.context; - - $scope.getStepNumber = function(step) { - return _.indexOf($scope.steps, step) + 1; - }; - - $scope.goTo = function(step) { - //if this is the first time the wizard is loading it bi-passes step validation - if(firstRun){ - //deselect all steps so you can set fresh below - unselectAll(); - $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; - } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); - //setting variable to false so all other step changes must pass validation - firstRun = false; - } else { - //createing variables to capture current state that goTo() was invoked from and allow booleans - var thisStep; - var exitallowed = false; - var enterallowed = false; - //getting data for step you are transitioning out of - if($scope.currentStepNumber() > 0){ - thisStep = $scope.currentStepNumber() - 1; - } else if ($scope.currentStepNumber() === 0){ - thisStep = 0; - } - //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); - if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ - exitallowed = true; - } - if($scope.getStepNumber(step) < $scope.currentStepNumber()){ - exitallowed = true; - } - if(exitallowed && step.canenter === undefined || exitallowed && step.canenter($scope.context) === true){ - enterallowed = true; - } - - if(exitallowed && enterallowed){ - //deselect all steps so you can set fresh below - unselectAll(); - - //$log.log('value for canExit argument: ', $scope.currentStep.canexit); - $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; - } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); - //$log.log('current step number: ', $scope.currentStepNumber()); - } else { - return; - } - } - }; - - $scope.currentStepNumber = function() { - //retreive current step number - return _.indexOf($scope.steps , $scope.selectedStep) + 1; - }; - - //unSelect All Steps - function unselectAll() { - //traverse steps array and set each "selected" property to false - _.each($scope.steps, function (step) { - step.selected = false; - }); - //set selectedStep variable to null - $scope.selectedStep = null; - } - - //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() - - //Access to current step number from outside - this.currentStepNumber = function(){ - return $scope.currentStepNumber(); - }; - //method used for next button within step - this.next = function(callback) { - //setting variable equal to step you were on when next() was invoked - var index = _.indexOf($scope.steps , $scope.selectedStep); - //checking to see if callback is a function - if(angular.isFunction(callback)){ - if(callback()){ - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } - } else { - return; - } - } - if (!callback) { - //completed property set on scope which is used to add class/remove class from progress bar - $scope.selectedStep.completed = true; - } - //checking to see if this is the last step. If it is next behaves the same as finish() - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } - - }; - - //used to traverse to any step, step number placed as argument - this.goTo = function(step) { - var stepTo; - //checking that step is a Number - if (_.isNumber(step)) { - stepTo = $scope.steps[step]; - } else { - //finding the step associated with the title entered as goTo argument - stepTo = _.findWhere($scope.steps, {title: step}); - } - //going to step - $scope.goTo(stepTo); - }; - - //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. - this.finish = function() { - if ($scope.onFinish) { - $scope.onFinish(); - } - }; - - //cancel is alias for previous. - this.cancel = this.previous = function() { - //getting index of current step - var index = _.indexOf($scope.steps , $scope.selectedStep); - //ensuring you aren't trying to go back from the first step - if (index === 0) { - throw new Error("Can't go back. It's already in step 0"); - } else { - //go back one step from current step - $scope.goTo($scope.steps[index - 1]); - } - }; - }] - }; -}); -function wizardButtonDirective(action) { - angular.module('mgo-angular-wizard') - .directive(action, function() { - return { - restrict: 'A', - replace: false, - require: '^wizard', - link: function($scope, $element, $attrs, wizard) { - - $element.on("click", function(e) { - e.preventDefault(); - $scope.$apply(function() { - $scope.$eval($attrs[action]); - wizard[action.replace("wz", "").toLowerCase()](); - }); - }); - } - }; - }); -} - -wizardButtonDirective('wzNext'); -wizardButtonDirective('wzPrevious'); -wizardButtonDirective('wzFinish'); -wizardButtonDirective('wzCancel'); - -angular.module('mgo-angular-wizard').factory('WizardHandler', function() { - var service = {}; - - var wizards = {}; - - service.defaultName = "defaultWizard"; - - service.addWizard = function(name, wizard) { - wizards[name] = wizard; - }; - - service.removeWizard = function(name) { - delete wizards[name]; - }; - - service.wizard = function(name) { - var nameToUse = name; - if (!name) { - nameToUse = service.defaultName; - } - - return wizards[nameToUse]; - }; - - return service; -}); + +angular.module('mgo-angular-wizard').directive('wzStep', function() { + return { + restrict: 'EA', + replace: true, + transclude: true, + scope: { + wzTitle: '@', + title: '@', + canenter : '=', + canexit : '=' + }, + require: '^wizard', + templateUrl: function(element, attributes) { + return attributes.template || "step.html"; + }, + link: function($scope, $element, $attrs, wizard) { + $scope.title = $scope.title || $scope.wzTitle; + wizard.addStep($scope); + } + }; +}); + +//wizard directive +angular.module('mgo-angular-wizard').directive('wizard', function() { + return { + restrict: 'EA', + replace: true, + transclude: true, + scope: { + currentStep: '=', + onFinish: '&', + hideIndicators: '=', + editMode: '=', + name: '@' + }, + templateUrl: function(element, attributes) { + return attributes.template || "wizard.html"; + }, + + //controller for wizard directive, treat this just like an angular controller + controller: ['$scope', '$element', '$log', 'WizardHandler', function($scope, $element, $log, WizardHandler) { + //this variable allows directive to load without having to pass any step validation + var firstRun = true; + //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service + WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); + + $scope.$on('$destroy', function() { + WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); + }); + + //steps array where all the scopes of each step are added + $scope.steps = []; + + //access to context object for step validation + $scope.context = {}; + + //watching changes to currentStep + $scope.$watch('currentStep', function(step) { + //checking to make sure currentStep is truthy value + if (!step) return; + //setting stepTitle equal to current step title or default title + var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; + if ($scope.selectedStep && stepTitle !== $scope.currentStep) { + //invoking goTo() with step title as argument + $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); + } + + }); + + //watching steps array length and editMode value, if edit module is undefined or null the nothing is done + //if edit mode is truthy, then all steps are marked as completed + $scope.$watch('[editMode, steps.length]', function() { + var editMode = $scope.editMode; + if (_.isUndefined(editMode) || _.isNull(editMode)) return; + + if (editMode) { + _.each($scope.steps, function(step) { + step.completed = true; + }); + } + }, true); + + //called each time step directive is loaded + this.addStep = function(step) { + //pushing the scope of directive onto step array + $scope.steps.push(step); + //if this is first step being pushed then goTo that first step + if ($scope.steps.length === 1) { + //goTo first step + $scope.goTo($scope.steps[0]); + } + }; + + this.context = $scope.context; + + $scope.getStepNumber = function(step) { + return _.indexOf($scope.steps, step) + 1; + }; + + $scope.goTo = function(step) { + //if this is the first time the wizard is loading it bi-passes step validation + if(firstRun){ + //deselect all steps so you can set fresh below + unselectAll(); + $scope.selectedStep = step; + //making sure current step is not undefined + if (!_.isUndefined($scope.currentStep)) { + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + //setting variable to false so all other step changes must pass validation + firstRun = false; + } else { + //createing variables to capture current state that goTo() was invoked from and allow booleans + var thisStep; + var exitallowed = false; + var enterallowed = false; + //getting data for step you are transitioning out of + if($scope.currentStepNumber() > 0){ + thisStep = $scope.currentStepNumber() - 1; + } else if ($scope.currentStepNumber() === 0){ + thisStep = 0; + } + //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); + if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ + exitallowed = true; + } + if($scope.getStepNumber(step) < $scope.currentStepNumber()){ + exitallowed = true; + } + if(exitallowed && step.canenter === undefined || exitallowed && step.canenter($scope.context) === true){ + enterallowed = true; + } + + if(exitallowed && enterallowed){ + //deselect all steps so you can set fresh below + unselectAll(); + + //$log.log('value for canExit argument: ', $scope.currentStep.canexit); + $scope.selectedStep = step; + //making sure current step is not undefined + if (!_.isUndefined($scope.currentStep)) { + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + //$log.log('current step number: ', $scope.currentStepNumber()); + } else { + return; + } + } + }; + + $scope.currentStepNumber = function() { + //retreive current step number + return _.indexOf($scope.steps , $scope.selectedStep) + 1; + }; + + //unSelect All Steps + function unselectAll() { + //traverse steps array and set each "selected" property to false + _.each($scope.steps, function (step) { + step.selected = false; + }); + //set selectedStep variable to null + $scope.selectedStep = null; + } + + //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + + //Access to current step number from outside + this.currentStepNumber = function(){ + return $scope.currentStepNumber(); + }; + //method used for next button within step + this.next = function(callback) { + //setting variable equal to step you were on when next() was invoked + var index = _.indexOf($scope.steps , $scope.selectedStep); + //checking to see if callback is a function + if(angular.isFunction(callback)){ + if(callback()){ + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + } else { + return; + } + } + if (!callback) { + //completed property set on scope which is used to add class/remove class from progress bar + $scope.selectedStep.completed = true; + } + //checking to see if this is the last step. If it is next behaves the same as finish() + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + + }; + + //used to traverse to any step, step number placed as argument + this.goTo = function(step) { + var stepTo; + //checking that step is a Number + if (_.isNumber(step)) { + stepTo = $scope.steps[step]; + } else { + //finding the step associated with the title entered as goTo argument + stepTo = _.findWhere($scope.steps, {title: step}); + } + //going to step + $scope.goTo(stepTo); + }; + + //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. + this.finish = function() { + if ($scope.onFinish) { + $scope.onFinish(); + } + }; + + //cancel is alias for previous. + this.cancel = this.previous = function() { + //getting index of current step + var index = _.indexOf($scope.steps , $scope.selectedStep); + //ensuring you aren't trying to go back from the first step + if (index === 0) { + throw new Error("Can't go back. It's already in step 0"); + } else { + //go back one step from current step + $scope.goTo($scope.steps[index - 1]); + } + }; + }] + }; +}); + +function wizardButtonDirective(action) { + angular.module('mgo-angular-wizard') + .directive(action, function() { + return { + restrict: 'A', + replace: false, + require: '^wizard', + link: function($scope, $element, $attrs, wizard) { + + $element.on("click", function(e) { + e.preventDefault(); + $scope.$apply(function() { + $scope.$eval($attrs[action]); + wizard[action.replace("wz", "").toLowerCase()](); + }); + }); + } + }; + }); +} + +wizardButtonDirective('wzNext'); +wizardButtonDirective('wzPrevious'); +wizardButtonDirective('wzFinish'); +wizardButtonDirective('wzCancel'); + +angular.module('mgo-angular-wizard').factory('WizardHandler', function() { + var service = {}; + + var wizards = {}; + + service.defaultName = "defaultWizard"; + + service.addWizard = function(name, wizard) { + wizards[name] = wizard; + }; + + service.removeWizard = function(name) { + delete wizards[name]; + }; + + service.wizard = function(name) { + var nameToUse = name; + if (!name) { + nameToUse = service.defaultName; + } + + return wizards[nameToUse]; + }; + + return service; +}); diff --git a/dist/angular-wizard.less b/dist/angular-wizard.less old mode 100644 new mode 100755 index 9556344..6effb8e --- a/dist/angular-wizard.less +++ b/dist/angular-wizard.less @@ -96,7 +96,7 @@ &:before { position: absolute; top: -7px; - left: ~'calc(50% - 7px)'; + left: calc(~"50% - 7px"); width: 14px; height: 14px; border-radius: 100%; diff --git a/dist/angular-wizard.min.css b/dist/angular-wizard.min.css old mode 100644 new mode 100755 index 52636f3..37f7185 --- a/dist/angular-wizard.min.css +++ b/dist/angular-wizard.min.css @@ -1 +1 @@ -.steps-indicator{right:0;bottom:0;left:0;height:30px;padding:20px 0 0 0;margin:0;list-style:none}.steps-indicator:before{position:absolute;height:1px;background-color:#e6e6e6;content:''}.steps-indicator.steps-2:before{right:calc(25%);left:calc(25%)}.steps-indicator.steps-3:before{right:calc(16.666666666666668%);left:calc(16.666666666666668%)}.steps-indicator.steps-4:before{right:calc(12.5%);left:calc(12.5%)}.steps-indicator.steps-5:before{right:calc(10%);left:calc(10%)}.steps-indicator.steps-6:before{right:calc(8.333333333333334%);left:calc(8.333333333333334%)}.steps-indicator.steps-7:before{right:calc(7.142857142857143%);left:calc(7.142857142857143%)}.steps-indicator.steps-8:before{right:calc(6.25%);left:calc(6.25%)}.steps-indicator.steps-9:before{right:calc(5.555555555555555%);left:calc(5.555555555555555%)}.steps-indicator.steps-10:before{right:calc(5%);left:calc(5%)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;padding:0;padding-top:10px;margin:0;line-height:15px;text-align:center}.steps-indicator li a{font-weight:bold;color:#808080;text-decoration:none;text-transform:uppercase;cursor:pointer;transition:.25s}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(43%);width:14px;height:14px;background-color:#e6e6e6;border-radius:100%;content:'';transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(50%)}.steps-indicator.steps-3 li{width:calc(33.333333333333336%)}.steps-indicator.steps-4 li{width:calc(25%)}.steps-indicator.steps-5 li{width:calc(20%)}.steps-indicator.steps-6 li{width:calc(16.666666666666668%)}.steps-indicator.steps-7 li{width:calc(14.285714285714286%)}.steps-indicator.steps-8 li{width:calc(12.5%)}.steps-indicator.steps-9 li{width:calc(11.11111111111111%)}.steps-indicator.steps-10 li{width:calc(10%)}.steps-indicator.steps-11 li{width:calc(9.090909090909092%)}.steps-indicator li.default{pointer-events:none}.steps-indicator li.default a:hover{color:#808080}.steps-indicator li.current,.steps-indicator li.editing{pointer-events:none}.steps-indicator li.current a:before{background-color:#808080}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:#f00} \ No newline at end of file +.steps-indicator li a:before,.steps-indicator:before{background-color:#e6e6e6;content:''}.steps-indicator li.current,.steps-indicator li.default,.steps-indicator li.editing{pointer-events:none}.steps-indicator{right:0;bottom:0;left:0;margin:0;padding:20px 0 0 0;height:30px;list-style:none}.steps-indicator:before{position:absolute;height:1px}.steps-indicator.steps-2:before{left:calc(100% / 2 / 2);right:calc(100% / 2 / 2)}.steps-indicator.steps-3:before{left:calc(100% / 3 / 2);right:calc(100% / 3 / 2)}.steps-indicator.steps-4:before{left:calc(100% / 4 / 2);right:calc(100% / 4 / 2)}.steps-indicator.steps-5:before{left:calc(100% / 5 / 2);right:calc(100% / 5 / 2)}.steps-indicator.steps-6:before{left:calc(100% / 6 / 2);right:calc(100% / 6 / 2)}.steps-indicator.steps-7:before{left:calc(100% / 7 / 2);right:calc(100% / 7 / 2)}.steps-indicator.steps-8:before{left:calc(100% / 8 / 2);right:calc(100% / 8 / 2)}.steps-indicator.steps-9:before{left:calc(100% / 9 / 2);right:calc(100% / 9 / 2)}.steps-indicator.steps-10:before{left:calc(100% / 10 / 2);right:calc(100% / 10 / 2)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;margin:0;padding:0;padding-top:10px;text-align:center;line-height:15px}.steps-indicator li a{color:grey;text-decoration:none;text-transform:uppercase;font-weight:700;transition:.25s;cursor:pointer}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(50% - 7px);width:14px;height:14px;border-radius:100%;transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(100% / 2)}.steps-indicator.steps-3 li{width:calc(100% / 3)}.steps-indicator.steps-4 li{width:calc(100% / 4)}.steps-indicator.steps-5 li{width:calc(100% / 5)}.steps-indicator.steps-6 li{width:calc(100% / 6)}.steps-indicator.steps-7 li{width:calc(100% / 7)}.steps-indicator.steps-8 li{width:calc(100% / 8)}.steps-indicator.steps-9 li{width:calc(100% / 9)}.steps-indicator.steps-10 li{width:calc(100% / 10)}.steps-indicator.steps-11 li{width:calc(100% / 11)}.steps-indicator li.default a:hover{color:grey}.steps-indicator li.current a:before{background-color:grey}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:red} \ No newline at end of file diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js old mode 100644 new mode 100755 index 24557d7..0ac9040 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.2 - 2015-01-01 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.2 - 2015-04-03 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ From 0ed0df1fbbfee7070863c1c92aa28a3c8d4ce730 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 3 Apr 2015 16:05:37 -0700 Subject: [PATCH 069/185] removed recess added grunt-contrib-less and added grunt-contrib-cssmin --- Gruntfile.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 944b6dd..0682527 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -55,6 +55,26 @@ module.exports = function(grunt) { } } }, + less: { + build: { + options: { + paths: ["<%= dirs.dest %>"], + cleancss: true, + }, + files: {"<%= dirs.dest %>/<%= pkg.name %>.css": "src/angular-wizard.less"} + } + }, + cssmin: { + options: { + shorthandCompacting: false, + roundingPrecision: -1 + }, + target: { + files: { + '<%= dirs.dest %>/<%= pkg.name %>.min.css': ['<%= dirs.dest %>/<%= pkg.name %>.css'] + } + } + }, copy: { less_files: { files: [ @@ -129,7 +149,8 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-conventional-changelog'); - grunt.loadNpmTasks('grunt-recess'); + grunt.loadNpmTasks('grunt-contrib-less'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-ng-annotate'); @@ -144,7 +165,8 @@ module.exports = function(grunt) { 'clean', 'bowerInstall', 'copy', - 'recess', + 'less', + 'cssmin', 'html2js', 'concat', 'uglify', From bf05647e18ca8872f6384646a0dd420bbf7fd233 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 3 Apr 2015 16:07:27 -0700 Subject: [PATCH 070/185] removed recess dependency, added grunt contrib less and cssmin --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 82e259f..066133a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.4.2", + "version": "0.4.3", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", @@ -37,12 +37,13 @@ "grunt-contrib-clean": "~0.4.1", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.4.1", + "grunt-contrib-less": "~1.0.0", + "grunt-contrib-cssmin": "~0.12.2", "grunt-contrib-uglify": "~0.2.0", "grunt-conventional-changelog": "~0.1.1", "grunt-html2js": "~0.1.3", "grunt-karma": "~0.9.x", "grunt-ng-annotate": "^0.6.0", - "grunt-recess": "~0.3.0", "grunt-zip": "*", "jasmine-core": "^2.1.3", "karma-chrome-launcher": "^0.1.7", From e5f615ae1c3f43fad8b9075252d0be853439ce80 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 3 Apr 2015 16:07:44 -0700 Subject: [PATCH 071/185] Release version 0.4.3 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index fe681bc..e707bbc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.4.2", + "version": "0.4.3", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { From 3c2aa9ac8e6c7e3b359b3a83820e6b6c058bff9b Mon Sep 17 00:00:00 2001 From: Ryan Dale Date: Sat, 11 Apr 2015 23:28:27 -0400 Subject: [PATCH 072/185] Added support for promises and boolean values to the canenter and canexit attributes. --- dist/angular-wizard.js | 688 +++++++++++++++++++------------------ dist/angular-wizard.min.js | 4 +- src/wizard.js | 94 +++-- test/angularWizardSpec.js | 37 +- 4 files changed, 462 insertions(+), 361 deletions(-) mode change 100755 => 100644 dist/angular-wizard.js mode change 100755 => 100644 dist/angular-wizard.min.js diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js old mode 100755 new mode 100644 index 79f69d4..dff4bac --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,328 +1,362 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.4.2 - 2015-04-03 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
\n" + - "
"); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
\n" + - "
\n" + - " \n" + - "
\n" + - ""); -}]); - +/** + * Easy to use Wizard library for AngularJS + * @version v0.4.3 - 2015-04-11 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
\n" + + "
"); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
\n" + + "
\n" + + " \n" + + "
\n" + + ""); +}]); + angular.module('mgo-angular-wizard', ['templates-angularwizard']); - -angular.module('mgo-angular-wizard').directive('wzStep', function() { - return { - restrict: 'EA', - replace: true, - transclude: true, - scope: { - wzTitle: '@', - title: '@', - canenter : '=', - canexit : '=' - }, - require: '^wizard', - templateUrl: function(element, attributes) { - return attributes.template || "step.html"; - }, - link: function($scope, $element, $attrs, wizard) { - $scope.title = $scope.title || $scope.wzTitle; - wizard.addStep($scope); - } - }; -}); - -//wizard directive -angular.module('mgo-angular-wizard').directive('wizard', function() { - return { - restrict: 'EA', - replace: true, - transclude: true, - scope: { - currentStep: '=', - onFinish: '&', - hideIndicators: '=', - editMode: '=', - name: '@' - }, - templateUrl: function(element, attributes) { - return attributes.template || "wizard.html"; - }, - - //controller for wizard directive, treat this just like an angular controller - controller: ['$scope', '$element', '$log', 'WizardHandler', function($scope, $element, $log, WizardHandler) { - //this variable allows directive to load without having to pass any step validation - var firstRun = true; - //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service - WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); - - $scope.$on('$destroy', function() { - WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); - }); - - //steps array where all the scopes of each step are added - $scope.steps = []; - - //access to context object for step validation - $scope.context = {}; - - //watching changes to currentStep - $scope.$watch('currentStep', function(step) { - //checking to make sure currentStep is truthy value - if (!step) return; - //setting stepTitle equal to current step title or default title - var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; - if ($scope.selectedStep && stepTitle !== $scope.currentStep) { - //invoking goTo() with step title as argument - $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); - } - - }); - - //watching steps array length and editMode value, if edit module is undefined or null the nothing is done - //if edit mode is truthy, then all steps are marked as completed - $scope.$watch('[editMode, steps.length]', function() { - var editMode = $scope.editMode; - if (_.isUndefined(editMode) || _.isNull(editMode)) return; - - if (editMode) { - _.each($scope.steps, function(step) { - step.completed = true; - }); - } - }, true); - - //called each time step directive is loaded - this.addStep = function(step) { - //pushing the scope of directive onto step array - $scope.steps.push(step); - //if this is first step being pushed then goTo that first step - if ($scope.steps.length === 1) { - //goTo first step - $scope.goTo($scope.steps[0]); - } - }; - - this.context = $scope.context; - - $scope.getStepNumber = function(step) { - return _.indexOf($scope.steps, step) + 1; - }; - - $scope.goTo = function(step) { - //if this is the first time the wizard is loading it bi-passes step validation - if(firstRun){ - //deselect all steps so you can set fresh below - unselectAll(); - $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; - } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); - //setting variable to false so all other step changes must pass validation - firstRun = false; - } else { - //createing variables to capture current state that goTo() was invoked from and allow booleans - var thisStep; - var exitallowed = false; - var enterallowed = false; - //getting data for step you are transitioning out of - if($scope.currentStepNumber() > 0){ - thisStep = $scope.currentStepNumber() - 1; - } else if ($scope.currentStepNumber() === 0){ - thisStep = 0; - } - //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); - if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ - exitallowed = true; - } - if($scope.getStepNumber(step) < $scope.currentStepNumber()){ - exitallowed = true; - } - if(exitallowed && step.canenter === undefined || exitallowed && step.canenter($scope.context) === true){ - enterallowed = true; - } - - if(exitallowed && enterallowed){ - //deselect all steps so you can set fresh below - unselectAll(); - - //$log.log('value for canExit argument: ', $scope.currentStep.canexit); - $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; - } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); - //$log.log('current step number: ', $scope.currentStepNumber()); - } else { - return; - } - } - }; - - $scope.currentStepNumber = function() { - //retreive current step number - return _.indexOf($scope.steps , $scope.selectedStep) + 1; - }; - - //unSelect All Steps - function unselectAll() { - //traverse steps array and set each "selected" property to false - _.each($scope.steps, function (step) { - step.selected = false; - }); - //set selectedStep variable to null - $scope.selectedStep = null; - } - - //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() - - //Access to current step number from outside - this.currentStepNumber = function(){ - return $scope.currentStepNumber(); - }; - //method used for next button within step - this.next = function(callback) { - //setting variable equal to step you were on when next() was invoked - var index = _.indexOf($scope.steps , $scope.selectedStep); - //checking to see if callback is a function - if(angular.isFunction(callback)){ - if(callback()){ - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } - } else { - return; - } - } - if (!callback) { - //completed property set on scope which is used to add class/remove class from progress bar - $scope.selectedStep.completed = true; - } - //checking to see if this is the last step. If it is next behaves the same as finish() - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } - - }; - - //used to traverse to any step, step number placed as argument - this.goTo = function(step) { - var stepTo; - //checking that step is a Number - if (_.isNumber(step)) { - stepTo = $scope.steps[step]; - } else { - //finding the step associated with the title entered as goTo argument - stepTo = _.findWhere($scope.steps, {title: step}); - } - //going to step - $scope.goTo(stepTo); - }; - - //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. - this.finish = function() { - if ($scope.onFinish) { - $scope.onFinish(); - } - }; - - //cancel is alias for previous. - this.cancel = this.previous = function() { - //getting index of current step - var index = _.indexOf($scope.steps , $scope.selectedStep); - //ensuring you aren't trying to go back from the first step - if (index === 0) { - throw new Error("Can't go back. It's already in step 0"); - } else { - //go back one step from current step - $scope.goTo($scope.steps[index - 1]); - } - }; - }] - }; -}); - -function wizardButtonDirective(action) { - angular.module('mgo-angular-wizard') - .directive(action, function() { - return { - restrict: 'A', - replace: false, - require: '^wizard', - link: function($scope, $element, $attrs, wizard) { - - $element.on("click", function(e) { - e.preventDefault(); - $scope.$apply(function() { - $scope.$eval($attrs[action]); - wizard[action.replace("wz", "").toLowerCase()](); - }); - }); - } - }; - }); -} - -wizardButtonDirective('wzNext'); -wizardButtonDirective('wzPrevious'); -wizardButtonDirective('wzFinish'); -wizardButtonDirective('wzCancel'); - -angular.module('mgo-angular-wizard').factory('WizardHandler', function() { - var service = {}; - - var wizards = {}; - - service.defaultName = "defaultWizard"; - - service.addWizard = function(name, wizard) { - wizards[name] = wizard; - }; - - service.removeWizard = function(name) { - delete wizards[name]; - }; - - service.wizard = function(name) { - var nameToUse = name; - if (!name) { - nameToUse = service.defaultName; - } - - return wizards[nameToUse]; - }; - - return service; -}); + +angular.module('mgo-angular-wizard').directive('wzStep', function() { + return { + restrict: 'EA', + replace: true, + transclude: true, + scope: { + wzTitle: '@', + title: '@', + canenter : '=', + canexit : '=' + }, + require: '^wizard', + templateUrl: function(element, attributes) { + return attributes.template || "step.html"; + }, + link: function($scope, $element, $attrs, wizard) { + $scope.title = $scope.title || $scope.wzTitle; + wizard.addStep($scope); + } + }; +}); + +//wizard directive +angular.module('mgo-angular-wizard').directive('wizard', function() { + return { + restrict: 'EA', + replace: true, + transclude: true, + scope: { + currentStep: '=', + onFinish: '&', + hideIndicators: '=', + editMode: '=', + name: '@' + }, + templateUrl: function(element, attributes) { + return attributes.template || "wizard.html"; + }, + + //controller for wizard directive, treat this just like an angular controller + controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function($scope, $element, $log, WizardHandler, $q) { + //this variable allows directive to load without having to pass any step validation + var firstRun = true; + //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service + WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); + + $scope.$on('$destroy', function() { + WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); + }); + + //steps array where all the scopes of each step are added + $scope.steps = []; + + //access to context object for step validation + $scope.context = {}; + + //watching changes to currentStep + $scope.$watch('currentStep', function(step) { + //checking to make sure currentStep is truthy value + if (!step) return; + //setting stepTitle equal to current step title or default title + var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; + if ($scope.selectedStep && stepTitle !== $scope.currentStep) { + //invoking goTo() with step title as argument + $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); + } + + }); + + //watching steps array length and editMode value, if edit module is undefined or null the nothing is done + //if edit mode is truthy, then all steps are marked as completed + $scope.$watch('[editMode, steps.length]', function() { + var editMode = $scope.editMode; + if (_.isUndefined(editMode) || _.isNull(editMode)) return; + + if (editMode) { + _.each($scope.steps, function(step) { + step.completed = true; + }); + } + }, true); + + //called each time step directive is loaded + this.addStep = function(step) { + //pushing the scope of directive onto step array + $scope.steps.push(step); + //if this is first step being pushed then goTo that first step + if ($scope.steps.length === 1) { + //goTo first step + $scope.goTo($scope.steps[0]); + } + }; + + this.context = $scope.context; + + $scope.getStepNumber = function(step) { + return _.indexOf($scope.steps, step) + 1; + }; + + $scope.goTo = function(step) { + //if this is the first time the wizard is loading it bi-passes step validation + if(firstRun){ + //deselect all steps so you can set fresh below + unselectAll(); + $scope.selectedStep = step; + //making sure current step is not undefined + if (!_.isUndefined($scope.currentStep)) { + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + //setting variable to false so all other step changes must pass validation + firstRun = false; + } else { + //createing variables to capture current state that goTo() was invoked from and allow booleans + var thisStep; + //getting data for step you are transitioning out of + if($scope.currentStepNumber() > 0){ + thisStep = $scope.currentStepNumber() - 1; + } else if ($scope.currentStepNumber() === 0){ + thisStep = 0; + } + //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); + $q.all([canEnterStep(step), canExitStep($scope.steps[thisStep], step)]).then(function(data) { + if(data[0] && data[1]){ + //deselect all steps so you can set fresh below + unselectAll(); + + //$log.log('value for canExit argument: ', $scope.currentStep.canexit); + $scope.selectedStep = step; + //making sure current step is not undefined + if(!_.isUndefined($scope.currentStep)){ + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps, step)}); + //$log.log('current step number: ', $scope.currentStepNumber()); + } + }); + } + }; + + function canEnterStep(step) { + var defer, + canEnter; + //If no validation function is provided, allow the user to enter the step + if(step.canenter === undefined){ + return true; + } + //If canenter is a boolean value instead of a function, return the value + if(typeof step.canenter === 'boolean'){ + return step.canenter; + } + //Check to see if the canenter function is a promise which needs to be returned + canEnter = step.canenter(); + if(angular.isFunction(canEnter.then)){ + defer = $q.defer(); + canEnter.then(function(response){ + defer.resolve(response); + }); + return defer.promise; + } + return step.canenter($scope.context) === true; + } + + function canExitStep(step, stepTo) { + var defer, + canExit; + //Exiting the step should be allowed if no validation function was provided or if the user is moving backwards + if(typeof(step.canexit) === 'undefined' || $scope.getStepNumber(stepTo) < $scope.currentStepNumber()){ + return true; + } + //If canexit is a boolean value instead of a function, return the value + if(typeof step.canexit === 'boolean'){ + return step.canexit; + } + //Check to see if the canexit function is a promise which needs to be returned + canExit = step.canexit(); + if(angular.isFunction(canExit.then)){ + defer = $q.defer(); + canExit.then(function(response){ + defer.resolve(response); + }); + return defer.promise; + } + return step.canexit($scope.context) === true; + } + + $scope.currentStepNumber = function() { + //retreive current step number + return _.indexOf($scope.steps , $scope.selectedStep) + 1; + }; + + //unSelect All Steps + function unselectAll() { + //traverse steps array and set each "selected" property to false + _.each($scope.steps, function (step) { + step.selected = false; + }); + //set selectedStep variable to null + $scope.selectedStep = null; + } + + //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + + //Access to current step number from outside + this.currentStepNumber = function(){ + return $scope.currentStepNumber(); + }; + //method used for next button within step + this.next = function(callback) { + //setting variable equal to step you were on when next() was invoked + var index = _.indexOf($scope.steps , $scope.selectedStep); + //checking to see if callback is a function + if(angular.isFunction(callback)){ + if(callback()){ + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + } else { + return; + } + } + if (!callback) { + //completed property set on scope which is used to add class/remove class from progress bar + $scope.selectedStep.completed = true; + } + //checking to see if this is the last step. If it is next behaves the same as finish() + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + + }; + + //used to traverse to any step, step number placed as argument + this.goTo = function(step) { + var stepTo; + //checking that step is a Number + if (_.isNumber(step)) { + stepTo = $scope.steps[step]; + } else { + //finding the step associated with the title entered as goTo argument + stepTo = _.findWhere($scope.steps, {title: step}); + } + //going to step + $scope.goTo(stepTo); + }; + + //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. + this.finish = function() { + if ($scope.onFinish) { + $scope.onFinish(); + } + }; + + //cancel is alias for previous. + this.cancel = this.previous = function() { + //getting index of current step + var index = _.indexOf($scope.steps , $scope.selectedStep); + //ensuring you aren't trying to go back from the first step + if (index === 0) { + throw new Error("Can't go back. It's already in step 0"); + } else { + //go back one step from current step + $scope.goTo($scope.steps[index - 1]); + } + }; + }] + }; +}); + +function wizardButtonDirective(action) { + angular.module('mgo-angular-wizard') + .directive(action, function() { + return { + restrict: 'A', + replace: false, + require: '^wizard', + link: function($scope, $element, $attrs, wizard) { + + $element.on("click", function(e) { + e.preventDefault(); + $scope.$apply(function() { + $scope.$eval($attrs[action]); + wizard[action.replace("wz", "").toLowerCase()](); + }); + }); + } + }; + }); +} + +wizardButtonDirective('wzNext'); +wizardButtonDirective('wzPrevious'); +wizardButtonDirective('wzFinish'); +wizardButtonDirective('wzCancel'); + +angular.module('mgo-angular-wizard').factory('WizardHandler', function() { + var service = {}; + + var wizards = {}; + + service.defaultName = "defaultWizard"; + + service.addWizard = function(name, wizard) { + wizards[name] = wizard; + }; + + service.removeWizard = function(name) { + delete wizards[name]; + }; + + service.wizard = function(name) { + var nameToUse = name; + if (!name) { + nameToUse = service.defaultName; + } + + return wizards[nameToUse]; + }; + + return service; +}); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js old mode 100755 new mode 100644 index 0ac9040..bfbd9e6 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.2 - 2015-04-03 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.3 - 2015-04-11 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler",function(a,b,c,d){function e(){_.each(a.steps,function(a){a.selected=!1}),a.selectedStep=null}var f=!0;d.addWizard(a.name||d.defaultName,this),a.$on("$destroy",function(){d.removeWizard(a.name||d.defaultName)}),a.steps=[],a.context={},a.$watch("currentStep",function(b){if(b){var c=a.selectedStep.title||a.selectedStep.wzTitle;a.selectedStep&&c!==a.currentStep&&a.goTo(_.findWhere(a.steps,{title:a.currentStep}))}}),a.$watch("[editMode, steps.length]",function(){var b=a.editMode;_.isUndefined(b)||_.isNull(b)||b&&_.each(a.steps,function(a){a.completed=!0})},!0),this.addStep=function(b){a.steps.push(b),1===a.steps.length&&a.goTo(a.steps[0])},this.context=a.context,a.getStepNumber=function(b){return _.indexOf(a.steps,b)+1},a.goTo=function(b){if(f)e(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}),f=!1;else{var c,d=!1,g=!1;if(a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),("undefined"==typeof a.steps[c].canexit||a.steps[c].canexit(a.context)===!0)&&(d=!0),a.getStepNumber(b)\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([f(b),g(a.steps[c],b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/wizard.js b/src/wizard.js index 3109cba..272cf29 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -16,7 +16,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }, //controller for wizard directive, treat this just like an angular controller - controller: ['$scope', '$element', '$log', 'WizardHandler', function($scope, $element, $log, WizardHandler) { + controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function($scope, $element, $log, WizardHandler, $q) { //this variable allows directive to load without having to pass any step validation var firstRun = true; //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service @@ -94,8 +94,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } else { //createing variables to capture current state that goTo() was invoked from and allow booleans var thisStep; - var exitallowed = false; - var enterallowed = false; //getting data for step you are transitioning out of if($scope.currentStepNumber() > 0){ thisStep = $scope.currentStepNumber() - 1; @@ -103,37 +101,73 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { thisStep = 0; } //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); - if(typeof($scope.steps[thisStep].canexit) === 'undefined' || $scope.steps[thisStep].canexit($scope.context) === true){ - exitallowed = true; - } - if($scope.getStepNumber(step) < $scope.currentStepNumber()){ - exitallowed = true; - } - if(exitallowed && step.canenter === undefined || exitallowed && step.canenter($scope.context) === true){ - enterallowed = true; - } + $q.all([canEnterStep(step), canExitStep($scope.steps[thisStep], step)]).then(function(data) { + if(data[0] && data[1]){ + //deselect all steps so you can set fresh below + unselectAll(); - if(exitallowed && enterallowed){ - //deselect all steps so you can set fresh below - unselectAll(); - - //$log.log('value for canExit argument: ', $scope.currentStep.canexit); - $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; + //$log.log('value for canExit argument: ', $scope.currentStep.canexit); + $scope.selectedStep = step; + //making sure current step is not undefined + if(!_.isUndefined($scope.currentStep)){ + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps, step)}); + //$log.log('current step number: ', $scope.currentStepNumber()); } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); - //$log.log('current step number: ', $scope.currentStepNumber()); - } else { - return; - } + }); } }; + function canEnterStep(step) { + var defer, + canEnter; + //If no validation function is provided, allow the user to enter the step + if(step.canenter === undefined){ + return true; + } + //If canenter is a boolean value instead of a function, return the value + if(typeof step.canenter === 'boolean'){ + return step.canenter; + } + //Check to see if the canenter function is a promise which needs to be returned + canEnter = step.canenter(); + if(angular.isFunction(canEnter.then)){ + defer = $q.defer(); + canEnter.then(function(response){ + defer.resolve(response); + }); + return defer.promise; + } + return step.canenter($scope.context) === true; + } + + function canExitStep(step, stepTo) { + var defer, + canExit; + //Exiting the step should be allowed if no validation function was provided or if the user is moving backwards + if(typeof(step.canexit) === 'undefined' || $scope.getStepNumber(stepTo) < $scope.currentStepNumber()){ + return true; + } + //If canexit is a boolean value instead of a function, return the value + if(typeof step.canexit === 'boolean'){ + return step.canexit; + } + //Check to see if the canexit function is a promise which needs to be returned + canExit = step.canexit(); + if(angular.isFunction(canExit.then)){ + defer = $q.defer(); + canExit.then(function(response){ + defer.resolve(response); + }); + return defer.promise; + } + return step.canexit($scope.context) === true; + } + $scope.currentStepNumber = function() { //retreive current step number return _.indexOf($scope.steps , $scope.selectedStep) + 1; @@ -183,7 +217,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //invoking goTo() with step number next in line $scope.goTo($scope.steps[index + 1]); } - + }; //used to traverse to any step, step number placed as argument diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index 91f4e96..8003623 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -1,12 +1,14 @@ describe( 'AngularWizard', function() { - var $compile, $rootScope, WizardHandler; + var $compile, $q, $rootScope, $timeout, WizardHandler; beforeEach(module('mgo-angular-wizard')); - beforeEach(inject(function(_$compile_, _$rootScope_, _WizardHandler_) { + beforeEach(inject(function(_$compile_, _$q_, _$rootScope_, _$timeout_, _WizardHandler_) { $compile = _$compile_; + $q = _$q_; $rootScope = _$rootScope_; + $timeout = _$timeout_; WizardHandler = _WizardHandler_; })); @@ -197,6 +199,37 @@ describe( 'AngularWizard', function() { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Starting'); }); + it( "should go to the next step because the promise that CANENTER returns resolves to true", function(done) { + var scope = $rootScope.$new(); + var view = createView(scope); + scope.enterValidation = function(){ + var deferred = $q.defer(); + $timeout(function () { + deferred.resolve(true); + done(); + }); + return deferred.promise; + }; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $timeout.flush(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); + it( "should go to the next step because CANEXIT is set to true", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + scope.exitValidation = true; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); it( "should finish", function() { var scope = $rootScope.$new(); var flag = false; From e66ecfff141d2263f5f7d68089388ab4b158c439 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Wed, 27 May 2015 19:51:45 -0700 Subject: [PATCH 073/185] Project Build --- dist/angular-wizard.css | 0 dist/angular-wizard.js | 8 ++++---- dist/angular-wizard.less | 2 +- dist/angular-wizard.min.css | 2 +- dist/angular-wizard.min.js | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) mode change 100755 => 100644 dist/angular-wizard.css mode change 100755 => 100644 dist/angular-wizard.less mode change 100755 => 100644 dist/angular-wizard.min.css diff --git a/dist/angular-wizard.css b/dist/angular-wizard.css old mode 100755 new mode 100644 diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index dff4bac..917cc97 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.3 - 2015-04-11 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.3 - 2015-05-27 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -152,7 +152,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { thisStep = 0; } //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); - $q.all([canEnterStep(step), canExitStep($scope.steps[thisStep], step)]).then(function(data) { + $q.all([canExitStep($scope.steps[thisStep], step), canEnterStep(step)]).then(function(data) { if(data[0] && data[1]){ //deselect all steps so you can set fresh below unselectAll(); @@ -185,7 +185,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return step.canenter; } //Check to see if the canenter function is a promise which needs to be returned - canEnter = step.canenter(); + canEnter = step.canenter($scope.context); if(angular.isFunction(canEnter.then)){ defer = $q.defer(); canEnter.then(function(response){ @@ -208,7 +208,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return step.canexit; } //Check to see if the canexit function is a promise which needs to be returned - canExit = step.canexit(); + canExit = step.canexit($scope.context); if(angular.isFunction(canExit.then)){ defer = $q.defer(); canExit.then(function(response){ diff --git a/dist/angular-wizard.less b/dist/angular-wizard.less old mode 100755 new mode 100644 index 6effb8e..9556344 --- a/dist/angular-wizard.less +++ b/dist/angular-wizard.less @@ -96,7 +96,7 @@ &:before { position: absolute; top: -7px; - left: calc(~"50% - 7px"); + left: ~'calc(50% - 7px)'; width: 14px; height: 14px; border-radius: 100%; diff --git a/dist/angular-wizard.min.css b/dist/angular-wizard.min.css old mode 100755 new mode 100644 index 37f7185..32cbfb4 --- a/dist/angular-wizard.min.css +++ b/dist/angular-wizard.min.css @@ -1 +1 @@ -.steps-indicator li a:before,.steps-indicator:before{background-color:#e6e6e6;content:''}.steps-indicator li.current,.steps-indicator li.default,.steps-indicator li.editing{pointer-events:none}.steps-indicator{right:0;bottom:0;left:0;margin:0;padding:20px 0 0 0;height:30px;list-style:none}.steps-indicator:before{position:absolute;height:1px}.steps-indicator.steps-2:before{left:calc(100% / 2 / 2);right:calc(100% / 2 / 2)}.steps-indicator.steps-3:before{left:calc(100% / 3 / 2);right:calc(100% / 3 / 2)}.steps-indicator.steps-4:before{left:calc(100% / 4 / 2);right:calc(100% / 4 / 2)}.steps-indicator.steps-5:before{left:calc(100% / 5 / 2);right:calc(100% / 5 / 2)}.steps-indicator.steps-6:before{left:calc(100% / 6 / 2);right:calc(100% / 6 / 2)}.steps-indicator.steps-7:before{left:calc(100% / 7 / 2);right:calc(100% / 7 / 2)}.steps-indicator.steps-8:before{left:calc(100% / 8 / 2);right:calc(100% / 8 / 2)}.steps-indicator.steps-9:before{left:calc(100% / 9 / 2);right:calc(100% / 9 / 2)}.steps-indicator.steps-10:before{left:calc(100% / 10 / 2);right:calc(100% / 10 / 2)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;margin:0;padding:0;padding-top:10px;text-align:center;line-height:15px}.steps-indicator li a{color:grey;text-decoration:none;text-transform:uppercase;font-weight:700;transition:.25s;cursor:pointer}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(50% - 7px);width:14px;height:14px;border-radius:100%;transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(100% / 2)}.steps-indicator.steps-3 li{width:calc(100% / 3)}.steps-indicator.steps-4 li{width:calc(100% / 4)}.steps-indicator.steps-5 li{width:calc(100% / 5)}.steps-indicator.steps-6 li{width:calc(100% / 6)}.steps-indicator.steps-7 li{width:calc(100% / 7)}.steps-indicator.steps-8 li{width:calc(100% / 8)}.steps-indicator.steps-9 li{width:calc(100% / 9)}.steps-indicator.steps-10 li{width:calc(100% / 10)}.steps-indicator.steps-11 li{width:calc(100% / 11)}.steps-indicator li.default a:hover{color:grey}.steps-indicator li.current a:before{background-color:grey}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:red} \ No newline at end of file +.steps-indicator li a:before,.steps-indicator:before{background-color:#e6e6e6;content:''}.steps-indicator li.current,.steps-indicator li.default,.steps-indicator li.editing{pointer-events:none}.steps-indicator{right:0;bottom:0;left:0;margin:0;padding:20px 0 0;height:30px;list-style:none}.steps-indicator:before{position:absolute;height:1px}.steps-indicator.steps-2:before{left:calc(100% / 2 / 2);right:calc(100% / 2 / 2)}.steps-indicator.steps-3:before{left:calc(100% / 3 / 2);right:calc(100% / 3 / 2)}.steps-indicator.steps-4:before{left:calc(100% / 4 / 2);right:calc(100% / 4 / 2)}.steps-indicator.steps-5:before{left:calc(100% / 5 / 2);right:calc(100% / 5 / 2)}.steps-indicator.steps-6:before{left:calc(100% / 6 / 2);right:calc(100% / 6 / 2)}.steps-indicator.steps-7:before{left:calc(100% / 7 / 2);right:calc(100% / 7 / 2)}.steps-indicator.steps-8:before{left:calc(100% / 8 / 2);right:calc(100% / 8 / 2)}.steps-indicator.steps-9:before{left:calc(100% / 9 / 2);right:calc(100% / 9 / 2)}.steps-indicator.steps-10:before{left:calc(100% / 10 / 2);right:calc(100% / 10 / 2)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;margin:0;padding:0;padding-top:10px;text-align:center;line-height:15px}.steps-indicator li a{color:grey;text-decoration:none;text-transform:uppercase;font-weight:700;transition:.25s;cursor:pointer}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(50% - 7px);width:14px;height:14px;border-radius:100%;transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(100% / 2)}.steps-indicator.steps-3 li{width:calc(100% / 3)}.steps-indicator.steps-4 li{width:calc(100% / 4)}.steps-indicator.steps-5 li{width:calc(100% / 5)}.steps-indicator.steps-6 li{width:calc(100% / 6)}.steps-indicator.steps-7 li{width:calc(100% / 7)}.steps-indicator.steps-8 li{width:calc(100% / 8)}.steps-indicator.steps-9 li{width:calc(100% / 9)}.steps-indicator.steps-10 li{width:calc(100% / 10)}.steps-indicator.steps-11 li{width:calc(100% / 11)}.steps-indicator li.default a:hover{color:grey}.steps-indicator li.current a:before{background-color:grey}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:red} \ No newline at end of file diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index bfbd9e6..f8cde66 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.3 - 2015-04-11 * @link https://github.com/mgonto/angular-wizard + * @version v0.4.3 - 2015-05-27 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([f(b),g(a.steps[c],b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.steps[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 991c98dfd11a42f530b23b31b663f52beb4dc9b7 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Wed, 27 May 2015 19:52:45 -0700 Subject: [PATCH 074/185] users can now use async calls using promises with canexit and canenter validation --- src/wizard.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index 272cf29..e23437a 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -101,7 +101,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { thisStep = 0; } //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); - $q.all([canEnterStep(step), canExitStep($scope.steps[thisStep], step)]).then(function(data) { + $q.all([canExitStep($scope.steps[thisStep], step), canEnterStep(step)]).then(function(data) { if(data[0] && data[1]){ //deselect all steps so you can set fresh below unselectAll(); @@ -134,7 +134,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return step.canenter; } //Check to see if the canenter function is a promise which needs to be returned - canEnter = step.canenter(); + canEnter = step.canenter($scope.context); if(angular.isFunction(canEnter.then)){ defer = $q.defer(); canEnter.then(function(response){ @@ -157,7 +157,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return step.canexit; } //Check to see if the canexit function is a promise which needs to be returned - canExit = step.canexit(); + canExit = step.canexit($scope.context); if(angular.isFunction(canExit.then)){ defer = $q.defer(); canExit.then(function(response){ From 1cc9732a28a2b3a39f9812be1d470c3973bd86d8 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Wed, 27 May 2015 19:53:53 -0700 Subject: [PATCH 075/185] Release version 0.5.0 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index e707bbc..270b42b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.4.3", + "version": "0.5.0", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { diff --git a/package.json b/package.json index 066133a..77a64c7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.4.3", + "version": "0.5.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 52f6c0365cb97d7a7fd69be073c6094e65174ae0 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 27 May 2015 20:02:42 -0700 Subject: [PATCH 076/185] Promises supported in validation Can use promises in canexit and canenter functions --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c44db9..37e88d9 100644 --- a/README.md +++ b/README.md @@ -96,8 +96,8 @@ In this case, the `setMode` function will be called before going to the next ste ## Wizard Step Validation The wzStep directive has the following options as attributes: -* **canexit**: Here you can reference a function from your controller. If this attribute is listed the funtion must return true in order for the wizard to move to the next step. If it is ommitted no validation will be required. -* **canenter**: Here you can reference a function from your controller. If this attribute is listed the funtion must return true in order for the wizard to move into this step. If it is ommitted no validation will be required. +* **canexit**: Here you can reference a function from your controller. If this attribute is listed the funtion must return true in order for the wizard to move to the next step. Promises are supported but must resolve with a thruthy value. If it is ommitted no validation will be required. +* **canenter**: Here you can reference a function from your controller. If this attribute is listed the funtion must return true in order for the wizard to move into this step. Promises are supported but must resolve with a thruthy value. If it is ommitted no validation will be required. **Example** @@ -129,6 +129,18 @@ $scope.enterValidation = function(){ $scope.exitValidation = function(){ return true; }; +//example using context object +$scope.exitValidation = function(context){ + return context.firstName === "Jacob"; +} +//example using promises +$scope.exitValidation = function(){ + var d = $q.defer() + $timeout(function(){ + return d.resolve(true); + }, 2000); + return d.promise; +} ```` If a step requires information from a previous step to populate itself you can access this information through the `context` object. The context object is automatically passed in as an argument into your canexit and canenter methods. You can access the context objext from your controller via: `WizardHandler.wizard().context` From 8f7afbf9c7a02e13098d464910f7585379faa381 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 2 Jun 2015 18:46:30 -0700 Subject: [PATCH 077/185] Updated JsDelivr CDN links --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 37e88d9..d893357 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ You can download this by: ````html - - + + - - + + ```` The dist folder contains the following files: From d25b30efea550081e07f37a418b66cdc4fad83d6 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 4 Jun 2015 09:01:54 -0700 Subject: [PATCH 078/185] Project Build --- dist/angular-wizard.css | 0 dist/angular-wizard.js | 722 ++++++++++++++++++------------------ dist/angular-wizard.less | 0 dist/angular-wizard.min.css | 2 +- dist/angular-wizard.min.js | 2 +- 5 files changed, 363 insertions(+), 363 deletions(-) mode change 100644 => 100755 dist/angular-wizard.css mode change 100644 => 100755 dist/angular-wizard.js mode change 100644 => 100755 dist/angular-wizard.less mode change 100644 => 100755 dist/angular-wizard.min.css mode change 100644 => 100755 dist/angular-wizard.min.js diff --git a/dist/angular-wizard.css b/dist/angular-wizard.css old mode 100644 new mode 100755 diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js old mode 100644 new mode 100755 index 917cc97..0378c30 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,362 +1,362 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.4.3 - 2015-05-27 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
\n" + - "
"); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
\n" + - "
\n" + - " \n" + - "
\n" + - ""); -}]); - +/** + * Easy to use Wizard library for AngularJS + * @version v0.5.0 - 2015-06-04 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
\n" + + "
"); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
\n" + + "
\n" + + " \n" + + "
\n" + + ""); +}]); + angular.module('mgo-angular-wizard', ['templates-angularwizard']); - -angular.module('mgo-angular-wizard').directive('wzStep', function() { - return { - restrict: 'EA', - replace: true, - transclude: true, - scope: { - wzTitle: '@', - title: '@', - canenter : '=', - canexit : '=' - }, - require: '^wizard', - templateUrl: function(element, attributes) { - return attributes.template || "step.html"; - }, - link: function($scope, $element, $attrs, wizard) { - $scope.title = $scope.title || $scope.wzTitle; - wizard.addStep($scope); - } - }; -}); - -//wizard directive -angular.module('mgo-angular-wizard').directive('wizard', function() { - return { - restrict: 'EA', - replace: true, - transclude: true, - scope: { - currentStep: '=', - onFinish: '&', - hideIndicators: '=', - editMode: '=', - name: '@' - }, - templateUrl: function(element, attributes) { - return attributes.template || "wizard.html"; - }, - - //controller for wizard directive, treat this just like an angular controller - controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function($scope, $element, $log, WizardHandler, $q) { - //this variable allows directive to load without having to pass any step validation - var firstRun = true; - //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service - WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); - - $scope.$on('$destroy', function() { - WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); - }); - - //steps array where all the scopes of each step are added - $scope.steps = []; - - //access to context object for step validation - $scope.context = {}; - - //watching changes to currentStep - $scope.$watch('currentStep', function(step) { - //checking to make sure currentStep is truthy value - if (!step) return; - //setting stepTitle equal to current step title or default title - var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; - if ($scope.selectedStep && stepTitle !== $scope.currentStep) { - //invoking goTo() with step title as argument - $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); - } - - }); - - //watching steps array length and editMode value, if edit module is undefined or null the nothing is done - //if edit mode is truthy, then all steps are marked as completed - $scope.$watch('[editMode, steps.length]', function() { - var editMode = $scope.editMode; - if (_.isUndefined(editMode) || _.isNull(editMode)) return; - - if (editMode) { - _.each($scope.steps, function(step) { - step.completed = true; - }); - } - }, true); - - //called each time step directive is loaded - this.addStep = function(step) { - //pushing the scope of directive onto step array - $scope.steps.push(step); - //if this is first step being pushed then goTo that first step - if ($scope.steps.length === 1) { - //goTo first step - $scope.goTo($scope.steps[0]); - } - }; - - this.context = $scope.context; - - $scope.getStepNumber = function(step) { - return _.indexOf($scope.steps, step) + 1; - }; - - $scope.goTo = function(step) { - //if this is the first time the wizard is loading it bi-passes step validation - if(firstRun){ - //deselect all steps so you can set fresh below - unselectAll(); - $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; - } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); - //setting variable to false so all other step changes must pass validation - firstRun = false; - } else { - //createing variables to capture current state that goTo() was invoked from and allow booleans - var thisStep; - //getting data for step you are transitioning out of - if($scope.currentStepNumber() > 0){ - thisStep = $scope.currentStepNumber() - 1; - } else if ($scope.currentStepNumber() === 0){ - thisStep = 0; - } - //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); - $q.all([canExitStep($scope.steps[thisStep], step), canEnterStep(step)]).then(function(data) { - if(data[0] && data[1]){ - //deselect all steps so you can set fresh below - unselectAll(); - - //$log.log('value for canExit argument: ', $scope.currentStep.canexit); - $scope.selectedStep = step; - //making sure current step is not undefined - if(!_.isUndefined($scope.currentStep)){ - $scope.currentStep = step.title || step.wzTitle; - } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps, step)}); - //$log.log('current step number: ', $scope.currentStepNumber()); - } - }); - } - }; - - function canEnterStep(step) { - var defer, - canEnter; - //If no validation function is provided, allow the user to enter the step - if(step.canenter === undefined){ - return true; - } - //If canenter is a boolean value instead of a function, return the value - if(typeof step.canenter === 'boolean'){ - return step.canenter; - } - //Check to see if the canenter function is a promise which needs to be returned - canEnter = step.canenter($scope.context); - if(angular.isFunction(canEnter.then)){ - defer = $q.defer(); - canEnter.then(function(response){ - defer.resolve(response); - }); - return defer.promise; - } - return step.canenter($scope.context) === true; - } - - function canExitStep(step, stepTo) { - var defer, - canExit; - //Exiting the step should be allowed if no validation function was provided or if the user is moving backwards - if(typeof(step.canexit) === 'undefined' || $scope.getStepNumber(stepTo) < $scope.currentStepNumber()){ - return true; - } - //If canexit is a boolean value instead of a function, return the value - if(typeof step.canexit === 'boolean'){ - return step.canexit; - } - //Check to see if the canexit function is a promise which needs to be returned - canExit = step.canexit($scope.context); - if(angular.isFunction(canExit.then)){ - defer = $q.defer(); - canExit.then(function(response){ - defer.resolve(response); - }); - return defer.promise; - } - return step.canexit($scope.context) === true; - } - - $scope.currentStepNumber = function() { - //retreive current step number - return _.indexOf($scope.steps , $scope.selectedStep) + 1; - }; - - //unSelect All Steps - function unselectAll() { - //traverse steps array and set each "selected" property to false - _.each($scope.steps, function (step) { - step.selected = false; - }); - //set selectedStep variable to null - $scope.selectedStep = null; - } - - //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() - - //Access to current step number from outside - this.currentStepNumber = function(){ - return $scope.currentStepNumber(); - }; - //method used for next button within step - this.next = function(callback) { - //setting variable equal to step you were on when next() was invoked - var index = _.indexOf($scope.steps , $scope.selectedStep); - //checking to see if callback is a function - if(angular.isFunction(callback)){ - if(callback()){ - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } - } else { - return; - } - } - if (!callback) { - //completed property set on scope which is used to add class/remove class from progress bar - $scope.selectedStep.completed = true; - } - //checking to see if this is the last step. If it is next behaves the same as finish() - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } - - }; - - //used to traverse to any step, step number placed as argument - this.goTo = function(step) { - var stepTo; - //checking that step is a Number - if (_.isNumber(step)) { - stepTo = $scope.steps[step]; - } else { - //finding the step associated with the title entered as goTo argument - stepTo = _.findWhere($scope.steps, {title: step}); - } - //going to step - $scope.goTo(stepTo); - }; - - //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. - this.finish = function() { - if ($scope.onFinish) { - $scope.onFinish(); - } - }; - - //cancel is alias for previous. - this.cancel = this.previous = function() { - //getting index of current step - var index = _.indexOf($scope.steps , $scope.selectedStep); - //ensuring you aren't trying to go back from the first step - if (index === 0) { - throw new Error("Can't go back. It's already in step 0"); - } else { - //go back one step from current step - $scope.goTo($scope.steps[index - 1]); - } - }; - }] - }; -}); - -function wizardButtonDirective(action) { - angular.module('mgo-angular-wizard') - .directive(action, function() { - return { - restrict: 'A', - replace: false, - require: '^wizard', - link: function($scope, $element, $attrs, wizard) { - - $element.on("click", function(e) { - e.preventDefault(); - $scope.$apply(function() { - $scope.$eval($attrs[action]); - wizard[action.replace("wz", "").toLowerCase()](); - }); - }); - } - }; - }); -} - -wizardButtonDirective('wzNext'); -wizardButtonDirective('wzPrevious'); -wizardButtonDirective('wzFinish'); -wizardButtonDirective('wzCancel'); - -angular.module('mgo-angular-wizard').factory('WizardHandler', function() { - var service = {}; - - var wizards = {}; - - service.defaultName = "defaultWizard"; - - service.addWizard = function(name, wizard) { - wizards[name] = wizard; - }; - - service.removeWizard = function(name) { - delete wizards[name]; - }; - - service.wizard = function(name) { - var nameToUse = name; - if (!name) { - nameToUse = service.defaultName; - } - - return wizards[nameToUse]; - }; - - return service; -}); + +angular.module('mgo-angular-wizard').directive('wzStep', function() { + return { + restrict: 'EA', + replace: true, + transclude: true, + scope: { + wzTitle: '@', + title: '@', + canenter : '=', + canexit : '=' + }, + require: '^wizard', + templateUrl: function(element, attributes) { + return attributes.template || "step.html"; + }, + link: function($scope, $element, $attrs, wizard) { + $scope.title = $scope.title || $scope.wzTitle; + wizard.addStep($scope); + } + }; +}); + +//wizard directive +angular.module('mgo-angular-wizard').directive('wizard', function() { + return { + restrict: 'EA', + replace: true, + transclude: true, + scope: { + currentStep: '=', + onFinish: '&', + hideIndicators: '=', + editMode: '=', + name: '@' + }, + templateUrl: function(element, attributes) { + return attributes.template || "wizard.html"; + }, + + //controller for wizard directive, treat this just like an angular controller + controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function($scope, $element, $log, WizardHandler, $q) { + //this variable allows directive to load without having to pass any step validation + var firstRun = true; + //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service + WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); + + $scope.$on('$destroy', function() { + WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); + }); + + //steps array where all the scopes of each step are added + $scope.steps = []; + + //access to context object for step validation + $scope.context = {}; + + //watching changes to currentStep + $scope.$watch('currentStep', function(step) { + //checking to make sure currentStep is truthy value + if (!step) return; + //setting stepTitle equal to current step title or default title + var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; + if ($scope.selectedStep && stepTitle !== $scope.currentStep) { + //invoking goTo() with step title as argument + $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); + } + + }); + + //watching steps array length and editMode value, if edit module is undefined or null the nothing is done + //if edit mode is truthy, then all steps are marked as completed + $scope.$watch('[editMode, steps.length]', function() { + var editMode = $scope.editMode; + if (_.isUndefined(editMode) || _.isNull(editMode)) return; + + if (editMode) { + _.each($scope.steps, function(step) { + step.completed = true; + }); + } + }, true); + + //called each time step directive is loaded + this.addStep = function(step) { + //pushing the scope of directive onto step array + $scope.steps.push(step); + //if this is first step being pushed then goTo that first step + if ($scope.steps.length === 1) { + //goTo first step + $scope.goTo($scope.steps[0]); + } + }; + + this.context = $scope.context; + + $scope.getStepNumber = function(step) { + return _.indexOf($scope.steps, step) + 1; + }; + + $scope.goTo = function(step) { + //if this is the first time the wizard is loading it bi-passes step validation + if(firstRun){ + //deselect all steps so you can set fresh below + unselectAll(); + $scope.selectedStep = step; + //making sure current step is not undefined + if (!_.isUndefined($scope.currentStep)) { + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + //setting variable to false so all other step changes must pass validation + firstRun = false; + } else { + //createing variables to capture current state that goTo() was invoked from and allow booleans + var thisStep; + //getting data for step you are transitioning out of + if($scope.currentStepNumber() > 0){ + thisStep = $scope.currentStepNumber() - 1; + } else if ($scope.currentStepNumber() === 0){ + thisStep = 0; + } + //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); + $q.all([canExitStep($scope.steps[thisStep], step), canEnterStep(step)]).then(function(data) { + if(data[0] && data[1]){ + //deselect all steps so you can set fresh below + unselectAll(); + + //$log.log('value for canExit argument: ', $scope.currentStep.canexit); + $scope.selectedStep = step; + //making sure current step is not undefined + if(!_.isUndefined($scope.currentStep)){ + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps, step)}); + //$log.log('current step number: ', $scope.currentStepNumber()); + } + }); + } + }; + + function canEnterStep(step) { + var defer, + canEnter; + //If no validation function is provided, allow the user to enter the step + if(step.canenter === undefined){ + return true; + } + //If canenter is a boolean value instead of a function, return the value + if(typeof step.canenter === 'boolean'){ + return step.canenter; + } + //Check to see if the canenter function is a promise which needs to be returned + canEnter = step.canenter($scope.context); + if(angular.isFunction(canEnter.then)){ + defer = $q.defer(); + canEnter.then(function(response){ + defer.resolve(response); + }); + return defer.promise; + } + return step.canenter($scope.context) === true; + } + + function canExitStep(step, stepTo) { + var defer, + canExit; + //Exiting the step should be allowed if no validation function was provided or if the user is moving backwards + if(typeof(step.canexit) === 'undefined' || $scope.getStepNumber(stepTo) < $scope.currentStepNumber()){ + return true; + } + //If canexit is a boolean value instead of a function, return the value + if(typeof step.canexit === 'boolean'){ + return step.canexit; + } + //Check to see if the canexit function is a promise which needs to be returned + canExit = step.canexit($scope.context); + if(angular.isFunction(canExit.then)){ + defer = $q.defer(); + canExit.then(function(response){ + defer.resolve(response); + }); + return defer.promise; + } + return step.canexit($scope.context) === true; + } + + $scope.currentStepNumber = function() { + //retreive current step number + return _.indexOf($scope.steps , $scope.selectedStep) + 1; + }; + + //unSelect All Steps + function unselectAll() { + //traverse steps array and set each "selected" property to false + _.each($scope.steps, function (step) { + step.selected = false; + }); + //set selectedStep variable to null + $scope.selectedStep = null; + } + + //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + + //Access to current step number from outside + this.currentStepNumber = function(){ + return $scope.currentStepNumber(); + }; + //method used for next button within step + this.next = function(callback) { + //setting variable equal to step you were on when next() was invoked + var index = _.indexOf($scope.steps , $scope.selectedStep); + //checking to see if callback is a function + if(angular.isFunction(callback)){ + if(callback()){ + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + } else { + return; + } + } + if (!callback) { + //completed property set on scope which is used to add class/remove class from progress bar + $scope.selectedStep.completed = true; + } + //checking to see if this is the last step. If it is next behaves the same as finish() + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + + }; + + //used to traverse to any step, step number placed as argument + this.goTo = function(step) { + var stepTo; + //checking that step is a Number + if (_.isNumber(step)) { + stepTo = $scope.steps[step]; + } else { + //finding the step associated with the title entered as goTo argument + stepTo = _.findWhere($scope.steps, {title: step}); + } + //going to step + $scope.goTo(stepTo); + }; + + //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. + this.finish = function() { + if ($scope.onFinish) { + $scope.onFinish(); + } + }; + + //cancel is alias for previous. + this.cancel = this.previous = function() { + //getting index of current step + var index = _.indexOf($scope.steps , $scope.selectedStep); + //ensuring you aren't trying to go back from the first step + if (index === 0) { + throw new Error("Can't go back. It's already in step 0"); + } else { + //go back one step from current step + $scope.goTo($scope.steps[index - 1]); + } + }; + }] + }; +}); + +function wizardButtonDirective(action) { + angular.module('mgo-angular-wizard') + .directive(action, function() { + return { + restrict: 'A', + replace: false, + require: '^wizard', + link: function($scope, $element, $attrs, wizard) { + + $element.on("click", function(e) { + e.preventDefault(); + $scope.$apply(function() { + $scope.$eval($attrs[action]); + wizard[action.replace("wz", "").toLowerCase()](); + }); + }); + } + }; + }); +} + +wizardButtonDirective('wzNext'); +wizardButtonDirective('wzPrevious'); +wizardButtonDirective('wzFinish'); +wizardButtonDirective('wzCancel'); + +angular.module('mgo-angular-wizard').factory('WizardHandler', function() { + var service = {}; + + var wizards = {}; + + service.defaultName = "defaultWizard"; + + service.addWizard = function(name, wizard) { + wizards[name] = wizard; + }; + + service.removeWizard = function(name) { + delete wizards[name]; + }; + + service.wizard = function(name) { + var nameToUse = name; + if (!name) { + nameToUse = service.defaultName; + } + + return wizards[nameToUse]; + }; + + return service; +}); diff --git a/dist/angular-wizard.less b/dist/angular-wizard.less old mode 100644 new mode 100755 diff --git a/dist/angular-wizard.min.css b/dist/angular-wizard.min.css old mode 100644 new mode 100755 index 32cbfb4..37f7185 --- a/dist/angular-wizard.min.css +++ b/dist/angular-wizard.min.css @@ -1 +1 @@ -.steps-indicator li a:before,.steps-indicator:before{background-color:#e6e6e6;content:''}.steps-indicator li.current,.steps-indicator li.default,.steps-indicator li.editing{pointer-events:none}.steps-indicator{right:0;bottom:0;left:0;margin:0;padding:20px 0 0;height:30px;list-style:none}.steps-indicator:before{position:absolute;height:1px}.steps-indicator.steps-2:before{left:calc(100% / 2 / 2);right:calc(100% / 2 / 2)}.steps-indicator.steps-3:before{left:calc(100% / 3 / 2);right:calc(100% / 3 / 2)}.steps-indicator.steps-4:before{left:calc(100% / 4 / 2);right:calc(100% / 4 / 2)}.steps-indicator.steps-5:before{left:calc(100% / 5 / 2);right:calc(100% / 5 / 2)}.steps-indicator.steps-6:before{left:calc(100% / 6 / 2);right:calc(100% / 6 / 2)}.steps-indicator.steps-7:before{left:calc(100% / 7 / 2);right:calc(100% / 7 / 2)}.steps-indicator.steps-8:before{left:calc(100% / 8 / 2);right:calc(100% / 8 / 2)}.steps-indicator.steps-9:before{left:calc(100% / 9 / 2);right:calc(100% / 9 / 2)}.steps-indicator.steps-10:before{left:calc(100% / 10 / 2);right:calc(100% / 10 / 2)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;margin:0;padding:0;padding-top:10px;text-align:center;line-height:15px}.steps-indicator li a{color:grey;text-decoration:none;text-transform:uppercase;font-weight:700;transition:.25s;cursor:pointer}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(50% - 7px);width:14px;height:14px;border-radius:100%;transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(100% / 2)}.steps-indicator.steps-3 li{width:calc(100% / 3)}.steps-indicator.steps-4 li{width:calc(100% / 4)}.steps-indicator.steps-5 li{width:calc(100% / 5)}.steps-indicator.steps-6 li{width:calc(100% / 6)}.steps-indicator.steps-7 li{width:calc(100% / 7)}.steps-indicator.steps-8 li{width:calc(100% / 8)}.steps-indicator.steps-9 li{width:calc(100% / 9)}.steps-indicator.steps-10 li{width:calc(100% / 10)}.steps-indicator.steps-11 li{width:calc(100% / 11)}.steps-indicator li.default a:hover{color:grey}.steps-indicator li.current a:before{background-color:grey}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:red} \ No newline at end of file +.steps-indicator li a:before,.steps-indicator:before{background-color:#e6e6e6;content:''}.steps-indicator li.current,.steps-indicator li.default,.steps-indicator li.editing{pointer-events:none}.steps-indicator{right:0;bottom:0;left:0;margin:0;padding:20px 0 0 0;height:30px;list-style:none}.steps-indicator:before{position:absolute;height:1px}.steps-indicator.steps-2:before{left:calc(100% / 2 / 2);right:calc(100% / 2 / 2)}.steps-indicator.steps-3:before{left:calc(100% / 3 / 2);right:calc(100% / 3 / 2)}.steps-indicator.steps-4:before{left:calc(100% / 4 / 2);right:calc(100% / 4 / 2)}.steps-indicator.steps-5:before{left:calc(100% / 5 / 2);right:calc(100% / 5 / 2)}.steps-indicator.steps-6:before{left:calc(100% / 6 / 2);right:calc(100% / 6 / 2)}.steps-indicator.steps-7:before{left:calc(100% / 7 / 2);right:calc(100% / 7 / 2)}.steps-indicator.steps-8:before{left:calc(100% / 8 / 2);right:calc(100% / 8 / 2)}.steps-indicator.steps-9:before{left:calc(100% / 9 / 2);right:calc(100% / 9 / 2)}.steps-indicator.steps-10:before{left:calc(100% / 10 / 2);right:calc(100% / 10 / 2)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;margin:0;padding:0;padding-top:10px;text-align:center;line-height:15px}.steps-indicator li a{color:grey;text-decoration:none;text-transform:uppercase;font-weight:700;transition:.25s;cursor:pointer}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(50% - 7px);width:14px;height:14px;border-radius:100%;transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(100% / 2)}.steps-indicator.steps-3 li{width:calc(100% / 3)}.steps-indicator.steps-4 li{width:calc(100% / 4)}.steps-indicator.steps-5 li{width:calc(100% / 5)}.steps-indicator.steps-6 li{width:calc(100% / 6)}.steps-indicator.steps-7 li{width:calc(100% / 7)}.steps-indicator.steps-8 li{width:calc(100% / 8)}.steps-indicator.steps-9 li{width:calc(100% / 9)}.steps-indicator.steps-10 li{width:calc(100% / 10)}.steps-indicator.steps-11 li{width:calc(100% / 11)}.steps-indicator li.default a:hover{color:grey}.steps-indicator li.current a:before{background-color:grey}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:red} \ No newline at end of file diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js old mode 100644 new mode 100755 index f8cde66..064ab3a --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.4.3 - 2015-05-27 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.0 - 2015-06-04 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ From e92e4c413eaa0a195dd9a11fda32f570659ab964 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 4 Jun 2015 09:08:05 -0700 Subject: [PATCH 079/185] Project Build --- dist/angular-wizard.js | 1 - 1 file changed, 1 deletion(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 0378c30..2275701 100755 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -307,7 +307,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }] }; }); - function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') .directive(action, function() { From d6916b4f1d7194ebe2f065617b07998f19bd2d3d Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 4 Jun 2015 09:08:42 -0700 Subject: [PATCH 080/185] updating bower so it pulls latest version --- src/wizard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wizard.js b/src/wizard.js index e23437a..9b69bc2 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -255,4 +255,4 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; }] }; -}); +}); \ No newline at end of file From cd7043acd4fb01101d0254ba23a08491df2c171b Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 4 Jun 2015 09:10:10 -0700 Subject: [PATCH 081/185] Release version 0.5.1 --- bower.json | 2 +- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 270b42b..b140cae 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.5.0", + "version": "0.5.1", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 2275701..b84e1f9 100755 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.0 - 2015-06-04 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.1 - 2015-06-04 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 064ab3a..339beef 100755 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.0 - 2015-06-04 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.1 - 2015-06-04 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/package.json b/package.json index 77a64c7..799b5cd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.5.0", + "version": "0.5.1", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 4889b2219e6408bf896a57259da64ab1b84e9bbd Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 4 Jun 2015 09:17:51 -0700 Subject: [PATCH 082/185] Updated JsDelivr CDN links --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d893357..cb50cb1 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ You can download this by: ````html - - + + - - + + ```` The dist folder contains the following files: From 3627ba17c957fb1c6f51599b5038b1426f57aa8e Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 8 Jun 2015 11:13:25 -0700 Subject: [PATCH 083/185] cancel button now takes you to first step as specified in documentation --- src/wizard.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index 9b69bc2..85044ea 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -241,8 +241,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } }; - //cancel is alias for previous. - this.cancel = this.previous = function() { + + this.previous = function() { //getting index of current step var index = _.indexOf($scope.steps , $scope.selectedStep); //ensuring you aren't trying to go back from the first step @@ -253,6 +253,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo($scope.steps[index - 1]); } }; + + //cancel is alias for previous. + this.cancel = function() { + //getting index of current step + var index = _.indexOf($scope.steps , $scope.selectedStep); + //ensuring you aren't trying to go back from the first step + if (index === 0) { + throw new Error("Can't go back. It's already in step 0"); + } else { + //go back one step from current step + $scope.goTo($scope.steps[0]); + } + }; }] }; }); \ No newline at end of file From 96af2c235d6091f434abe540606aebbb35153466 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 8 Jun 2015 11:13:43 -0700 Subject: [PATCH 084/185] Project Build --- dist/angular-wizard.css | 0 dist/angular-wizard.js | 733 ++++++++++++++++++------------------ dist/angular-wizard.less | 0 dist/angular-wizard.min.css | 2 +- dist/angular-wizard.min.js | 4 +- 5 files changed, 376 insertions(+), 363 deletions(-) mode change 100755 => 100644 dist/angular-wizard.css mode change 100755 => 100644 dist/angular-wizard.js mode change 100755 => 100644 dist/angular-wizard.less mode change 100755 => 100644 dist/angular-wizard.min.css mode change 100755 => 100644 dist/angular-wizard.min.js diff --git a/dist/angular-wizard.css b/dist/angular-wizard.css old mode 100755 new mode 100644 diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js old mode 100755 new mode 100644 index b84e1f9..77ac7c6 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,361 +1,374 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.5.1 - 2015-06-04 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
\n" + - "
"); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
\n" + - "
\n" + - " \n" + - "
\n" + - ""); -}]); - +/** + * Easy to use Wizard library for AngularJS + * @version v0.5.2 - 2015-06-08 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
\n" + + "
"); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
\n" + + "
\n" + + " \n" + + "
\n" + + ""); +}]); + angular.module('mgo-angular-wizard', ['templates-angularwizard']); - -angular.module('mgo-angular-wizard').directive('wzStep', function() { - return { - restrict: 'EA', - replace: true, - transclude: true, - scope: { - wzTitle: '@', - title: '@', - canenter : '=', - canexit : '=' - }, - require: '^wizard', - templateUrl: function(element, attributes) { - return attributes.template || "step.html"; - }, - link: function($scope, $element, $attrs, wizard) { - $scope.title = $scope.title || $scope.wzTitle; - wizard.addStep($scope); - } - }; -}); - -//wizard directive -angular.module('mgo-angular-wizard').directive('wizard', function() { - return { - restrict: 'EA', - replace: true, - transclude: true, - scope: { - currentStep: '=', - onFinish: '&', - hideIndicators: '=', - editMode: '=', - name: '@' - }, - templateUrl: function(element, attributes) { - return attributes.template || "wizard.html"; - }, - - //controller for wizard directive, treat this just like an angular controller - controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function($scope, $element, $log, WizardHandler, $q) { - //this variable allows directive to load without having to pass any step validation - var firstRun = true; - //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service - WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); - - $scope.$on('$destroy', function() { - WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); - }); - - //steps array where all the scopes of each step are added - $scope.steps = []; - - //access to context object for step validation - $scope.context = {}; - - //watching changes to currentStep - $scope.$watch('currentStep', function(step) { - //checking to make sure currentStep is truthy value - if (!step) return; - //setting stepTitle equal to current step title or default title - var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; - if ($scope.selectedStep && stepTitle !== $scope.currentStep) { - //invoking goTo() with step title as argument - $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); - } - - }); - - //watching steps array length and editMode value, if edit module is undefined or null the nothing is done - //if edit mode is truthy, then all steps are marked as completed - $scope.$watch('[editMode, steps.length]', function() { - var editMode = $scope.editMode; - if (_.isUndefined(editMode) || _.isNull(editMode)) return; - - if (editMode) { - _.each($scope.steps, function(step) { - step.completed = true; - }); - } - }, true); - - //called each time step directive is loaded - this.addStep = function(step) { - //pushing the scope of directive onto step array - $scope.steps.push(step); - //if this is first step being pushed then goTo that first step - if ($scope.steps.length === 1) { - //goTo first step - $scope.goTo($scope.steps[0]); - } - }; - - this.context = $scope.context; - - $scope.getStepNumber = function(step) { - return _.indexOf($scope.steps, step) + 1; - }; - - $scope.goTo = function(step) { - //if this is the first time the wizard is loading it bi-passes step validation - if(firstRun){ - //deselect all steps so you can set fresh below - unselectAll(); - $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; - } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); - //setting variable to false so all other step changes must pass validation - firstRun = false; - } else { - //createing variables to capture current state that goTo() was invoked from and allow booleans - var thisStep; - //getting data for step you are transitioning out of - if($scope.currentStepNumber() > 0){ - thisStep = $scope.currentStepNumber() - 1; - } else if ($scope.currentStepNumber() === 0){ - thisStep = 0; - } - //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); - $q.all([canExitStep($scope.steps[thisStep], step), canEnterStep(step)]).then(function(data) { - if(data[0] && data[1]){ - //deselect all steps so you can set fresh below - unselectAll(); - - //$log.log('value for canExit argument: ', $scope.currentStep.canexit); - $scope.selectedStep = step; - //making sure current step is not undefined - if(!_.isUndefined($scope.currentStep)){ - $scope.currentStep = step.title || step.wzTitle; - } - //setting selected step to argument passed into goTo() - step.selected = true; - //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps, step)}); - //$log.log('current step number: ', $scope.currentStepNumber()); - } - }); - } - }; - - function canEnterStep(step) { - var defer, - canEnter; - //If no validation function is provided, allow the user to enter the step - if(step.canenter === undefined){ - return true; - } - //If canenter is a boolean value instead of a function, return the value - if(typeof step.canenter === 'boolean'){ - return step.canenter; - } - //Check to see if the canenter function is a promise which needs to be returned - canEnter = step.canenter($scope.context); - if(angular.isFunction(canEnter.then)){ - defer = $q.defer(); - canEnter.then(function(response){ - defer.resolve(response); - }); - return defer.promise; - } - return step.canenter($scope.context) === true; - } - - function canExitStep(step, stepTo) { - var defer, - canExit; - //Exiting the step should be allowed if no validation function was provided or if the user is moving backwards - if(typeof(step.canexit) === 'undefined' || $scope.getStepNumber(stepTo) < $scope.currentStepNumber()){ - return true; - } - //If canexit is a boolean value instead of a function, return the value - if(typeof step.canexit === 'boolean'){ - return step.canexit; - } - //Check to see if the canexit function is a promise which needs to be returned - canExit = step.canexit($scope.context); - if(angular.isFunction(canExit.then)){ - defer = $q.defer(); - canExit.then(function(response){ - defer.resolve(response); - }); - return defer.promise; - } - return step.canexit($scope.context) === true; - } - - $scope.currentStepNumber = function() { - //retreive current step number - return _.indexOf($scope.steps , $scope.selectedStep) + 1; - }; - - //unSelect All Steps - function unselectAll() { - //traverse steps array and set each "selected" property to false - _.each($scope.steps, function (step) { - step.selected = false; - }); - //set selectedStep variable to null - $scope.selectedStep = null; - } - - //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() - - //Access to current step number from outside - this.currentStepNumber = function(){ - return $scope.currentStepNumber(); - }; - //method used for next button within step - this.next = function(callback) { - //setting variable equal to step you were on when next() was invoked - var index = _.indexOf($scope.steps , $scope.selectedStep); - //checking to see if callback is a function - if(angular.isFunction(callback)){ - if(callback()){ - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } - } else { - return; - } - } - if (!callback) { - //completed property set on scope which is used to add class/remove class from progress bar - $scope.selectedStep.completed = true; - } - //checking to see if this is the last step. If it is next behaves the same as finish() - if (index === $scope.steps.length - 1) { - this.finish(); - } else { - //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); - } - - }; - - //used to traverse to any step, step number placed as argument - this.goTo = function(step) { - var stepTo; - //checking that step is a Number - if (_.isNumber(step)) { - stepTo = $scope.steps[step]; - } else { - //finding the step associated with the title entered as goTo argument - stepTo = _.findWhere($scope.steps, {title: step}); - } - //going to step - $scope.goTo(stepTo); - }; - - //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. - this.finish = function() { - if ($scope.onFinish) { - $scope.onFinish(); - } - }; - - //cancel is alias for previous. - this.cancel = this.previous = function() { - //getting index of current step - var index = _.indexOf($scope.steps , $scope.selectedStep); - //ensuring you aren't trying to go back from the first step - if (index === 0) { - throw new Error("Can't go back. It's already in step 0"); - } else { - //go back one step from current step - $scope.goTo($scope.steps[index - 1]); - } - }; - }] - }; -}); -function wizardButtonDirective(action) { - angular.module('mgo-angular-wizard') - .directive(action, function() { - return { - restrict: 'A', - replace: false, - require: '^wizard', - link: function($scope, $element, $attrs, wizard) { - - $element.on("click", function(e) { - e.preventDefault(); - $scope.$apply(function() { - $scope.$eval($attrs[action]); - wizard[action.replace("wz", "").toLowerCase()](); - }); - }); - } - }; - }); -} - -wizardButtonDirective('wzNext'); -wizardButtonDirective('wzPrevious'); -wizardButtonDirective('wzFinish'); -wizardButtonDirective('wzCancel'); - -angular.module('mgo-angular-wizard').factory('WizardHandler', function() { - var service = {}; - - var wizards = {}; - - service.defaultName = "defaultWizard"; - - service.addWizard = function(name, wizard) { - wizards[name] = wizard; - }; - - service.removeWizard = function(name) { - delete wizards[name]; - }; - - service.wizard = function(name) { - var nameToUse = name; - if (!name) { - nameToUse = service.defaultName; - } - - return wizards[nameToUse]; - }; - - return service; -}); + +angular.module('mgo-angular-wizard').directive('wzStep', function() { + return { + restrict: 'EA', + replace: true, + transclude: true, + scope: { + wzTitle: '@', + title: '@', + canenter : '=', + canexit : '=' + }, + require: '^wizard', + templateUrl: function(element, attributes) { + return attributes.template || "step.html"; + }, + link: function($scope, $element, $attrs, wizard) { + $scope.title = $scope.title || $scope.wzTitle; + wizard.addStep($scope); + } + }; +}); + +//wizard directive +angular.module('mgo-angular-wizard').directive('wizard', function() { + return { + restrict: 'EA', + replace: true, + transclude: true, + scope: { + currentStep: '=', + onFinish: '&', + hideIndicators: '=', + editMode: '=', + name: '@' + }, + templateUrl: function(element, attributes) { + return attributes.template || "wizard.html"; + }, + + //controller for wizard directive, treat this just like an angular controller + controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function($scope, $element, $log, WizardHandler, $q) { + //this variable allows directive to load without having to pass any step validation + var firstRun = true; + //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service + WizardHandler.addWizard($scope.name || WizardHandler.defaultName, this); + + $scope.$on('$destroy', function() { + WizardHandler.removeWizard($scope.name || WizardHandler.defaultName); + }); + + //steps array where all the scopes of each step are added + $scope.steps = []; + + //access to context object for step validation + $scope.context = {}; + + //watching changes to currentStep + $scope.$watch('currentStep', function(step) { + //checking to make sure currentStep is truthy value + if (!step) return; + //setting stepTitle equal to current step title or default title + var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; + if ($scope.selectedStep && stepTitle !== $scope.currentStep) { + //invoking goTo() with step title as argument + $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); + } + + }); + + //watching steps array length and editMode value, if edit module is undefined or null the nothing is done + //if edit mode is truthy, then all steps are marked as completed + $scope.$watch('[editMode, steps.length]', function() { + var editMode = $scope.editMode; + if (_.isUndefined(editMode) || _.isNull(editMode)) return; + + if (editMode) { + _.each($scope.steps, function(step) { + step.completed = true; + }); + } + }, true); + + //called each time step directive is loaded + this.addStep = function(step) { + //pushing the scope of directive onto step array + $scope.steps.push(step); + //if this is first step being pushed then goTo that first step + if ($scope.steps.length === 1) { + //goTo first step + $scope.goTo($scope.steps[0]); + } + }; + + this.context = $scope.context; + + $scope.getStepNumber = function(step) { + return _.indexOf($scope.steps, step) + 1; + }; + + $scope.goTo = function(step) { + //if this is the first time the wizard is loading it bi-passes step validation + if(firstRun){ + //deselect all steps so you can set fresh below + unselectAll(); + $scope.selectedStep = step; + //making sure current step is not undefined + if (!_.isUndefined($scope.currentStep)) { + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + //setting variable to false so all other step changes must pass validation + firstRun = false; + } else { + //createing variables to capture current state that goTo() was invoked from and allow booleans + var thisStep; + //getting data for step you are transitioning out of + if($scope.currentStepNumber() > 0){ + thisStep = $scope.currentStepNumber() - 1; + } else if ($scope.currentStepNumber() === 0){ + thisStep = 0; + } + //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); + $q.all([canExitStep($scope.steps[thisStep], step), canEnterStep(step)]).then(function(data) { + if(data[0] && data[1]){ + //deselect all steps so you can set fresh below + unselectAll(); + + //$log.log('value for canExit argument: ', $scope.currentStep.canexit); + $scope.selectedStep = step; + //making sure current step is not undefined + if(!_.isUndefined($scope.currentStep)){ + $scope.currentStep = step.title || step.wzTitle; + } + //setting selected step to argument passed into goTo() + step.selected = true; + //emit event upwards with data on goTo() invoktion + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps, step)}); + //$log.log('current step number: ', $scope.currentStepNumber()); + } + }); + } + }; + + function canEnterStep(step) { + var defer, + canEnter; + //If no validation function is provided, allow the user to enter the step + if(step.canenter === undefined){ + return true; + } + //If canenter is a boolean value instead of a function, return the value + if(typeof step.canenter === 'boolean'){ + return step.canenter; + } + //Check to see if the canenter function is a promise which needs to be returned + canEnter = step.canenter($scope.context); + if(angular.isFunction(canEnter.then)){ + defer = $q.defer(); + canEnter.then(function(response){ + defer.resolve(response); + }); + return defer.promise; + } + return step.canenter($scope.context) === true; + } + + function canExitStep(step, stepTo) { + var defer, + canExit; + //Exiting the step should be allowed if no validation function was provided or if the user is moving backwards + if(typeof(step.canexit) === 'undefined' || $scope.getStepNumber(stepTo) < $scope.currentStepNumber()){ + return true; + } + //If canexit is a boolean value instead of a function, return the value + if(typeof step.canexit === 'boolean'){ + return step.canexit; + } + //Check to see if the canexit function is a promise which needs to be returned + canExit = step.canexit($scope.context); + if(angular.isFunction(canExit.then)){ + defer = $q.defer(); + canExit.then(function(response){ + defer.resolve(response); + }); + return defer.promise; + } + return step.canexit($scope.context) === true; + } + + $scope.currentStepNumber = function() { + //retreive current step number + return _.indexOf($scope.steps , $scope.selectedStep) + 1; + }; + + //unSelect All Steps + function unselectAll() { + //traverse steps array and set each "selected" property to false + _.each($scope.steps, function (step) { + step.selected = false; + }); + //set selectedStep variable to null + $scope.selectedStep = null; + } + + //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + + //Access to current step number from outside + this.currentStepNumber = function(){ + return $scope.currentStepNumber(); + }; + //method used for next button within step + this.next = function(callback) { + //setting variable equal to step you were on when next() was invoked + var index = _.indexOf($scope.steps , $scope.selectedStep); + //checking to see if callback is a function + if(angular.isFunction(callback)){ + if(callback()){ + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + } else { + return; + } + } + if (!callback) { + //completed property set on scope which is used to add class/remove class from progress bar + $scope.selectedStep.completed = true; + } + //checking to see if this is the last step. If it is next behaves the same as finish() + if (index === $scope.steps.length - 1) { + this.finish(); + } else { + //invoking goTo() with step number next in line + $scope.goTo($scope.steps[index + 1]); + } + + }; + + //used to traverse to any step, step number placed as argument + this.goTo = function(step) { + var stepTo; + //checking that step is a Number + if (_.isNumber(step)) { + stepTo = $scope.steps[step]; + } else { + //finding the step associated with the title entered as goTo argument + stepTo = _.findWhere($scope.steps, {title: step}); + } + //going to step + $scope.goTo(stepTo); + }; + + //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. + this.finish = function() { + if ($scope.onFinish) { + $scope.onFinish(); + } + }; + + + this.previous = function() { + //getting index of current step + var index = _.indexOf($scope.steps , $scope.selectedStep); + //ensuring you aren't trying to go back from the first step + if (index === 0) { + throw new Error("Can't go back. It's already in step 0"); + } else { + //go back one step from current step + $scope.goTo($scope.steps[index - 1]); + } + }; + + //cancel is alias for previous. + this.cancel = function() { + //getting index of current step + var index = _.indexOf($scope.steps , $scope.selectedStep); + //ensuring you aren't trying to go back from the first step + if (index === 0) { + throw new Error("Can't go back. It's already in step 0"); + } else { + //go back one step from current step + $scope.goTo($scope.steps[0]); + } + }; + }] + }; +}); +function wizardButtonDirective(action) { + angular.module('mgo-angular-wizard') + .directive(action, function() { + return { + restrict: 'A', + replace: false, + require: '^wizard', + link: function($scope, $element, $attrs, wizard) { + + $element.on("click", function(e) { + e.preventDefault(); + $scope.$apply(function() { + $scope.$eval($attrs[action]); + wizard[action.replace("wz", "").toLowerCase()](); + }); + }); + } + }; + }); +} + +wizardButtonDirective('wzNext'); +wizardButtonDirective('wzPrevious'); +wizardButtonDirective('wzFinish'); +wizardButtonDirective('wzCancel'); + +angular.module('mgo-angular-wizard').factory('WizardHandler', function() { + var service = {}; + + var wizards = {}; + + service.defaultName = "defaultWizard"; + + service.addWizard = function(name, wizard) { + wizards[name] = wizard; + }; + + service.removeWizard = function(name) { + delete wizards[name]; + }; + + service.wizard = function(name) { + var nameToUse = name; + if (!name) { + nameToUse = service.defaultName; + } + + return wizards[nameToUse]; + }; + + return service; +}); diff --git a/dist/angular-wizard.less b/dist/angular-wizard.less old mode 100755 new mode 100644 diff --git a/dist/angular-wizard.min.css b/dist/angular-wizard.min.css old mode 100755 new mode 100644 index 37f7185..32cbfb4 --- a/dist/angular-wizard.min.css +++ b/dist/angular-wizard.min.css @@ -1 +1 @@ -.steps-indicator li a:before,.steps-indicator:before{background-color:#e6e6e6;content:''}.steps-indicator li.current,.steps-indicator li.default,.steps-indicator li.editing{pointer-events:none}.steps-indicator{right:0;bottom:0;left:0;margin:0;padding:20px 0 0 0;height:30px;list-style:none}.steps-indicator:before{position:absolute;height:1px}.steps-indicator.steps-2:before{left:calc(100% / 2 / 2);right:calc(100% / 2 / 2)}.steps-indicator.steps-3:before{left:calc(100% / 3 / 2);right:calc(100% / 3 / 2)}.steps-indicator.steps-4:before{left:calc(100% / 4 / 2);right:calc(100% / 4 / 2)}.steps-indicator.steps-5:before{left:calc(100% / 5 / 2);right:calc(100% / 5 / 2)}.steps-indicator.steps-6:before{left:calc(100% / 6 / 2);right:calc(100% / 6 / 2)}.steps-indicator.steps-7:before{left:calc(100% / 7 / 2);right:calc(100% / 7 / 2)}.steps-indicator.steps-8:before{left:calc(100% / 8 / 2);right:calc(100% / 8 / 2)}.steps-indicator.steps-9:before{left:calc(100% / 9 / 2);right:calc(100% / 9 / 2)}.steps-indicator.steps-10:before{left:calc(100% / 10 / 2);right:calc(100% / 10 / 2)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;margin:0;padding:0;padding-top:10px;text-align:center;line-height:15px}.steps-indicator li a{color:grey;text-decoration:none;text-transform:uppercase;font-weight:700;transition:.25s;cursor:pointer}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(50% - 7px);width:14px;height:14px;border-radius:100%;transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(100% / 2)}.steps-indicator.steps-3 li{width:calc(100% / 3)}.steps-indicator.steps-4 li{width:calc(100% / 4)}.steps-indicator.steps-5 li{width:calc(100% / 5)}.steps-indicator.steps-6 li{width:calc(100% / 6)}.steps-indicator.steps-7 li{width:calc(100% / 7)}.steps-indicator.steps-8 li{width:calc(100% / 8)}.steps-indicator.steps-9 li{width:calc(100% / 9)}.steps-indicator.steps-10 li{width:calc(100% / 10)}.steps-indicator.steps-11 li{width:calc(100% / 11)}.steps-indicator li.default a:hover{color:grey}.steps-indicator li.current a:before{background-color:grey}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:red} \ No newline at end of file +.steps-indicator li a:before,.steps-indicator:before{background-color:#e6e6e6;content:''}.steps-indicator li.current,.steps-indicator li.default,.steps-indicator li.editing{pointer-events:none}.steps-indicator{right:0;bottom:0;left:0;margin:0;padding:20px 0 0;height:30px;list-style:none}.steps-indicator:before{position:absolute;height:1px}.steps-indicator.steps-2:before{left:calc(100% / 2 / 2);right:calc(100% / 2 / 2)}.steps-indicator.steps-3:before{left:calc(100% / 3 / 2);right:calc(100% / 3 / 2)}.steps-indicator.steps-4:before{left:calc(100% / 4 / 2);right:calc(100% / 4 / 2)}.steps-indicator.steps-5:before{left:calc(100% / 5 / 2);right:calc(100% / 5 / 2)}.steps-indicator.steps-6:before{left:calc(100% / 6 / 2);right:calc(100% / 6 / 2)}.steps-indicator.steps-7:before{left:calc(100% / 7 / 2);right:calc(100% / 7 / 2)}.steps-indicator.steps-8:before{left:calc(100% / 8 / 2);right:calc(100% / 8 / 2)}.steps-indicator.steps-9:before{left:calc(100% / 9 / 2);right:calc(100% / 9 / 2)}.steps-indicator.steps-10:before{left:calc(100% / 10 / 2);right:calc(100% / 10 / 2)}.steps-indicator *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.steps-indicator li{position:relative;float:left;margin:0;padding:0;padding-top:10px;text-align:center;line-height:15px}.steps-indicator li a{color:grey;text-decoration:none;text-transform:uppercase;font-weight:700;transition:.25s;cursor:pointer}.steps-indicator li a:before{position:absolute;top:-7px;left:calc(50% - 7px);width:14px;height:14px;border-radius:100%;transition:.25s}.steps-indicator li a:hover{color:#4d4d4d}.steps-indicator.steps-2 li{width:calc(100% / 2)}.steps-indicator.steps-3 li{width:calc(100% / 3)}.steps-indicator.steps-4 li{width:calc(100% / 4)}.steps-indicator.steps-5 li{width:calc(100% / 5)}.steps-indicator.steps-6 li{width:calc(100% / 6)}.steps-indicator.steps-7 li{width:calc(100% / 7)}.steps-indicator.steps-8 li{width:calc(100% / 8)}.steps-indicator.steps-9 li{width:calc(100% / 9)}.steps-indicator.steps-10 li{width:calc(100% / 10)}.steps-indicator.steps-11 li{width:calc(100% / 11)}.steps-indicator li.default a:hover{color:grey}.steps-indicator li.current a:before{background-color:grey}.steps-indicator li.done a:before{background-color:#393}.steps-indicator li.editing a:before{background-color:red} \ No newline at end of file diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js old mode 100755 new mode 100644 index 339beef..0ac96c8 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.1 - 2015-06-04 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.2 - 2015-06-08 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.steps[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.cancel=this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
\n
')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
\n
\n \n
\n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.steps[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])},this.cancel=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[0])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From fef914f5099e8d3151ac262cae48669f75f5443e Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 8 Jun 2015 11:13:57 -0700 Subject: [PATCH 085/185] release version 0.5.2 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index b140cae..8b1475e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.5.1", + "version": "0.5.2", "main": "./dist/angular-wizard.js", "description": "Easy to use Wizard library for AngularJS", "repository": { diff --git a/package.json b/package.json index 799b5cd..b24ec13 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.5.1", + "version": "0.5.2", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 9bf56260a4cb836fc46cb59be9927a9fc180d654 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 11 Jun 2015 08:24:29 -0700 Subject: [PATCH 086/185] added css file to main property and bumped version --- bower.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 8b1475e..e3a800e 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,10 @@ { "name": "angular-wizard", - "version": "0.5.2", - "main": "./dist/angular-wizard.js", + "version": "0.5.3", + "main": [ + "./dist/angular-wizard.js", + "./dist/angular-wizard.css" + ], "description": "Easy to use Wizard library for AngularJS", "repository": { "type": "git", From fb137de9e7f74406629ad4bec898d1c7db27671c Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 11 Jun 2015 08:24:43 -0700 Subject: [PATCH 087/185] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b24ec13..b2e1436 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.5.2", + "version": "0.5.3", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 553dca8825eaa3e0127654fcee39887a1bc8a316 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 11 Jun 2015 08:24:55 -0700 Subject: [PATCH 088/185] project build --- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 77ac7c6..71e16cd 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.2 - 2015-06-08 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.3 - 2015-06-11 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 0ac96c8..629b5b5 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.2 - 2015-06-08 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.3 - 2015-06-11 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ From f4991eb28e8c8e931a651552cb94087b19d59b84 Mon Sep 17 00:00:00 2001 From: drmikecrowe Date: Sun, 23 Aug 2015 23:31:42 -0400 Subject: [PATCH 089/185] Merged sushil-vishwanathan/angular-wizard (conditional steps) in with latest branch. --- .gitignore | 1 + bower.json | 6 ++-- dist/angular-wizard.js | 61 ++++++++++++++++++++++---------------- dist/angular-wizard.min.js | 4 +-- karma.conf.js | 2 +- package.json | 2 +- src/step.js | 3 +- src/wizard.html | 4 +-- src/wizard.js | 52 ++++++++++++++++++-------------- test/angularWizardSpec.js | 42 ++++++++++++++++++++++++-- 10 files changed, 117 insertions(+), 60 deletions(-) diff --git a/.gitignore b/.gitignore index 346cb48..5ae53ee 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ bower_components npm-debug.log src/*.tpls.js .idea/ +angular-wizard.iml diff --git a/bower.json b/bower.json index e3a800e..efbe274 100644 --- a/bower.json +++ b/bower.json @@ -1,9 +1,9 @@ { "name": "angular-wizard", - "version": "0.5.3", + "version": "0.5.4", "main": [ - "./dist/angular-wizard.js", - "./dist/angular-wizard.css" + "./dist/angular-wizard.min.js", + "./dist/angular-wizard.min.css" ], "description": "Easy to use Wizard library for AngularJS", "repository": { diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 71e16cd..823da4c 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.3 - 2015-06-11 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.3 - 2015-08-23 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -16,8 +16,8 @@ angular.module("wizard.html", []).run(["$templateCache", function($templateCache $templateCache.put("wizard.html", "
\n" + "
\n" + - "
    \n" + - "
  • \n" + + " \n" + @@ -36,7 +36,8 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { wzTitle: '@', title: '@', canenter : '=', - canexit : '=' + canexit : '=', + disabled: '@?wzDisabled' }, require: '^wizard', templateUrl: function(element, attributes) { @@ -91,7 +92,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; if ($scope.selectedStep && stepTitle !== $scope.currentStep) { //invoking goTo() with step title as argument - $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); + $scope.goTo(_.findWhere($scope.getEnabledSteps(), {title: $scope.currentStep})); } }); @@ -103,7 +104,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if (_.isUndefined(editMode) || _.isNull(editMode)) return; if (editMode) { - _.each($scope.steps, function(step) { + _.each($scope.getEnabledSteps(), function(step) { step.completed = true; }); } @@ -114,16 +115,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //pushing the scope of directive onto step array $scope.steps.push(step); //if this is first step being pushed then goTo that first step - if ($scope.steps.length === 1) { + if ($scope.getEnabledSteps().length === 1) { //goTo first step - $scope.goTo($scope.steps[0]); + $scope.goTo($scope.getEnabledSteps()[0]); } }; this.context = $scope.context; $scope.getStepNumber = function(step) { - return _.indexOf($scope.steps, step) + 1; + return _.indexOf($scope.getEnabledSteps(), step) + 1; }; $scope.goTo = function(step) { @@ -139,7 +140,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //setting selected step to argument passed into goTo() step.selected = true; //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps() , step)}); //setting variable to false so all other step changes must pass validation firstRun = false; } else { @@ -151,8 +152,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } else if ($scope.currentStepNumber() === 0){ thisStep = 0; } - //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); - $q.all([canExitStep($scope.steps[thisStep], step), canEnterStep(step)]).then(function(data) { + //$log.log('steps[thisStep] Data: ', $scope.getEnabledSteps()[thisStep].canexit); + $q.all([canExitStep($scope.getEnabledSteps()[thisStep], step), canEnterStep(step)]).then(function(data) { if(data[0] && data[1]){ //deselect all steps so you can set fresh below unselectAll(); @@ -166,7 +167,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //setting selected step to argument passed into goTo() step.selected = true; //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps, step)}); + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); //$log.log('current step number: ', $scope.currentStepNumber()); } }); @@ -221,13 +222,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.currentStepNumber = function() { //retreive current step number - return _.indexOf($scope.steps , $scope.selectedStep) + 1; + return _.indexOf($scope.getEnabledSteps() , $scope.selectedStep) + 1; + }; + + $scope.getEnabledSteps = function() { + return _.filter($scope.steps, function(step){ + return step.disabled !== 'true'; + }); }; //unSelect All Steps function unselectAll() { //traverse steps array and set each "selected" property to false - _.each($scope.steps, function (step) { + _.each($scope.getEnabledSteps(), function (step) { step.selected = false; }); //set selectedStep variable to null @@ -242,16 +249,17 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; //method used for next button within step this.next = function(callback) { + var enabledSteps = $scope.getEnabledSteps(); //setting variable equal to step you were on when next() was invoked - var index = _.indexOf($scope.steps , $scope.selectedStep); + var index = _.indexOf(enabledSteps, $scope.selectedStep); //checking to see if callback is a function if(angular.isFunction(callback)){ if(callback()){ - if (index === $scope.steps.length - 1) { + if (index === enabledSteps.length - 1) { this.finish(); } else { //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); + $scope.goTo(enabledSteps[index + 1]); } } else { return; @@ -262,24 +270,25 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.selectedStep.completed = true; } //checking to see if this is the last step. If it is next behaves the same as finish() - if (index === $scope.steps.length - 1) { + if (index === enabledSteps.length - 1) { this.finish(); } else { //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); + $scope.goTo(enabledSteps[index + 1]); } }; //used to traverse to any step, step number placed as argument this.goTo = function(step) { + var enabledSteps = $scope.getEnabledSteps(); var stepTo; //checking that step is a Number if (_.isNumber(step)) { - stepTo = $scope.steps[step]; + stepTo = enabledSteps[step]; } else { //finding the step associated with the title entered as goTo argument - stepTo = _.findWhere($scope.steps, {title: step}); + stepTo = _.findWhere(enabledSteps, {title: step}); } //going to step $scope.goTo(stepTo); @@ -295,26 +304,26 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.previous = function() { //getting index of current step - var index = _.indexOf($scope.steps , $scope.selectedStep); + var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); } else { //go back one step from current step - $scope.goTo($scope.steps[index - 1]); + $scope.goTo($scope.getEnabledSteps()[index - 1]); } }; //cancel is alias for previous. this.cancel = function() { //getting index of current step - var index = _.indexOf($scope.steps , $scope.selectedStep); + var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); } else { //go back one step from current step - $scope.goTo($scope.steps[0]); + $scope.goTo($scope.getEnabledSteps()[0]); } }; }] diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 629b5b5..c5f653e 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.3 - 2015-06-11 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.3 - 2015-08-23 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
    \n
    ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
    \n
    \n \n
    \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.steps[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.steps,b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.steps,a.selectedStep)+1},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=_.indexOf(a.steps,a.selectedStep);if(angular.isFunction(b)){if(!b())return;c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])}b||(a.selectedStep.completed=!0),c===a.steps.length-1?this.finish():a.goTo(a.steps[c+1])},this.goTo=function(b){var c;c=_.isNumber(b)?a.steps[b]:_.findWhere(a.steps,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[b-1])},this.cancel=function(){var b=_.indexOf(a.steps,a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.steps[0])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
    \n
    ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
    \n
    \n \n
    \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.getEnabledSteps()[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.getEnabledSteps(),b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.getEnabledSteps(),a.selectedStep)+1},a.getEnabledSteps=function(){return _.filter(a.steps,function(a){return"true"!==a.disabled})},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=_.indexOf(c,a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){var c,d=a.getEnabledSteps();c=_.isNumber(b)?d[b]:_.findWhere(d,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=_.indexOf(a.getEnabledSteps(),a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=_.indexOf(a.getEnabledSteps(),a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js index 9f422ec..997c655 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -14,7 +14,7 @@ module.exports = function(config) { 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js', 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular-mocks.js', 'http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js', - 'dist/*.js', + 'dist/*.min.js', 'test/*.js' ], diff --git a/package.json b/package.json index b2e1436..8c6d60e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.5.3", + "version": "0.5.4", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", diff --git a/src/step.js b/src/step.js index bbe5d05..7603e67 100644 --- a/src/step.js +++ b/src/step.js @@ -7,7 +7,8 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { wzTitle: '@', title: '@', canenter : '=', - canexit : '=' + canexit : '=', + disabled: '@?wzDisabled' }, require: '^wizard', templateUrl: function(element, attributes) { diff --git a/src/wizard.html b/src/wizard.html index 06e9e4c..0e8c660 100644 --- a/src/wizard.html +++ b/src/wizard.html @@ -1,7 +1,7 @@
    -
      -
    • + diff --git a/src/wizard.js b/src/wizard.js index 85044ea..5fa6450 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -40,7 +40,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; if ($scope.selectedStep && stepTitle !== $scope.currentStep) { //invoking goTo() with step title as argument - $scope.goTo(_.findWhere($scope.steps, {title: $scope.currentStep})); + $scope.goTo(_.findWhere($scope.getEnabledSteps(), {title: $scope.currentStep})); } }); @@ -52,7 +52,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if (_.isUndefined(editMode) || _.isNull(editMode)) return; if (editMode) { - _.each($scope.steps, function(step) { + _.each($scope.getEnabledSteps(), function(step) { step.completed = true; }); } @@ -63,16 +63,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //pushing the scope of directive onto step array $scope.steps.push(step); //if this is first step being pushed then goTo that first step - if ($scope.steps.length === 1) { + if ($scope.getEnabledSteps().length === 1) { //goTo first step - $scope.goTo($scope.steps[0]); + $scope.goTo($scope.getEnabledSteps()[0]); } }; this.context = $scope.context; $scope.getStepNumber = function(step) { - return _.indexOf($scope.steps, step) + 1; + return _.indexOf($scope.getEnabledSteps(), step) + 1; }; $scope.goTo = function(step) { @@ -88,7 +88,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //setting selected step to argument passed into goTo() step.selected = true; //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps , step)}); + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps() , step)}); //setting variable to false so all other step changes must pass validation firstRun = false; } else { @@ -100,8 +100,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } else if ($scope.currentStepNumber() === 0){ thisStep = 0; } - //$log.log('steps[thisStep] Data: ', $scope.steps[thisStep].canexit); - $q.all([canExitStep($scope.steps[thisStep], step), canEnterStep(step)]).then(function(data) { + //$log.log('steps[thisStep] Data: ', $scope.getEnabledSteps()[thisStep].canexit); + $q.all([canExitStep($scope.getEnabledSteps()[thisStep], step), canEnterStep(step)]).then(function(data) { if(data[0] && data[1]){ //deselect all steps so you can set fresh below unselectAll(); @@ -115,7 +115,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //setting selected step to argument passed into goTo() step.selected = true; //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.steps, step)}); + $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); //$log.log('current step number: ', $scope.currentStepNumber()); } }); @@ -170,13 +170,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.currentStepNumber = function() { //retreive current step number - return _.indexOf($scope.steps , $scope.selectedStep) + 1; + return _.indexOf($scope.getEnabledSteps() , $scope.selectedStep) + 1; + }; + + $scope.getEnabledSteps = function() { + return _.filter($scope.steps, function(step){ + return step.disabled !== 'true'; + }); }; //unSelect All Steps function unselectAll() { //traverse steps array and set each "selected" property to false - _.each($scope.steps, function (step) { + _.each($scope.getEnabledSteps(), function (step) { step.selected = false; }); //set selectedStep variable to null @@ -191,16 +197,17 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; //method used for next button within step this.next = function(callback) { + var enabledSteps = $scope.getEnabledSteps(); //setting variable equal to step you were on when next() was invoked - var index = _.indexOf($scope.steps , $scope.selectedStep); + var index = _.indexOf(enabledSteps, $scope.selectedStep); //checking to see if callback is a function if(angular.isFunction(callback)){ if(callback()){ - if (index === $scope.steps.length - 1) { + if (index === enabledSteps.length - 1) { this.finish(); } else { //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); + $scope.goTo(enabledSteps[index + 1]); } } else { return; @@ -211,24 +218,25 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.selectedStep.completed = true; } //checking to see if this is the last step. If it is next behaves the same as finish() - if (index === $scope.steps.length - 1) { + if (index === enabledSteps.length - 1) { this.finish(); } else { //invoking goTo() with step number next in line - $scope.goTo($scope.steps[index + 1]); + $scope.goTo(enabledSteps[index + 1]); } }; //used to traverse to any step, step number placed as argument this.goTo = function(step) { + var enabledSteps = $scope.getEnabledSteps(); var stepTo; //checking that step is a Number if (_.isNumber(step)) { - stepTo = $scope.steps[step]; + stepTo = enabledSteps[step]; } else { //finding the step associated with the title entered as goTo argument - stepTo = _.findWhere($scope.steps, {title: step}); + stepTo = _.findWhere(enabledSteps, {title: step}); } //going to step $scope.goTo(stepTo); @@ -244,26 +252,26 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.previous = function() { //getting index of current step - var index = _.indexOf($scope.steps , $scope.selectedStep); + var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); } else { //go back one step from current step - $scope.goTo($scope.steps[index - 1]); + $scope.goTo($scope.getEnabledSteps()[index - 1]); } }; //cancel is alias for previous. this.cancel = function() { //getting index of current step - var index = _.indexOf($scope.steps , $scope.selectedStep); + var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); } else { //go back one step from current step - $scope.goTo($scope.steps[0]); + $scope.goTo($scope.getEnabledSteps()[0]); } }; }] diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index 8003623..cbfe8c3 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -25,6 +25,11 @@ describe( 'AngularWizard', function() { + '

      Here you can use whatever you want. You can use other directives, binding, etc.

      ' + ' ' + ' ' + + ' ' + + '

      Dynamic {{dynamicStepDisabled}}

      ' + + '

      You have continued here!

      ' + + ' ' + + '
      ' + ' ' + '

      Continuing

      ' + '

      You have continued here!

      ' @@ -44,21 +49,40 @@ describe( 'AngularWizard', function() { var scope = $rootScope.$new(); var view = createView(scope); expect(WizardHandler).toBeTruthy(); - expect(view.find('section').length).toEqual(3); + expect(view.find('section').length).toEqual(4); // expect the correct step to be desirable one expect(scope.referenceCurrentStep).toEqual('Starting'); }); - it( "should go to the next step", function() { var scope = $rootScope.$new(); var view = createView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Dynamic'); + }); + it( "should render only those steps which are enabled", function() { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('Continuing'); }); + it( "should enable or disable dynamic steps based on conditions", function() { + var scope = $rootScope.$new(); + var view = createView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + scope.dynamicStepDisabled = 'Y'; + $rootScope.$digest(); + WizardHandler.wizard().goTo(2); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); it( "should return to a previous step", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); @@ -70,6 +94,7 @@ describe( 'AngularWizard', function() { }); it( "should go to a step specified by name", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo('More steps'); @@ -78,6 +103,7 @@ describe( 'AngularWizard', function() { }); it( "should go to a step specified by index", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo(2); @@ -86,6 +112,7 @@ describe( 'AngularWizard', function() { }); it( "should go to next step becasue callback is truthy", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(function(){ @@ -96,6 +123,7 @@ describe( 'AngularWizard', function() { }); it( "should NOT go to next step because callback is falsey", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(function(){ @@ -106,6 +134,7 @@ describe( 'AngularWizard', function() { }); it( "should go to next step because CANEXIT is UNDEFINED", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); @@ -114,6 +143,7 @@ describe( 'AngularWizard', function() { }); it( "should go to next step because CANEXIT is TRUE", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); scope.stepValidation = function(){ return true; @@ -128,6 +158,7 @@ describe( 'AngularWizard', function() { }); it( "should NOT go to next step because CANEXIT is FALSE", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); scope.stepValidation = function(){ return false; @@ -142,6 +173,7 @@ describe( 'AngularWizard', function() { }); it( "should go to next step because CANENTER is TRUE", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); scope.enterValidation = function(){ return true; @@ -156,6 +188,7 @@ describe( 'AngularWizard', function() { }); it( "should NOT go to next step because CANENTER is FALSE", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); scope.enterValidation = function(){ return false; @@ -170,6 +203,7 @@ describe( 'AngularWizard', function() { }); it( "should NOT return to a previous step. Although CANEXIT is false and we are heading to a previous state, the can enter validation is false", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); scope.stepValidation = function(){ return false; @@ -187,6 +221,7 @@ describe( 'AngularWizard', function() { }); it( "should return to a previous step even though CANEXIT is false", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); scope.stepValidation = function(){ return false; @@ -201,6 +236,7 @@ describe( 'AngularWizard', function() { }); it( "should go to the next step because the promise that CANENTER returns resolves to true", function(done) { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); scope.enterValidation = function(){ var deferred = $q.defer(); @@ -220,6 +256,7 @@ describe( 'AngularWizard', function() { }); it( "should go to the next step because CANEXIT is set to true", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var view = createView(scope); scope.exitValidation = true; expect(scope.referenceCurrentStep).toEqual('Starting'); @@ -232,6 +269,7 @@ describe( 'AngularWizard', function() { }); it( "should finish", function() { var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; var flag = false; scope.finishedWizard = function() { flag = true; }; var view = createView(scope); From 8ed0d71bf02fbf3c90ebf2fe03842fc35b95ad87 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 24 Aug 2015 10:22:40 -0700 Subject: [PATCH 090/185] Project Build --- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 823da4c..d1dce90 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.3 - 2015-08-23 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.4 - 2015-08-24 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index c5f653e..9910a82 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.3 - 2015-08-23 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.4 - 2015-08-24 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ From 04356c837c273ea48ef237adc8d72372b67500ba Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Mon, 24 Aug 2015 10:25:12 -0700 Subject: [PATCH 091/185] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb50cb1..a159f66 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ You can download this by: - - + + ```` The dist folder contains the following files: @@ -78,6 +78,7 @@ Let's go step by step to see how this works. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. * **current-step**: You need to set here a property from your scope (similar to `ng-model`) and that property will always have the name of the current step being shown on the screen. * **template**: Path to a custom template. +* **wz-disabled**: expression that when evaluated to `true` will remove said step from the wizard 2) Inside the wizard, we can have as many steps as we want. Each step MUST have a title which is going to be used to identify it. Inside each step, we can put whatever we want. Other directives, bindings, controls, forms, etc. From 0c13c296bcff69cc131b0803c971a00e65432d63 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 25 Aug 2015 11:38:46 -0700 Subject: [PATCH 092/185] Updated README.md --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index a159f66..ffa61f4 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,37 @@ All of this attributes can receive an optional function to be called before chan In this case, the `setMode` function will be called before going to the next step. +## Wizard Dynamic Steps +A step can be conditionally disabled and may change at any time either adding it or removing it from the wizard step flow. + + **Example** + +HTML +````html + + +

      This is the first step

      +

      Here you can use whatever you want. You can use other directives, binding, etc.

      + +
      + +

      Continuing

      +

      You have continued here!

      + +
      + +

      Even more steps!!

      + +
      +
      +```` +Controller +````javascript +//this will cause the step to be hidden +$scope.disabled = 'true'; +```` + + ## Wizard Step Validation The wzStep directive has the following options as attributes: * **canexit**: Here you can reference a function from your controller. If this attribute is listed the funtion must return true in order for the wizard to move to the next step. Promises are supported but must resolve with a thruthy value. If it is ommitted no validation will be required. From 291763f80a99491e7de6f122887a65da150f2449 Mon Sep 17 00:00:00 2001 From: Andreas Bade Date: Fri, 4 Sep 2015 22:00:26 +0200 Subject: [PATCH 093/185] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ffa61f4..8aaf00d 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ You can download this by: - + ```` From 7137b7c9336e1dd53fa142a416b2f02caf3ab9ae Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 21 Sep 2015 14:34:43 -0700 Subject: [PATCH 094/185] bump to version 0.5.5 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index efbe274..9607458 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.5.4", + "version": "0.5.5", "main": [ "./dist/angular-wizard.min.js", "./dist/angular-wizard.min.css" diff --git a/package.json b/package.json index 8c6d60e..987a6b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.5.4", + "version": "0.5.5", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 99e6f7c7876d6e09c7ea3b7e9d9774f2c42b6e07 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 21 Sep 2015 14:34:56 -0700 Subject: [PATCH 095/185] removed testing with Phantom --- karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index 997c655..fbc77e3 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -59,7 +59,7 @@ module.exports = function(config) { // - Safari (only Mac) // - PhantomJS // - IE (only Windows) - browsers: ['Chrome', 'Firefox', 'PhantomJS'], + browsers: ['Chrome', 'Firefox'], // If browser does not capture in given timeout [ms], kill it From eecbc09eef0ba33d3dcb4b88929003f8196b3d1c Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 21 Sep 2015 14:35:13 -0700 Subject: [PATCH 096/185] added get current step title method --- src/wizard.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wizard.js b/src/wizard.js index 5fa6450..aa0c810 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -191,6 +191,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + this.currentStepTitle = function(){ + return $scope.selectedStep.title; + }; + //Access to current step number from outside this.currentStepNumber = function(){ return $scope.currentStepNumber(); From 9990913f2b070d568790898d501e3483d276f733 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 21 Sep 2015 14:35:23 -0700 Subject: [PATCH 097/185] Project Build --- dist/angular-wizard.js | 6 +++++- dist/angular-wizard.min.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index d1dce90..3b7f4a7 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.4 - 2015-08-24 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.5 - 2015-09-21 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -243,6 +243,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + this.currentStepTitle = function(){ + return $scope.selectedStep.title; + }; + //Access to current step number from outside this.currentStepNumber = function(){ return $scope.currentStepNumber(); diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 9910a82..14b8f22 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.4 - 2015-08-24 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.5 - 2015-09-21 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.getEnabledSteps()[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.getEnabledSteps(),b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.getEnabledSteps(),a.selectedStep)+1},a.getEnabledSteps=function(){return _.filter(a.steps,function(a){return"true"!==a.disabled})},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=_.indexOf(c,a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){var c,d=a.getEnabledSteps();c=_.isNumber(b)?d[b]:_.findWhere(d,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=_.indexOf(a.getEnabledSteps(),a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=_.indexOf(a.getEnabledSteps(),a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.getEnabledSteps()[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.getEnabledSteps(),b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.getEnabledSteps(),a.selectedStep)+1},a.getEnabledSteps=function(){return _.filter(a.steps,function(a){return"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.title},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=_.indexOf(c,a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){var c,d=a.getEnabledSteps();c=_.isNumber(b)?d[b]:_.findWhere(d,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=_.indexOf(a.getEnabledSteps(),a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=_.indexOf(a.getEnabledSteps(),a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 0c9f0b392f4333637a2a26f01eb6c3f289d49b57 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Mon, 21 Sep 2015 14:41:49 -0700 Subject: [PATCH 098/185] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8aaf00d..31c8749 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ You can download this by: - - + + ```` The dist folder contains the following files: @@ -204,6 +204,7 @@ The functions available in the `wizard()` are: * **finish**: Finishes the wizard. * **goTo(number|title)**: This goes to the indicated step. It can receive either the number of the step (starting from 0) or the title of the step to go to. * **currentStepNumber()**: This returns a Number which is the current step number you are on. +* **currentStepTitle()**: This returns a String which is the title of the step you are on. ## Navigation bar From 3edf5ce0bd03ea4e961ef2d9554c2ae271d6cf17 Mon Sep 17 00:00:00 2001 From: jjust Date: Thu, 5 Nov 2015 12:10:38 +0100 Subject: [PATCH 099/185] Support custom onCancel function defined in the linked controller. --- src/wizard.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index aa0c810..7550efb 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -6,6 +6,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { transclude: true, scope: { currentStep: '=', + onCancel: '&', onFinish: '&', hideIndicators: '=', editMode: '=', @@ -268,14 +269,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //cancel is alias for previous. this.cancel = function() { - //getting index of current step - var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); - //ensuring you aren't trying to go back from the first step - if (index === 0) { - throw new Error("Can't go back. It's already in step 0"); + if ($scope.onCancel) { + //onCancel is linked to controller via wizard directive: + $scope.onCancel(); } else { - //go back one step from current step - $scope.goTo($scope.getEnabledSteps()[0]); + //getting index of current step + var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); + //ensuring you aren't trying to go back from the first step + if (index === 0) { + throw new Error("Can't go back. It's already in step 0"); + } else { + //go back one step from current step + $scope.goTo($scope.getEnabledSteps()[0]); + } } }; }] From cba6735765c75d2b529ec3b3e7d70aad5d213f1e Mon Sep 17 00:00:00 2001 From: Nathan Abu Date: Sat, 7 Nov 2015 18:11:20 +0200 Subject: [PATCH 100/185] Fix type in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31c8749..c341cea 100644 --- a/README.md +++ b/README.md @@ -128,8 +128,8 @@ $scope.disabled = 'true'; ## Wizard Step Validation The wzStep directive has the following options as attributes: -* **canexit**: Here you can reference a function from your controller. If this attribute is listed the funtion must return true in order for the wizard to move to the next step. Promises are supported but must resolve with a thruthy value. If it is ommitted no validation will be required. -* **canenter**: Here you can reference a function from your controller. If this attribute is listed the funtion must return true in order for the wizard to move into this step. Promises are supported but must resolve with a thruthy value. If it is ommitted no validation will be required. +* **canexit**: Here you can reference a function from your controller. If this attribute is listed the function must return true in order for the wizard to move to the next step. Promises are supported but must resolve with a thruthy value. If it is ommitted no validation will be required. +* **canenter**: Here you can reference a function from your controller. If this attribute is listed the function must return true in order for the wizard to move into this step. Promises are supported but must resolve with a thruthy value. If it is ommitted no validation will be required. **Example** From da98ba5e9fec7628054f34b0dd981a8103fa2546 Mon Sep 17 00:00:00 2001 From: jjust Date: Fri, 13 Nov 2015 07:18:44 +0100 Subject: [PATCH 101/185] fix indention and documented on-cancel in readme --- README.md | 5 +++-- src/wizard.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 31c8749..5846ad2 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ angular.module('your-app', ['mgo-angular-wizard']); Now, in some HTML for a controller, you can just add a wizard as follows: ````html - +

      This is the first step

      Here you can use whatever you want. You can use other directives, binding, etc.

      @@ -73,6 +73,7 @@ Let's go step by step to see how this works. 1) You need to declare a master `wizard` directive. This wizard directive, has the following options as attributes: * **on-finish**: Here you can put a function to be called when the wizard is finished. The syntax here is very similar to `ng-click` +* **on-cancel**: Here you can put a function to be called when the wizard is cancelled. The syntax here is very similar to `ng-click` * **name**: The name of the wizard. By default, it's called "Default wizard". It's used for the `WizardHandler` which we'll explain later. * **edit-mode**: If set to true, this will set the wizard as edit mode. Edit mode means that all steps have been completed and the user can now navigate to and modify any step. Defaults to false. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. @@ -102,7 +103,7 @@ A step can be conditionally disabled and may change at any time either adding it HTML ````html - +

      This is the first step

      Here you can use whatever you want. You can use other directives, binding, etc.

      diff --git a/src/wizard.js b/src/wizard.js index 7550efb..50a1b92 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -270,8 +270,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //cancel is alias for previous. this.cancel = function() { if ($scope.onCancel) { - //onCancel is linked to controller via wizard directive: - $scope.onCancel(); + //onCancel is linked to controller via wizard directive: + $scope.onCancel(); } else { //getting index of current step var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); From 930f2a1b8cb0c8758fc90558576f9ccb29394fe7 Mon Sep 17 00:00:00 2001 From: jjust Date: Fri, 13 Nov 2015 07:19:54 +0100 Subject: [PATCH 102/185] indention --- src/wizard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index 50a1b92..460ea6b 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -270,8 +270,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //cancel is alias for previous. this.cancel = function() { if ($scope.onCancel) { - //onCancel is linked to controller via wizard directive: - $scope.onCancel(); + //onCancel is linked to controller via wizard directive: + $scope.onCancel(); } else { //getting index of current step var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); From 46ed1c95fcda46452f0131692a06dc057e76ac0c Mon Sep 17 00:00:00 2001 From: jjust Date: Fri, 13 Nov 2015 07:26:20 +0100 Subject: [PATCH 103/185] more doc --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5846ad2..b6e6132 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Let's go step by step to see how this works. 3) Inside the step, we now see a button which has a `wz-next` attribute. That means that clicking that button will send the user to the next step of wizard. Similar to `wz-next`, we have the following attributes: * **wz-previous**: Goes to the previous step -* **wz-cancel**: Goes back to the first step +* **wz-cancel**: Calls on-cancel if defined, otherwise the default action is to go back to the first step * **wz-finish**: Finishes the wizard and calls the on-finish later on. It's important to note that if we're in the last step and we put `wz-next` it'll be the same as putting `wz-finish` as the wizard will know we're at the last screen. All of this attributes can receive an optional function to be called before changing the step. Something like: @@ -136,7 +136,7 @@ The wzStep directive has the following options as attributes: HTML ````html - +

      This is the first step

      Here you can use whatever you want. You can use other directives, binding, etc.

      From 21f51cc19dc86d9e5b334ddae13c762f4540467f Mon Sep 17 00:00:00 2001 From: jjust Date: Wed, 18 Nov 2015 09:45:49 +0100 Subject: [PATCH 104/185] We need validation in the wizard, but we only want to display the validation errors when the user clicks next, added an event to support this. --- src/wizard.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wizard.js b/src/wizard.js index 460ea6b..8d6064e 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -118,6 +118,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //emit event upwards with data on goTo() invoktion $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); //$log.log('current step number: ', $scope.currentStepNumber()); + } else { + $scope.$emit('wizard:stepChangedFailed', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); } }); } From 3acd1122b65ccf0c2c0ddd3cdc6d5b87d7428864 Mon Sep 17 00:00:00 2001 From: jjust Date: Wed, 18 Nov 2015 09:48:33 +0100 Subject: [PATCH 105/185] event name --- src/wizard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wizard.js b/src/wizard.js index 8d6064e..2ea766e 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -119,7 +119,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); //$log.log('current step number: ', $scope.currentStepNumber()); } else { - $scope.$emit('wizard:stepChangedFailed', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); + $scope.$emit('wizard:stepChangeFailed', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); } }); } From 3ddcb21be4d42d7c4bef81f30c77b53341ba448b Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 24 Dec 2015 17:15:56 -0700 Subject: [PATCH 106/185] corrected error causing step title to never be set --- src/wizard.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index aa0c810..e79ce66 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -81,10 +81,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //deselect all steps so you can set fresh below unselectAll(); $scope.selectedStep = step; - //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; - } + $scope.currentStep = step.title || step.wzTitle; //setting selected step to argument passed into goTo() step.selected = true; //emit event upwards with data on goTo() invoktion From 6c1ed6e07b8cfd4372f435e55a729759945916e2 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 24 Dec 2015 17:26:09 -0700 Subject: [PATCH 107/185] fixed error causing canexit function to call twice --- src/wizard.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wizard.js b/src/wizard.js index e79ce66..e94d26f 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -161,8 +161,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { defer.resolve(response); }); return defer.promise; + } else { + return canExit === true; } - return step.canexit($scope.context) === true; } $scope.currentStepNumber = function() { From 609a986ebbe882adf9f99acd78a272f5d5fe64a8 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 24 Dec 2015 17:27:25 -0700 Subject: [PATCH 108/185] fixed error causing canenter function to call twice --- src/wizard.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wizard.js b/src/wizard.js index e94d26f..0745f16 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -138,8 +138,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { defer.resolve(response); }); return defer.promise; + } else { + return canEnter === true; } - return step.canenter($scope.context) === true; } function canExitStep(step, stepTo) { From d4f4b8a7511d6e5e5ffb5f81c8cd52e7430820d8 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Thu, 24 Dec 2015 17:39:17 -0700 Subject: [PATCH 109/185] corrected issue that only allowed edit mode to toggle once --- src/wizard.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wizard.js b/src/wizard.js index 0745f16..2402e27 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -55,6 +55,13 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { _.each($scope.getEnabledSteps(), function(step) { step.completed = true; }); + } else { + var completedStepsIndex = $scope.currentStepNumber() - 1; + angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { + if(stepIndex >= completedStepsIndex) { + step.completed = false; + } + }); } }, true); From 3ffdbbc830003b980664888f5fce30ec5e46ca2e Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 25 Dec 2015 00:02:11 -0700 Subject: [PATCH 110/185] added reset button --- src/wizard.js | 10 ++++++++++ src/wizardButtons.js | 1 + 2 files changed, 11 insertions(+) diff --git a/src/wizard.js b/src/wizard.js index 2402e27..6b022e8 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -284,6 +284,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo($scope.getEnabledSteps()[0]); } }; + + //reset + this.reset = function(){ + //traverse steps array and set each "completed" property to false + angular.forEach($scope.getEnabledSteps(), function (step) { + step.completed = false; + }); + //go to first step + this.goTo(0); + }; }] }; }); \ No newline at end of file diff --git a/src/wizardButtons.js b/src/wizardButtons.js index dd596d5..0afb46f 100644 --- a/src/wizardButtons.js +++ b/src/wizardButtons.js @@ -23,3 +23,4 @@ wizardButtonDirective('wzNext'); wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); +wizardButtonDirective('wzReset'); From 5aed118b45543c288f34c06313bc9d6474431abb Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 25 Dec 2015 00:35:59 -0700 Subject: [PATCH 111/185] added step description and service methods for retrieving description and step data --- src/step.js | 3 ++- src/wizard.js | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/step.js b/src/step.js index 7603e67..58b005f 100644 --- a/src/step.js +++ b/src/step.js @@ -8,7 +8,8 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { title: '@', canenter : '=', canexit : '=', - disabled: '@?wzDisabled' + disabled: '@?wzDisabled', + description: '@' }, require: '^wizard', templateUrl: function(element, attributes) { diff --git a/src/wizard.js b/src/wizard.js index 6b022e8..fd5e4b7 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -197,6 +197,14 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + this.currentStepDescription = function(){ + return $scope.selectedStep.description; + }; + + this.currentStep = function(){ + return $scope.selectedStep; + }; + this.currentStepTitle = function(){ return $scope.selectedStep.title; }; From 0fa455c950190ac4d8b3b5dc770e77747b6ffa68 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Fri, 25 Dec 2015 00:38:48 -0700 Subject: [PATCH 112/185] get total step count --- src/wizard.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wizard.js b/src/wizard.js index fd5e4b7..ebca540 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -213,6 +213,12 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.currentStepNumber = function(){ return $scope.currentStepNumber(); }; + + //Access to current step number from outside + this.getStepCount = function(){ + return $scope.getEnabledSteps().length; + }; + //method used for next button within step this.next = function(callback) { var enabledSteps = $scope.getEnabledSteps(); From b37185f904506f0f5e7685db886466b826248c74 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 28 Dec 2015 22:20:21 -0700 Subject: [PATCH 113/185] removed lodash dependency --- bower.json | 1 - dist/angular-wizard.js | 107 +++++++++++++++++++++++++++---------- dist/angular-wizard.less | 25 ++++----- dist/angular-wizard.min.js | 4 +- src/step.js | 3 +- src/wizard.js | 78 +++++++++++++++++---------- test/angularWizardSpec.js | 8 +-- 7 files changed, 150 insertions(+), 76 deletions(-) diff --git a/bower.json b/bower.json index 9607458..6c2df4f 100644 --- a/bower.json +++ b/bower.json @@ -11,7 +11,6 @@ "url": "git://github.com/mgonto/angular-wizard.git" }, "dependencies": { - "lodash": ">=1.3.0 <2.5.0", "angular": "*" }, "ignore": [ diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 3b7f4a7..e1233ab 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.5 - 2015-09-21 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.5 - 2015-12-28 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -34,17 +34,17 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { transclude: true, scope: { wzTitle: '@', - title: '@', canenter : '=', canexit : '=', - disabled: '@?wzDisabled' + disabled: '@?wzDisabled', + description: '@' }, require: '^wizard', templateUrl: function(element, attributes) { return attributes.template || "step.html"; }, link: function($scope, $element, $attrs, wizard) { - $scope.title = $scope.title || $scope.wzTitle; + $scope.title = $scope.wzTitle; wizard.addStep($scope); } }; @@ -81,6 +81,28 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //steps array where all the scopes of each step are added $scope.steps = []; + var stepIdx = function(step) { + var idx = 0; + var res = -1; + angular.forEach($scope.getEnabledSteps(), function(currStep) { + if (currStep === step) { + res = idx; + } + idx++; + }); + return res; + }; + + var stepByTitle = function(titleToFind) { + var foundStep = null; + angular.forEach($scope.getEnabledSteps(), function(step) { + if (step.wzTitle === titleToFind) { + foundStep = step; + } + }); + return foundStep; + }; + //access to context object for step validation $scope.context = {}; @@ -89,10 +111,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //checking to make sure currentStep is truthy value if (!step) return; //setting stepTitle equal to current step title or default title - var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; + var stepTitle = $scope.selectedStep.wzTitle; if ($scope.selectedStep && stepTitle !== $scope.currentStep) { //invoking goTo() with step title as argument - $scope.goTo(_.findWhere($scope.getEnabledSteps(), {title: $scope.currentStep})); + $scope.goTo(stepByTitle($scope.currentStep)); } }); @@ -101,12 +123,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //if edit mode is truthy, then all steps are marked as completed $scope.$watch('[editMode, steps.length]', function() { var editMode = $scope.editMode; - if (_.isUndefined(editMode) || _.isNull(editMode)) return; + if (angular.isUndefined(editMode) || (editMode === null)) return; if (editMode) { - _.each($scope.getEnabledSteps(), function(step) { + angular.forEach($scope.getEnabledSteps(), function(step) { step.completed = true; }); + } else { + var completedStepsIndex = $scope.currentStepNumber() - 1; + angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { + if(stepIndex >= completedStepsIndex) { + step.completed = false; + } + }); } }, true); @@ -124,7 +153,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.context = $scope.context; $scope.getStepNumber = function(step) { - return _.indexOf($scope.getEnabledSteps(), step) + 1; + return stepIdx(step) + 1; }; $scope.goTo = function(step) { @@ -134,13 +163,13 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { unselectAll(); $scope.selectedStep = step; //making sure current step is not undefined - if (!_.isUndefined($scope.currentStep)) { - $scope.currentStep = step.title || step.wzTitle; + if (!angular.isUndefined($scope.currentStep)) { + $scope.currentStep = step.wzTitle; } //setting selected step to argument passed into goTo() step.selected = true; //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps() , step)}); + $scope.$emit('wizard:stepChanged', {step: step, index: stepIdx(step)}); //setting variable to false so all other step changes must pass validation firstRun = false; } else { @@ -161,13 +190,13 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //$log.log('value for canExit argument: ', $scope.currentStep.canexit); $scope.selectedStep = step; //making sure current step is not undefined - if(!_.isUndefined($scope.currentStep)){ - $scope.currentStep = step.title || step.wzTitle; + if(!angular.isUndefined($scope.currentStep)){ + $scope.currentStep = step.wzTitle; } //setting selected step to argument passed into goTo() step.selected = true; //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); + $scope.$emit('wizard:stepChanged', {step: step, index: stepIdx(step)}); //$log.log('current step number: ', $scope.currentStepNumber()); } }); @@ -193,8 +222,9 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { defer.resolve(response); }); return defer.promise; + } else { + return canEnter === true; } - return step.canenter($scope.context) === true; } function canExitStep(step, stepTo) { @@ -216,17 +246,18 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { defer.resolve(response); }); return defer.promise; + } else { + return canExit === true; } - return step.canexit($scope.context) === true; } $scope.currentStepNumber = function() { //retreive current step number - return _.indexOf($scope.getEnabledSteps() , $scope.selectedStep) + 1; + return stepIdx($scope.selectedStep) + 1; }; $scope.getEnabledSteps = function() { - return _.filter($scope.steps, function(step){ + return $scope.steps.filter(function(step){ return step.disabled !== 'true'; }); }; @@ -234,7 +265,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //unSelect All Steps function unselectAll() { //traverse steps array and set each "selected" property to false - _.each($scope.getEnabledSteps(), function (step) { + angular.forEach($scope.getEnabledSteps(), function (step) { step.selected = false; }); //set selectedStep variable to null @@ -244,9 +275,21 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() this.currentStepTitle = function(){ - return $scope.selectedStep.title; + return $scope.selectedStep.wzTitle; }; + this.currentStepDescription = function(){ + return $scope.selectedStep.description; + }; + + this.currentStep = function(){ + return $scope.selectedStep; + }; + + this.totalStepCount = function() { + return $scope.getEnabledSteps().length; + } + //Access to current step number from outside this.currentStepNumber = function(){ return $scope.currentStepNumber(); @@ -255,7 +298,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.next = function(callback) { var enabledSteps = $scope.getEnabledSteps(); //setting variable equal to step you were on when next() was invoked - var index = _.indexOf(enabledSteps, $scope.selectedStep); + var index = stepIdx($scope.selectedStep); //checking to see if callback is a function if(angular.isFunction(callback)){ if(callback()){ @@ -288,11 +331,11 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { var enabledSteps = $scope.getEnabledSteps(); var stepTo; //checking that step is a Number - if (_.isNumber(step)) { + if (angular.isNumber(step)) { stepTo = enabledSteps[step]; } else { //finding the step associated with the title entered as goTo argument - stepTo = _.findWhere(enabledSteps, {title: step}); + stepTo = stepByTitle(step); } //going to step $scope.goTo(stepTo); @@ -304,11 +347,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.onFinish(); } }; - this.previous = function() { //getting index of current step - var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); + var index = stepIdx($scope.selectedStep); //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); @@ -321,7 +363,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //cancel is alias for previous. this.cancel = function() { //getting index of current step - var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); + var index = stepIdx($scope.selectedStep); //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); @@ -330,6 +372,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo($scope.getEnabledSteps()[0]); } }; + + //reset + this.reset = function(){ + //traverse steps array and set each "completed" property to false + angular.forEach($scope.getEnabledSteps(), function (step) { + step.completed = false; + }); + //go to first step + this.goTo(0); + }; }] }; }); @@ -358,6 +410,7 @@ wizardButtonDirective('wzNext'); wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); +wizardButtonDirective('wzReset'); angular.module('mgo-angular-wizard').factory('WizardHandler', function() { var service = {}; diff --git a/dist/angular-wizard.less b/dist/angular-wizard.less index 9556344..5f13666 100644 --- a/dist/angular-wizard.less +++ b/dist/angular-wizard.less @@ -1,10 +1,11 @@ +@wz-color-default: #E6E6E6; +@wz-color-current: #808080; +@wz-color-done: #339933; +@wz-color-editing: #FF0000; + .steps-indicator { /* ---- steps quantity ---- */ - @color-default: #E6E6E6; - @color-current: #808080; - @color-done: #339933; - @color-editing: #FF0000; right: 0; bottom: 0; @@ -17,7 +18,7 @@ &:before { - background-color: @color-default; + background-color: @wz-color-default; content: ''; position: absolute; height: 1px; @@ -86,7 +87,7 @@ line-height: 15px; a { - color: @color-current; + color: @wz-color-current; text-decoration: none; text-transform: uppercase; font-weight: bold; @@ -100,13 +101,13 @@ width: 14px; height: 14px; border-radius: 100%; - background-color: @color-default; + background-color: @wz-color-default; content: ''; transition: 0.25s; } &:hover { - color: darken(@color-current, 20%); + color: darken(@wz-color-current, 20%); } } } @@ -155,7 +156,7 @@ pointer-events: none; a:hover { - color: @color-current; + color: @wz-color-current; } } @@ -165,14 +166,14 @@ } li.current a:before { - background-color: @color-current; + background-color: @wz-color-current; } li.done a:before { - background-color: @color-done; + background-color: @wz-color-done; } li.editing a:before { - background-color: @color-editing; + background-color: @wz-color-editing; } } diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 14b8f22..07a300c 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.5 - 2015-09-21 * @link https://github.com/mgonto/angular-wizard + * @version v0.5.5 - 2015-12-28 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",title:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.title||a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):b.canenter(a.context)===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.getEnabledSteps()[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,_.isUndefined(a.currentStep)||(a.currentStep=b.title||b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:_.indexOf(a.getEnabledSteps(),b)}))})}},a.currentStepNumber=function(){return _.indexOf(a.getEnabledSteps(),a.selectedStep)+1},a.getEnabledSteps=function(){return _.filter(a.steps,function(a){return"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.title},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=_.indexOf(c,a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){var c,d=a.getEnabledSteps();c=_.isNumber(b)?d[b]:_.findWhere(d,{title:b}),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=_.indexOf(a.getEnabledSteps(),a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=_.indexOf(a.getEnabledSteps(),a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){a.steps.push(b),1===a.getEnabledSteps().length&&a.goTo(a.getEnabledSteps()[0])},this.context=a.context,a.getStepNumber=function(a){return j(a)+1},a.goTo=function(b){if(i)h(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:j(b)}),i=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.getEnabledSteps()[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:j(b)}))})}},a.currentStepNumber=function(){return j(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=j(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:k(b),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=j(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=j(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file diff --git a/src/step.js b/src/step.js index 58b005f..8db7793 100644 --- a/src/step.js +++ b/src/step.js @@ -5,7 +5,6 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { transclude: true, scope: { wzTitle: '@', - title: '@', canenter : '=', canexit : '=', disabled: '@?wzDisabled', @@ -16,7 +15,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { return attributes.template || "step.html"; }, link: function($scope, $element, $attrs, wizard) { - $scope.title = $scope.title || $scope.wzTitle; + $scope.title = $scope.wzTitle; wizard.addStep($scope); } }; diff --git a/src/wizard.js b/src/wizard.js index ebca540..524f4bb 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -29,6 +29,28 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //steps array where all the scopes of each step are added $scope.steps = []; + var stepIdx = function(step) { + var idx = 0; + var res = -1; + angular.forEach($scope.getEnabledSteps(), function(currStep) { + if (currStep === step) { + res = idx; + } + idx++; + }); + return res; + }; + + var stepByTitle = function(titleToFind) { + var foundStep = null; + angular.forEach($scope.getEnabledSteps(), function(step) { + if (step.wzTitle === titleToFind) { + foundStep = step; + } + }); + return foundStep; + }; + //access to context object for step validation $scope.context = {}; @@ -37,10 +59,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //checking to make sure currentStep is truthy value if (!step) return; //setting stepTitle equal to current step title or default title - var stepTitle = $scope.selectedStep.title || $scope.selectedStep.wzTitle; + var stepTitle = $scope.selectedStep.wzTitle; if ($scope.selectedStep && stepTitle !== $scope.currentStep) { //invoking goTo() with step title as argument - $scope.goTo(_.findWhere($scope.getEnabledSteps(), {title: $scope.currentStep})); + $scope.goTo(stepByTitle($scope.currentStep)); } }); @@ -49,10 +71,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //if edit mode is truthy, then all steps are marked as completed $scope.$watch('[editMode, steps.length]', function() { var editMode = $scope.editMode; - if (_.isUndefined(editMode) || _.isNull(editMode)) return; + if (angular.isUndefined(editMode) || (editMode === null)) return; if (editMode) { - _.each($scope.getEnabledSteps(), function(step) { + angular.forEach($scope.getEnabledSteps(), function(step) { step.completed = true; }); } else { @@ -79,7 +101,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.context = $scope.context; $scope.getStepNumber = function(step) { - return _.indexOf($scope.getEnabledSteps(), step) + 1; + return stepIdx(step) + 1; }; $scope.goTo = function(step) { @@ -88,11 +110,14 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //deselect all steps so you can set fresh below unselectAll(); $scope.selectedStep = step; - $scope.currentStep = step.title || step.wzTitle; + //making sure current step is not undefined + if (!angular.isUndefined($scope.currentStep)) { + $scope.currentStep = step.wzTitle; + } //setting selected step to argument passed into goTo() step.selected = true; //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps() , step)}); + $scope.$emit('wizard:stepChanged', {step: step, index: stepIdx(step)}); //setting variable to false so all other step changes must pass validation firstRun = false; } else { @@ -113,13 +138,13 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //$log.log('value for canExit argument: ', $scope.currentStep.canexit); $scope.selectedStep = step; //making sure current step is not undefined - if(!_.isUndefined($scope.currentStep)){ - $scope.currentStep = step.title || step.wzTitle; + if(!angular.isUndefined($scope.currentStep)){ + $scope.currentStep = step.wzTitle; } //setting selected step to argument passed into goTo() step.selected = true; //emit event upwards with data on goTo() invoktion - $scope.$emit('wizard:stepChanged', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); + $scope.$emit('wizard:stepChanged', {step: step, index: stepIdx(step)}); //$log.log('current step number: ', $scope.currentStepNumber()); } }); @@ -176,11 +201,11 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.currentStepNumber = function() { //retreive current step number - return _.indexOf($scope.getEnabledSteps() , $scope.selectedStep) + 1; + return stepIdx($scope.selectedStep) + 1; }; $scope.getEnabledSteps = function() { - return _.filter($scope.steps, function(step){ + return $scope.steps.filter(function(step){ return step.disabled !== 'true'; }); }; @@ -188,7 +213,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //unSelect All Steps function unselectAll() { //traverse steps array and set each "selected" property to false - _.each($scope.getEnabledSteps(), function (step) { + angular.forEach($scope.getEnabledSteps(), function (step) { step.selected = false; }); //set selectedStep variable to null @@ -197,6 +222,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() + this.currentStepTitle = function(){ + return $scope.selectedStep.wzTitle; + }; + this.currentStepDescription = function(){ return $scope.selectedStep.description; }; @@ -205,25 +234,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return $scope.selectedStep; }; - this.currentStepTitle = function(){ - return $scope.selectedStep.title; - }; + this.totalStepCount = function() { + return $scope.getEnabledSteps().length; + } //Access to current step number from outside this.currentStepNumber = function(){ return $scope.currentStepNumber(); }; - - //Access to current step number from outside - this.getStepCount = function(){ - return $scope.getEnabledSteps().length; - }; - //method used for next button within step this.next = function(callback) { var enabledSteps = $scope.getEnabledSteps(); //setting variable equal to step you were on when next() was invoked - var index = _.indexOf(enabledSteps, $scope.selectedStep); + var index = stepIdx($scope.selectedStep); //checking to see if callback is a function if(angular.isFunction(callback)){ if(callback()){ @@ -256,11 +279,11 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { var enabledSteps = $scope.getEnabledSteps(); var stepTo; //checking that step is a Number - if (_.isNumber(step)) { + if (angular.isNumber(step)) { stepTo = enabledSteps[step]; } else { //finding the step associated with the title entered as goTo argument - stepTo = _.findWhere(enabledSteps, {title: step}); + stepTo = stepByTitle(step); } //going to step $scope.goTo(stepTo); @@ -272,11 +295,10 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.onFinish(); } }; - this.previous = function() { //getting index of current step - var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); + var index = stepIdx($scope.selectedStep); //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); @@ -289,7 +311,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //cancel is alias for previous. this.cancel = function() { //getting index of current step - var index = _.indexOf($scope.getEnabledSteps() , $scope.selectedStep); + var index = stepIdx($scope.selectedStep); //ensuring you aren't trying to go back from the first step if (index === 0) { throw new Error("Can't go back. It's already in step 0"); diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index cbfe8c3..9362399 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -20,22 +20,22 @@ describe( 'AngularWizard', function() { function createView(scope) { scope.referenceCurrentStep = null; var element = angular.element('' - + ' ' + + ' ' + '

      This is the first step

      ' + '

      Here you can use whatever you want. You can use other directives, binding, etc.

      ' + ' ' + '
      ' - + ' ' + + ' ' + '

      Dynamic {{dynamicStepDisabled}}

      ' + '

      You have continued here!

      ' + ' ' + '
      ' - + ' ' + + ' ' + '

      Continuing

      ' + '

      You have continued here!

      ' + ' ' + '
      ' - + ' ' + + ' ' + '

      Even more steps!!

      ' + ' ' + '
      ' From c68531725a6ab5c5082ab9f5c390b4f4e33c8cbc Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 28 Dec 2015 22:24:18 -0700 Subject: [PATCH 114/185] project build --- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index e1233ab..4575bbc 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.5 - 2015-12-28 * @link https://github.com/mgonto/angular-wizard + * @version v0.6.0 - 2015-12-28 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 07a300c..8a85090 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.5.5 - 2015-12-28 * @link https://github.com/mgonto/angular-wizard + * @version v0.6.0 - 2015-12-28 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ From fee70e7638a05fd01b77e1ffca874ac8670539a6 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Mon, 28 Dec 2015 22:25:36 -0700 Subject: [PATCH 115/185] release version 0.6.0 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 6c2df4f..c31edc4 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.5.5", + "version": "0.6.0", "main": [ "./dist/angular-wizard.min.js", "./dist/angular-wizard.min.css" diff --git a/package.json b/package.json index 987a6b3..89e42ce 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.5.5", + "version": "0.6.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 4f108232530378044bc9ae0de488414c7e169e86 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 31 Dec 2015 09:07:02 -0700 Subject: [PATCH 116/185] Re-Pushing for Bower update to 0.6.0 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index c31edc4..a9610ba 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,7 @@ "./dist/angular-wizard.min.js", "./dist/angular-wizard.min.css" ], - "description": "Easy to use Wizard library for AngularJS", + "description": "Easy to use Wizard library for AngularJS ", "repository": { "type": "git", "url": "git://github.com/mgonto/angular-wizard.git" From 6a3e6fc1505ff0eca5f19a86e335b9264c03ec33 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 31 Dec 2015 10:04:59 -0700 Subject: [PATCH 117/185] adding step description and ability to get enabled steps --- src/step.js | 3 ++- src/wizard.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/step.js b/src/step.js index 8db7793..2a26625 100644 --- a/src/step.js +++ b/src/step.js @@ -8,7 +8,8 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { canenter : '=', canexit : '=', disabled: '@?wzDisabled', - description: '@' + description: '@', + wzData: '=' }, require: '^wizard', templateUrl: function(element, attributes) { diff --git a/src/wizard.js b/src/wizard.js index 524f4bb..f820000 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -238,6 +238,11 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return $scope.getEnabledSteps().length; } + //Access to enabled steps from outside + this.getEnabledSteps = function(){ + return $scope.getEnabledSteps(); + }; + //Access to current step number from outside this.currentStepNumber = function(){ return $scope.currentStepNumber(); From 6295369c60c17c3f9e98c3fcdfc4c589e17bd2ba Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 31 Dec 2015 10:05:15 -0700 Subject: [PATCH 118/185] update README.md with new features --- README.md | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 31ee229..c85aae3 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Angular-wizard is a component that will make it easy for you to create wizards i # How do I add this to my project? You can download this by: -* Using bower and running bower install angular-wizard -* Using npm and running npm install angular-wizard +* Using bower and running `bower install angular-wizard` +* Using npm and running `npm install angular-wizard` * Downloading it manually by getting the files from the dist folder * Using JsDelivr CDN files: @@ -19,8 +19,8 @@ You can download this by: - - + + ```` The dist folder contains the following files: @@ -30,7 +30,7 @@ The dist folder contains the following files: * LESS file with styles for the directive. If you have less in your project, I recommend using the less instead of the CSS since it has variables to configure Wizard colors. # Dependencies -Angular-wizard depends on Angular and Lodash (or Underscore). +Angular-wizard depends on Angular. # Starter Guide @@ -78,14 +78,20 @@ Let's go step by step to see how this works. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. * **current-step**: You need to set here a property from your scope (similar to `ng-model`) and that property will always have the name of the current step being shown on the screen. * **template**: Path to a custom template. -* **wz-disabled**: expression that when evaluated to `true` will remove said step from the wizard -2) Inside the wizard, we can have as many steps as we want. Each step MUST have a title which is going to be used to identify it. Inside each step, we can put whatever we want. Other directives, bindings, controls, forms, etc. +2) Inside the wizard, we can have as many steps as we want. Each step MUST have a title which is going to be used to identify it. Inside each step, we can put whatever we want. Other directives, bindings, controls, forms, etc. Each step can have the following attributes (we will go into detail on each further below): +* **wz-title:** A unique title used for identifying each step. +* **canenter** +* **canexit** +* **wz-disabled** +* **description:** A description available to use in each step's UI. +* **wz-data** Data you wish to make available to the steps scope. 3) Inside the step, we now see a button which has a `wz-next` attribute. That means that clicking that button will send the user to the next step of wizard. Similar to `wz-next`, we have the following attributes: * **wz-previous**: Goes to the previous step * **wz-cancel**: Goes back to the first step * **wz-finish**: Finishes the wizard and calls the on-finish later on. It's important to note that if we're in the last step and we put `wz-next` it'll be the same as putting `wz-finish` as the wizard will know we're at the last screen. +* **wz-reset**: This will reset the wizard meaning bring the user to the first step and reset each step to being incomplete. All of this attributes can receive an optional function to be called before changing the step. Something like: @@ -199,16 +205,22 @@ $scope.changeLabelAndGoNext = function() { In this case, we're changing a label and moving forward on the steps. The functions available in the `wizard()` are: -* **next**: Goes to the next step -* **previous**: Goes to the previous step +* **next**: Goes to the next step. +* **previous**: Goes to the previous step. +* **cancel**: Goes to the previous step. +* **reset**: Goes to the first step and resets all steps to incomplete. * **finish**: Finishes the wizard. * **goTo(number|title)**: This goes to the indicated step. It can receive either the number of the step (starting from 0) or the title of the step to go to. * **currentStepNumber()**: This returns a Number which is the current step number you are on. * **currentStepTitle()**: This returns a String which is the title of the step you are on. +* **currentStepDescription()**: This returns a String which is the description of the step you are on. +* **currentStep()**: This returns an Object which is the current step you are on. +* **totalStepCount()**: This returns an Number which is the total number of **enabled** steps. +* **getEnabledSteps()**: This returns an Array which is the **enabled** steps. ## Navigation bar -The navigation bar shown below works in the following way: +Any changed you wish to make to the navigation bar can be done by overwritting the CSS. Because everyone wants the navigation bar in a different location and in a different style we have provided a default which you can change via your own HTML and CSS. The navigation bar shown below works in the following way: * Completed steps are painted as green * Current step is painted as dark grey From 39b4d3c881864b41a2e7cdb8652f76d5f7428802 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 31 Dec 2015 10:05:26 -0700 Subject: [PATCH 119/185] adding tests for new features --- test/angularWizardSpec.js | 62 +++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index 9362399..2b155db 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -13,14 +13,14 @@ describe( 'AngularWizard', function() { })); /** - * Create the view with wizard to test + * Create the generic view with wizard to test * @param {Scope} scope A scope to bind to * @return {[DOM element]} A DOM element compiled */ - function createView(scope) { + function createGenericView(scope) { scope.referenceCurrentStep = null; var element = angular.element('' - + ' ' + + ' ' + '

      This is the first step

      ' + '

      Here you can use whatever you want. You can use other directives, binding, etc.

      ' + ' ' @@ -47,7 +47,7 @@ describe( 'AngularWizard', function() { it("should correctly create the wizard", function() { var scope = $rootScope.$new(); - var view = createView(scope); + var view = createGenericView(scope); expect(WizardHandler).toBeTruthy(); expect(view.find('section').length).toEqual(4); // expect the correct step to be desirable one @@ -55,7 +55,7 @@ describe( 'AngularWizard', function() { }); it( "should go to the next step", function() { var scope = $rootScope.$new(); - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); $rootScope.$digest(); @@ -64,7 +64,7 @@ describe( 'AngularWizard', function() { it( "should render only those steps which are enabled", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); $rootScope.$digest(); @@ -72,7 +72,7 @@ describe( 'AngularWizard', function() { }); it( "should enable or disable dynamic steps based on conditions", function() { var scope = $rootScope.$new(); - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); scope.dynamicStepDisabled = 'Y'; $rootScope.$digest(); @@ -83,7 +83,7 @@ describe( 'AngularWizard', function() { it( "should return to a previous step", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); $rootScope.$digest(); @@ -95,7 +95,7 @@ describe( 'AngularWizard', function() { it( "should go to a step specified by name", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo('More steps'); $rootScope.$digest(); @@ -104,7 +104,7 @@ describe( 'AngularWizard', function() { it( "should go to a step specified by index", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo(2); $rootScope.$digest(); @@ -113,7 +113,7 @@ describe( 'AngularWizard', function() { it( "should go to next step becasue callback is truthy", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(function(){ return true @@ -124,7 +124,7 @@ describe( 'AngularWizard', function() { it( "should NOT go to next step because callback is falsey", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(function(){ return false @@ -135,7 +135,7 @@ describe( 'AngularWizard', function() { it( "should go to next step because CANEXIT is UNDEFINED", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); $rootScope.$digest(); @@ -144,7 +144,7 @@ describe( 'AngularWizard', function() { it( "should go to next step because CANEXIT is TRUE", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); scope.stepValidation = function(){ return true; }; @@ -159,7 +159,7 @@ describe( 'AngularWizard', function() { it( "should NOT go to next step because CANEXIT is FALSE", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); scope.stepValidation = function(){ return false; }; @@ -174,7 +174,7 @@ describe( 'AngularWizard', function() { it( "should go to next step because CANENTER is TRUE", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); scope.enterValidation = function(){ return true; }; @@ -189,7 +189,7 @@ describe( 'AngularWizard', function() { it( "should NOT go to next step because CANENTER is FALSE", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); scope.enterValidation = function(){ return false; }; @@ -204,7 +204,7 @@ describe( 'AngularWizard', function() { it( "should NOT return to a previous step. Although CANEXIT is false and we are heading to a previous state, the can enter validation is false", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); scope.stepValidation = function(){ return false; }; @@ -222,7 +222,7 @@ describe( 'AngularWizard', function() { it( "should return to a previous step even though CANEXIT is false", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); scope.stepValidation = function(){ return false; }; @@ -237,7 +237,7 @@ describe( 'AngularWizard', function() { it( "should go to the next step because the promise that CANENTER returns resolves to true", function(done) { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); scope.enterValidation = function(){ var deferred = $q.defer(); $timeout(function () { @@ -257,7 +257,7 @@ describe( 'AngularWizard', function() { it( "should go to the next step because CANEXIT is set to true", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; - var view = createView(scope); + var view = createGenericView(scope); scope.exitValidation = true; expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().next(); @@ -272,10 +272,28 @@ describe( 'AngularWizard', function() { scope.dynamicStepDisabled = 'Y'; var flag = false; scope.finishedWizard = function() { flag = true; }; - var view = createView(scope); + var view = createGenericView(scope); expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().finish(); expect(flag).toBeTruthy(); $rootScope.$digest(); }); + it( "should go to first step when reset is called", function() { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().goTo(2); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + WizardHandler.wizard().reset(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Starting'); + }); + it( "step description should be accessible", function() { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); + expect(view.isolateScope().steps[0].description).toEqual('Step description'); + }); }); From 4f3b1f4d102d625a7716c14032a97e42764b3a08 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 31 Dec 2015 10:05:53 -0700 Subject: [PATCH 120/185] project build --- dist/angular-wizard.js | 70 +++++++++++++++++++++----------------- dist/angular-wizard.min.js | 4 +-- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 4575bbc..b7923b7 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,32 +1,32 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.6.0 - 2015-12-28 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
      \n" + - "
      "); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
      \n" + - "
      \n" + - " \n" + - "
      \n" + - ""); -}]); - +/** + * Easy to use Wizard library for AngularJS + * @version v0.6.0 - 2015-12-31 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
      \n" + + "
      "); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
      \n" + + "
      \n" + + " \n" + + "
      \n" + + ""); +}]); + angular.module('mgo-angular-wizard', ['templates-angularwizard']); - + angular.module('mgo-angular-wizard').directive('wzStep', function() { return { restrict: 'EA', @@ -37,7 +37,8 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { canenter : '=', canexit : '=', disabled: '@?wzDisabled', - description: '@' + description: '@', + wzData: '=' }, require: '^wizard', templateUrl: function(element, attributes) { @@ -49,7 +50,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { } }; }); - + //wizard directive angular.module('mgo-angular-wizard').directive('wizard', function() { return { @@ -290,6 +291,11 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return $scope.getEnabledSteps().length; } + //Access to enabled steps from outside + this.getEnabledSteps = function(){ + return $scope.getEnabledSteps(); + }; + //Access to current step number from outside this.currentStepNumber = function(){ return $scope.currentStepNumber(); @@ -384,7 +390,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; }] }; -}); +}); function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') .directive(action, function() { @@ -411,7 +417,7 @@ wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); wizardButtonDirective('wzReset'); - + angular.module('mgo-angular-wizard').factory('WizardHandler', function() { var service = {}; diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 8a85090..6927a90 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.6.0 - 2015-12-28 * @link https://github.com/mgonto/angular-wizard + * @version v0.6.0 - 2015-12-31 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){a.steps.push(b),1===a.getEnabledSteps().length&&a.goTo(a.getEnabledSteps()[0])},this.context=a.context,a.getStepNumber=function(a){return j(a)+1},a.goTo=function(b){if(i)h(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:j(b)}),i=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.getEnabledSteps()[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:j(b)}))})}},a.currentStepNumber=function(){return j(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=j(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:k(b),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=j(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=j(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){a.steps.push(b),1===a.getEnabledSteps().length&&a.goTo(a.getEnabledSteps()[0])},this.context=a.context,a.getStepNumber=function(a){return j(a)+1},a.goTo=function(b){if(i)h(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:j(b)}),i=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.getEnabledSteps()[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:j(b)}))})}},a.currentStepNumber=function(){return j(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=j(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:k(b),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=j(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=j(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 1060f3333c552d1ddd6949a876608db4a5e2c1d3 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 31 Dec 2015 10:06:07 -0700 Subject: [PATCH 121/185] updating to version 0.6.1 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index a9610ba..d0d5aca 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.6.0", + "version": "0.6.1", "main": [ "./dist/angular-wizard.min.js", "./dist/angular-wizard.min.css" diff --git a/package.json b/package.json index 89e42ce..5548d08 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.6.0", + "version": "0.6.1", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.min.js", "homepage": "https://github.com/mgonto/angular-wizard", From 02217e0ed67c9efffd62bd94f99c5f98a740be2c Mon Sep 17 00:00:00 2001 From: Keval Bhatt Date: Sat, 9 Jan 2016 12:40:59 +0530 Subject: [PATCH 122/185] changed title attribute name to wz-title I tried yor example from readme, but when i run your example then title is not showing because attribute is title so i want to your site and checked your html then you are using wz-title so please update document with same --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c85aae3..30c6f06 100644 --- a/README.md +++ b/README.md @@ -48,17 +48,17 @@ Now, in some HTML for a controller, you can just add a wizard as follows: ````html - +

      This is the first step

      Here you can use whatever you want. You can use other directives, binding, etc.

      - +

      Continuing

      You have continued here!

      - +

      Even more steps!!

      @@ -109,17 +109,17 @@ A step can be conditionally disabled and may change at any time either adding it HTML ````html - +

      This is the first step

      Here you can use whatever you want. You can use other directives, binding, etc.

      - +

      Continuing

      You have continued here!

      - +

      Even more steps!!

      @@ -142,17 +142,17 @@ The wzStep directive has the following options as attributes: HTML ````html - +

      This is the first step

      Here you can use whatever you want. You can use other directives, binding, etc.

      - +

      Continuing

      You have continued here!

      - +

      Even more steps!!

      @@ -190,7 +190,7 @@ For those cases, we can inject the `WizardHandler` to our controller. The main function of this service is the `wizard(name)` which will let you get the wizard to manipulate it. If you have just one wizard in the screen and you didn't set a name to it, you can just call it as `wizard()`. Let's see an example: ````html - + ```` From b57d27bbfdb4433ca0858e227f334032d54b08d6 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 5 Feb 2016 11:58:27 +0000 Subject: [PATCH 123/185] don't link to the minified version for Webpack/browserify --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5548d08..0f42101 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Easy to use Wizard library for AngularJS", "version": "0.6.1", "filename": "angular-wizard.min.js", - "main": "./dist/angular-wizard.min.js", + "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", "author": "Martin Gontovnikas ", "repository": { @@ -55,4 +55,4 @@ "test": "grunt travis --verbose" }, "license": "MIT" -} \ No newline at end of file +} From a20fdfedeebc4d08765faf060fdf8297ad9b3f1e Mon Sep 17 00:00:00 2001 From: Diego Date: Thu, 25 Feb 2016 05:48:57 -0300 Subject: [PATCH 124/185] Update README.md title is now wz-title --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c85aae3..2e152cf 100644 --- a/README.md +++ b/README.md @@ -48,17 +48,17 @@ Now, in some HTML for a controller, you can just add a wizard as follows: ````html - +

      This is the first step

      Here you can use whatever you want. You can use other directives, binding, etc.

      - +

      Continuing

      You have continued here!

      - +

      Even more steps!!

      From f8fdb42c61a146d3410d820604592a5e9d7d0db9 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 21 Apr 2016 08:54:19 -0700 Subject: [PATCH 125/185] Update CHANGELOG.md 0.6.1 Release --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..18e1336 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ + +# 0.6.1 (2015-12-31) + + +## Updates + +- **wz-title:** the `title` attribute has been changed to `wz-title`. Examples in README have been updated. From 8210d68cb192a48174d9388c43847019de0b5c14 Mon Sep 17 00:00:00 2001 From: Ruben B Date: Fri, 2 Sep 2016 14:19:25 +0200 Subject: [PATCH 126/185] Added indicators-position setting, defaults to top. --- src/wizard.html | 3 ++- src/wizard.js | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wizard.html b/src/wizard.html index 0e8c660..0dcbadf 100644 --- a/src/wizard.html +++ b/src/wizard.html @@ -1,8 +1,9 @@ diff --git a/src/wizard.js b/src/wizard.js index f820000..fa642fe 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -9,14 +9,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { onFinish: '&', hideIndicators: '=', editMode: '=', - name: '@' + name: '@', + indicatorsPosition: '@?' }, templateUrl: function(element, attributes) { return attributes.template || "wizard.html"; }, //controller for wizard directive, treat this just like an angular controller - controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function($scope, $element, $log, WizardHandler, $q) { + controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function ($scope, $element, $log, WizardHandler, $q) { + if ($scope.indicatorsPosition == undefined) $scope.indicatorsPosition = 'top'; //this variable allows directive to load without having to pass any step validation var firstRun = true; //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service From 2c3dc3306114be81f0e4ed7a2df4029e6d4c4213 Mon Sep 17 00:00:00 2001 From: Zhang Zengbo Date: Fri, 25 Dec 2015 15:16:35 +0800 Subject: [PATCH 127/185] enable dynamic steps by watch $destroy event. i.e. {{step}} in scope, just create steps array to dynamic change steps. --- src/step.js | 3 +++ src/wizard.js | 10 ++++++++++ test/angularWizardSpec.js | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/step.js b/src/step.js index 2a26625..2ec522c 100644 --- a/src/step.js +++ b/src/step.js @@ -18,6 +18,9 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { link: function($scope, $element, $attrs, wizard) { $scope.title = $scope.wzTitle; wizard.addStep($scope); + $scope.$on('$destroy', function(){ + wizard.removeStep($scope); + }) } }; }); diff --git a/src/wizard.js b/src/wizard.js index fa642fe..eab57ab 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -99,6 +99,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo($scope.getEnabledSteps()[0]); } }; + + // called each time step diretive is destroyed + this.removeStep = function (step) { + // + var index = $scope.steps.indexOf(step); + if (index > 0) { + $scope.steps.splice(index, 1); + } + + } this.context = $scope.context; diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index 2b155db..9bc34ed 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -296,4 +296,15 @@ describe( 'AngularWizard', function() { var view = createGenericView(scope); expect(view.isolateScope().steps[0].description).toEqual('Step description'); }); + it("should create and delete dynamic steps", function () { + // sorry don't know how to test this. + var scope = $rootScope.$new(); + scope.steps = ["1", "2", "3", "4"]; + var element = angular.element('{{step}}'); + var elementCompiled = $compile(element)(scope); + console.log(elementCompiled); + scope.steps = ["5", "6", "7"]; + $rootScope.$digest(); + console.log(elementCompiled); + }); }); From 3756c69fbe1d8aea11426767ebc2d38efcb1aa29 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Sep 2016 12:59:48 -0700 Subject: [PATCH 128/185] created remove step logic and wrapped goTo in --- src/step.js | 2 +- src/wizard.js | 37 ++++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/step.js b/src/step.js index 2ec522c..ac30bf6 100644 --- a/src/step.js +++ b/src/step.js @@ -20,7 +20,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { wizard.addStep($scope); $scope.$on('$destroy', function(){ wizard.removeStep($scope); - }) + }); } }; }); diff --git a/src/wizard.js b/src/wizard.js index eab57ab..07ec3c3 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -17,8 +17,11 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }, //controller for wizard directive, treat this just like an angular controller - controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function ($scope, $element, $log, WizardHandler, $q) { - if ($scope.indicatorsPosition == undefined) $scope.indicatorsPosition = 'top'; + controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', '$timeout', function ($scope, $element, $log, WizardHandler, $q, $timeout) { + //setting default step position if none declared. + if ($scope.indicatorsPosition == undefined) { + $scope.indicatorsPosition = 'bottom'; + } //this variable allows directive to load without having to pass any step validation var firstRun = true; //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service @@ -66,7 +69,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //invoking goTo() with step title as argument $scope.goTo(stepByTitle($scope.currentStep)); } - }); //watching steps array length and editMode value, if edit module is undefined or null the nothing is done @@ -100,14 +102,12 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } }; - // called each time step diretive is destroyed + //called each time step diretive is destroyed this.removeStep = function (step) { - // var index = $scope.steps.indexOf(step); if (index > 0) { $scope.steps.splice(index, 1); } - } this.context = $scope.context; @@ -293,17 +293,20 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //used to traverse to any step, step number placed as argument this.goTo = function(step) { - var enabledSteps = $scope.getEnabledSteps(); - var stepTo; - //checking that step is a Number - if (angular.isNumber(step)) { - stepTo = enabledSteps[step]; - } else { - //finding the step associated with the title entered as goTo argument - stepTo = stepByTitle(step); - } - //going to step - $scope.goTo(stepTo); + //wrapped inside $timeout so newly enabled steps are included. + $timeout(function() { + var enabledSteps = $scope.getEnabledSteps(); + var stepTo; + //checking that step is a Number + if (angular.isNumber(step)) { + stepTo = enabledSteps[step]; + } else { + //finding the step associated with the title entered as goTo argument + stepTo = stepByTitle(step); + } + //going to step + $scope.goTo(stepTo); + }); }; //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. From 6b8b5c08c9e088b1a0ad0d27d7fa75f3518e5685 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Sep 2016 13:00:06 -0700 Subject: [PATCH 129/185] update project files --- dist/angular-wizard.js | 51 ++++++++++++++++++++++++++------------ dist/angular-wizard.min.js | 4 +-- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index b7923b7..6e01267 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.6.0 - 2015-12-31 * @link https://github.com/mgonto/angular-wizard + * @version v0.6.1 - 2016-09-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -15,12 +15,13 @@ angular.module("step.html", []).run(["$templateCache", function($templateCache) angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { $templateCache.put("wizard.html", "
      \n" + - "
      \n" + + "
      \n" + " \n" + + "
      \n" + "
      \n" + ""); }]); @@ -47,6 +48,9 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { link: function($scope, $element, $attrs, wizard) { $scope.title = $scope.wzTitle; wizard.addStep($scope); + $scope.$on('$destroy', function(){ + wizard.removeStep($scope); + }); } }; }); @@ -62,14 +66,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { onFinish: '&', hideIndicators: '=', editMode: '=', - name: '@' + name: '@', + indicatorsPosition: '@?' }, templateUrl: function(element, attributes) { return attributes.template || "wizard.html"; }, //controller for wizard directive, treat this just like an angular controller - controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', function($scope, $element, $log, WizardHandler, $q) { + controller: ['$scope', '$element', '$log', 'WizardHandler', '$q', '$timeout', function ($scope, $element, $log, WizardHandler, $q, $timeout) { + //setting default step position if none declared. + if ($scope.indicatorsPosition == undefined) { + $scope.indicatorsPosition = 'bottom'; + } //this variable allows directive to load without having to pass any step validation var firstRun = true; //creating instance of wizard, passing this as second argument allows access to functions attached to this via Service @@ -117,7 +126,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //invoking goTo() with step title as argument $scope.goTo(stepByTitle($scope.currentStep)); } - }); //watching steps array length and editMode value, if edit module is undefined or null the nothing is done @@ -150,6 +158,14 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo($scope.getEnabledSteps()[0]); } }; + + //called each time step diretive is destroyed + this.removeStep = function (step) { + var index = $scope.steps.indexOf(step); + if (index > 0) { + $scope.steps.splice(index, 1); + } + } this.context = $scope.context; @@ -334,17 +350,20 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //used to traverse to any step, step number placed as argument this.goTo = function(step) { - var enabledSteps = $scope.getEnabledSteps(); - var stepTo; - //checking that step is a Number - if (angular.isNumber(step)) { - stepTo = enabledSteps[step]; - } else { - //finding the step associated with the title entered as goTo argument - stepTo = stepByTitle(step); - } - //going to step - $scope.goTo(stepTo); + //wrapped inside $timeout so newly enabled steps are included. + $timeout(function() { + var enabledSteps = $scope.getEnabledSteps(); + var stepTo; + //checking that step is a Number + if (angular.isNumber(step)) { + stepTo = enabledSteps[step]; + } else { + //finding the step associated with the title entered as goTo argument + stepTo = stepByTitle(step); + } + //going to step + $scope.goTo(stepTo); + }); }; //calls finish() which calls onFinish() which is declared on an attribute and linked to controller via wizard directive. diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 6927a90..4e1cc74 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.6.0 - 2015-12-31 * @link https://github.com/mgonto/angular-wizard + * @version v0.6.1 - 2016-09-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.wzTitle,d.addStep(a)}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q",function(a,b,c,d,e){function f(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function g(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){a.steps.push(b),1===a.getEnabledSteps().length&&a.goTo(a.getEnabledSteps()[0])},this.context=a.context,a.getStepNumber=function(a){return j(a)+1},a.goTo=function(b){if(i)h(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:j(b)}),i=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([g(a.getEnabledSteps()[c],b),f(b)]).then(function(c){c[0]&&c[1]&&(h(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:j(b)}))})}},a.currentStepNumber=function(){return j(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=j(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:k(b),a.goTo(c)},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=j(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=j(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function(a,b,c,d,e,f){function g(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function h(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){a.steps.push(b),1===a.getEnabledSteps().length&&a.goTo(a.getEnabledSteps()[0])},this.removeStep=function(b){var c=a.steps.indexOf(b);c>0&&a.steps.splice(c,1)},this.context=a.context,a.getStepNumber=function(a){return k(a)+1},a.goTo=function(b){if(j)i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}),j=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([h(a.getEnabledSteps()[c],b),g(b)]).then(function(c){c[0]&&c[1]&&(i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}))})}},a.currentStepNumber=function(){return k(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=k(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){f(function(){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:l(b),a.goTo(c)})},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 05bc24360f12d6d4ad863b4ece2769d57cc92fd6 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Sep 2016 13:00:44 -0700 Subject: [PATCH 130/185] update README and CHANGELOG --- CHANGELOG.md | 10 +++++++++- README.md | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18e1336..d437c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ + +# 0.7.0 (2016-09-07) + +## Updates + +- **indicators-position:** the `indicators-position` attribute has been added to `wizard` directive to allow you to specify "top" or "bottom" for defualt step positions. +- Created $destroy event that remove steps from wizard for wizards built using `ng-repeat` for step creation +- Wrapped goTo method in $timeout to fix bug where step recently enabled weren't being seen by `getEnabledSteps` + # 0.6.1 (2015-12-31) - ## Updates - **wz-title:** the `title` attribute has been changed to `wz-title`. Examples in README have been updated. diff --git a/README.md b/README.md index 30c6f06..ee822ab 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Let's go step by step to see how this works. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. * **current-step**: You need to set here a property from your scope (similar to `ng-model`) and that property will always have the name of the current step being shown on the screen. * **template**: Path to a custom template. +* **indicators-portion**: Can use "top" or "bottom" to specify default position for steps. 2) Inside the wizard, we can have as many steps as we want. Each step MUST have a title which is going to be used to identify it. Inside each step, we can put whatever we want. Other directives, bindings, controls, forms, etc. Each step can have the following attributes (we will go into detail on each further below): * **wz-title:** A unique title used for identifying each step. From a56a68cb2398a92c4e8bcd25d383798e16c2e975 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Sep 2016 13:00:57 -0700 Subject: [PATCH 131/185] update unit tests for new features --- test/angularWizardSpec.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index 9bc34ed..a97fdae 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -78,6 +78,7 @@ describe( 'AngularWizard', function() { $rootScope.$digest(); WizardHandler.wizard().goTo(2); $rootScope.$digest(); + $timeout.flush(); expect(scope.referenceCurrentStep).toEqual('More steps'); }); it( "should return to a previous step", function() { @@ -99,6 +100,7 @@ describe( 'AngularWizard', function() { expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo('More steps'); $rootScope.$digest(); + $timeout.flush() expect(scope.referenceCurrentStep).toEqual('More steps'); }); it( "should go to a step specified by index", function() { @@ -108,6 +110,7 @@ describe( 'AngularWizard', function() { expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo(2); $rootScope.$digest(); + $timeout.flush(); expect(scope.referenceCurrentStep).toEqual('More steps'); }); it( "should go to next step becasue callback is truthy", function() { @@ -285,9 +288,11 @@ describe( 'AngularWizard', function() { expect(scope.referenceCurrentStep).toEqual('Starting'); WizardHandler.wizard().goTo(2); $rootScope.$digest(); + $timeout.flush(); expect(scope.referenceCurrentStep).toEqual('More steps'); WizardHandler.wizard().reset(); $rootScope.$digest(); + $timeout.flush(); expect(scope.referenceCurrentStep).toEqual('Starting'); }); it( "step description should be accessible", function() { @@ -297,14 +302,14 @@ describe( 'AngularWizard', function() { expect(view.isolateScope().steps[0].description).toEqual('Step description'); }); it("should create and delete dynamic steps", function () { - // sorry don't know how to test this. var scope = $rootScope.$new(); scope.steps = ["1", "2", "3", "4"]; - var element = angular.element('{{step}}'); - var elementCompiled = $compile(element)(scope); - console.log(elementCompiled); - scope.steps = ["5", "6", "7"]; + var element = angular.element('{{step}}'); + var view = $compile(element)(scope); $rootScope.$digest(); - console.log(elementCompiled); + expect(WizardHandler.wizard().getEnabledSteps().length).toBe(4); + view.isolateScope().steps = ["5", "6", "7"]; + view.isolateScope().$digest(); + expect(WizardHandler.wizard().getEnabledSteps().length).toBe(3); }); }); From 688f1eb57a0855d85e684bfbd7c8b232d890025f Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Sep 2016 13:01:09 -0700 Subject: [PATCH 132/185] bump to version 0.7.0 --- bower.json | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index d0d5aca..30a6df1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.6.1", + "version": "0.7.0", "main": [ "./dist/angular-wizard.min.js", "./dist/angular-wizard.min.css" diff --git a/package.json b/package.json index 0f42101..d83e880 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.6.1", + "version": "0.7.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", @@ -55,4 +55,4 @@ "test": "grunt travis --verbose" }, "license": "MIT" -} +} \ No newline at end of file From 77dabb8d7d5566710f5ab133b781fbd54ecb1c8d Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Sep 2016 13:09:47 -0700 Subject: [PATCH 133/185] update version to 0.7.0 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d437c66..b91dcc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ - -# 0.7.0 (2016-09-07) + +# 0.7.1 (2016-09-07) ## Updates From 8a3f7fd5f25ee1a790dcd643166d968d473007a8 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Sep 2016 13:09:56 -0700 Subject: [PATCH 134/185] update project files --- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 6e01267..a8ee445 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.6.1 - 2016-09-07 * @link https://github.com/mgonto/angular-wizard + * @version v0.7.1 - 2016-09-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 4e1cc74..384b9b4 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.6.1 - 2016-09-07 * @link https://github.com/mgonto/angular-wizard + * @version v0.7.1 - 2016-09-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ From 8082fe629666b70824e74b4e71b23fe0eadb1b2c Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Sep 2016 13:48:05 -0700 Subject: [PATCH 135/185] update to version 0.7.1 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 30a6df1..456f22d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.7.0", + "version": "0.7.1", "main": [ "./dist/angular-wizard.min.js", "./dist/angular-wizard.min.css" diff --git a/package.json b/package.json index d83e880..86949df 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.7.0", + "version": "0.7.1", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", From 96ffef04e2c2c42004716bbc870981fd75f7940c Mon Sep 17 00:00:00 2001 From: Joshua Vaughn Date: Thu, 8 Sep 2016 15:09:14 -0400 Subject: [PATCH 136/185] add ability to specify an order for each step while maintaining backward compatibility --- src/step.js | 3 ++- src/wizard.js | 18 ++++++++++-------- test/angularWizardSpec.js | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/step.js b/src/step.js index ac30bf6..1e3e0ca 100644 --- a/src/step.js +++ b/src/step.js @@ -9,7 +9,8 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { canexit : '=', disabled: '@?wzDisabled', description: '@', - wzData: '=' + wzData: '=', + wzOrder: '@?' }, require: '^wizard', templateUrl: function(element, attributes) { diff --git a/src/wizard.js b/src/wizard.js index 07ec3c3..d52ff7a 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -93,22 +93,24 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //called each time step directive is loaded this.addStep = function(step) { - //pushing the scope of directive onto step array - $scope.steps.push(step); - //if this is first step being pushed then goTo that first step - if ($scope.getEnabledSteps().length === 1) { + var wzOrder = (step.wzOrder >= 0 && !$scope.steps[step.wzOrder]) ? step.wzOrder : $scope.steps.length, + currentFirstStepIdx = stepIdx($scope.getEnabledSteps()[0]); + //adding the scope of directive onto step array + $scope.steps[wzOrder] = step; + //if this step is the new first then goTo it + if (wzOrder === 0 || stepIdx(step) < currentFirstStepIdx) { //goTo first step $scope.goTo($scope.getEnabledSteps()[0]); } }; - //called each time step diretive is destroyed + //called each time step directive is destroyed this.removeStep = function (step) { var index = $scope.steps.indexOf(step); if (index > 0) { $scope.steps.splice(index, 1); } - } + }; this.context = $scope.context; @@ -218,7 +220,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.getEnabledSteps = function() { return $scope.steps.filter(function(step){ - return step.disabled !== 'true'; + return step && step.disabled !== 'true'; }); }; @@ -248,7 +250,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.totalStepCount = function() { return $scope.getEnabledSteps().length; - } + }; //Access to enabled steps from outside this.getEnabledSteps = function(){ diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index a97fdae..728d5e1 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -311,5 +311,39 @@ describe( 'AngularWizard', function() { view.isolateScope().steps = ["5", "6", "7"]; view.isolateScope().$digest(); expect(WizardHandler.wizard().getEnabledSteps().length).toBe(3); - }); + }); + it("should add steps based on order", function () { + var scope = $rootScope.$new(); + scope.steps = [{title: "One", order: 1}, {title: "Zero", order: 0}]; + var element = angular.element('{{step.title}}'); + var view = $compile(element)(scope); + $rootScope.$digest(); + expect(WizardHandler.wizard().totalStepCount()).toBe(2); + expect(view.isolateScope().steps[0].wzTitle).toEqual(scope.steps[1].title); + }); + it("should append step to end if step at order exists", function () { + var scope = $rootScope.$new(); + scope.steps = [{title: "One", order: 1}, {title: "Zero", order: 0}]; + var element = angular.element('{{step.title}}'); + var view = $compile(element)(scope); + $rootScope.$digest(); + var newStep = $rootScope.$new(); + newStep.wzTitle = 'New Step'; + newStep.wzOrder = 0; + WizardHandler.wizard().addStep(newStep); + $rootScope.$digest(); + expect(WizardHandler.wizard().totalStepCount()).toBe(3); + expect(view.isolateScope().steps[2].wzTitle).toEqual(newStep.wzTitle); + }); + it("should always append to end if no order defined", function () { + var scope = $rootScope.$new(); + scope.steps = [{title: "One"}, {title: "Zero"}, {title: "Two"}]; + var element = angular.element('{{step.title}}'); + var view = $compile(element)(scope); + $rootScope.$digest(); + expect(WizardHandler.wizard().totalStepCount()).toBe(3); + scope.steps.forEach(function (step, index) { + expect(view.isolateScope().steps[index].wzTitle).toEqual(step.title); + }); + }); }); From 6b740fe296f38503e003fa7e6581e7a4aeba6655 Mon Sep 17 00:00:00 2001 From: Joshua Vaughn Date: Thu, 8 Sep 2016 15:17:34 -0400 Subject: [PATCH 137/185] Update the readme to reflect the newly added property and what it does --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ee822ab..839b2ff 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ Let's go step by step to see how this works. * **wz-disabled** * **description:** A description available to use in each step's UI. * **wz-data** Data you wish to make available to the steps scope. +* **wz-order** The order in which the steps should be in. If no order or duplicated order it will add the step to the end. 3) Inside the step, we now see a button which has a `wz-next` attribute. That means that clicking that button will send the user to the next step of wizard. Similar to `wz-next`, we have the following attributes: * **wz-previous**: Goes to the previous step From 75ab2c22b257d75a6a54498d532495075d7d2ba2 Mon Sep 17 00:00:00 2001 From: Joshua Vaughn Date: Thu, 8 Sep 2016 21:01:53 -0400 Subject: [PATCH 138/185] Over thinking how to go to the first enabled step when all that is needed is to see if the one just added is the first enabled step and if it is go to it --- src/wizard.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index d52ff7a..bc47813 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -93,12 +93,11 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //called each time step directive is loaded this.addStep = function(step) { - var wzOrder = (step.wzOrder >= 0 && !$scope.steps[step.wzOrder]) ? step.wzOrder : $scope.steps.length, - currentFirstStepIdx = stepIdx($scope.getEnabledSteps()[0]); + var wzOrder = (step.wzOrder >= 0 && !$scope.steps[step.wzOrder]) ? step.wzOrder : $scope.steps.length; //adding the scope of directive onto step array $scope.steps[wzOrder] = step; //if this step is the new first then goTo it - if (wzOrder === 0 || stepIdx(step) < currentFirstStepIdx) { + if ($scope.getEnabledSteps()[0] === step) { //goTo first step $scope.goTo($scope.getEnabledSteps()[0]); } From 8564a52ea28402c21233f022d4981b5f4d1aa6dc Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Sun, 11 Sep 2016 12:07:18 -0700 Subject: [PATCH 139/185] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ee822ab..28b2f2e 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ Let's go step by step to see how this works. * **hide-indicators**: If set to true, the indicators in the bottom of the page showing the current page and allowing navigation for the wizard will be hidden. Defaults to false. * **current-step**: You need to set here a property from your scope (similar to `ng-model`) and that property will always have the name of the current step being shown on the screen. * **template**: Path to a custom template. -* **indicators-portion**: Can use "top" or "bottom" to specify default position for steps. +* **indicators-position**: Can use "top" or "bottom" to specify default position for steps. 2) Inside the wizard, we can have as many steps as we want. Each step MUST have a title which is going to be used to identify it. Inside each step, we can put whatever we want. Other directives, bindings, controls, forms, etc. Each step can have the following attributes (we will go into detail on each further below): * **wz-title:** A unique title used for identifying each step. From c589c735424105dd1ea565515adc117b94f8056b Mon Sep 17 00:00:00 2001 From: Ruben B Date: Mon, 12 Sep 2016 11:36:40 +0200 Subject: [PATCH 140/185] Translation support - fix --- src/step.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/step.js b/src/step.js index ac30bf6..7bdb562 100644 --- a/src/step.js +++ b/src/step.js @@ -15,7 +15,6 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { templateUrl: function(element, attributes) { return attributes.template || "step.html"; }, - link: function($scope, $element, $attrs, wizard) { $scope.title = $scope.wzTitle; wizard.addStep($scope); $scope.$on('$destroy', function(){ From 5567b516703a199aa815f12172e09d266ae78bba Mon Sep 17 00:00:00 2001 From: Ruben B Date: Mon, 12 Sep 2016 11:41:10 +0200 Subject: [PATCH 141/185] Add translation support --- src/step.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/step.js b/src/step.js index 7bdb562..33844d1 100644 --- a/src/step.js +++ b/src/step.js @@ -15,7 +15,14 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { templateUrl: function(element, attributes) { return attributes.template || "step.html"; }, + link: function ($scope, $element, $attrs, wizard) { + //OPTION1: ADD observe on the wzTitle attribute and change the title accordingly + $attrs.$observe('wzTitle', function (value) { + $scope.title = $scope.wzTitle; + }); $scope.title = $scope.wzTitle; + //OPTION2: DON'T set the title on the scope + // So remove $scope.title = $scope.wzTitle; wizard.addStep($scope); $scope.$on('$destroy', function(){ wizard.removeStep($scope); From ad9da564acfbb2b7c124b05c0ad491f0699b797f Mon Sep 17 00:00:00 2001 From: Richard Vialoux Date: Mon, 12 Sep 2016 14:48:43 -0500 Subject: [PATCH 142/185] fix typo "any changed you wish to make" to "any changes you wish to make" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28b2f2e..69564ca 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ The functions available in the `wizard()` are: ## Navigation bar -Any changed you wish to make to the navigation bar can be done by overwritting the CSS. Because everyone wants the navigation bar in a different location and in a different style we have provided a default which you can change via your own HTML and CSS. The navigation bar shown below works in the following way: +Any changes you wish to make to the navigation bar can be done by overwritting the CSS. Because everyone wants the navigation bar in a different location and in a different style we have provided a default which you can change via your own HTML and CSS. The navigation bar shown below works in the following way: * Completed steps are painted as green * Current step is painted as dark grey From 48f6eaa63917dfd4da50591545d1f153e150efa6 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Mon, 12 Sep 2016 17:34:42 -0700 Subject: [PATCH 143/185] Project build --- dist/angular-wizard.js | 22 ++++++++++++---------- dist/angular-wizard.min.js | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index a8ee445..dbb5e1a 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.7.1 - 2016-09-07 * @link https://github.com/mgonto/angular-wizard + * @version v0.8.0 - 2016-09-12 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -39,7 +39,8 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { canexit : '=', disabled: '@?wzDisabled', description: '@', - wzData: '=' + wzData: '=', + wzOrder: '@?' }, require: '^wizard', templateUrl: function(element, attributes) { @@ -150,22 +151,23 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //called each time step directive is loaded this.addStep = function(step) { - //pushing the scope of directive onto step array - $scope.steps.push(step); - //if this is first step being pushed then goTo that first step - if ($scope.getEnabledSteps().length === 1) { + var wzOrder = (step.wzOrder >= 0 && !$scope.steps[step.wzOrder]) ? step.wzOrder : $scope.steps.length; + //adding the scope of directive onto step array + $scope.steps[wzOrder] = step; + //if this step is the new first then goTo it + if ($scope.getEnabledSteps()[0] === step) { //goTo first step $scope.goTo($scope.getEnabledSteps()[0]); } }; - //called each time step diretive is destroyed + //called each time step directive is destroyed this.removeStep = function (step) { var index = $scope.steps.indexOf(step); if (index > 0) { $scope.steps.splice(index, 1); } - } + }; this.context = $scope.context; @@ -275,7 +277,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.getEnabledSteps = function() { return $scope.steps.filter(function(step){ - return step.disabled !== 'true'; + return step && step.disabled !== 'true'; }); }; @@ -305,7 +307,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { this.totalStepCount = function() { return $scope.getEnabledSteps().length; - } + }; //Access to enabled steps from outside this.getEnabledSteps = function(){ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 384b9b4..b0cced1 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.7.1 - 2016-09-07 * @link https://github.com/mgonto/angular-wizard + * @version v0.8.0 - 2016-09-12 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"="},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function(a,b,c,d,e,f){function g(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function h(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){a.steps.push(b),1===a.getEnabledSteps().length&&a.goTo(a.getEnabledSteps()[0])},this.removeStep=function(b){var c=a.steps.indexOf(b);c>0&&a.steps.splice(c,1)},this.context=a.context,a.getStepNumber=function(a){return k(a)+1},a.goTo=function(b){if(j)i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}),j=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([h(a.getEnabledSteps()[c],b),g(b)]).then(function(c){c[0]&&c[1]&&(i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}))})}},a.currentStepNumber=function(){return k(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=k(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){f(function(){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:l(b),a.goTo(c)})},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"=",wzOrder:"@?"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function(a,b,c,d,e,f){function g(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function h(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){var c=b.wzOrder>=0&&!a.steps[b.wzOrder]?b.wzOrder:a.steps.length;a.steps[c]=b,a.getEnabledSteps()[0]===b&&a.goTo(a.getEnabledSteps()[0])},this.removeStep=function(b){var c=a.steps.indexOf(b);c>0&&a.steps.splice(c,1)},this.context=a.context,a.getStepNumber=function(a){return k(a)+1},a.goTo=function(b){if(j)i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}),j=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([h(a.getEnabledSteps()[c],b),g(b)]).then(function(c){c[0]&&c[1]&&(i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}))})}},a.currentStepNumber=function(){return k(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return a&&"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=k(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){f(function(){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:l(b),a.goTo(c)})},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 2052b35d11bde6303be8ec83741c5f471580105d Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Mon, 12 Sep 2016 17:34:58 -0700 Subject: [PATCH 144/185] add new wzOrder attribute --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b91dcc4..2a8af44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ + +# 0.8.0 (2016-09-12) + +## Updates + +- **wizard-order:** the `wizard-order` attribute affects the order in which the steps should be in. If no order or duplicated order it will add the step to the end. + # 0.7.1 (2016-09-07) From 5462b08747aff204e50dc570399c5b57b6ef729a Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Mon, 12 Sep 2016 17:35:07 -0700 Subject: [PATCH 145/185] update version --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 456f22d..5f61d52 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.7.1", + "version": "0.8.0", "main": [ "./dist/angular-wizard.min.js", "./dist/angular-wizard.min.css" diff --git a/package.json b/package.json index 86949df..d552535 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for AngularJS", - "version": "0.7.1", + "version": "0.8.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", From c8912b491a607ad63ac486069f9026a49dc8a041 Mon Sep 17 00:00:00 2001 From: Ruben B Date: Tue, 13 Sep 2016 08:38:37 +0200 Subject: [PATCH 146/185] Fix #184 - Remove line that sets title on scope --- src/step.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/step.js b/src/step.js index 33844d1..2af329b 100644 --- a/src/step.js +++ b/src/step.js @@ -16,13 +16,6 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { return attributes.template || "step.html"; }, link: function ($scope, $element, $attrs, wizard) { - //OPTION1: ADD observe on the wzTitle attribute and change the title accordingly - $attrs.$observe('wzTitle', function (value) { - $scope.title = $scope.wzTitle; - }); - $scope.title = $scope.wzTitle; - //OPTION2: DON'T set the title on the scope - // So remove $scope.title = $scope.wzTitle; wizard.addStep($scope); $scope.$on('$destroy', function(){ wizard.removeStep($scope); From cc9bc6660fc39be4352cc7520645d9fd26d8a664 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Wed, 14 Sep 2016 22:48:45 -0700 Subject: [PATCH 147/185] testing travis ci --- .gitignore | 1 + .travis.yml | 21 ++++++++++--- dist/angular-wizard.js | 64 +++++++++++++++++++------------------- dist/angular-wizard.min.js | 2 +- karma.conf.js | 35 ++++++++++++++------- package.json | 8 +++++ 6 files changed, 82 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index 5ae53ee..9b15570 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ logs results lib node_modules +coverage components bower_components npm-debug.log diff --git a/.travis.yml b/.travis.yml index 1426a7a..5b53f61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,20 @@ -language: node_js +nguage: node_js node_js: - - "0.10" + - "4.2.4" before_script: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start + - npm install + - npm install -g bower + - npm install -g grunt + +script: + - npm test + +after_success: + - npm run coveralls + - npm run codacy + +notifications: + - email: false + +sudo: false \ No newline at end of file diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index dbb5e1a..7aec09c 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,33 +1,33 @@ -/** - * Easy to use Wizard library for AngularJS - * @version v0.8.0 - 2016-09-12 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
      \n" + - "
      "); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
      \n" + - "
      \n" + - " \n" + - "
      \n" + - "
      \n" + - ""); -}]); - +/** + * Easy to use Wizard library for AngularJS + * @version v0.8.0 - 2016-09-14 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
      \n" + + "
      "); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
      \n" + + "
      \n" + + " \n" + + "
      \n" + + "
      \n" + + ""); +}]); + angular.module('mgo-angular-wizard', ['templates-angularwizard']); - + angular.module('mgo-angular-wizard').directive('wzStep', function() { return { restrict: 'EA', @@ -55,7 +55,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { } }; }); - + //wizard directive angular.module('mgo-angular-wizard').directive('wizard', function() { return { @@ -411,7 +411,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; }] }; -}); +}); function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') .directive(action, function() { @@ -438,7 +438,7 @@ wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); wizardButtonDirective('wzReset'); - + angular.module('mgo-angular-wizard').factory('WizardHandler', function() { var service = {}; diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index b0cced1..2444e1f 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for AngularJS - * @version v0.8.0 - 2016-09-12 * @link https://github.com/mgonto/angular-wizard + * @version v0.8.0 - 2016-09-14 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/karma.conf.js b/karma.conf.js index fbc77e3..1ab4bb1 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -14,21 +14,36 @@ module.exports = function(config) { 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js', 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular-mocks.js', 'http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js', - 'dist/*.min.js', + 'src/*.js', 'test/*.js' ], - - // list of files to exclude - exclude: [ - + plugins: [ + "karma-phantomjs-launcher", + "karma-jasmine", + "karma-coverage" ], + preprocessors: { + "src/*.js": ["coverage"] + }, + + // optionally, configure the reporter + coverageReporter: { + dir : "coverage/", + reporters: [ + {type: "lcov", subdir: "lcov"} + ] + }, // test results reporter to use - // possible values: 'dots', 'progress', 'junit' - reporters: ['progress'], + // possible values: "dots", "progress", "junit" + reporters: ["dots", "coverage"], + // list of files to exclude + exclude: [ + + ], // web server port port: 9876, @@ -59,7 +74,7 @@ module.exports = function(config) { // - Safari (only Mac) // - PhantomJS // - IE (only Windows) - browsers: ['Chrome', 'Firefox'], + browsers: ['PhantomJS'], // If browser does not capture in given timeout [ms], kill it @@ -72,9 +87,5 @@ module.exports = function(config) { }; - if (process.env.TRAVIS) { - configuration.browsers = ['Firefox', 'PhantomJS']; - } - config.set(configuration); }; diff --git a/package.json b/package.json index d552535..efee21b 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,11 @@ "engines": { "node": ">= 0.9" }, + "scripts": { + "test": "grunt build", + "coveralls": "cat ./coverage/lcov/lcov.info | coveralls", + "codacy": "cat ./coverage/lcov/lcov.info | codacy-coverage --verbose" + }, "keywords": [ "angular", "client", @@ -29,6 +34,8 @@ ], "dependencies": {}, "devDependencies": { + "codacy-coverage": "*", + "coveralls": "*", "grunt": "~0.4.1", "grunt-bower": "*", "grunt-bower-task": "*", @@ -43,6 +50,7 @@ "grunt-conventional-changelog": "~0.1.1", "grunt-html2js": "~0.1.3", "grunt-karma": "~0.9.x", + "karma-coverage": "*", "grunt-ng-annotate": "^0.6.0", "grunt-zip": "*", "jasmine-core": "^2.1.3", From 5ce73be27532cc280722c86152a86f63f13e7b9e Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 14 Sep 2016 23:01:30 -0700 Subject: [PATCH 148/185] added build badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37cee23..ab845d5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Angular-Wizard -[![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using PayPal") +[![Build Status](https://travis-ci.org/angular-wizard/angular-wizard.svg?branch=master)](https://travis-ci.org/angular-wizard/angular-wizard) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8a488d7e632d4d1ea973bfcd25ea15a0)](https://www.codacy.com/app/jc_2/angular-wizard?utm_source=github.com&utm_medium=referral&utm_content=angular-wizard/angular-wizard&utm_campaign=Badge_Grade) [![Coverage Status](https://coveralls.io/repos/github/angular-wizard/angular-wizard/badge.svg?branch=master)](https://coveralls.io/github/angular-wizard/angular-wizard?branch=master) [![npm version](https://badge.fury.io/js/angular-wizard.svg)](https://badge.fury.io/js/angular-wizard) [![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using PayPal") [![Donate on Gratipay](http://img.shields.io/gratipay/mgonto.svg)](https://gratipay.com/mgonto/) Angular-wizard is a component that will make it easy for you to create wizards in your app. You can check a running example of the wizard [by clicking here](http://mgonto.github.io/angular-wizard/) From 48a024b0e6a45826b6cda0502ab55119e9b39a03 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Wed, 14 Sep 2016 23:02:43 -0700 Subject: [PATCH 149/185] testing coveralls --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index efee21b..2959675 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "description": "Easy to use Wizard library for AngularJS", + "description": "Easy to use Wizard library for Angular JS", "version": "0.8.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", From a8c1b691d50948fe92a2b191b983d337b7c57ab8 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Wed, 14 Sep 2016 23:10:47 -0700 Subject: [PATCH 150/185] update contribute.md --- CONTRIBUTE.md | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index 73a2b43..8938d60 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -1,17 +1,37 @@ -In order to Contribute just git clone the repository and then run: +# Contributing Guidelines -``` -npm install grunt-cli --global -npm install -grunt -``` +First of all, thank you for considering to contribute to the Angular Wizard project. +The community is important to us and we appreciate your time and effort to help pushing towards a better generic tree component. -Be sure to have PhantomJS installed as Karma tests use it. Otherwise, in mac just run +## Submitting a PR -``` -brew install phantomjs -``` +As an attempt to make the process of contributing more pleasant for you and the reviewers, we've created a checklist. +Please make sure your PR confirms to critera listed below. -All changes must be done in src/restangular.js and then after running grunt all changes will be submited to dist/ +- Use a descriptive title using proper grammar (this is important because the same text will be used for the changelog) +- Make sure the build passes `grunt build` +- Do not include files from the `dist/` directory (These are created when a new release is made. Adding them to every PR will result in merge conflicts for other PR's.) -Please submit a Pull Request or create issues for anything you want :). +## Accepting a PR + +1. Manually review PR in the 'Files Changed' tab of the GitHub PR section +2. Ensure Travis build passing +3. Review Coveralls and Codacy reports. +A fail does not necessarily mean a PR should be rejected, but it is a red flag that you should take a close look at the report. +4. Merge the PR. If the PR is simple and good as-is you can merge it using GitHub's web UI. If the PR needs some amending, or you want to test the changes, perform a command line merge (the 'commandline instructions' link gives the commands). +5. Test the PR locally and run the tests (grunt test) +6. Make any additional changes you need (update README, update example site, etc) +7. Push the changes + +## Creating a release + +1. Run the tests (`$ grunt test`) +3. Update CHANGELOG.md with release notes for the changes in the this release +4. Update version with `grunt bump` add the type flag otherwise a "patch" version change will be applied. e.g. `grunt bump --type=minor` +5. Run `$ grunt build` and commit, this time including the new dist files. +6. Tag the commit as a new release (like v2.18.0) +7. Push all the changes including tags (eg. `$ git push --tags`) +8. Publish to npm with `$ npm publish ./` +9. Add a new [Release in GitHub](https://github.com/angular-wizard/angular-wizard/releases) + +Our intention is to keep working on this document. Happy coding! \ No newline at end of file From ac48cded1cf231d502d5d2cf0a098ef1f2979d54 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Wed, 14 Sep 2016 23:25:31 -0700 Subject: [PATCH 151/185] push to test coveralls --- Gruntfile.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0682527..10f4f00 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,4 +1,4 @@ - 'use strict'; +'use strict'; module.exports = function(grunt) { @@ -118,11 +118,6 @@ module.exports = function(grunt) { singleRun: true, autoWatch: false }, - travis: { - singleRun: true, - autoWatch: false, - browsers: ['Firefox'] - }, dev: { autoWatch: true } @@ -139,16 +134,10 @@ module.exports = function(grunt) { // Load the plugin that provides the "uglify" task. grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-bower-task'); - grunt.renameTask("bower", "bowerInstall"); - - grunt.loadNpmTasks('grunt-karma'); grunt.loadNpmTasks('grunt-karma'); - grunt.loadNpmTasks('grunt-conventional-changelog'); - grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-clean'); From 473ab055f76e83ff96f1606eaede41dd8e93d02b Mon Sep 17 00:00:00 2001 From: Ruben B Date: Mon, 19 Sep 2016 10:19:45 +0200 Subject: [PATCH 152/185] Fix #184 Undo remove of $scope.title Add $observe on wzTitle --- src/step.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/step.js b/src/step.js index 2af329b..b2f5b12 100644 --- a/src/step.js +++ b/src/step.js @@ -16,6 +16,10 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { return attributes.template || "step.html"; }, link: function ($scope, $element, $attrs, wizard) { + $attrs.$observe('wzTitle', function (value) { + $scope.title = $scope.wzTitle; + }); + $scope.title = $scope.wzTitle; wizard.addStep($scope); $scope.$on('$destroy', function(){ wizard.removeStep($scope); From e42d429fb6ef206b5493a913884c603fa7ad6fde Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 20 Sep 2016 00:48:09 -0700 Subject: [PATCH 153/185] update version - minor --- bower.json | 2 +- package.json | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index 5f61d52..bc06f00 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.8.0", + "version": "0.9.0", "main": [ "./dist/angular-wizard.min.js", "./dist/angular-wizard.min.css" diff --git a/package.json b/package.json index 2959675..7bff463 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for Angular JS", - "version": "0.8.0", + "version": "0.9.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", @@ -14,9 +14,7 @@ "node": ">= 0.9" }, "scripts": { - "test": "grunt build", - "coveralls": "cat ./coverage/lcov/lcov.info | coveralls", - "codacy": "cat ./coverage/lcov/lcov.info | codacy-coverage --verbose" + "test": "grunt travis --verbose" }, "keywords": [ "angular", @@ -59,8 +57,5 @@ "karma-jasmine": "~0.3.x", "karma-phantomjs-launcher": "~0.1.x" }, - "scripts": { - "test": "grunt travis --verbose" - }, "license": "MIT" } \ No newline at end of file From 5f3b1b53987745949a88deb3dfad14d7ddeb1500 Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 20 Sep 2016 00:48:21 -0700 Subject: [PATCH 154/185] added 0.9.0 updates --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a8af44..c45e1c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ + +# 0.9.0 (2016-09-19) + +## Updates + +- Fix for Issue [#184](https://github.com/angular-wizard/angular-wizard/issues/184). +- Step title updates on change. + # 0.8.0 (2016-09-12) From 4802b8e6d56807e8a8b4868a90b9b81e91ea5c2f Mon Sep 17 00:00:00 2001 From: jacobscarter Date: Tue, 20 Sep 2016 00:48:31 -0700 Subject: [PATCH 155/185] Project build --- dist/angular-wizard.js | 9 ++++++--- dist/angular-wizard.min.js | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 7aec09c..4d19cd9 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** - * Easy to use Wizard library for AngularJS - * @version v0.8.0 - 2016-09-14 * @link https://github.com/mgonto/angular-wizard + * Easy to use Wizard library for Angular JS + * @version v0.9.0 - 2016-09-20 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -46,7 +46,10 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { templateUrl: function(element, attributes) { return attributes.template || "step.html"; }, - link: function($scope, $element, $attrs, wizard) { + link: function ($scope, $element, $attrs, wizard) { + $attrs.$observe('wzTitle', function (value) { + $scope.title = $scope.wzTitle; + }); $scope.title = $scope.wzTitle; wizard.addStep($scope); $scope.$on('$destroy', function(){ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 2444e1f..159248e 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** - * Easy to use Wizard library for AngularJS - * @version v0.8.0 - 2016-09-14 * @link https://github.com/mgonto/angular-wizard + * Easy to use Wizard library for Angular JS + * @version v0.9.0 - 2016-09-20 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"=",wzOrder:"@?"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function(a,b,c,d,e,f){function g(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function h(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){var c=b.wzOrder>=0&&!a.steps[b.wzOrder]?b.wzOrder:a.steps.length;a.steps[c]=b,a.getEnabledSteps()[0]===b&&a.goTo(a.getEnabledSteps()[0])},this.removeStep=function(b){var c=a.steps.indexOf(b);c>0&&a.steps.splice(c,1)},this.context=a.context,a.getStepNumber=function(a){return k(a)+1},a.goTo=function(b){if(j)i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}),j=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([h(a.getEnabledSteps()[c],b),g(b)]).then(function(c){c[0]&&c[1]&&(i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}))})}},a.currentStepNumber=function(){return k(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return a&&"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=k(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){f(function(){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:l(b),a.goTo(c)})},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"=",wzOrder:"@?"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){c.$observe("wzTitle",function(b){a.title=a.wzTitle}),a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function(a,b,c,d,e,f){function g(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function h(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){var c=b.wzOrder>=0&&!a.steps[b.wzOrder]?b.wzOrder:a.steps.length;a.steps[c]=b,a.getEnabledSteps()[0]===b&&a.goTo(a.getEnabledSteps()[0])},this.removeStep=function(b){var c=a.steps.indexOf(b);c>0&&a.steps.splice(c,1)},this.context=a.context,a.getStepNumber=function(a){return k(a)+1},a.goTo=function(b){if(j)i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}),j=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([h(a.getEnabledSteps()[c],b),g(b)]).then(function(c){c[0]&&c[1]&&(i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}))})}},a.currentStepNumber=function(){return k(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return a&&"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=k(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){f(function(){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:l(b),a.goTo(c)})},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 369c95b3fa75faa148985af44c5d37b5ec831785 Mon Sep 17 00:00:00 2001 From: Ruben B Date: Thu, 13 Oct 2016 15:00:06 +0200 Subject: [PATCH 156/185] Fix for edit-mode true and disabled steps --- src/wizard.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index bc47813..0ee5973 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -77,15 +77,17 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { var editMode = $scope.editMode; if (angular.isUndefined(editMode) || (editMode === null)) return; - if (editMode) { - angular.forEach($scope.getEnabledSteps(), function(step) { - step.completed = true; - }); - } else { - var completedStepsIndex = $scope.currentStepNumber() - 1; + //Set completed for all steps to the value of editMode + angular.forEach($scope.steps, function (step) { + step.completed = editMode; + }); + + //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed + if (!editMode) { + var completedStepsIndex = $scope.currentStepNumber() - 1; angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { - if(stepIndex >= completedStepsIndex) { - step.completed = false; + if(stepIndex < completedStepsIndex) { + step.completed = true; } }); } From cda64a7db0b11100d85d88f6050f00ee3e825e13 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 22 Dec 2016 13:00:35 -0700 Subject: [PATCH 157/185] update changelog for 0.10.0 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c45e1c3..4547b12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ + +# 0.10.0 (2016-12-22) + +## Updates + +- Fix for Issue [#210](https://github.com/angular-wizard/angular-wizard/issues/210). +- Newly enabled steps are set to complete. + # 0.9.0 (2016-09-19) From 7e0724003413b0e94e59d2ae859bd19ac0ffce9a Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 22 Dec 2016 13:00:52 -0700 Subject: [PATCH 158/185] bump version number and add karma --- bower.json | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index bc06f00..9c2bc00 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.9.0", + "version": "0.10.0", "main": [ "./dist/angular-wizard.min.js", "./dist/angular-wizard.min.css" diff --git a/package.json b/package.json index 7bff463..0cb7f90 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for Angular JS", - "version": "0.9.0", + "version": "0.10.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", @@ -48,6 +48,7 @@ "grunt-conventional-changelog": "~0.1.1", "grunt-html2js": "~0.1.3", "grunt-karma": "~0.9.x", + "karma": "*", "karma-coverage": "*", "grunt-ng-annotate": "^0.6.0", "grunt-zip": "*", From 78f773022a921fb6b8feff1f602964df29906da9 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Thu, 22 Dec 2016 13:01:00 -0700 Subject: [PATCH 159/185] Project build --- dist/angular-wizard.js | 82 +++++++++++++++++++------------------- dist/angular-wizard.min.js | 4 +- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 4d19cd9..4240eb5 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,33 +1,33 @@ -/** - * Easy to use Wizard library for Angular JS - * @version v0.9.0 - 2016-09-20 * @link https://github.com/mgonto/angular-wizard - * @author Martin Gontovnikas - * @license MIT License, http://www.opensource.org/licenses/MIT - */ -angular.module('templates-angularwizard', ['step.html', 'wizard.html']); - -angular.module("step.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("step.html", - "
      \n" + - "
      "); -}]); - -angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { - $templateCache.put("wizard.html", - "
      \n" + - "
      \n" + - " \n" + - "
      \n" + - "
      \n" + - ""); -}]); - +/** + * Easy to use Wizard library for Angular JS + * @version v0.10.0 - 2016-12-22 * @link https://github.com/mgonto/angular-wizard + * @author Martin Gontovnikas + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +angular.module('templates-angularwizard', ['step.html', 'wizard.html']); + +angular.module("step.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("step.html", + "
      \n" + + "
      "); +}]); + +angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { + $templateCache.put("wizard.html", + "
      \n" + + "
      \n" + + " \n" + + "
      \n" + + "
      \n" + + ""); +}]); + angular.module('mgo-angular-wizard', ['templates-angularwizard']); - + angular.module('mgo-angular-wizard').directive('wzStep', function() { return { restrict: 'EA', @@ -58,7 +58,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { } }; }); - + //wizard directive angular.module('mgo-angular-wizard').directive('wizard', function() { return { @@ -138,15 +138,17 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { var editMode = $scope.editMode; if (angular.isUndefined(editMode) || (editMode === null)) return; - if (editMode) { - angular.forEach($scope.getEnabledSteps(), function(step) { - step.completed = true; - }); - } else { - var completedStepsIndex = $scope.currentStepNumber() - 1; + //Set completed for all steps to the value of editMode + angular.forEach($scope.steps, function (step) { + step.completed = editMode; + }); + + //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed + if (!editMode) { + var completedStepsIndex = $scope.currentStepNumber() - 1; angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { - if(stepIndex >= completedStepsIndex) { - step.completed = false; + if(stepIndex < completedStepsIndex) { + step.completed = true; } }); } @@ -414,7 +416,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; }] }; -}); +}); function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') .directive(action, function() { @@ -441,7 +443,7 @@ wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); wizardButtonDirective('wzReset'); - + angular.module('mgo-angular-wizard').factory('WizardHandler', function() { var service = {}; diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 159248e..4bdef35 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for Angular JS - * @version v0.9.0 - 2016-09-20 * @link https://github.com/mgonto/angular-wizard + * @version v0.10.0 - 2016-12-22 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"=",wzOrder:"@?"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){c.$observe("wzTitle",function(b){a.title=a.wzTitle}),a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function(a,b,c,d,e,f){function g(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function h(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)=c&&(a.completed=!1)})}},!0),this.addStep=function(b){var c=b.wzOrder>=0&&!a.steps[b.wzOrder]?b.wzOrder:a.steps.length;a.steps[c]=b,a.getEnabledSteps()[0]===b&&a.goTo(a.getEnabledSteps()[0])},this.removeStep=function(b){var c=a.steps.indexOf(b);c>0&&a.steps.splice(c,1)},this.context=a.context,a.getStepNumber=function(a){return k(a)+1},a.goTo=function(b){if(j)i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}),j=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([h(a.getEnabledSteps()[c],b),g(b)]).then(function(c){c[0]&&c[1]&&(i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}))})}},a.currentStepNumber=function(){return k(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return a&&"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=k(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){f(function(){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:l(b),a.goTo(c)})},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
      \n
      ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
      \n
      \n \n
      \n
      \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"=",wzOrder:"@?"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){c.$observe("wzTitle",function(b){a.title=a.wzTitle}),a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function(a,b,c,d,e,f){function g(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function h(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)b&&(a.completed=!0)})}},!0),this.addStep=function(b){var c=b.wzOrder>=0&&!a.steps[b.wzOrder]?b.wzOrder:a.steps.length;a.steps[c]=b,a.getEnabledSteps()[0]===b&&a.goTo(a.getEnabledSteps()[0])},this.removeStep=function(b){var c=a.steps.indexOf(b);c>0&&a.steps.splice(c,1)},this.context=a.context,a.getStepNumber=function(a){return k(a)+1},a.goTo=function(b){if(j)i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}),j=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([h(a.getEnabledSteps()[c],b),g(b)]).then(function(c){c[0]&&c[1]&&(i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}))})}},a.currentStepNumber=function(){return k(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return a&&"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=k(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){f(function(){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:l(b),a.goTo(c)})},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 22115959b79c1e9ea0295cbffc75cea314c2c310 Mon Sep 17 00:00:00 2001 From: Tyler Hogan Date: Thu, 22 Dec 2016 12:41:42 -0800 Subject: [PATCH 160/185] Allow canenter / canexit to be strings --- package.json | 8 +++++--- src/wizard.js | 24 +++++++++++++++++----- test/angularWizardSpec.js | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 0cb7f90..4384791 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,8 @@ "grunt-contrib-clean": "~0.4.1", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.4.1", - "grunt-contrib-less": "~1.0.0", "grunt-contrib-cssmin": "~0.12.2", + "grunt-contrib-less": "~1.0.0", "grunt-contrib-uglify": "~0.2.0", "grunt-conventional-changelog": "~0.1.1", "grunt-html2js": "~0.1.3", @@ -53,10 +53,12 @@ "grunt-ng-annotate": "^0.6.0", "grunt-zip": "*", "jasmine-core": "^2.1.3", + "karma": "^0.12.0", "karma-chrome-launcher": "^0.1.7", + "karma-coverage": "^1.1.1", "karma-firefox-launcher": "~0.1.x", - "karma-jasmine": "~0.3.x", + "karma-jasmine": "^0.3.8", "karma-phantomjs-launcher": "~0.1.x" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/src/wizard.js b/src/wizard.js index 0ee5973..3ad963e 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -104,7 +104,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo($scope.getEnabledSteps()[0]); } }; - + //called each time step directive is destroyed this.removeStep = function (step) { var index = $scope.steps.indexOf(step); @@ -177,8 +177,15 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if(typeof step.canenter === 'boolean'){ return step.canenter; } + var canEnter; + //If canenter is a string instead of a function, evaluate the function + if(typeof step.canenter === 'string'){ + var splitFunction = step.canenter.split('('); + canEnter = eval('$scope.$parent.' + splitFunction[0] + '($scope.context' + splitFunction[1]) + } else { + canEnter = step.canenter($scope.context); + } //Check to see if the canenter function is a promise which needs to be returned - canEnter = step.canenter($scope.context); if(angular.isFunction(canEnter.then)){ defer = $q.defer(); canEnter.then(function(response){ @@ -201,8 +208,15 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if(typeof step.canexit === 'boolean'){ return step.canexit; } + var canExit; + //If canenter is a string instead of a function, evaluate the function + if(typeof step.canexit === 'string'){ + var splitFunction = step.canexit.split('('); + canExit = eval('$scope.$parent.' + splitFunction[0] + '($scope.context' + splitFunction[1]) + } else { + canExit = step.canexit($scope.context); + } //Check to see if the canexit function is a promise which needs to be returned - canExit = step.canexit($scope.context); if(angular.isFunction(canExit.then)){ defer = $q.defer(); canExit.then(function(response){ @@ -318,7 +332,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.onFinish(); } }; - + this.previous = function() { //getting index of current step var index = stepIdx($scope.selectedStep); @@ -355,4 +369,4 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; }] }; -}); \ No newline at end of file +}); diff --git a/test/angularWizardSpec.js b/test/angularWizardSpec.js index 728d5e1..708230a 100644 --- a/test/angularWizardSpec.js +++ b/test/angularWizardSpec.js @@ -257,6 +257,27 @@ describe( 'AngularWizard', function() { $timeout.flush(); expect(scope.referenceCurrentStep).toEqual('More steps'); }); + it( "should go to the next step because the promise that the evaluated string of CANENTER resolves to true", function(done) { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); + scope.enterValidation = 'stringEnterValidation()' + scope.stringEnterValidation = function(){ + var deferred = $q.defer(); + $timeout(function () { + deferred.resolve(true); + done(); + }); + return deferred.promise; + }; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $timeout.flush(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); it( "should go to the next step because CANEXIT is set to true", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; @@ -270,6 +291,27 @@ describe( 'AngularWizard', function() { $rootScope.$digest(); expect(scope.referenceCurrentStep).toEqual('More steps'); }); + it( "should go to the next step because the promise that the evaluated string of CANEXIT resolves to true", function(done) { + var scope = $rootScope.$new(); + scope.dynamicStepDisabled = 'Y'; + var view = createGenericView(scope); + scope.stepValidation = 'stringStepValidation()' + scope.stringStepValidation = function(){ + var deferred = $q.defer(); + $timeout(function () { + deferred.resolve(true); + done(); + }); + return deferred.promise; + }; + expect(scope.referenceCurrentStep).toEqual('Starting'); + WizardHandler.wizard().next(); + $rootScope.$digest(); + expect(scope.referenceCurrentStep).toEqual('Continuing'); + WizardHandler.wizard().next(); + $timeout.flush(); + expect(scope.referenceCurrentStep).toEqual('More steps'); + }); it( "should finish", function() { var scope = $rootScope.$new(); scope.dynamicStepDisabled = 'Y'; From 8e1d074bca3a255d549ed58eaca60942ca656a74 Mon Sep 17 00:00:00 2001 From: Boris Date: Tue, 10 Jan 2017 15:12:29 +0100 Subject: [PATCH 161/185] Fixed main files in bower.json Main files in bower.json should not be minified --- bower.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index 9c2bc00..fa0dc06 100644 --- a/bower.json +++ b/bower.json @@ -2,8 +2,8 @@ "name": "angular-wizard", "version": "0.10.0", "main": [ - "./dist/angular-wizard.min.js", - "./dist/angular-wizard.min.css" + "./dist/angular-wizard.js", + "./dist/angular-wizard.css" ], "description": "Easy to use Wizard library for AngularJS ", "repository": { @@ -18,4 +18,4 @@ "components", "lib" ] -} \ No newline at end of file +} From dc815751748813491e724cc123052c1212af29af Mon Sep 17 00:00:00 2001 From: craig w Date: Wed, 29 Mar 2017 15:28:20 -0400 Subject: [PATCH 162/185] Added ability to explicitly set the edit mode and force changes. --- README.md | 1 + src/wizard.js | 44 +++++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ab845d5..f248cd3 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,7 @@ The functions available in the `wizard()` are: * **currentStep()**: This returns an Object which is the current step you are on. * **totalStepCount()**: This returns an Number which is the total number of **enabled** steps. * **getEnabledSteps()**: This returns an Array which is the **enabled** steps. +* **setEditMode(mode)**: Set the edit mode of the wizard. ## Navigation bar diff --git a/src/wizard.js b/src/wizard.js index 0ee5973..bffb358 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -74,23 +74,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //watching steps array length and editMode value, if edit module is undefined or null the nothing is done //if edit mode is truthy, then all steps are marked as completed $scope.$watch('[editMode, steps.length]', function() { - var editMode = $scope.editMode; - if (angular.isUndefined(editMode) || (editMode === null)) return; - - //Set completed for all steps to the value of editMode - angular.forEach($scope.steps, function (step) { - step.completed = editMode; - }); - - //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed - if (!editMode) { - var completedStepsIndex = $scope.currentStepNumber() - 1; - angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { - if(stepIndex < completedStepsIndex) { - step.completed = true; - } - }); - } + handleEditModeChange(); }, true); //called each time step directive is loaded @@ -353,6 +337,32 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //go to first step this.goTo(0); }; + + //change edit mode + this.setEditMode = function(mode) { + $scope.editMode = mode; + handleEditModeChange(); + }; + + function handleEditModeChange() { + var editMode = $scope.editMode; + if (angular.isUndefined(editMode) || (editMode === null)) return; + + //Set completed for all steps to the value of editMode + angular.forEach($scope.steps, function (step) { + step.completed = editMode; + }); + + //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed + if (!editMode) { + var completedStepsIndex = $scope.currentStepNumber() - 1; + angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { + if(stepIndex < completedStepsIndex) { + step.completed = true; + } + }); + } + } }] }; }); \ No newline at end of file From 17d1c4d9380dc384117f5d98461ff3fa1cd5a73b Mon Sep 17 00:00:00 2001 From: craig w Date: Wed, 29 Mar 2017 17:06:02 -0400 Subject: [PATCH 163/185] Moved location of handleEditModeChange to resolve codacy error --- src/wizard.js | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index bffb358..c7c5b43 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -219,6 +219,27 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.selectedStep = null; } + //update completed state for each step based on the editMode and current step number + function handleEditModeChange() { + var editMode = $scope.editMode; + if (angular.isUndefined(editMode) || (editMode === null)) return; + + //Set completed for all steps to the value of editMode + angular.forEach($scope.steps, function (step) { + step.completed = editMode; + }); + + //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed + if (!editMode) { + var completedStepsIndex = $scope.currentStepNumber() - 1; + angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { + if(stepIndex < completedStepsIndex) { + step.completed = true; + } + }); + } + } + //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() this.currentStepTitle = function(){ @@ -343,26 +364,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.editMode = mode; handleEditModeChange(); }; - - function handleEditModeChange() { - var editMode = $scope.editMode; - if (angular.isUndefined(editMode) || (editMode === null)) return; - - //Set completed for all steps to the value of editMode - angular.forEach($scope.steps, function (step) { - step.completed = editMode; - }); - - //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed - if (!editMode) { - var completedStepsIndex = $scope.currentStepNumber() - 1; - angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { - if(stepIndex < completedStepsIndex) { - step.completed = true; - } - }); - } - } }] }; }); \ No newline at end of file From 2888510166712627eafb0829a61bbb74029671cc Mon Sep 17 00:00:00 2001 From: craig w Date: Wed, 29 Mar 2017 17:10:03 -0400 Subject: [PATCH 164/185] Moved location of handleEditModeChange to resolve codacy error, once more. --- src/wizard.js | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index c7c5b43..12e0518 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -56,6 +56,28 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return foundStep; }; + + //update completed state for each step based on the editMode and current step number + var handleEditModeChange = function() { + var editMode = $scope.editMode; + if (angular.isUndefined(editMode) || (editMode === null)) return; + + //Set completed for all steps to the value of editMode + angular.forEach($scope.steps, function (step) { + step.completed = editMode; + }); + + //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed + if (!editMode) { + var completedStepsIndex = $scope.currentStepNumber() - 1; + angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { + if(stepIndex < completedStepsIndex) { + step.completed = true; + } + }); + } + } + //access to context object for step validation $scope.context = {}; @@ -219,27 +241,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.selectedStep = null; } - //update completed state for each step based on the editMode and current step number - function handleEditModeChange() { - var editMode = $scope.editMode; - if (angular.isUndefined(editMode) || (editMode === null)) return; - - //Set completed for all steps to the value of editMode - angular.forEach($scope.steps, function (step) { - step.completed = editMode; - }); - - //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed - if (!editMode) { - var completedStepsIndex = $scope.currentStepNumber() - 1; - angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { - if(stepIndex < completedStepsIndex) { - step.completed = true; - } - }); - } - } - //ALL METHODS ATTACHED TO this ARE ACCESSIBLE VIA WizardHandler.wizard().methodName() this.currentStepTitle = function(){ From 7dd140e28da9ff3056ecc187ecf91c0cbc7f3cbf Mon Sep 17 00:00:00 2001 From: craig w Date: Wed, 29 Mar 2017 17:14:41 -0400 Subject: [PATCH 165/185] Added missing semi-colon per codacy code review. --- src/wizard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wizard.js b/src/wizard.js index 12e0518..5462349 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -76,7 +76,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } }); } - } + }; //access to context object for step validation $scope.context = {}; From 66a1b94617f29c0fb8350098944931af4cb90125 Mon Sep 17 00:00:00 2001 From: Dat Pham Date: Thu, 1 Jun 2017 05:30:28 +0700 Subject: [PATCH 166/185] Add Heading Title for each Step --- src/step.js | 1 + src/wizard.html | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/step.js b/src/step.js index 6a33e1e..587bbe1 100644 --- a/src/step.js +++ b/src/step.js @@ -5,6 +5,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { transclude: true, scope: { wzTitle: '@', + wzHeadingTitle: '@', canenter : '=', canexit : '=', disabled: '@?wzDisabled', diff --git a/src/wizard.html b/src/wizard.html index 0dcbadf..7870906 100644 --- a/src/wizard.html +++ b/src/wizard.html @@ -1,4 +1,6 @@
      +

      {{ selectedStep.wzHeadingTitle }}

      +
      • From cb20257baaa5a8091375978c218c4185c680ded6 Mon Sep 17 00:00:00 2001 From: Dat Pham Date: Thu, 1 Jun 2017 05:33:34 +0700 Subject: [PATCH 167/185] update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ab845d5..7aa14e9 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ Let's go step by step to see how this works. 2) Inside the wizard, we can have as many steps as we want. Each step MUST have a title which is going to be used to identify it. Inside each step, we can put whatever we want. Other directives, bindings, controls, forms, etc. Each step can have the following attributes (we will go into detail on each further below): * **wz-title:** A unique title used for identifying each step. +* **wz-heading-title** A heading title display above step indicators * **canenter** * **canexit** * **wz-disabled** From b60cad3fcd237910583c29da55ddd0d8509b7f54 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 14:12:54 -0700 Subject: [PATCH 168/185] update karmaphantom package version, correct travis config file, update node version for travis --- .travis.yml | 5 ++--- package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b53f61..dd79aa3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ -nguage: node_js +language: node_js node_js: - - "4.2.4" + - "5" before_script: - - npm install - npm install -g bower - npm install -g grunt diff --git a/package.json b/package.json index 0cb7f90..09309a3 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "karma-chrome-launcher": "^0.1.7", "karma-firefox-launcher": "~0.1.x", "karma-jasmine": "~0.3.x", - "karma-phantomjs-launcher": "~0.1.x" + "karma-phantomjs-launcher": "~1.0.x" }, "license": "MIT" } \ No newline at end of file From 48b90b7ef8e510b28be23cd2a2ceae4973883b44 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 15:25:02 -0700 Subject: [PATCH 169/185] cleaned up duplicate variable declaration --- src/wizard.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index 709e6cc..d0c0b94 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -176,8 +176,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { }; function canEnterStep(step) { - var defer, - canEnter; + var defer; + var canEnter; //If no validation function is provided, allow the user to enter the step if(step.canenter === undefined){ return true; @@ -186,7 +186,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if(typeof step.canenter === 'boolean'){ return step.canenter; } - var canEnter; //If canenter is a string instead of a function, evaluate the function if(typeof step.canenter === 'string'){ var splitFunction = step.canenter.split('('); @@ -207,8 +206,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } function canExitStep(step, stepTo) { - var defer, - canExit; + var defer; + var canExit; //Exiting the step should be allowed if no validation function was provided or if the user is moving backwards if(typeof(step.canexit) === 'undefined' || $scope.getStepNumber(stepTo) < $scope.currentStepNumber()){ return true; @@ -217,7 +216,6 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if(typeof step.canexit === 'boolean'){ return step.canexit; } - var canExit; //If canenter is a string instead of a function, evaluate the function if(typeof step.canexit === 'string'){ var splitFunction = step.canexit.split('('); From a6ac6f4810f7ffd210472e2db4e7417808cb7b54 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 15:42:20 -0700 Subject: [PATCH 170/185] Update CHANGELOG for version 1.0.0 --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4547b12..3e3ddda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ + +# 1.0.0 (2017-06-06) + +- `canExit` and `canEnter` functions may now be strings. +- `setEditMode(mode)` methoda added to wizard so a user can explicitly set the edit mode on a wizard. +- Main files in bower.json no longer reference minified files. +- Travis CI config files updated to allow CI automated testing to pass +- npm package versions updated. + +## Updates + +- Fix for Issue [#210](https://github.com/angular-wizard/angular-wizard/issues/210). +- Newly enabled steps are set to complete. + # 0.10.0 (2016-12-22) From bc228149ab338ed9c888b2b05c26d4ae4709dcde Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 15:42:32 -0700 Subject: [PATCH 171/185] Project build --- dist/angular-wizard.js | 101 ++++++++++++++++++++++++------------- dist/angular-wizard.min.js | 4 +- 2 files changed, 69 insertions(+), 36 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 4240eb5..c9dc575 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for Angular JS - * @version v0.10.0 - 2016-12-22 * @link https://github.com/mgonto/angular-wizard + * @version v1.0.0 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -67,6 +67,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { transclude: true, scope: { currentStep: '=', + onCancel: '&', onFinish: '&', hideIndicators: '=', editMode: '=', @@ -117,6 +118,28 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { return foundStep; }; + + //update completed state for each step based on the editMode and current step number + var handleEditModeChange = function() { + var editMode = $scope.editMode; + if (angular.isUndefined(editMode) || (editMode === null)) return; + + //Set completed for all steps to the value of editMode + angular.forEach($scope.steps, function (step) { + step.completed = editMode; + }); + + //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed + if (!editMode) { + var completedStepsIndex = $scope.currentStepNumber() - 1; + angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { + if(stepIndex < completedStepsIndex) { + step.completed = true; + } + }); + } + }; + //access to context object for step validation $scope.context = {}; @@ -135,23 +158,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //watching steps array length and editMode value, if edit module is undefined or null the nothing is done //if edit mode is truthy, then all steps are marked as completed $scope.$watch('[editMode, steps.length]', function() { - var editMode = $scope.editMode; - if (angular.isUndefined(editMode) || (editMode === null)) return; - - //Set completed for all steps to the value of editMode - angular.forEach($scope.steps, function (step) { - step.completed = editMode; - }); - - //If editMode is false, set ONLY ENABLED steps with index lower then completedIndex to completed - if (!editMode) { - var completedStepsIndex = $scope.currentStepNumber() - 1; - angular.forEach($scope.getEnabledSteps(), function(step, stepIndex) { - if(stepIndex < completedStepsIndex) { - step.completed = true; - } - }); - } + handleEditModeChange(); }, true); //called each time step directive is loaded @@ -165,7 +172,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.goTo($scope.getEnabledSteps()[0]); } }; - + //called each time step directive is destroyed this.removeStep = function (step) { var index = $scope.steps.indexOf(step); @@ -222,14 +229,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //emit event upwards with data on goTo() invoktion $scope.$emit('wizard:stepChanged', {step: step, index: stepIdx(step)}); //$log.log('current step number: ', $scope.currentStepNumber()); + } else { + $scope.$emit('wizard:stepChangeFailed', {step: step, index: _.indexOf($scope.getEnabledSteps(), step)}); } }); } }; function canEnterStep(step) { - var defer, - canEnter; + var defer; + var canEnter; //If no validation function is provided, allow the user to enter the step if(step.canenter === undefined){ return true; @@ -238,8 +247,14 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if(typeof step.canenter === 'boolean'){ return step.canenter; } + //If canenter is a string instead of a function, evaluate the function + if(typeof step.canenter === 'string'){ + var splitFunction = step.canenter.split('('); + canEnter = eval('$scope.$parent.' + splitFunction[0] + '($scope.context' + splitFunction[1]) + } else { + canEnter = step.canenter($scope.context); + } //Check to see if the canenter function is a promise which needs to be returned - canEnter = step.canenter($scope.context); if(angular.isFunction(canEnter.then)){ defer = $q.defer(); canEnter.then(function(response){ @@ -252,8 +267,8 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { } function canExitStep(step, stepTo) { - var defer, - canExit; + var defer; + var canExit; //Exiting the step should be allowed if no validation function was provided or if the user is moving backwards if(typeof(step.canexit) === 'undefined' || $scope.getStepNumber(stepTo) < $scope.currentStepNumber()){ return true; @@ -262,8 +277,14 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { if(typeof step.canexit === 'boolean'){ return step.canexit; } + //If canenter is a string instead of a function, evaluate the function + if(typeof step.canexit === 'string'){ + var splitFunction = step.canexit.split('('); + canExit = eval('$scope.$parent.' + splitFunction[0] + '($scope.context' + splitFunction[1]) + } else { + canExit = step.canexit($scope.context); + } //Check to see if the canexit function is a promise which needs to be returned - canExit = step.canexit($scope.context); if(angular.isFunction(canExit.then)){ defer = $q.defer(); canExit.then(function(response){ @@ -379,7 +400,7 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { $scope.onFinish(); } }; - + this.previous = function() { //getting index of current step var index = stepIdx($scope.selectedStep); @@ -394,14 +415,19 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //cancel is alias for previous. this.cancel = function() { - //getting index of current step - var index = stepIdx($scope.selectedStep); - //ensuring you aren't trying to go back from the first step - if (index === 0) { - throw new Error("Can't go back. It's already in step 0"); + if ($scope.onCancel) { + //onCancel is linked to controller via wizard directive: + $scope.onCancel(); } else { - //go back one step from current step - $scope.goTo($scope.getEnabledSteps()[0]); + //getting index of current step + var index = stepIdx($scope.selectedStep); + //ensuring you aren't trying to go back from the first step + if (index === 0) { + throw new Error("Can't go back. It's already in step 0"); + } else { + //go back one step from current step + $scope.goTo($scope.getEnabledSteps()[0]); + } } }; @@ -414,9 +440,16 @@ angular.module('mgo-angular-wizard').directive('wizard', function() { //go to first step this.goTo(0); }; + + //change edit mode + this.setEditMode = function(mode) { + $scope.editMode = mode; + handleEditModeChange(); + }; }] }; -}); +}); + function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') .directive(action, function() { diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 4bdef35..f101caa 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for Angular JS - * @version v0.10.0 - 2016-12-22 * @link https://github.com/mgonto/angular-wizard + * @version v1.0.0 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
        \n
        ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
        \n
        \n \n
        \n
        \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"=",wzOrder:"@?"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){c.$observe("wzTitle",function(b){a.title=a.wzTitle}),a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function(a,b,c,d,e,f){function g(b){var c,d;return void 0===b.canenter?!0:"boolean"==typeof b.canenter?b.canenter:(d=b.canenter(a.context),angular.isFunction(d.then)?(c=e.defer(),d.then(function(a){c.resolve(a)}),c.promise):d===!0)}function h(b,c){var d,f;return"undefined"==typeof b.canexit||a.getStepNumber(c)b&&(a.completed=!0)})}},!0),this.addStep=function(b){var c=b.wzOrder>=0&&!a.steps[b.wzOrder]?b.wzOrder:a.steps.length;a.steps[c]=b,a.getEnabledSteps()[0]===b&&a.goTo(a.getEnabledSteps()[0])},this.removeStep=function(b){var c=a.steps.indexOf(b);c>0&&a.steps.splice(c,1)},this.context=a.context,a.getStepNumber=function(a){return k(a)+1},a.goTo=function(b){if(j)i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}),j=!1;else{var c;a.currentStepNumber()>0?c=a.currentStepNumber()-1:0===a.currentStepNumber()&&(c=0),e.all([h(a.getEnabledSteps()[c],b),g(b)]).then(function(c){c[0]&&c[1]&&(i(),a.selectedStep=b,angular.isUndefined(a.currentStep)||(a.currentStep=b.wzTitle),b.selected=!0,a.$emit("wizard:stepChanged",{step:b,index:k(b)}))})}},a.currentStepNumber=function(){return k(a.selectedStep)+1},a.getEnabledSteps=function(){return a.steps.filter(function(a){return a&&"true"!==a.disabled})},this.currentStepTitle=function(){return a.selectedStep.wzTitle},this.currentStepDescription=function(){return a.selectedStep.description},this.currentStep=function(){return a.selectedStep},this.totalStepCount=function(){return a.getEnabledSteps().length},this.getEnabledSteps=function(){return a.getEnabledSteps()},this.currentStepNumber=function(){return a.currentStepNumber()},this.next=function(b){var c=a.getEnabledSteps(),d=k(a.selectedStep);if(angular.isFunction(b)){if(!b())return;d===c.length-1?this.finish():a.goTo(c[d+1])}b||(a.selectedStep.completed=!0),d===c.length-1?this.finish():a.goTo(c[d+1])},this.goTo=function(b){f(function(){var c,d=a.getEnabledSteps();c=angular.isNumber(b)?d[b]:l(b),a.goTo(c)})},this.finish=function(){a.onFinish&&a.onFinish()},this.previous=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[b-1])},this.cancel=function(){var b=k(a.selectedStep);if(0===b)throw new Error("Can't go back. It's already in step 0");a.goTo(a.getEnabledSteps()[0])},this.reset=function(){angular.forEach(a.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
        \n
        ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
        \n
        \n \n
        \n
        \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"=",wzOrder:"@?"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){c.$observe("wzTitle",function(b){a.title=a.wzTitle}),a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onCancel:"&",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function($scope,$element,$log,WizardHandler,$q,$timeout){function canEnterStep(step){var defer,canEnter;if(void 0===step.canenter)return!0;if("boolean"==typeof step.canenter)return step.canenter;if("string"==typeof step.canenter){var splitFunction=step.canenter.split("(");canEnter=eval("$scope.$parent."+splitFunction[0]+"($scope.context"+splitFunction[1])}else canEnter=step.canenter($scope.context);return angular.isFunction(canEnter.then)?(defer=$q.defer(),canEnter.then(function(a){defer.resolve(a)}),defer.promise):canEnter===!0}function canExitStep(step,stepTo){var defer,canExit;if("undefined"==typeof step.canexit||$scope.getStepNumber(stepTo)<$scope.currentStepNumber())return!0;if("boolean"==typeof step.canexit)return step.canexit;if("string"==typeof step.canexit){var splitFunction=step.canexit.split("(");canExit=eval("$scope.$parent."+splitFunction[0]+"($scope.context"+splitFunction[1])}else canExit=step.canexit($scope.context);return angular.isFunction(canExit.then)?(defer=$q.defer(),canExit.then(function(a){defer.resolve(a)}),defer.promise):canExit===!0}function unselectAll(){angular.forEach($scope.getEnabledSteps(),function(a){a.selected=!1}),$scope.selectedStep=null}void 0==$scope.indicatorsPosition&&($scope.indicatorsPosition="bottom");var firstRun=!0;WizardHandler.addWizard($scope.name||WizardHandler.defaultName,this),$scope.$on("$destroy",function(){WizardHandler.removeWizard($scope.name||WizardHandler.defaultName)}),$scope.steps=[];var stepIdx=function(a){var b=0,c=-1;return angular.forEach($scope.getEnabledSteps(),function(d){d===a&&(c=b),b++}),c},stepByTitle=function(a){var b=null;return angular.forEach($scope.getEnabledSteps(),function(c){c.wzTitle===a&&(b=c)}),b},handleEditModeChange=function(){var a=$scope.editMode;if(!angular.isUndefined(a)&&null!==a&&(angular.forEach($scope.steps,function(b){b.completed=a}),!a)){var b=$scope.currentStepNumber()-1;angular.forEach($scope.getEnabledSteps(),function(a,c){b>c&&(a.completed=!0)})}};$scope.context={},$scope.$watch("currentStep",function(a){if(a){var b=$scope.selectedStep.wzTitle;$scope.selectedStep&&b!==$scope.currentStep&&$scope.goTo(stepByTitle($scope.currentStep))}}),$scope.$watch("[editMode, steps.length]",function(){handleEditModeChange()},!0),this.addStep=function(a){var b=a.wzOrder>=0&&!$scope.steps[a.wzOrder]?a.wzOrder:$scope.steps.length;$scope.steps[b]=a,$scope.getEnabledSteps()[0]===a&&$scope.goTo($scope.getEnabledSteps()[0])},this.removeStep=function(a){var b=$scope.steps.indexOf(a);b>0&&$scope.steps.splice(b,1)},this.context=$scope.context,$scope.getStepNumber=function(a){return stepIdx(a)+1},$scope.goTo=function(a){if(firstRun)unselectAll(),$scope.selectedStep=a,angular.isUndefined($scope.currentStep)||($scope.currentStep=a.wzTitle),a.selected=!0,$scope.$emit("wizard:stepChanged",{step:a,index:stepIdx(a)}),firstRun=!1;else{var b;$scope.currentStepNumber()>0?b=$scope.currentStepNumber()-1:0===$scope.currentStepNumber()&&(b=0),$q.all([canExitStep($scope.getEnabledSteps()[b],a),canEnterStep(a)]).then(function(b){b[0]&&b[1]?(unselectAll(),$scope.selectedStep=a,angular.isUndefined($scope.currentStep)||($scope.currentStep=a.wzTitle),a.selected=!0,$scope.$emit("wizard:stepChanged",{step:a,index:stepIdx(a)})):$scope.$emit("wizard:stepChangeFailed",{step:a,index:_.indexOf($scope.getEnabledSteps(),a)})})}},$scope.currentStepNumber=function(){return stepIdx($scope.selectedStep)+1},$scope.getEnabledSteps=function(){return $scope.steps.filter(function(a){return a&&"true"!==a.disabled})},this.currentStepTitle=function(){return $scope.selectedStep.wzTitle},this.currentStepDescription=function(){return $scope.selectedStep.description},this.currentStep=function(){return $scope.selectedStep},this.totalStepCount=function(){return $scope.getEnabledSteps().length},this.getEnabledSteps=function(){return $scope.getEnabledSteps()},this.currentStepNumber=function(){return $scope.currentStepNumber()},this.next=function(a){var b=$scope.getEnabledSteps(),c=stepIdx($scope.selectedStep);if(angular.isFunction(a)){if(!a())return;c===b.length-1?this.finish():$scope.goTo(b[c+1])}a||($scope.selectedStep.completed=!0),c===b.length-1?this.finish():$scope.goTo(b[c+1])},this.goTo=function(a){$timeout(function(){var b,c=$scope.getEnabledSteps();b=angular.isNumber(a)?c[a]:stepByTitle(a),$scope.goTo(b)})},this.finish=function(){$scope.onFinish&&$scope.onFinish()},this.previous=function(){var a=stepIdx($scope.selectedStep);if(0===a)throw new Error("Can't go back. It's already in step 0");$scope.goTo($scope.getEnabledSteps()[a-1])},this.cancel=function(){if($scope.onCancel)$scope.onCancel();else{var a=stepIdx($scope.selectedStep);if(0===a)throw new Error("Can't go back. It's already in step 0");$scope.goTo($scope.getEnabledSteps()[0])}},this.reset=function(){angular.forEach($scope.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)},this.setEditMode=function(a){$scope.editMode=a,handleEditModeChange()}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From d797ee6485dd3cca3ae5289cd9c2e62d84faa3e5 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 15:43:39 -0700 Subject: [PATCH 172/185] Release version 1.0.0 --- bower.json | 4 ++-- package.json | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index fa0dc06..540eb90 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "0.10.0", + "version": "1.0.0", "main": [ "./dist/angular-wizard.js", "./dist/angular-wizard.css" @@ -18,4 +18,4 @@ "components", "lib" ] -} +} \ No newline at end of file diff --git a/package.json b/package.json index 02c256d..8f542b9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for Angular JS", - "version": "0.10.0", + "version": "1.0.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", @@ -48,17 +48,15 @@ "grunt-conventional-changelog": "~0.1.1", "grunt-html2js": "~0.1.3", "grunt-karma": "~0.9.x", - "karma": "*", - "karma-coverage": "*", + "karma": "^0.12.0", + "karma-coverage": "^1.1.1", "grunt-ng-annotate": "^0.6.0", "grunt-zip": "*", "jasmine-core": "^2.1.3", - "karma": "^0.12.0", "karma-chrome-launcher": "^0.1.7", - "karma-coverage": "^1.1.1", "karma-firefox-launcher": "~0.1.x", "karma-jasmine": "~0.3.x", "karma-phantomjs-launcher": "~1.0.x" }, "license": "MIT" -} +} \ No newline at end of file From 9428c7cd8dd0794347e79831c37ca0d4e8682065 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 15:43:54 -0700 Subject: [PATCH 173/185] update CONTRIBUTE.md with tagging instructions --- CONTRIBUTE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index 8938d60..01c4352 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -29,7 +29,7 @@ A fail does not necessarily mean a PR should be rejected, but it is a red flag t 3. Update CHANGELOG.md with release notes for the changes in the this release 4. Update version with `grunt bump` add the type flag otherwise a "patch" version change will be applied. e.g. `grunt bump --type=minor` 5. Run `$ grunt build` and commit, this time including the new dist files. -6. Tag the commit as a new release (like v2.18.0) +6. Tag the commit as a new release (like v2.18.0) (eg. `$ git tag -a v0.0.2 -m "Release version 0.0.2"`) 7. Push all the changes including tags (eg. `$ git push --tags`) 8. Publish to npm with `$ npm publish ./` 9. Add a new [Release in GitHub](https://github.com/angular-wizard/angular-wizard/releases) From ac260c417d7ddf8db6dc9a1200ff1b6bd2476cd3 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 16:01:58 -0700 Subject: [PATCH 174/185] update cdn for version 1.0.1 --- CHANGELOG.md | 6 ++++++ README.md | 8 ++++---- bower.json | 2 +- package.json | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e3ddda..ef242bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ + +# 1.0.1 (2017-06-06) + +- Update CDN instructions on README.md + + # 1.0.0 (2017-06-06) diff --git a/README.md b/README.md index 410caf6..9a34da5 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ You can download this by: ````html - - + + - - + + ```` The dist folder contains the following files: diff --git a/bower.json b/bower.json index 540eb90..21b169c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "1.0.0", + "version": "1.0.1", "main": [ "./dist/angular-wizard.js", "./dist/angular-wizard.css" diff --git a/package.json b/package.json index 8f542b9..d8282e5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for Angular JS", - "version": "1.0.0", + "version": "1.0.1", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", From c4dbd1c9dc5d2e5fc29105585633fafa0dda063a Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 16:02:26 -0700 Subject: [PATCH 175/185] update CDN to 1.0.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a34da5..2b1055d 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ You can download this by: - - + + ```` The dist folder contains the following files: From 14e54f6cf9f75257f16de0fc6e96c5329bf12387 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 16:02:36 -0700 Subject: [PATCH 176/185] project build --- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index c9dc575..044d1f2 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for Angular JS - * @version v1.0.0 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard + * @version v1.0.1 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index f101caa..03f310e 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for Angular JS - * @version v1.0.0 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard + * @version v1.0.1 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ From 4f72a35f7505cdbe148369a75adc511ac720f976 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Tue, 6 Jun 2017 16:15:37 -0700 Subject: [PATCH 177/185] update CDN url --- CHANGELOG.md | 8 +++++++- README.md | 12 ++++++------ bower.json | 2 +- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- package.json | 2 +- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef242bf..b098cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ + +# 1.0.2 (2017-06-06) + +- Update README.md to update Repository URLs + + -# 1.0.1 (2017-06-06) +# 1.0.2 (2017-06-06) - Update CDN instructions on README.md diff --git a/README.md b/README.md index 2b1055d..17b1aee 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Build Status](https://travis-ci.org/angular-wizard/angular-wizard.svg?branch=master)](https://travis-ci.org/angular-wizard/angular-wizard) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/8a488d7e632d4d1ea973bfcd25ea15a0)](https://www.codacy.com/app/jc_2/angular-wizard?utm_source=github.com&utm_medium=referral&utm_content=angular-wizard/angular-wizard&utm_campaign=Badge_Grade) [![Coverage Status](https://coveralls.io/repos/github/angular-wizard/angular-wizard/badge.svg?branch=master)](https://coveralls.io/github/angular-wizard/angular-wizard?branch=master) [![npm version](https://badge.fury.io/js/angular-wizard.svg)](https://badge.fury.io/js/angular-wizard) [![PayPal donate button](http://img.shields.io/paypal/donate.png?color=yellow)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=martin%40gon%2eto&lc=US&item_name=Martin%20Gontovnikas¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted "Donate once-off to this project using PayPal") [![Donate on Gratipay](http://img.shields.io/gratipay/mgonto.svg)](https://gratipay.com/mgonto/) -Angular-wizard is a component that will make it easy for you to create wizards in your app. You can check a running example of the wizard [by clicking here](http://mgonto.github.io/angular-wizard/) +Angular-wizard is a component that will make it easy for you to create wizards in your app. You can check a running example of the wizard [by clicking here](http://angular-wizard.github.io/angular-wizard/) # How do I add this to my project? You can download this by: @@ -19,8 +19,8 @@ You can download this by: - - + + ```` The dist folder contains the following files: @@ -247,10 +247,10 @@ The available variables are: # Live sample -You can check out a live sample of the Wizard [clicking here](http://mgonto.github.io/angular-wizard/) +You can check out a live sample of the Wizard [clicking here](http://angular-wizard.github.io/angular-wizard/) # Releases Notes -Releases notes are together with releases in GitHub at: https://github.com/mgonto/angular-wizard/releases +Releases notes are together with releases in GitHub at: https://github.com/angular-wizard/angular-wizard/releases # License @@ -265,5 +265,5 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mgonto/angular-wizard/trend.png)](https://bitdeli.com/free "Bitdeli Badge") +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/angular-wizard/angular-wizard/trend.png)](https://bitdeli.com/free "Bitdeli Badge") diff --git a/bower.json b/bower.json index 21b169c..8910739 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "1.0.1", + "version": "1.0.2", "main": [ "./dist/angular-wizard.js", "./dist/angular-wizard.css" diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 044d1f2..5647c85 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for Angular JS - * @version v1.0.1 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard + * @version v1.0.2 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 03f310e..bdd5c52 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for Angular JS - * @version v1.0.1 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard + * @version v1.0.2 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/package.json b/package.json index d8282e5..123c64d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for Angular JS", - "version": "1.0.1", + "version": "1.0.2", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", From 81e9c14b8b1bbdb4d5bc2e1cf3599ee214556779 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Jun 2017 10:45:29 -0700 Subject: [PATCH 178/185] Update README.md with setEditMode instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 17b1aee..e65e930 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,7 @@ The functions available in the `wizard()` are: * **currentStep()**: This returns an Object which is the current step you are on. * **totalStepCount()**: This returns an Number which is the total number of **enabled** steps. * **getEnabledSteps()**: This returns an Array which is the **enabled** steps. -* **setEditMode(mode)**: Set the edit mode of the wizard. +* **setEditMode(boolean)**: Set the edit mode of the wizard. Setting editMode to `true` will make ALL steps accessible, setting edit mode to `false` will make all steps with an index lower than the latest "completed" step accessible. ## Navigation bar From a8fe9fb39b3c12e0d5c65324b5e00c073eae6ce3 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Jun 2017 10:50:15 -0700 Subject: [PATCH 179/185] Bump to version 1.1.0 --- CHANGELOG.md | 7 +++++++ bower.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b098cff..eaef8c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ + +# 1.1.0 (2017-06-07) + +- Update README.md to explain Edit Mode. +- Add `wz-heading-title` attribute to each step. + + # 1.0.2 (2017-06-06) diff --git a/bower.json b/bower.json index 8910739..a724e53 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "1.0.2", + "version": "1.1.0", "main": [ "./dist/angular-wizard.js", "./dist/angular-wizard.css" diff --git a/package.json b/package.json index 123c64d..29e14a9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for Angular JS", - "version": "1.0.2", + "version": "1.1.0", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", From badc1c844829017a00e4ada4340ccfbf37e9678d Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Jun 2017 10:50:26 -0700 Subject: [PATCH 180/185] Project build --- dist/angular-wizard.js | 5 ++++- dist/angular-wizard.min.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 5647c85..72f9346 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for Angular JS - * @version v1.0.2 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard + * @version v1.1.0 - 2017-06-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ @@ -15,6 +15,8 @@ angular.module("step.html", []).run(["$templateCache", function($templateCache) angular.module("wizard.html", []).run(["$templateCache", function($templateCache) { $templateCache.put("wizard.html", "
        \n" + + "

        {{ selectedStep.wzHeadingTitle }}

        \n" + + "\n" + "
        \n" + "
          \n" + "
        • \n" + @@ -35,6 +37,7 @@ angular.module('mgo-angular-wizard').directive('wzStep', function() { transclude: true, scope: { wzTitle: '@', + wzHeadingTitle: '@', canenter : '=', canexit : '=', disabled: '@?wzDisabled', diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index bdd5c52..41ef181 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,7 +1,7 @@ /** * Easy to use Wizard library for Angular JS - * @version v1.0.2 - 2017-06-06 * @link https://github.com/mgonto/angular-wizard + * @version v1.1.0 - 2017-06-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ -function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
          \n
          ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
          \n
          \n \n
          \n
          \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"=",wzOrder:"@?"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){c.$observe("wzTitle",function(b){a.title=a.wzTitle}),a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onCancel:"&",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function($scope,$element,$log,WizardHandler,$q,$timeout){function canEnterStep(step){var defer,canEnter;if(void 0===step.canenter)return!0;if("boolean"==typeof step.canenter)return step.canenter;if("string"==typeof step.canenter){var splitFunction=step.canenter.split("(");canEnter=eval("$scope.$parent."+splitFunction[0]+"($scope.context"+splitFunction[1])}else canEnter=step.canenter($scope.context);return angular.isFunction(canEnter.then)?(defer=$q.defer(),canEnter.then(function(a){defer.resolve(a)}),defer.promise):canEnter===!0}function canExitStep(step,stepTo){var defer,canExit;if("undefined"==typeof step.canexit||$scope.getStepNumber(stepTo)<$scope.currentStepNumber())return!0;if("boolean"==typeof step.canexit)return step.canexit;if("string"==typeof step.canexit){var splitFunction=step.canexit.split("(");canExit=eval("$scope.$parent."+splitFunction[0]+"($scope.context"+splitFunction[1])}else canExit=step.canexit($scope.context);return angular.isFunction(canExit.then)?(defer=$q.defer(),canExit.then(function(a){defer.resolve(a)}),defer.promise):canExit===!0}function unselectAll(){angular.forEach($scope.getEnabledSteps(),function(a){a.selected=!1}),$scope.selectedStep=null}void 0==$scope.indicatorsPosition&&($scope.indicatorsPosition="bottom");var firstRun=!0;WizardHandler.addWizard($scope.name||WizardHandler.defaultName,this),$scope.$on("$destroy",function(){WizardHandler.removeWizard($scope.name||WizardHandler.defaultName)}),$scope.steps=[];var stepIdx=function(a){var b=0,c=-1;return angular.forEach($scope.getEnabledSteps(),function(d){d===a&&(c=b),b++}),c},stepByTitle=function(a){var b=null;return angular.forEach($scope.getEnabledSteps(),function(c){c.wzTitle===a&&(b=c)}),b},handleEditModeChange=function(){var a=$scope.editMode;if(!angular.isUndefined(a)&&null!==a&&(angular.forEach($scope.steps,function(b){b.completed=a}),!a)){var b=$scope.currentStepNumber()-1;angular.forEach($scope.getEnabledSteps(),function(a,c){b>c&&(a.completed=!0)})}};$scope.context={},$scope.$watch("currentStep",function(a){if(a){var b=$scope.selectedStep.wzTitle;$scope.selectedStep&&b!==$scope.currentStep&&$scope.goTo(stepByTitle($scope.currentStep))}}),$scope.$watch("[editMode, steps.length]",function(){handleEditModeChange()},!0),this.addStep=function(a){var b=a.wzOrder>=0&&!$scope.steps[a.wzOrder]?a.wzOrder:$scope.steps.length;$scope.steps[b]=a,$scope.getEnabledSteps()[0]===a&&$scope.goTo($scope.getEnabledSteps()[0])},this.removeStep=function(a){var b=$scope.steps.indexOf(a);b>0&&$scope.steps.splice(b,1)},this.context=$scope.context,$scope.getStepNumber=function(a){return stepIdx(a)+1},$scope.goTo=function(a){if(firstRun)unselectAll(),$scope.selectedStep=a,angular.isUndefined($scope.currentStep)||($scope.currentStep=a.wzTitle),a.selected=!0,$scope.$emit("wizard:stepChanged",{step:a,index:stepIdx(a)}),firstRun=!1;else{var b;$scope.currentStepNumber()>0?b=$scope.currentStepNumber()-1:0===$scope.currentStepNumber()&&(b=0),$q.all([canExitStep($scope.getEnabledSteps()[b],a),canEnterStep(a)]).then(function(b){b[0]&&b[1]?(unselectAll(),$scope.selectedStep=a,angular.isUndefined($scope.currentStep)||($scope.currentStep=a.wzTitle),a.selected=!0,$scope.$emit("wizard:stepChanged",{step:a,index:stepIdx(a)})):$scope.$emit("wizard:stepChangeFailed",{step:a,index:_.indexOf($scope.getEnabledSteps(),a)})})}},$scope.currentStepNumber=function(){return stepIdx($scope.selectedStep)+1},$scope.getEnabledSteps=function(){return $scope.steps.filter(function(a){return a&&"true"!==a.disabled})},this.currentStepTitle=function(){return $scope.selectedStep.wzTitle},this.currentStepDescription=function(){return $scope.selectedStep.description},this.currentStep=function(){return $scope.selectedStep},this.totalStepCount=function(){return $scope.getEnabledSteps().length},this.getEnabledSteps=function(){return $scope.getEnabledSteps()},this.currentStepNumber=function(){return $scope.currentStepNumber()},this.next=function(a){var b=$scope.getEnabledSteps(),c=stepIdx($scope.selectedStep);if(angular.isFunction(a)){if(!a())return;c===b.length-1?this.finish():$scope.goTo(b[c+1])}a||($scope.selectedStep.completed=!0),c===b.length-1?this.finish():$scope.goTo(b[c+1])},this.goTo=function(a){$timeout(function(){var b,c=$scope.getEnabledSteps();b=angular.isNumber(a)?c[a]:stepByTitle(a),$scope.goTo(b)})},this.finish=function(){$scope.onFinish&&$scope.onFinish()},this.previous=function(){var a=stepIdx($scope.selectedStep);if(0===a)throw new Error("Can't go back. It's already in step 0");$scope.goTo($scope.getEnabledSteps()[a-1])},this.cancel=function(){if($scope.onCancel)$scope.onCancel();else{var a=stepIdx($scope.selectedStep);if(0===a)throw new Error("Can't go back. It's already in step 0");$scope.goTo($scope.getEnabledSteps()[0])}},this.reset=function(){angular.forEach($scope.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)},this.setEditMode=function(a){$scope.editMode=a,handleEditModeChange()}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file +function wizardButtonDirective(a){angular.module("mgo-angular-wizard").directive(a,function(){return{restrict:"A",replace:!1,require:"^wizard",link:function(b,c,d,e){c.on("click",function(c){c.preventDefault(),b.$apply(function(){b.$eval(d[a]),e[a.replace("wz","").toLowerCase()]()})})}}})}angular.module("templates-angularwizard",["step.html","wizard.html"]),angular.module("step.html",[]).run(["$templateCache",function(a){a.put("step.html",'
          \n
          ')}]),angular.module("wizard.html",[]).run(["$templateCache",function(a){a.put("wizard.html",'
          \n

          {{ selectedStep.wzHeadingTitle }}

          \n\n
          \n \n
          \n
          \n')}]),angular.module("mgo-angular-wizard",["templates-angularwizard"]),angular.module("mgo-angular-wizard").directive("wzStep",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{wzTitle:"@",wzHeadingTitle:"@",canenter:"=",canexit:"=",disabled:"@?wzDisabled",description:"@",wzData:"=",wzOrder:"@?"},require:"^wizard",templateUrl:function(a,b){return b.template||"step.html"},link:function(a,b,c,d){c.$observe("wzTitle",function(b){a.title=a.wzTitle}),a.title=a.wzTitle,d.addStep(a),a.$on("$destroy",function(){d.removeStep(a)})}}}),angular.module("mgo-angular-wizard").directive("wizard",function(){return{restrict:"EA",replace:!0,transclude:!0,scope:{currentStep:"=",onCancel:"&",onFinish:"&",hideIndicators:"=",editMode:"=",name:"@",indicatorsPosition:"@?"},templateUrl:function(a,b){return b.template||"wizard.html"},controller:["$scope","$element","$log","WizardHandler","$q","$timeout",function($scope,$element,$log,WizardHandler,$q,$timeout){function canEnterStep(step){var defer,canEnter;if(void 0===step.canenter)return!0;if("boolean"==typeof step.canenter)return step.canenter;if("string"==typeof step.canenter){var splitFunction=step.canenter.split("(");canEnter=eval("$scope.$parent."+splitFunction[0]+"($scope.context"+splitFunction[1])}else canEnter=step.canenter($scope.context);return angular.isFunction(canEnter.then)?(defer=$q.defer(),canEnter.then(function(a){defer.resolve(a)}),defer.promise):canEnter===!0}function canExitStep(step,stepTo){var defer,canExit;if("undefined"==typeof step.canexit||$scope.getStepNumber(stepTo)<$scope.currentStepNumber())return!0;if("boolean"==typeof step.canexit)return step.canexit;if("string"==typeof step.canexit){var splitFunction=step.canexit.split("(");canExit=eval("$scope.$parent."+splitFunction[0]+"($scope.context"+splitFunction[1])}else canExit=step.canexit($scope.context);return angular.isFunction(canExit.then)?(defer=$q.defer(),canExit.then(function(a){defer.resolve(a)}),defer.promise):canExit===!0}function unselectAll(){angular.forEach($scope.getEnabledSteps(),function(a){a.selected=!1}),$scope.selectedStep=null}void 0==$scope.indicatorsPosition&&($scope.indicatorsPosition="bottom");var firstRun=!0;WizardHandler.addWizard($scope.name||WizardHandler.defaultName,this),$scope.$on("$destroy",function(){WizardHandler.removeWizard($scope.name||WizardHandler.defaultName)}),$scope.steps=[];var stepIdx=function(a){var b=0,c=-1;return angular.forEach($scope.getEnabledSteps(),function(d){d===a&&(c=b),b++}),c},stepByTitle=function(a){var b=null;return angular.forEach($scope.getEnabledSteps(),function(c){c.wzTitle===a&&(b=c)}),b},handleEditModeChange=function(){var a=$scope.editMode;if(!angular.isUndefined(a)&&null!==a&&(angular.forEach($scope.steps,function(b){b.completed=a}),!a)){var b=$scope.currentStepNumber()-1;angular.forEach($scope.getEnabledSteps(),function(a,c){b>c&&(a.completed=!0)})}};$scope.context={},$scope.$watch("currentStep",function(a){if(a){var b=$scope.selectedStep.wzTitle;$scope.selectedStep&&b!==$scope.currentStep&&$scope.goTo(stepByTitle($scope.currentStep))}}),$scope.$watch("[editMode, steps.length]",function(){handleEditModeChange()},!0),this.addStep=function(a){var b=a.wzOrder>=0&&!$scope.steps[a.wzOrder]?a.wzOrder:$scope.steps.length;$scope.steps[b]=a,$scope.getEnabledSteps()[0]===a&&$scope.goTo($scope.getEnabledSteps()[0])},this.removeStep=function(a){var b=$scope.steps.indexOf(a);b>0&&$scope.steps.splice(b,1)},this.context=$scope.context,$scope.getStepNumber=function(a){return stepIdx(a)+1},$scope.goTo=function(a){if(firstRun)unselectAll(),$scope.selectedStep=a,angular.isUndefined($scope.currentStep)||($scope.currentStep=a.wzTitle),a.selected=!0,$scope.$emit("wizard:stepChanged",{step:a,index:stepIdx(a)}),firstRun=!1;else{var b;$scope.currentStepNumber()>0?b=$scope.currentStepNumber()-1:0===$scope.currentStepNumber()&&(b=0),$q.all([canExitStep($scope.getEnabledSteps()[b],a),canEnterStep(a)]).then(function(b){b[0]&&b[1]?(unselectAll(),$scope.selectedStep=a,angular.isUndefined($scope.currentStep)||($scope.currentStep=a.wzTitle),a.selected=!0,$scope.$emit("wizard:stepChanged",{step:a,index:stepIdx(a)})):$scope.$emit("wizard:stepChangeFailed",{step:a,index:_.indexOf($scope.getEnabledSteps(),a)})})}},$scope.currentStepNumber=function(){return stepIdx($scope.selectedStep)+1},$scope.getEnabledSteps=function(){return $scope.steps.filter(function(a){return a&&"true"!==a.disabled})},this.currentStepTitle=function(){return $scope.selectedStep.wzTitle},this.currentStepDescription=function(){return $scope.selectedStep.description},this.currentStep=function(){return $scope.selectedStep},this.totalStepCount=function(){return $scope.getEnabledSteps().length},this.getEnabledSteps=function(){return $scope.getEnabledSteps()},this.currentStepNumber=function(){return $scope.currentStepNumber()},this.next=function(a){var b=$scope.getEnabledSteps(),c=stepIdx($scope.selectedStep);if(angular.isFunction(a)){if(!a())return;c===b.length-1?this.finish():$scope.goTo(b[c+1])}a||($scope.selectedStep.completed=!0),c===b.length-1?this.finish():$scope.goTo(b[c+1])},this.goTo=function(a){$timeout(function(){var b,c=$scope.getEnabledSteps();b=angular.isNumber(a)?c[a]:stepByTitle(a),$scope.goTo(b)})},this.finish=function(){$scope.onFinish&&$scope.onFinish()},this.previous=function(){var a=stepIdx($scope.selectedStep);if(0===a)throw new Error("Can't go back. It's already in step 0");$scope.goTo($scope.getEnabledSteps()[a-1])},this.cancel=function(){if($scope.onCancel)$scope.onCancel();else{var a=stepIdx($scope.selectedStep);if(0===a)throw new Error("Can't go back. It's already in step 0");$scope.goTo($scope.getEnabledSteps()[0])}},this.reset=function(){angular.forEach($scope.getEnabledSteps(),function(a){a.completed=!1}),this.goTo(0)},this.setEditMode=function(a){$scope.editMode=a,handleEditModeChange()}}]}}),wizardButtonDirective("wzNext"),wizardButtonDirective("wzPrevious"),wizardButtonDirective("wzFinish"),wizardButtonDirective("wzCancel"),wizardButtonDirective("wzReset"),angular.module("mgo-angular-wizard").factory("WizardHandler",function(){var a={},b={};return a.defaultName="defaultWizard",a.addWizard=function(a,c){b[a]=c},a.removeWizard=function(a){delete b[a]},a.wizard=function(c){var d=c;return c||(d=a.defaultName),b[d]},a}); \ No newline at end of file From 999e094fd2d88d1e9e43d3474d0a8b97aa89c084 Mon Sep 17 00:00:00 2001 From: Gonzalo Date: Wed, 7 Jun 2017 15:29:47 -0300 Subject: [PATCH 181/185] Add event docs to README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 17b1aee..bfac4ea 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,16 @@ The functions available in the `wizard()` are: * **getEnabledSteps()**: This returns an Array which is the **enabled** steps. * **setEditMode(mode)**: Set the edit mode of the wizard. +## Events +Angular Wizard emits the following events on the `scope` and pass an object with the step info and the index as argument: +- `wizard:stepChanged`: When succeed changing the current step +- `wizard:stepChangeFailed`: When changing step and either fails `canexit` of leaving step or `canenter` of arriving step. +````javascript +$scope.$on('wizard:stepChanged',function(event, args) { + console.log(args); +} +```` + ## Navigation bar Any changes you wish to make to the navigation bar can be done by overwritting the CSS. Because everyone wants the navigation bar in a different location and in a different style we have provided a default which you can change via your own HTML and CSS. The navigation bar shown below works in the following way: From ce4d87f58eccef996adb972536d2472fb2c48532 Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Jun 2017 16:54:21 -0700 Subject: [PATCH 182/185] update verbiage and log for 1.1.1 --- CHANGELOG.md | 6 ++++++ README.md | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaef8c6..01e4922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ + +# 1.1.1 (2017-06-07) + +- Update README.md to expose $broadcasts the Wizard offers. + + # 1.1.0 (2017-06-07) diff --git a/README.md b/README.md index 8a3e4c9..db0243f 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ You can download this by: - - + + ```` The dist folder contains the following files: From 15f208108e2fb729e7242f990c5436043c9cee6b Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Jun 2017 16:54:33 -0700 Subject: [PATCH 183/185] bump version patch --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index a724e53..54cfbe0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-wizard", - "version": "1.1.0", + "version": "1.1.1", "main": [ "./dist/angular-wizard.js", "./dist/angular-wizard.css" diff --git a/package.json b/package.json index 29e14a9..c64fae3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-wizard", "description": "Easy to use Wizard library for Angular JS", - "version": "1.1.0", + "version": "1.1.1", "filename": "angular-wizard.min.js", "main": "./dist/angular-wizard.js", "homepage": "https://github.com/mgonto/angular-wizard", From c9b3533aeee490c00c9dc37f36da31aabcf4bf0f Mon Sep 17 00:00:00 2001 From: Jacob Carter Date: Wed, 7 Jun 2017 16:54:43 -0700 Subject: [PATCH 184/185] Project build --- dist/angular-wizard.js | 2 +- dist/angular-wizard.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/angular-wizard.js b/dist/angular-wizard.js index 72f9346..6380ed4 100644 --- a/dist/angular-wizard.js +++ b/dist/angular-wizard.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for Angular JS - * @version v1.1.0 - 2017-06-07 * @link https://github.com/mgonto/angular-wizard + * @version v1.1.1 - 2017-06-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ diff --git a/dist/angular-wizard.min.js b/dist/angular-wizard.min.js index 41ef181..e3c7e7e 100644 --- a/dist/angular-wizard.min.js +++ b/dist/angular-wizard.min.js @@ -1,6 +1,6 @@ /** * Easy to use Wizard library for Angular JS - * @version v1.1.0 - 2017-06-07 * @link https://github.com/mgonto/angular-wizard + * @version v1.1.1 - 2017-06-07 * @link https://github.com/mgonto/angular-wizard * @author Martin Gontovnikas * @license MIT License, http://www.opensource.org/licenses/MIT */ From 9823e1f67d1fc60c88125f41dfc3fc5ab62e505c Mon Sep 17 00:00:00 2001 From: Sebastian Zelonka Date: Wed, 12 Jul 2017 12:28:31 -0300 Subject: [PATCH 185/185] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db0243f..e932f42 100644 --- a/README.md +++ b/README.md @@ -253,7 +253,7 @@ The available variables are: # Contributors -* @sebazelonka helped me with all of the styles in the Wizard. +* [@sebazelonka](https://github.com/sebazelonka) helped me with all of the styles in the Wizard. * [@jacobscarter](https://github.com/jacobscarter) is helping with manteinance, PRS merging and adding new features # Live sample