Skip to content

Commit

Permalink
7.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Danial Farid authored and Danial Farid committed Sep 20, 2015
1 parent 6a9df98 commit a9b5de6
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 28 deletions.
2 changes: 1 addition & 1 deletion FileAPI.min.js

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

42 changes: 31 additions & 11 deletions 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 7.3.4
* @version 7.3.5
*/

(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 7.3.4
* @version 7.3.5
*/

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

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

ngFileUpload.version = '7.3.4';
ngFileUpload.version = '7.3.5';

ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
var upload = this;
var sliceSupported = window.Blob && new Blob().slice;

this.isResumeSupported = function () {
return window.Blob && new Blob().slice;
};

var resumeSupported = this.isResumeSupported();

function sendHttp(config) {
config.method = config.method || 'POST';
Expand All @@ -470,15 +475,16 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
}

function getNotifyEvent(n) {
if (config._start != null && sliceSupported) {
if (config._start != null && resumeSupported) {
return {
loaded: n.loaded + config._start, total: config._file.size, type: n.type, config: config,
lengthComputable: true, target: n.target
};
}else {
} else {
return n;
}
}

config.headers.__setXHR_ = function () {
return function (xhr) {
if (!xhr) return;
Expand Down Expand Up @@ -514,7 +520,7 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
});
}

if (!sliceSupported) {
if (!resumeSupported) {
uploadWithAngular();
} else if (config._chunkSize && config._end && !config._finished) {
config._start = config._end;
Expand All @@ -531,12 +537,16 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
config._end = config._start + config._chunkSize;
}
uploadWithAngular();
}, function (e) {throw e;});
}, function (e) {
throw e;
});
} else if (config.resumeSize) {
config.resumeSize().then(function(size) {
config.resumeSize().then(function (size) {
config._start = size;
uploadWithAngular();
}, function(e) {throw e;});
}, function (e) {
throw e;
});
} else {
uploadWithAngular();
}
Expand Down Expand Up @@ -620,7 +630,7 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
function addFileToFormData(formData, file, key) {
if (isFile(file)) {
config._file = config._file || file;
if (config._start != null && sliceSupported) {
if (config._start != null && resumeSupported) {
if (config._end && config._end >= file.size) {
config._finished = true;
config._end = file.size;
Expand Down Expand Up @@ -1186,6 +1196,12 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
if (directiveName === 'ngfThumbnail' && !size) {
size = {width: elem[0].clientWidth, height: elem[0].clientHeight};
}
if (size.width === 0 && window.getComputedStyle) {
var style = getComputedStyle(elem[0]);
size = {width: parseInt(style.width.slice(0, -2)),
height: parseInt(style.height.slice(0, -2))};
}

if (angular.isString(file)) {
elem.removeClass('ngf-hide');
if (isBackground) {
Expand Down Expand Up @@ -1694,6 +1710,10 @@ ngFileUpload.service('UploadResize', ['UploadValidate', '$q', '$timeout', functi
var deferred = $q.defer();
var canvasElement = document.createElement('canvas');
var imagenElement = document.createElement('img');
if (width === 0) {
width = imagenElement.width;
height = imagenElement.height;
}
imagenElement.onload = function () {
try {
var dimensions = calculateAspectRatioFit(imagenElement.width, imagenElement.height, width, height);
Expand Down
4 changes: 2 additions & 2 deletions ng-file-upload-all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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 7.3.4
* @version 7.3.5
*/

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

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

40 changes: 30 additions & 10 deletions 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 7.3.4
* @version 7.3.5
*/

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

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

ngFileUpload.version = '7.3.4';
ngFileUpload.version = '7.3.5';

ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http, $q, $timeout) {
var upload = this;
var sliceSupported = window.Blob && new Blob().slice;

this.isResumeSupported = function () {
return window.Blob && new Blob().slice;
};

var resumeSupported = this.isResumeSupported();

function sendHttp(config) {
config.method = config.method || 'POST';
Expand All @@ -48,15 +53,16 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
}

function getNotifyEvent(n) {
if (config._start != null && sliceSupported) {
if (config._start != null && resumeSupported) {
return {
loaded: n.loaded + config._start, total: config._file.size, type: n.type, config: config,
lengthComputable: true, target: n.target
};
}else {
} else {
return n;
}
}

config.headers.__setXHR_ = function () {
return function (xhr) {
if (!xhr) return;
Expand Down Expand Up @@ -92,7 +98,7 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
});
}

if (!sliceSupported) {
if (!resumeSupported) {
uploadWithAngular();
} else if (config._chunkSize && config._end && !config._finished) {
config._start = config._end;
Expand All @@ -109,12 +115,16 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
config._end = config._start + config._chunkSize;
}
uploadWithAngular();
}, function (e) {throw e;});
}, function (e) {
throw e;
});
} else if (config.resumeSize) {
config.resumeSize().then(function(size) {
config.resumeSize().then(function (size) {
config._start = size;
uploadWithAngular();
}, function(e) {throw e;});
}, function (e) {
throw e;
});
} else {
uploadWithAngular();
}
Expand Down Expand Up @@ -198,7 +208,7 @@ ngFileUpload.service('UploadBase', ['$http', '$q', '$timeout', function ($http,
function addFileToFormData(formData, file, key) {
if (isFile(file)) {
config._file = config._file || file;
if (config._start != null && sliceSupported) {
if (config._start != null && resumeSupported) {
if (config._end && config._end >= file.size) {
config._finished = true;
config._end = file.size;
Expand Down Expand Up @@ -764,6 +774,12 @@ ngFileUpload.directive('ngfSelect', ['$parse', '$timeout', '$compile', 'Upload',
if (directiveName === 'ngfThumbnail' && !size) {
size = {width: elem[0].clientWidth, height: elem[0].clientHeight};
}
if (size.width === 0 && window.getComputedStyle) {
var style = getComputedStyle(elem[0]);
size = {width: parseInt(style.width.slice(0, -2)),
height: parseInt(style.height.slice(0, -2))};
}

if (angular.isString(file)) {
elem.removeClass('ngf-hide');
if (isBackground) {
Expand Down Expand Up @@ -1272,6 +1288,10 @@ ngFileUpload.service('UploadResize', ['UploadValidate', '$q', '$timeout', functi
var deferred = $q.defer();
var canvasElement = document.createElement('canvas');
var imagenElement = document.createElement('img');
if (width === 0) {
width = imagenElement.width;
height = imagenElement.height;
}
imagenElement.onload = function () {
try {
var dimensions = calculateAspectRatioFit(imagenElement.width, imagenElement.height, width, height);
Expand Down
4 changes: 2 additions & 2 deletions ng-file-upload.min.js

Large diffs are not rendered by default.

0 comments on commit a9b5de6

Please sign in to comment.