From 6fceefabfffb1e582847c558614f12ee3cbddd39 Mon Sep 17 00:00:00 2001 From: Eelco Cramer Date: Tue, 12 Aug 2014 11:06:35 +0200 Subject: [PATCH 1/3] Selects all the input fields --- src/modules/rcWizard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/rcWizard.js b/src/modules/rcWizard.js index 2fcdd66..b40b70e 100644 --- a/src/modules/rcWizard.js +++ b/src/modules/rcWizard.js @@ -114,7 +114,7 @@ var rcWizardDirective = { // automatically focus on the first input of the current tab. This // allows for easier keyboard-ony navigation. if (steps.length > currentIndex && steps[currentIndex].element) { - steps[currentIndex].element.find('input').first().focus(); + steps[currentIndex].element.find(':input').first().focus(); } }; From f48cdbebdc31069cb5e477defe0a304421e296d6 Mon Sep 17 00:00:00 2001 From: Eelco Cramer Date: Tue, 12 Aug 2014 11:26:19 +0200 Subject: [PATCH 2/3] Updates version --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index e393db5..1a980ed 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "angularjs-utilities", - "version": "0.0.9", + "version": "0.0.10", "homepage": "https://github.com/realcrowd/angularjs-utilities", From ff5a40740191b8c83d40cee3f3ad633ca8cc9330 Mon Sep 17 00:00:00 2001 From: Eelco Cramer Date: Tue, 16 Sep 2014 11:23:38 +0200 Subject: [PATCH 3/3] Always scroll to the top of the page. --- src/modules/rcWizard.js | 97 +++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/src/modules/rcWizard.js b/src/modules/rcWizard.js index b40b70e..76a9051 100644 --- a/src/modules/rcWizard.js +++ b/src/modules/rcWizard.js @@ -14,7 +14,7 @@ * Configures the specified element as a wizard. Uses the jQuery Bootstrap Wizard Plug-in * * @element ANY - * @param {name} Specifies the name of the wizard which can be used to look at state + * @param {name} Specifies the name of the wizard which can be used to look at state * information on the scope. */ var rcWizardDirective = { @@ -22,33 +22,33 @@ var rcWizardDirective = { return { restrict: 'A', controller: ['$scope', function ($scope) { - + var self; var wizardElement; var wizardOptions = {}; var steps = []; - + this.currentIndex = 0; this.firstIndex = 0; this.navigationLength = 0; - + this.addStep = function (step) { - + steps.push(step); - + if (!step.element || !step.submitController) return; - - // if a rcSubmitController is being used, automatically add a _hidden_ - // submit button so that - - // in order to place an submit button that is still functional it - // has to technically be visible, so instead we place it way off + + // if a rcSubmitController is being used, automatically add a _hidden_ + // submit button so that + + // in order to place an submit button that is still functional it + // has to technically be visible, so instead we place it way off // screen jQuery(step.element) .append('') .attr('action', 'javascript:void(0);'); - - // bind to the submit complete event on the rcSubmitController and + + // bind to the submit complete event on the rcSubmitController and // if the action was successful, trigger a next on the wizard. step.submitController.onSubmitComplete(function (evt) { if (evt.success) { @@ -56,50 +56,50 @@ var rcWizardDirective = { } }); }; - + this.forward = function () { - + if (steps.length) - + var currentStep = (steps.length > self.currentIndex) ? steps[self.currentIndex] : null; - + if (0 < steps.length && !currentStep) return; - + if (0 < steps.length && currentStep.submitController) { currentStep.submitController.submit(); } else { onForward(currentStep); } }; - + var onForward = function(currentStep) { - - if (0 < steps.length && - currentStep.formController && + + if (0 < steps.length && + currentStep.formController && currentStep.formController.$invalid) return; - + wizardElement.bootstrapWizard('next'); }; - + this.backward = function () { wizardElement.bootstrapWizard('previous'); }; - + var onTabChange = function (activeTab, navigation, currentIndex, nextTab) { - + self.currentIndex = nextTab; self.firstIndex = wizardElement.bootstrapWizard('firstIndex'); self.navigationLength = wizardElement.bootstrapWizard('navigationLength'); - + if (!$scope.$$phase) $scope.$apply(); }; - + var onTabClick = function (activeTab, navigation, currentIndex, clickedIndex) { return false; }; - + var onTabShow = function (activeTab, navigation, currentIndex) { - + if (currentIndex > 0) { wizardElement .find('.nav li:gt(' + (currentIndex - 1) + ')') @@ -109,31 +109,34 @@ var rcWizardDirective = { } else { wizardElement.find('.nav li').removeClass("success"); } - - // if a rcStep is being used on the current tab, + + // if a rcStep is being used on the current tab, // automatically focus on the first input of the current tab. This // allows for easier keyboard-ony navigation. if (steps.length > currentIndex && steps[currentIndex].element) { steps[currentIndex].element.find(':input').first().focus(); } + + // scroll page to top + $window.scrollTo(0,0); }; - + var updateWizard = function (options) { - + wizardOptions = options; - + if (wizardElement) { wizardElement.bootstrapWizard(options); self.currentIndex = wizardElement.bootstrapWizard('currentIndex'); self.firstIndex = wizardElement.bootstrapWizard('firstIndex'); self.navigationLength = wizardElement.bootstrapWizard('navigationLength'); - + if (!$scope.$$phase) $scope.$apply(); } }; - + this.setWizardElement = function (element) { - + wizardElement = element; self = this; updateWizard({ @@ -146,7 +149,7 @@ var rcWizardDirective = { compile: function (cElement, cAttributes, transclude) { return { pre: function (scope, formElement, attributes, wizardController) { - // put a reference to the wizardcontroller on the scope so we can + // put a reference to the wizardcontroller on the scope so we can // use some of the properties in the markup scope.rc = scope.rc || {}; scope.rc[attributes.rcWizard] = wizardController; @@ -179,17 +182,17 @@ var rcWizardStepDirective = { restrict: 'A', require: ['^rcWizard', '?form', '?rcSubmit'], link: function (scope, element, attributes, controllers) { - + var wizardController = controllers[0]; - + // find all the optional controllers for the step var formController = controllers.length > 1 ? controllers[1] : null; var submitController = controllers.length > 2 ? controllers[2] : null; - + // add the step to the wizard controller - var step = wizardController.addStep({ - 'element': element, - 'attributes': attributes, + var step = wizardController.addStep({ + 'element': element, + 'attributes': attributes, 'formController': formController, 'submitController': submitController }); } @@ -200,4 +203,4 @@ var rcWizardStepDirective = { angular.module('rcWizard', ['ng']) .directive(rcWizardDirective) -.directive(rcWizardStepDirective); \ No newline at end of file +.directive(rcWizardStepDirective);