Skip to content

Commit 9813193

Browse files
committed
1 parent b496cf6 commit 9813193

15 files changed

+128
-144
lines changed

Gruntfile.js

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
11
module.exports = function(grunt) {
2+
grunt.initConfig({
3+
pkg : grunt.file.readJSON('package.json'),
24

3-
grunt.initConfig({
4-
pkg: grunt.file.readJSON('package.json'),
5+
copy : {
6+
build : {
7+
options : {
8+
processContent : function(content, srcpath) {
9+
return grunt.template.process(content);
10+
}
11+
},
12+
files : [ {
13+
expand : true,
14+
cwd : 'demo/war/js/',
15+
src : '<%= pkg.name %>*.js',
16+
dest : 'dist/',
17+
flatten : true,
18+
filter : 'isFile'
19+
}, {
20+
expand : true,
21+
cwd : 'demo/war/js/',
22+
src : 'FileAPI.flash.swf',
23+
dest : 'dist/',
24+
flatten : true,
25+
filter : 'isFile'
26+
}, {
27+
expand : true,
28+
cwd : 'demo/war/js/',
29+
src : 'FileAPI.min.js',
30+
dest : 'dist/',
31+
flatten : true,
32+
filter : 'isFile'
33+
} ]
34+
}
35+
},
36+
uglify : {
37+
options : {
38+
banner : '/*! <%= pkg.version %> */\n'
39+
},
40+
build : {
41+
files : [ {
42+
'dist/<%= pkg.name %>.min.js' : 'dist/<%= pkg.name %>.js',
43+
'dist/<%= pkg.name %>-shim.min.js' : 'dist/<%= pkg.name %>-shim.js',
44+
'dist/<%= pkg.name %>-html5-shim.min.js' : 'dist/<%= pkg.name %>-html5-shim.js'
45+
} ]
46+
}
47+
}
48+
});
549

6-
copy: {
7-
build: {
8-
files: [{
9-
expand: true,
10-
cwd: 'demo/war/js/',
11-
src: '<%= pkg.name %>*.js',
12-
dest: 'dist/',
13-
flatten: true,
14-
filter: 'isFile'
15-
}, {
16-
expand: true,
17-
cwd: 'demo/war/js/',
18-
src: 'FileAPI.flash.swf',
19-
dest: 'dist/',
20-
flatten: true,
21-
filter: 'isFile'
22-
}, {
23-
expand: true,
24-
cwd: 'demo/war/js/',
25-
src: 'FileAPI.min.js',
26-
dest: 'dist/',
27-
flatten: true,
28-
filter: 'isFile'
29-
}]
30-
}
31-
},
32-
uglify: {
33-
options: {
34-
banner: '/*! <%= pkg.version %> */\n'
35-
},
36-
build: {
37-
files: [{
38-
'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.js',
39-
'dist/<%= pkg.name %>-shim.min.js': 'dist/<%= pkg.name %>-shim.js',
40-
'dist/<%= pkg.name %>-html5-shim.min.js': 'dist/<%= pkg.name %>-html5-shim.js'
41-
}]
42-
}
43-
}
44-
});
50+
// Load the plugin that provides the "uglify" task.
51+
grunt.loadNpmTasks('grunt-contrib-copy');
52+
grunt.loadNpmTasks('grunt-contrib-uglify');
4553

46-
// Load the plugin that provides the "uglify" task.
47-
grunt.loadNpmTasks('grunt-contrib-copy');
48-
grunt.loadNpmTasks('grunt-contrib-uglify');
49-
50-
// Default task(s).
51-
grunt.registerTask('default', ['copy', 'uglify']);
54+
// Default task(s).
55+
grunt.registerTask('default', [ 'copy', 'uglify' ]);
5256

5357
};

bower.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

demo/war/js/angular-file-upload-html5-shim.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**!
22
* AngularJS file upload shim for angular XHR HTML5 browsers
33
* @author Danial <danial.farid@gmail.com>
4-
* @version 1.2.1
4+
* @version <%= pkg.version %>
55
*/
66
if (window.XMLHttpRequest) {
77
if (window.FormData) {
@@ -25,5 +25,6 @@ if (window.XMLHttpRequest) {
2525
return xhr;
2626
}
2727
})(XMLHttpRequest);
28+
window.XMLHttpRequest.__isShim = true;
2829
}
2930
}

demo/war/js/angular-file-upload-shim.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**!
22
* AngularJS file upload shim for HTML5 FormData
33
* @author Danial <danial.farid@gmail.com>
4-
* @version 1.2.1
4+
* @version <%= pkg.version %>
55
*/
66
(function() {
77

88
if (window.XMLHttpRequest) {
99
if (window.FormData) {
1010
// allow access to Angular XHR private field: https://github.com/angular/angular.js/issues/1934
11-
XMLHttpRequest = (function(origXHR) {
11+
window.XMLHttpRequest = (function(origXHR) {
1212
return function() {
1313
var xhr = new origXHR();
1414
xhr.setRequestHeader = (function(orig) {
@@ -26,9 +26,9 @@ if (window.XMLHttpRequest) {
2626
})(xhr.setRequestHeader);
2727
return xhr;
2828
}
29-
})(XMLHttpRequest);
29+
})(window.XMLHttpRequest);
3030
} else {
31-
XMLHttpRequest = (function(origXHR) {
31+
window.XMLHttpRequest = (function(origXHR) {
3232
return function() {
3333
var xhr = new origXHR();
3434
var origSend = xhr.send;
@@ -120,8 +120,9 @@ if (window.XMLHttpRequest) {
120120
}
121121
return xhr;
122122
}
123-
})(XMLHttpRequest);
123+
})(window.XMLHttpRequest);
124124
}
125+
window.XMLHttpRequest.__isShim = true;
125126
}
126127

127128
if (!window.FormData) {
@@ -234,6 +235,7 @@ if (!window.FormData) {
234235
})();
235236
}
236237

238+
/*
237239
if (!window.FileReader) {
238240
window.FileReader = function() {
239241
var _this = this, loadStarted = false;
@@ -294,5 +296,5 @@ if (!window.FileReader) {
294296
}
295297
}
296298
}
297-
299+
*/
298300
})();

