Skip to content

Commit 07827fc

Browse files
committed
Fixing up the indentation.
1 parent 95767fa commit 07827fc

7 files changed

+485
-483
lines changed

src/app.provider.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
angular.module('bootstrap.angular.validation').provider('bsValidationConfig', function() {
3+
angular.module('bootstrap.angular.validation').provider('bsValidationConfig', function () {
44

55
// Can be a string or list of any combination of "blur", "submit" & "display"
66
var validateFieldsOn = 'blur';
@@ -45,7 +45,7 @@ angular.module('bootstrap.angular.validation').provider('bsValidationConfig', fu
4545
equalto: 'Please enter the same {{matchName}} again.'
4646
};
4747

48-
this.global.setValidateFieldsOn = function(event) {
48+
this.global.setValidateFieldsOn = function (event) {
4949
if (!event) {
5050
throw 'Please provide an string or list of events to validate fields on';
5151
}
@@ -57,54 +57,54 @@ angular.module('bootstrap.angular.validation').provider('bsValidationConfig', fu
5757
validateFieldsOn = event;
5858
};
5959

60-
this.global.setDisplayErrorsAs = function(type) {
60+
this.global.setDisplayErrorsAs = function (type) {
6161
if (!type) {
6262
throw 'Please provide the way validation error should be displayed. In-built options are "simple" & "tooltip".';
6363
}
6464

6565
displayErrorsAs = type;
6666
};
6767

68-
this.global.useMessageFilters = function(filters) {
69-
if (!filters) {
70-
throw 'Please provide a string or list of filters to apply to messages';
71-
}
68+
this.global.useMessageFilters = function (filters) {
69+
if (!filters) {
70+
throw 'Please provide a string or list of filters to apply to messages';
71+
}
7272

73-
if (!angular.isString(filters) && !angular.isArray(filters)) {
74-
throw 'Filters should either be a string or a list';
75-
}
73+
if (!angular.isString(filters) && !angular.isArray(filters)) {
74+
throw 'Filters should either be a string or a list';
75+
}
7676

77-
messageFilters = filters;
77+
messageFilters = filters;
7878

79-
if (!angular.isArray(messageFilters)) {
80-
messageFilters = [messageFilters];
81-
}
79+
if (!angular.isArray(messageFilters)) {
80+
messageFilters = [messageFilters];
81+
}
8282
};
8383

84-
this.$get = [function() {
84+
this.$get = [function () {
8585
return {
8686
messages: _this.global.messages,
8787
errorClass: _this.global.errorClass,
8888
successClass: _this.global.successClass,
8989
tooltipAppendToBody: _this.global.tooltipAppendToBody,
9090

91-
getDisplayErrorsAs: function() {
91+
getDisplayErrorsAs: function () {
9292
return displayErrorsAs;
9393
},
9494

95-
getErrorMessagePrefix: function() {
95+
getErrorMessagePrefix: function () {
9696
return _this.global.errorMessagePrefix || '';
9797
},
9898

9999
getMessageFilters: function () {
100100
return messageFilters;
101101
},
102102

103-
getTooltipPlacement: function() {
103+
getTooltipPlacement: function () {
104104
return _this.global.tooltipPlacement;
105105
},
106106

107-
shouldAddSuccessClass: function() {
107+
shouldAddSuccessClass: function () {
108108
return _this.global.addSuccessClass;
109109
},
110110

src/directives/form.directive.js

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,83 +7,82 @@
77
* element.
88
*/
99
angular.module('bootstrap.angular.validation').directive('form', [
10-
'$parse', 'BsValidationService',
11-
function($parse, validationService) {
10+
'$parse', 'BsValidationService', function ($parse, validationService) {
1211
return {
1312
restrict: 'E',
1413
require: 'form',
1514
priority: 1000, // Setting a higher priority so that this directive compiles first.
16-
compile: function($formElement, $formAttributes) {
17-
if (validationService.isValidationDisabled($formElement)) {
18-
return;
19-
}
15+
compile: function ($formElement, $formAttributes) {
16+
if (validationService.isValidationDisabled($formElement)) {
17+
return;
18+
}
2019

21-
// Disable HTML5 validation display
22-
$formElement.attr('novalidate', 'novalidate');
20+
// Disable HTML5 validation display
21+
$formElement.attr('novalidate', 'novalidate');
2322

24-
var ngSubmit = $formAttributes.ngSubmit;
25-
/*
26-
* Removing ngSubmit attribute if any since ngSubmit by default doesn't respects the validation errors
27-
* on the input fields.
28-
*/
29-
delete $formAttributes.ngSubmit;
23+
var ngSubmit = $formAttributes.ngSubmit;
24+
/*
25+
* Removing ngSubmit attribute if any since ngSubmit by default doesn't respects the validation errors
26+
* on the input fields.
27+
*/
28+
delete $formAttributes.ngSubmit;
3029

31-
var preLinkFunction = function($scope, formElement, $attr, formController) {
32-
// Expose a method to manually show the validation state
33-
formController.$showValidation = function() {
34-
formController.$setSubmitted();
35-
// Tell form elements to show validation state
36-
$scope.$broadcast('onBsValidationStateChange', {showValidationState: true});
37-
};
30+
var preLinkFunction = function ($scope, formElement, $attr, formController) {
31+
// Expose a method to manually show the validation state
32+
formController.$showValidation = function () {
33+
formController.$setSubmitted();
34+
// Tell form elements to show validation state
35+
$scope.$broadcast('onBsValidationStateChange', {showValidationState: true});
36+
};
3837

39-
formController.$hideValidation = function () {
40-
formController.$setPristine();
41-
// Tell form elements to hide validation state
42-
$scope.$broadcast('onBsValidationStateChange', {showValidationState: false});
43-
};
38+
formController.$hideValidation = function () {
39+
formController.$setPristine();
40+
// Tell form elements to hide validation state
41+
$scope.$broadcast('onBsValidationStateChange', {showValidationState: false});
42+
};
4443

45-
var markPristineAfterSubmit = formElement[0].attributes.hasOwnProperty('bs-pristine-on-submit');
44+
var markPristineAfterSubmit = formElement[0].attributes.hasOwnProperty('bs-pristine-on-submit');
4645

47-
formElement.on('submit', function(e) {
48-
// If any of the form element has not passed the validation
49-
if (formController.$invalid) {
50-
// Then focus the first invalid element
51-
formElement[0].querySelector('.ng-invalid').focus();
52-
return false;
53-
}
46+
formElement.on('submit', function (e) {
47+
// If any of the form element has not passed the validation
48+
if (formController.$invalid) {
49+
// Then focus the first invalid element
50+
formElement[0].querySelector('.ng-invalid').focus();
51+
return false;
52+
}
5453

55-
// Parse the handler of ng-submit & execute it
56-
var submitHandler = $parse(ngSubmit);
57-
$scope.$apply(function() {
58-
submitHandler($scope, {$event: e});
54+
// Parse the handler of ng-submit & execute it
55+
var submitHandler = $parse(ngSubmit);
56+
$scope.$apply(function () {
57+
submitHandler($scope, {$event: e});
5958

60-
formController.$commitViewValue();
61-
formController.$setSubmitted();
62-
63-
if (markPristineAfterSubmit) {
64-
formController.$hideValidation();
65-
}
66-
});
59+
formController.$commitViewValue();
60+
formController.$setSubmitted();
6761

6862
if (markPristineAfterSubmit) {
69-
/**
70-
* Prevent other submit event listener registered via Angular so that we can mark the form with
71-
* the pristine state. Otherwise, that Angular's listener is getting called at the last and is again
72-
* setting form to the submitted.
73-
*
74-
* https://api.jquery.com/event.stopimmediatepropagation/
75-
*/
76-
e.stopImmediatePropagation();
77-
e.preventDefault();
63+
formController.$hideValidation();
7864
}
79-
80-
return true;
8165
});
82-
};
8366

84-
return {
85-
pre: preLinkFunction
86-
};
67+
if (markPristineAfterSubmit) {
68+
/**
69+
* Prevent other submit event listener registered via Angular so that we can mark the form with
70+
* the pristine state. Otherwise, that Angular's listener is getting called at the last and is again
71+
* setting form to the submitted.
72+
*
73+
* https://api.jquery.com/event.stopimmediatepropagation/
74+
*/
75+
e.stopImmediatePropagation();
76+
e.preventDefault();
77+
}
78+
79+
return true;
80+
});
81+
};
82+
83+
return {
84+
pre: preLinkFunction
85+
};
8786
}
8887
};
89-
}]);
88+
}]);

0 commit comments

Comments
 (0)