Skip to content

Commit

Permalink
fixed #281
Browse files Browse the repository at this point in the history
  • Loading branch information
Danial Farid authored and Danial Farid committed Jul 28, 2014
1 parent a47e241 commit 8cf9b7a
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 18 deletions.
4 changes: 2 additions & 2 deletions demo/war/WEB-INF/appengine-web.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>angular-file-upload-cors-srv</application>
<version>1-6-1</version>
<application>angular-file-upload</application>
<version>1-6-2</version>

<!--
Allows App Engine to send multiple requests to one instance in parallel:
Expand Down
2 changes: 1 addition & 1 deletion demo/war/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ <h3>
</ul>
</div>
</div>
<div style="position:fixed;bottom:10px;right:10px;font-size:smaller;color:#777">Last update: 2014-07-20</div>
<div style="position:fixed;bottom:10px;right:10px;font-size:smaller;color:#777">Last update: 2014-07-27</div>
</body>
</html>
19 changes: 16 additions & 3 deletions demo/war/js/angular-file-upload-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ if (window.XMLHttpRequest) {
Object.defineProperty(xhr, 'responseText', {get: function() {return fileApiXHR.responseText}});
Object.defineProperty(xhr, 'response', {get: function() {return fileApiXHR.responseText}});
xhr.__fileApiXHR = fileApiXHR;
xhr.onreadystatechange();
if (xhr.onreadystatechange) xhr.onreadystatechange();
},
fileprogress: function(e) {
e.target = xhr;
Expand Down Expand Up @@ -194,7 +194,15 @@ if (!window.FormData || (window.FileAPI && FileAPI.forceLoad)) {
(evt.__files_ || evt.target.files).item = function(i) {
return (evt.__files_ || evt.target.files)[i] || null;
}
fn(evt);
if (fn) {
fn.apply(this, [evt]);
} else {
// fix for #281 jQuery on IE8
var handlers = jQuery._data(this, "events").change;
for (var i = 1; i < handlers.length; i++) {
handlers[i].handler.apply(this, [evt]);
}
}
};
};
var isFileChange = function(elem, e) {
Expand All @@ -217,7 +225,12 @@ if (!window.FormData || (window.FileAPI && FileAPI.forceLoad)) {
return function(e, fn) {
if (isFileChange(this, e)) {
addFlash(this);
origAttachEvent.apply(this, [e, changeFnWrapper(fn)]);
if (jQuery) {
// fix for #281 jQuery on IE8
angular.element(this).bind("change", changeFnWrapper(null));
} else {
origAttachEvent.apply(this, [e, changeFnWrapper(fn)]);
}
} else {
origAttachEvent.apply(this, [e, fn]);
}
Expand Down
2 changes: 1 addition & 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 <danial.farid@gmail.com>
* @version 1.6.2
* @version 1.6.3
*/
if (window.XMLHttpRequest) {
if (window.FormData) {
Expand Down
2 changes: 1 addition & 1 deletion 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.

21 changes: 17 additions & 4 deletions dist/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 <danial.farid@gmail.com>
* @version 1.6.2
* @version 1.6.3
*/
(function() {

Expand Down Expand Up @@ -118,7 +118,7 @@ if (window.XMLHttpRequest) {
Object.defineProperty(xhr, 'responseText', {get: function() {return fileApiXHR.responseText}});
Object.defineProperty(xhr, 'response', {get: function() {return fileApiXHR.responseText}});
xhr.__fileApiXHR = fileApiXHR;
xhr.onreadystatechange();
if (xhr.onreadystatechange) xhr.onreadystatechange();
},
fileprogress: function(e) {
e.target = xhr;
Expand Down Expand Up @@ -194,7 +194,15 @@ if (!window.FormData || (window.FileAPI && FileAPI.forceLoad)) {
(evt.__files_ || evt.target.files).item = function(i) {
return (evt.__files_ || evt.target.files)[i] || null;
}
fn(evt);
if (fn) {
fn.apply(this, [evt]);
} else {
// fix for #281 jQuery on IE8
var handlers = jQuery._data(this, "events").change;
for (var i = 1; i < handlers.length; i++) {
handlers[i].handler.apply(this, [evt]);
}
}
};
};
var isFileChange = function(elem, e) {
Expand All @@ -217,7 +225,12 @@ if (!window.FormData || (window.FileAPI && FileAPI.forceLoad)) {
return function(e, fn) {
if (isFileChange(this, e)) {
addFlash(this);
origAttachEvent.apply(this, [e, changeFnWrapper(fn)]);
if (jQuery) {
// fix for #281 jQuery on IE8
angular.element(this).bind("change", changeFnWrapper(null));
} else {
origAttachEvent.apply(this, [e, changeFnWrapper(fn)]);
}
} else {
origAttachEvent.apply(this, [e, fn]);
}
Expand Down
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.

2 changes: 1 addition & 1 deletion dist/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 <danial.farid@gmail.com>
* @version 1.6.2
* @version 1.6.3
*/
(function() {

Expand Down
Loading

0 comments on commit 8cf9b7a

Please sign in to comment.