Skip to content

Commit a1a80fc

Browse files
author
Luca Trazzi
committed
updated dist
1 parent 67ca534 commit a1a80fc

2 files changed

Lines changed: 36 additions & 8 deletions

File tree

dist/angular-validation.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
angular.module('validation.provider', []);
44
angular.module('validation.directive', ['validation.provider']);
55
}).call(this);
6-
6+
77
(function() {
88
angular
99
.module('validation.provider')
@@ -35,6 +35,12 @@
3535
*/
3636
var expression = {};
3737

38+
/**
39+
* default valid method
40+
* @type {{}}
41+
*/
42+
var validMethod = null;
43+
3844
/**
3945
* default error, success message
4046
* @type {{}}
@@ -79,6 +85,23 @@
7985
return defaultMsg[msg];
8086
};
8187

88+
/**
89+
* allow user to set the global valid method
90+
* @param v
91+
* @returns {*}
92+
*/
93+
this.setValidMethod = function(v) {
94+
validMethod = v;
95+
};
96+
97+
/**
98+
* Get the valid method
99+
* @returns {*}
100+
*/
101+
this.getValidMethod = function() {
102+
return validMethod;
103+
};
104+
82105
/**
83106
* Override the errorHTML function
84107
* @param func
@@ -247,6 +270,8 @@
247270
this.$get = ['$injector', function($injector) {
248271
setup($injector);
249272
return {
273+
setValidMethod: this.setValidMethod,
274+
getValidMethod: this.getValidMethod,
250275
setErrorHTML: this.setErrorHTML,
251276
getErrorHTML: this.getErrorHTML,
252277
setSuccessHTML: this.setSuccessHTML,
@@ -266,7 +291,7 @@
266291
}];
267292
}
268293
}).call(this);
269-
294+
270295
(function() {
271296
angular
272297
.module('validation.directive')
@@ -290,7 +315,7 @@
290315
}
291316
Reset.$inject = ['$injector'];
292317
}).call(this);
293-
318+
294319
(function() {
295320
angular
296321
.module('validation.directive')
@@ -321,7 +346,7 @@
321346
}
322347
Submit.$inject = ['$injector'];
323348
}).call(this);
324-
349+
325350
(function() {
326351
angular
327352
.module('validation.directive')
@@ -556,6 +581,9 @@
556581
* Check validator
557582
*/
558583

584+
585+
var validMethod = (angular.isUndefined(attrs.validMethod)) ? $validationProvider.getValidMethod() : attrs.validMethod;
586+
559587
/**
560588
* Click submit form, check the validity when submit
561589
*/
@@ -565,7 +593,7 @@
565593

566594
isValid = checkValidation(scope, element, attrs, ctrl, validation, value);
567595

568-
if (attrs.validMethod === 'submit') {
596+
if (validMethod === 'submit') {
569597
// clear previous scope.$watch
570598
watch();
571599
watch = scope.$watch(function() {
@@ -606,7 +634,7 @@
606634
/**
607635
* Validate blur method
608636
*/
609-
if (attrs.validMethod === 'blur') {
637+
if (validMethod === 'blur') {
610638
element.bind('blur', function() {
611639
var value = scope.$eval(attrs.ngModel);
612640
scope.$apply(function() {
@@ -620,7 +648,7 @@
620648
/**
621649
* Validate submit & submit-only method
622650
*/
623-
if (attrs.validMethod === 'submit' || attrs.validMethod === 'submit-only') {
651+
if (validMethod === 'submit' || validMethod === 'submit-only') {
624652
return;
625653
}
626654

dist/angular-validation.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)