Skip to content

Commit

Permalink
1.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
danialfarid committed Mar 24, 2014
1 parent d8f2691 commit 664f8a4
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 56 deletions.
2 changes: 1 addition & 1 deletion angular-file-upload-html5-shim.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**!
* AngularJS file upload shim for angular XHR HTML5 browsers
* @author Danial <[email protected]>
* @version 1.2.9
* @version 1.2.10
*/
if (window.XMLHttpRequest) {
if (window.FormData) {
Expand Down
2 changes: 1 addition & 1 deletion angular-file-upload-html5-shim.min.js

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

20 changes: 11 additions & 9 deletions angular-file-upload-shim.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**!
* AngularJS file upload shim for HTML5 FormData
* @author Danial <[email protected]>
* @version 1.2.9
* @version 1.2.10
*/
(function() {

Expand Down Expand Up @@ -45,13 +45,9 @@ if (window.XMLHttpRequest) {
xhr.__requestHeaders = [];
xhr.open = (function(orig) {
if (!xhr.upload) xhr.upload = {};
xhr.__listeners = [];
xhr.upload.addEventListener = function(t, fn, b) {
if (t === 'progress') {
xhr.__progress = fn;
}
if (t === 'load') {
xhr.__load = fn;
}
xhr.__listeners[t] = fn;
};
return function(m, url, b) {
orig.apply(xhr, [m, url, b]);
Expand Down Expand Up @@ -93,7 +89,12 @@ if (window.XMLHttpRequest) {
var config = {
url: xhr.__url,
complete: function(err, fileApiXHR) {
if (!err) xhr.__load({type: 'load', loaded: xhr.__total, total: xhr.__total, target: xhr, lengthComputable: true});
if (!err && xhr.__listeners['load'])
xhr.__listeners['load']({type: 'load', loaded: xhr.__loaded, total: xhr.__total, target: xhr, lengthComputable: true});
if (!err && xhr.__listeners['loadend'])
xhr.__listeners['loadend']({type: 'loadend', loaded: xhr.__loaded, total: xhr.__total, target: xhr, lengthComputable: true});
if (err === 'abort' && xhr.__listeners['abort'])
xhr.__listeners['abort']({type: 'abort', loaded: xhr.__loaded, total: xhr.__total, target: xhr, lengthComputable: true});
if (fileApiXHR.status !== undefined) Object.defineProperty(xhr, 'status', {get: function() {return fileApiXHR.status}});
if (fileApiXHR.statusText !== undefined) Object.defineProperty(xhr, 'statusText', {get: function() {return fileApiXHR.statusText}});
Object.defineProperty(xhr, 'readyState', {get: function() {return 4}});
Expand All @@ -104,8 +105,9 @@ if (window.XMLHttpRequest) {
},
progress: function(e) {
e.target = xhr;
xhr.__progress(e);
xhr.__listeners['progress'] && xhr.__listeners['progress'](e);
xhr.__total = e.total;
xhr.__loaded = e.loaded;
},
headers: xhr.__requestHeaders
}
Expand Down
4 changes: 2 additions & 2 deletions angular-file-upload-shim.min.js

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

Loading

0 comments on commit 664f8a4

Please sign in to comment.