Skip to content

Commit

Permalink
fixed #1646
Browse files Browse the repository at this point in the history
  • Loading branch information
danialfarid committed Sep 7, 2016
1 parent b885933 commit d294a48
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 72 deletions.
2 changes: 1 addition & 1 deletion demo/src/main/webapp/js/FileAPI.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions demo/src/main/webapp/js/ng-file-upload-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.2.7
* @version 12.2.8
*/

(function () {
Expand Down Expand Up @@ -424,7 +424,7 @@ if (!window.FileReader) {
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
* progress, resize, thumbnail, preview, validation and CORS
* @author Danial <[email protected]>
* @version 12.2.7
* @version 12.2.8
*/

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

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

ngFileUpload.version = '12.2.7';
ngFileUpload.version = '12.2.8';

ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
var upload = this;
Expand Down Expand Up @@ -1494,7 +1494,8 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
var size = resizeParams;
if (directiveName === 'ngfThumbnail') {
if (!size) {
size = {width: elem[0].clientWidth, height: elem[0].clientHeight};
size = {width: elem[0].naturalWidth || elem[0].clientWidth,
height: elem[0].naturalHeight || elem[0].clientHeight};
}
if (size.width === 0 && window.getComputedStyle) {
var style = getComputedStyle(elem[0]);
Expand Down Expand Up @@ -1990,8 +1991,8 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct
.css('max-width', 'none !important').css('max-height', 'none !important');

function success() {
var width = img[0].clientWidth;
var height = img[0].clientHeight;
var width = img[0].naturalWidth || img[0].clientWidth;
var height = img[0].naturalHeight || img[0].clientHeight;
img.remove();
file.$ngfWidth = width;
file.$ngfHeight = height;
Expand All @@ -2005,23 +2006,23 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct

img.on('load', success);
img.on('error', error);
var count = 0;

function checkLoadError() {
var secondsCounter = 0;
function checkLoadErrorInCaseOfNoCallback() {
$timeout(function () {
if (img[0].parentNode) {
if (img[0].clientWidth) {
success();
} else if (count > 10) {
} else if (secondsCounter++ > 10) {
error();
} else {
checkLoadError();
checkLoadErrorInCaseOfNoCallback();
}
}
}, 1000);
}

checkLoadError();
checkLoadErrorInCaseOfNoCallback();

angular.element(document.getElementsByTagName('body')[0]).append(img);
}, function () {
Expand Down
7 changes: 3 additions & 4 deletions demo/src/main/webapp/js/ng-file-upload-all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/src/main/webapp/js/ng-file-upload-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.2.7
* @version 12.2.8
*/

(function () {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/webapp/js/ng-file-upload-shim.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions demo/src/main/webapp/js/ng-file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
* progress, resize, thumbnail, preview, validation and CORS
* @author Danial <[email protected]>
* @version 12.2.7
* @version 12.2.8
*/

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

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

ngFileUpload.version = '12.2.7';
ngFileUpload.version = '12.2.8';

ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
var upload = this;
Expand Down Expand Up @@ -1072,7 +1072,8 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
var size = resizeParams;
if (directiveName === 'ngfThumbnail') {
if (!size) {
size = {width: elem[0].clientWidth, height: elem[0].clientHeight};
size = {width: elem[0].naturalWidth || elem[0].clientWidth,
height: elem[0].naturalHeight || elem[0].clientHeight};
}
if (size.width === 0 && window.getComputedStyle) {
var style = getComputedStyle(elem[0]);
Expand Down Expand Up @@ -1568,8 +1569,8 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct
.css('max-width', 'none !important').css('max-height', 'none !important');

function success() {
var width = img[0].clientWidth;
var height = img[0].clientHeight;
var width = img[0].naturalWidth || img[0].clientWidth;
var height = img[0].naturalHeight || img[0].clientHeight;
img.remove();
file.$ngfWidth = width;
file.$ngfHeight = height;
Expand All @@ -1583,23 +1584,23 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct

img.on('load', success);
img.on('error', error);
var count = 0;

function checkLoadError() {
var secondsCounter = 0;
function checkLoadErrorInCaseOfNoCallback() {
$timeout(function () {
if (img[0].parentNode) {
if (img[0].clientWidth) {
success();
} else if (count > 10) {
} else if (secondsCounter++ > 10) {
error();
} else {
checkLoadError();
checkLoadErrorInCaseOfNoCallback();
}
}
}, 1000);
}

checkLoadError();
checkLoadErrorInCaseOfNoCallback();

angular.element(document.getElementsByTagName('body')[0]).append(img);
}, function () {
Expand Down
6 changes: 3 additions & 3 deletions demo/src/main/webapp/js/ng-file-upload.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/FileAPI.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions dist/ng-file-upload-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.2.7
* @version 12.2.8
*/

(function () {
Expand Down Expand Up @@ -424,7 +424,7 @@ if (!window.FileReader) {
* AngularJS file upload directives and services. Supoorts: file upload/drop/paste, resume, cancel/abort,
* progress, resize, thumbnail, preview, validation and CORS
* @author Danial <[email protected]>
* @version 12.2.7
* @version 12.2.8
*/

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

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

ngFileUpload.version = '12.2.7';
ngFileUpload.version = '12.2.8';

ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
var upload = this;
Expand Down Expand Up @@ -1494,7 +1494,8 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
var size = resizeParams;
if (directiveName === 'ngfThumbnail') {
if (!size) {
size = {width: elem[0].clientWidth, height: elem[0].clientHeight};
size = {width: elem[0].naturalWidth || elem[0].clientWidth,
height: elem[0].naturalHeight || elem[0].clientHeight};
}
if (size.width === 0 && window.getComputedStyle) {
var style = getComputedStyle(elem[0]);
Expand Down Expand Up @@ -1990,8 +1991,8 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct
.css('max-width', 'none !important').css('max-height', 'none !important');

function success() {
var width = img[0].clientWidth;
var height = img[0].clientHeight;
var width = img[0].naturalWidth || img[0].clientWidth;
var height = img[0].naturalHeight || img[0].clientHeight;
img.remove();
file.$ngfWidth = width;
file.$ngfHeight = height;
Expand All @@ -2005,23 +2006,23 @@ ngFileUpload.service('UploadValidate', ['UploadDataUrl', '$q', '$timeout', funct

img.on('load', success);
img.on('error', error);
var count = 0;

function checkLoadError() {
var secondsCounter = 0;
function checkLoadErrorInCaseOfNoCallback() {
$timeout(function () {
if (img[0].parentNode) {
if (img[0].clientWidth) {
success();
} else if (count > 10) {
} else if (secondsCounter++ > 10) {
error();
} else {
checkLoadError();
checkLoadErrorInCaseOfNoCallback();
}
}
}, 1000);
}

checkLoadError();
checkLoadErrorInCaseOfNoCallback();

angular.element(document.getElementsByTagName('body')[0]).append(img);
}, function () {
Expand Down
7 changes: 3 additions & 4 deletions dist/ng-file-upload-all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ng-file-upload-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* progress, resize, thumbnail, preview, validation and CORS
* FileAPI Flash shim for old browsers not supporting FormData
* @author Danial <[email protected]>
* @version 12.2.7
* @version 12.2.8
*/

(function () {
Expand Down
Loading

0 comments on commit d294a48

Please sign in to comment.