Skip to content

Commit 28ea5dc

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 7fa7aba + 7199fa6 commit 28ea5dc

11 files changed

Lines changed: 147 additions & 20 deletions

API.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ You can also add a custom validation message by using `message-id` attribute. It
120120
<!-- Clean, right ? -->
121121
```
122122

123+
### **Select a global validation method** `watch blur submit submit-only`**
124+
125+
`validationProvider.setValidMethod('submit')`
126+
123127
### **Setup a new Validation `setExpression()` `setDefaultMsg()` with `RegExp` or `Function` in config phase**
124128
<a name="custom-function-huei"></a>
125129

Q&A.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ Before using `checkValid()`, you have to execute `submit` first to get the lates
2626
###How do we do tooltips for error messages upon focusing? [#68](https://github.com/huei90/angular-validation/issues/68#issuecomment-86445467)
2727

2828
Using `validCallback` and `invalidCallback` to implement
29+
30+
###Can this works correctly with AngularUI, ui-select, others ... ?###
31+
32+
Yes, `angular-validation` works perfectly with other directive. (isolation scope). Find out more from the demo page.

bower.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,5 @@
2424
"tests"
2525
],
2626
"dependencies": {
27-
"bootstrap": "~3.3.6",
28-
"angular-bootstrap": "~0.14.3",
29-
"ui-select": "angular-ui-select#~0.13.2",
30-
"angular-sanitize": "~0.0.2"
3127
}
3228
}

demo/demo.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
// -------------------
9191
.controller('index', ['$scope', '$injector', function($scope, $injector) {
9292
// Injector
93+
9394
var $validationProvider = $injector.get('$validation');
9495

9596
// Initial Value
@@ -150,6 +151,7 @@
150151
checkValid: $validationProvider.checkValid
151152
};
152153

154+
// Bootstrap Datepicker
153155
$scope.form7 = {
154156
dt: new Date(),
155157
open: function($event) {

dist/angular-validation.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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,
@@ -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)