Skip to content

Commit b885933

Browse files
committed
fixed #1691 fixed #1689
1 parent 20bd3d5 commit b885933

18 files changed

+81
-71
lines changed

demo/src/main/webapp/js/FileAPI.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.

demo/src/main/webapp/js/ng-file-upload-all.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* progress, resize, thumbnail, preview, validation and CORS
44
* FileAPI Flash shim for old browsers not supporting FormData
55
* @author Danial <danial.farid@gmail.com>
6-
* @version 12.2.6
6+
* @version 12.2.7
77
*/
88

99
(function () {
@@ -424,7 +424,7 @@ if (!window.FileReader) {
424424
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
425425
* progress, resize, thumbnail, preview, validation and CORS
426426
* @author Danial <danial.farid@gmail.com>
427-
* @version 12.2.6
427+
* @version 12.2.7
428428
*/
429429

430430
if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
@@ -445,7 +445,7 @@ if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
445445

446446
var ngFileUpload = angular.module('ngFileUpload', []);
447447

448-
ngFileUpload.version = '12.2.6';
448+
ngFileUpload.version = '12.2.7';
449449

450450
ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
451451
var upload = this;
@@ -907,7 +907,7 @@ ngFileUpload.service('Upload', ['$parse', '$timeout', '$compile', '$q', 'UploadE
907907
if (!resizeVal || !upload.isResizeSupported() || !files.length) return upload.emptyPromise();
908908
if (resizeVal instanceof Function) {
909909
var defer = $q.defer();
910-
resizeVal(files).then(function (p) {
910+
return resizeVal(files).then(function (p) {
911911
resizeWithParams(p, files, attr, scope).then(function (r) {
912912
defer.resolve(r);
913913
}, function (e) {
@@ -1837,7 +1837,7 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct
18371837
}
18381838
}
18391839

1840-
var promises = [upload.emptyPromise()];
1840+
var promises = [upload.emptyPromise(true)];
18411841
if (files) {
18421842
files = files.length === undefined ? [files] : files;
18431843
angular.forEach(files, function (file) {
@@ -1868,14 +1868,16 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct
18681868
});
18691869
}
18701870
var deffer = $q.defer();
1871-
$q.all(promises).then(function (value) {
1872-
if (value) {
1873-
ngModel.$ngfValidations.push({name: name, valid: true});
1874-
deffer.resolve(true);
1875-
} else {
1876-
ngModel.$ngfValidations.push({name: name, valid: false});
1877-
deffer.resolve(false);
1871+
$q.all(promises).then(function (values) {
1872+
var isValid = true;
1873+
for (var i = 0; i < values.length; i++) {
1874+
if (!values[i]) {
1875+
isValid = false;
1876+
break;
1877+
}
18781878
}
1879+
ngModel.$ngfValidations.push({name: name, valid: isValid});
1880+
deffer.resolve(isValid);
18791881
});
18801882
return deffer.promise;
18811883
}

demo/src/main/webapp/js/ng-file-upload-all.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/src/main/webapp/js/ng-file-upload-shim.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* progress, resize, thumbnail, preview, validation and CORS
44
* FileAPI Flash shim for old browsers not supporting FormData
55
* @author Danial <danial.farid@gmail.com>
6-
* @version 12.2.6
6+
* @version 12.2.7
77
*/
88

99
(function () {

demo/src/main/webapp/js/ng-file-upload-shim.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.

demo/src/main/webapp/js/ng-file-upload.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
33
* progress, resize, thumbnail, preview, validation and CORS
44
* @author Danial <danial.farid@gmail.com>
5-
* @version 12.2.6
5+
* @version 12.2.7
66
*/
77

88
if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
@@ -23,7 +23,7 @@ if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
2323

2424
var ngFileUpload = angular.module('ngFileUpload', []);
2525

26-
ngFileUpload.version = '12.2.6';
26+
ngFileUpload.version = '12.2.7';
2727

2828
ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
2929
var upload = this;
@@ -485,7 +485,7 @@ ngFileUpload.service('Upload', ['$parse', '$timeout', '$compile', '$q', 'UploadE
485485
if (!resizeVal || !upload.isResizeSupported() || !files.length) return upload.emptyPromise();
486486
if (resizeVal instanceof Function) {
487487
var defer = $q.defer();
488-
resizeVal(files).then(function (p) {
488+
return resizeVal(files).then(function (p) {
489489
resizeWithParams(p, files, attr, scope).then(function (r) {
490490
defer.resolve(r);
491491
}, function (e) {
@@ -1415,7 +1415,7 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct
14151415
}
14161416
}
14171417

1418-
var promises = [upload.emptyPromise()];
1418+
var promises = [upload.emptyPromise(true)];
14191419
if (files) {
14201420
files = files.length === undefined ? [files] : files;
14211421
angular.forEach(files, function (file) {
@@ -1446,14 +1446,16 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct
14461446
});
14471447
}
14481448
var deffer = $q.defer();
1449-
$q.all(promises).then(function (value) {
1450-
if (value) {
1451-
ngModel.$ngfValidations.push({name: name, valid: true});
1452-
deffer.resolve(true);
1453-
} else {
1454-
ngModel.$ngfValidations.push({name: name, valid: false});
1455-
deffer.resolve(false);
1449+
$q.all(promises).then(function (values) {
1450+
var isValid = true;
1451+
for (var i = 0; i < values.length; i++) {
1452+
if (!values[i]) {
1453+
isValid = false;
1454+
break;
1455+
}
14561456
}
1457+
ngModel.$ngfValidations.push({name: name, valid: isValid});
1458+
deffer.resolve(isValid);
14571459
});
14581460
return deffer.promise;
14591461
}

demo/src/main/webapp/js/ng-file-upload.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/FileAPI.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.

dist/ng-file-upload-all.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* progress, resize, thumbnail, preview, validation and CORS
44
* FileAPI Flash shim for old browsers not supporting FormData
55
* @author Danial <danial.farid@gmail.com>
6-
* @version 12.2.6
6+
* @version 12.2.7
77
*/
88

99
(function () {
@@ -424,7 +424,7 @@ if (!window.FileReader) {
424424
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
425425
* progress, resize, thumbnail, preview, validation and CORS
426426
* @author Danial <danial.farid@gmail.com>
427-
* @version 12.2.6
427+
* @version 12.2.7
428428
*/
429429

430430
if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
@@ -445,7 +445,7 @@ if (window.XMLHttpRequest && !(window.FileAPI && FileAPI.shouldLoad)) {
445445

446446
var ngFileUpload = angular.module('ngFileUpload', []);
447447

448-
ngFileUpload.version = '12.2.6';
448+
ngFileUpload.version = '12.2.7';
449449

450450
ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
451451
var upload = this;
@@ -907,7 +907,7 @@ ngFileUpload.service('Upload', ['$parse', '$timeout', '$compile', '$q', 'UploadE
907907
if (!resizeVal || !upload.isResizeSupported() || !files.length) return upload.emptyPromise();
908908
if (resizeVal instanceof Function) {
909909
var defer = $q.defer();
910-
resizeVal(files).then(function (p) {
910+
return resizeVal(files).then(function (p) {
911911
resizeWithParams(p, files, attr, scope).then(function (r) {
912912
defer.resolve(r);
913913
}, function (e) {
@@ -1837,7 +1837,7 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct
18371837
}
18381838
}
18391839

1840-
var promises = [upload.emptyPromise()];
1840+
var promises = [upload.emptyPromise(true)];
18411841
if (files) {
18421842
files = files.length === undefined ? [files] : files;
18431843
angular.forEach(files, function (file) {
@@ -1868,14 +1868,16 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct
18681868
});
18691869
}
18701870
var deffer = $q.defer();
1871-
$q.all(promises).then(function (value) {
1872-
if (value) {
1873-
ngModel.$ngfValidations.push({name: name, valid: true});
1874-
deffer.resolve(true);
1875-
} else {
1876-
ngModel.$ngfValidations.push({name: name, valid: false});
1877-
deffer.resolve(false);
1871+
$q.all(promises).then(function (values) {
1872+
var isValid = true;
1873+
for (var i = 0; i < values.length; i++) {
1874+
if (!values[i]) {
1875+
isValid = false;
1876+
break;
1877+
}
18781878
}
1879+
ngModel.$ngfValidations.push({name: name, valid: isValid});
1880+
deffer.resolve(isValid);
18791881
});
18801882
return deffer.promise;
18811883
}

dist/ng-file-upload-all.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)