demo/war/js/angular-file-upload.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**!
22
* AngularJS file upload/drop directive with http post and progress
33
* @author Danial <danial.farid@gmail.com>
4-
* @version 1.2.1
4+
* @version <%= pkg.version %>
55
*/
66
(function() {
77

@@ -18,27 +18,29 @@ angularFileUpload.service('$upload', ['$http', '$rootScope', '$timeout', functio
1818
return $http.defaults.transformRequest[0](data);
1919
};
2020

21-
config.headers['__setXHR_'] = function() {
22-
return function(xhr) {
23-
config.__XHR = xhr;
24-
xhr.upload.addEventListener('progress', function(e) {
25-
if (config.progress) {
26-
$timeout(function() {
27-
config.progress(e);
28-
});
29-
}
30-
}, false);
31-
//fix for firefox not firing upload progress end, also IE8-9
32-
xhr.upload.addEventListener('load', function(e) {
33-
if (e.lengthComputable) {
34-
$timeout(function() {
35-
config.progress(e);
36-
});
37-
}
38-
}, false);
39-
}
40-
};
41-
21+
if (window.XMLHttpRequest.__isShim) {
22+
config.headers['__setXHR_'] = function() {
23+
return function(xhr) {
24+
config.__XHR = xhr;
25+
xhr.upload.addEventListener('progress', function(e) {
26+
if (config.progress) {
27+
$timeout(function() {
28+
config.progress(e);
29+
});
30+
}
31+
}, false);
32+
//fix for firefox not firing upload progress end, also IE8-9
33+
xhr.upload.addEventListener('load', function(e) {
34+
if (e.lengthComputable) {
35+
$timeout(function() {
36+
config.progress(e);
37+
});
38+
}
39+
}, false);
40+
}
41+
};
42+
}
43+
4244
var promise = $http(config);
4345

4446
promise.progress = function(fn) {

dist/FileAPI.flash.swf

31.1 KB
Binary file not shown.

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/angular-file-upload-html5-shim.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**!
22
* AngularJS file upload shim for angular XHR HTML5 browsers
33
* @author Danial <danial.farid@gmail.com>
4-
* @version 1.2.1
4+
* @version 1.2.2
55
*/
66
if (window.XMLHttpRequest) {
77
if (window.FormData) {
@@ -25,5 +25,6 @@ if (window.XMLHttpRequest) {
2525
return xhr;
2626
}
2727
})(XMLHttpRequest);
28+
window.XMLHttpRequest.__isShim = true;
2829
}
2930
}

dist/angular-file-upload-html5-shim.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/angular-file-upload-shim.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**!
22
* AngularJS file upload shim for HTML5 FormData
33
* @author Danial <danial.farid@gmail.com>
4-
* @version 1.2.1
4+
* @version 1.2.2
55
*/
66
(function() {
77

88
if (window.XMLHttpRequest) {
99
if (window.FormData) {
1010
// allow access to Angular XHR private field: https://github.com/angular/angular.js/issues/1934
11-
XMLHttpRequest = (function(origXHR) {
11+
window.XMLHttpRequest = (function(origXHR) {
1212
return function() {
1313
var xhr = new origXHR();
1414
xhr.setRequestHeader = (function(orig) {
@@ -26,9 +26,9 @@ if (window.XMLHttpRequest) {
2626
})(xhr.setRequestHeader);
2727
return xhr;
2828
}
29-
})(XMLHttpRequest);
29+
})(window.XMLHttpRequest);
3030
} else {
31-
XMLHttpRequest = (function(origXHR) {
31+
window.XMLHttpRequest = (function(origXHR) {
3232
return function() {
3333
var xhr = new origXHR();
3434
var origSend = xhr.send;
@@ -120,8 +120,9 @@ if (window.XMLHttpRequest) {
120120
}
121121
return xhr;
122122
}
123-
})(XMLHttpRequest);
123+
})(window.XMLHttpRequest);
124124
}
125+
window.XMLHttpRequest.__isShim = true;
125126
}
126127

127128
if (!window.FormData) {
@@ -234,6 +235,7 @@ if (!window.FormData) {
234235
})();
235236
}
236237

238+
/*
237239
if (!window.FileReader) {
238240
window.FileReader = function() {
239241
var _this = this, loadStarted = false;
@@ -294,5 +296,5 @@ if (!window.FileReader) {
294296
}
295297
}
296298
}
297-
299+
*/
298300
})();

0 commit comments

Comments
 (0)