diff --git a/public/modules/forms/directives/field.client.directive.js b/public/modules/forms/directives/field.client.directive.js index 3360b700..3a170f68 100644 --- a/public/modules/forms/directives/field.client.directive.js +++ b/public/modules/forms/directives/field.client.directive.js @@ -45,7 +45,8 @@ angular.module('forms').directive('fieldDirective', ['$templateCache', '$http', scope: { field: '=', required: '&', - design: '=' + design: '=', + index: '=', }, link: function(scope, element) { scope.setActiveField = $rootScope.setActiveField; diff --git a/public/modules/forms/directives/focus-on.client.directive.js b/public/modules/forms/directives/focus-on.client.directive.js new file mode 100644 index 00000000..1f6b0d79 --- /dev/null +++ b/public/modules/forms/directives/focus-on.client.directive.js @@ -0,0 +1,31 @@ +'use strict'; + +angular.module('forms').directive('focusOn',function() { + return { + restrict : 'A', + link : function($scope, $element, $attr) { + $scope.$watch($attr.focusOn,function(focusVal) { + // console.log($element); + if(focusVal === true) { + setTimeout(function() { + var $input_element; + + if($element[0].querySelector('input')){ + $input_element = $element[0].querySelector('input'); + }else if($element[0].querySelector('select')){ + $input_element = $element[0].querySelector('select'); + }else if($element[0].querySelector('textarea')){ + $input_element = $element[0].querySelector('textarea'); + }else if($element[0].querySelector('.angular-input-stars')){ + $input_element = $element[0].querySelector('.angular-input-stars'); + } + // $('body').animate({ + // scrollTop: $input_element.offset().top + // }); + $input_element.focus(); + },50); + } + }); + } + } +}) \ No newline at end of file diff --git a/public/modules/forms/directives/submit-form.client.directive.js b/public/modules/forms/directives/submit-form.client.directive.js index 6e1da767..daa9d68b 100644 --- a/public/modules/forms/directives/submit-form.client.directive.js +++ b/public/modules/forms/directives/submit-form.client.directive.js @@ -9,24 +9,52 @@ angular.module('forms').directive('submitFormDirective', ['$http', '$timeout', ' myform:'=' }, controller: function($scope){ - angular.element(document).ready(function() { + // angular.element(document).ready(function() { $scope.error = ''; - $scope.selected = null; + $scope.selected = { + _id: $scope.myform.form_fields[0]._id, + index: 0, + }; + $scope.submitted = false; TimeCounter.startClock() $scope.exitStartPage = function(){ $scope.myform.startPage.showStart = false; - } - $rootScope.setActiveField = function (field_id) { - $scope.selected = field_id; }; - $scope.hideOverlay = function (){ + + $scope.nextField = function(){ + if($scope.selected.index < $scope.myform.form_fields.length){ + $scope.selected.index++; + $scope.selected._id = $scope.myform.form_fields[$scope.selected.index]._id; + } + }; + $scope.prevField = function(){ + if($scope.selected.index > 0){ + $scope.selected.index = $scope.selected.index - 1; + $scope.selected._id = $scope.myform.form_fields[$scope.selected.index]._id; + } + }; + + $rootScope.setActiveField = function(field_id, field_index) { + if($scope.selected === null){ + $scope.selected = { + _id: '', + index: 0, + }; + } + console.log('field_id: '+field_id); + console.log('field_index: '+field_index); + console.log($scope.selected); + $scope.selected._id = field_id; + $scope.selected.index = field_index; + }; + $scope.hideOverlay = function(){ $scope.selected = null; }; - $scope.submit = function(){ + $scope.submitForm = function(){ var _timeElapsed = TimeCounter.stopClock(); var form = _.cloneDeep($scope.myform); @@ -34,7 +62,6 @@ angular.module('forms').directive('submitFormDirective', ['$http', '$timeout', ' // console.log('percentageComplete: '+$filter('formValidity')($scope.myform)/$scope.myform.visible_form_fields.length*100+'%'); form.percentageComplete = $filter('formValidity')($scope.myform)/$scope.myform.visible_form_fields.length*100; - console.log(form.percentageComplete) delete form.visible_form_fields; $scope.authentication = Auth; @@ -62,7 +89,7 @@ angular.module('forms').directive('submitFormDirective', ['$http', '$timeout', ' return field; }).value(); }; - }); + // }); } }; diff --git a/public/modules/forms/views/directiveViews/field/checkbox.html b/public/modules/forms/views/directiveViews/field/checkbox.html index 3212d2c2..71f0ac8a 100755 --- a/public/modules/forms/views/directiveViews/field/checkbox.html +++ b/public/modules/forms/views/directiveViews/field/checkbox.html @@ -1,10 +1,10 @@ -
+
{{field.title}} (* required)