Skip to content

Commit

Permalink
fixed #89
Browse files Browse the repository at this point in the history
  • Loading branch information
danialfarid committed Dec 31, 2013
1 parent b496cf6 commit 9813193
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 144 deletions.
98 changes: 51 additions & 47 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy : {
build : {
options : {
processContent : function(content, srcpath) {
return grunt.template.process(content);
}
},
files : [ {
expand : true,
cwd : 'demo/war/js/',
src : '<%= pkg.name %>*.js',
dest : 'dist/',
flatten : true,
filter : 'isFile'
}, {
expand : true,
cwd : 'demo/war/js/',
src : 'FileAPI.flash.swf',
dest : 'dist/',
flatten : true,
filter : 'isFile'
}, {
expand : true,
cwd : 'demo/war/js/',
src : 'FileAPI.min.js',
dest : 'dist/',
flatten : true,
filter : 'isFile'
} ]
}
},
uglify : {
options : {
banner : '/*! <%= pkg.version %> */\n'
},
build : {
files : [ {
'dist/<%= pkg.name %>.min.js' : 'dist/<%= pkg.name %>.js',
'dist/<%= pkg.name %>-shim.min.js' : 'dist/<%= pkg.name %>-shim.js',
'dist/<%= pkg.name %>-html5-shim.min.js' : 'dist/<%= pkg.name %>-html5-shim.js'
} ]
}
}
});

copy: {
build: {
files: [{
expand: true,
cwd: 'demo/war/js/',
src: '<%= pkg.name %>*.js',
dest: 'dist/',
flatten: true,
filter: 'isFile'
}, {
expand: true,
cwd: 'demo/war/js/',
src: 'FileAPI.flash.swf',
dest: 'dist/',
flatten: true,
filter: 'isFile'
}, {
expand: true,
cwd: 'demo/war/js/',
src: 'FileAPI.min.js',
dest: 'dist/',
flatten: true,
filter: 'isFile'
}]
}
},
uglify: {
options: {
banner: '/*! <%= pkg.version %> */\n'
},
build: {
files: [{
'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.js',
'dist/<%= pkg.name %>-shim.min.js': 'dist/<%= pkg.name %>-shim.js',
'dist/<%= pkg.name %>-html5-shim.min.js': 'dist/<%= pkg.name %>-html5-shim.js'
}]
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');

// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');

// Default task(s).
grunt.registerTask('default', ['copy', 'uglify']);
// Default task(s).
grunt.registerTask('default', [ 'copy', 'uglify' ]);

};
30 changes: 0 additions & 30 deletions bower.json

This file was deleted.

3 changes: 2 additions & 1 deletion demo/war/js/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.1
* @version <%= pkg.version %>
*/
if (window.XMLHttpRequest) {
if (window.FormData) {
Expand All @@ -25,5 +25,6 @@ if (window.XMLHttpRequest) {
return xhr;
}
})(XMLHttpRequest);
window.XMLHttpRequest.__isShim = true;
}
}
14 changes: 8 additions & 6 deletions demo/war/js/angular-file-upload-shim.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**!
* AngularJS file upload shim for HTML5 FormData
* @author Danial <[email protected]>
* @version 1.2.1
* @version <%= pkg.version %>
*/
(function() {

if (window.XMLHttpRequest) {
if (window.FormData) {
// allow access to Angular XHR private field: https://github.com/angular/angular.js/issues/1934
XMLHttpRequest = (function(origXHR) {
window.XMLHttpRequest = (function(origXHR) {
return function() {
var xhr = new origXHR();
xhr.setRequestHeader = (function(orig) {
Expand All @@ -26,9 +26,9 @@ if (window.XMLHttpRequest) {
})(xhr.setRequestHeader);
return xhr;
}
})(XMLHttpRequest);
})(window.XMLHttpRequest);
} else {
XMLHttpRequest = (function(origXHR) {
window.XMLHttpRequest = (function(origXHR) {
return function() {
var xhr = new origXHR();
var origSend = xhr.send;
Expand Down Expand Up @@ -120,8 +120,9 @@ if (window.XMLHttpRequest) {
}
return xhr;
}
})(XMLHttpRequest);
})(window.XMLHttpRequest);
}
window.XMLHttpRequest.__isShim = true;
}

if (!window.FormData) {
Expand Down Expand Up @@ -234,6 +235,7 @@ if (!window.FormData) {
})();
}

/*
if (!window.FileReader) {
window.FileReader = function() {
var _this = this, loadStarted = false;
Expand Down Expand Up @@ -294,5 +296,5 @@ if (!window.FileReader) {
}
}
}

*/
})();
46 changes: 24 additions & 22 deletions demo/war/js/angular-file-upload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**!
* AngularJS file upload/drop directive with http post and progress
* @author Danial <[email protected]>
* @version 1.2.1
* @version <%= pkg.version %>
*/
(function() {

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

config.headers['__setXHR_'] = function() {
return function(xhr) {
config.__XHR = xhr;
xhr.upload.addEventListener('progress', function(e) {
if (config.progress) {
$timeout(function() {
config.progress(e);
});
}
}, false);
//fix for firefox not firing upload progress end, also IE8-9
xhr.upload.addEventListener('load', function(e) {
if (e.lengthComputable) {
$timeout(function() {
config.progress(e);
});
}
}, false);
}
};

if (window.XMLHttpRequest.__isShim) {
config.headers['__setXHR_'] = function() {
return function(xhr) {
config.__XHR = xhr;
xhr.upload.addEventListener('progress', function(e) {
if (config.progress) {
$timeout(function() {
config.progress(e);
});
}
}, false);
//fix for firefox not firing upload progress end, also IE8-9
xhr.upload.addEventListener('load', function(e) {
if (e.lengthComputable) {
$timeout(function() {
config.progress(e);
});
}
}, false);
}
};
}

var promise = $http(config);

promise.progress = function(fn) {
Expand Down
Binary file modified dist/FileAPI.flash.swf
Binary file not shown.
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.

3 changes: 2 additions & 1 deletion dist/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.1
* @version 1.2.2
*/
if (window.XMLHttpRequest) {
if (window.FormData) {
Expand All @@ -25,5 +25,6 @@ if (window.XMLHttpRequest) {
return xhr;
}
})(XMLHttpRequest);
window.XMLHttpRequest.__isShim = true;
}
}
4 changes: 2 additions & 2 deletions dist/angular-file-upload-html5-shim.min.js

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

14 changes: 8 additions & 6 deletions dist/angular-file-upload-shim.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**!
* AngularJS file upload shim for HTML5 FormData
* @author Danial <[email protected]>
* @version 1.2.1
* @version 1.2.2
*/
(function() {

if (window.XMLHttpRequest) {
if (window.FormData) {
// allow access to Angular XHR private field: https://github.com/angular/angular.js/issues/1934
XMLHttpRequest = (function(origXHR) {
window.XMLHttpRequest = (function(origXHR) {
return function() {
var xhr = new origXHR();
xhr.setRequestHeader = (function(orig) {
Expand All @@ -26,9 +26,9 @@ if (window.XMLHttpRequest) {
})(xhr.setRequestHeader);
return xhr;
}
})(XMLHttpRequest);
})(window.XMLHttpRequest);
} else {
XMLHttpRequest = (function(origXHR) {
window.XMLHttpRequest = (function(origXHR) {
return function() {
var xhr = new origXHR();
var origSend = xhr.send;
Expand Down Expand Up @@ -120,8 +120,9 @@ if (window.XMLHttpRequest) {
}
return xhr;
}
})(XMLHttpRequest);
})(window.XMLHttpRequest);
}
window.XMLHttpRequest.__isShim = true;
}

if (!window.FormData) {
Expand Down Expand Up @@ -234,6 +235,7 @@ if (!window.FormData) {
})();
}

/*
if (!window.FileReader) {
window.FileReader = function() {
var _this = this, loadStarted = false;
Expand Down Expand Up @@ -294,5 +296,5 @@ if (!window.FileReader) {
}
}
}

*/
})();
4 changes: 2 additions & 2 deletions dist/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 9813193

Please sign in to comment.