@@ -57,17 +57,17 @@ if (window.XMLHttpRequest) {
57
57
} ) ( xhr . open ) ;
58
58
xhr . getResponseHeader = ( function ( orig ) {
59
59
return function ( h ) {
60
- return xhr . __fileApiXHR ? xhr . __fileApiXHR . getResponseHeader ( h ) : orig . apply ( xhr , [ h ] ) ;
60
+ return xhr . __fileApiXHR ? xhr . __fileApiXHR . getResponseHeader ( h ) : orig . apply ( xhr , [ h ] ) ;
61
61
}
62
62
} ) ( xhr . getResponseHeader ) ;
63
63
xhr . getAllResponseHeaders = ( function ( orig ) {
64
64
return function ( ) {
65
- return xhr . __fileApiXHR ? xhr . __fileApiXHR . getAllResponseHeaders ( ) : orig . apply ( xhr ) ;
65
+ return xhr . __fileApiXHR ? xhr . __fileApiXHR . getAllResponseHeaders ( ) : orig . apply ( xhr ) ;
66
66
}
67
67
} ) ( xhr . getAllResponseHeaders ) ;
68
68
xhr . abort = ( function ( orig ) {
69
69
return function ( ) {
70
- return xhr . __fileApiXHR ? xhr . __fileApiXHR . abort ( ) : ( orig == null ? null : orig . apply ( xhr ) ) ;
70
+ return xhr . __fileApiXHR ? xhr . __fileApiXHR . abort ( ) : ( orig == null ? null : orig . apply ( xhr ) ) ;
71
71
}
72
72
} ) ( xhr . abort ) ;
73
73
xhr . setRequestHeader = ( function ( orig ) {
@@ -83,7 +83,7 @@ if (window.XMLHttpRequest) {
83
83
}
84
84
}
85
85
} ) ( xhr . setRequestHeader ) ;
86
-
86
+
87
87
xhr . send = function ( ) {
88
88
if ( arguments [ 0 ] && arguments [ 0 ] . __isShim ) {
89
89
var formData = arguments [ 0 ] ;
@@ -116,7 +116,7 @@ if (window.XMLHttpRequest) {
116
116
config . data [ item . key ] = item . val ;
117
117
}
118
118
}
119
-
119
+
120
120
setTimeout ( function ( ) {
121
121
if ( ! hasFlash ) {
122
122
alert ( 'Please install Adode Flash Player to upload files.' ) ;
@@ -169,19 +169,19 @@ if (!window.FormData) {
169
169
return function ( e , fn , b , d ) {
170
170
if ( isFileChange ( this , e ) ) {
171
171
wrapFileApi ( this ) ;
172
- origAddEventListener . apply ( this , [ e , changeFnWrapper ( fn ) , b , d ] ) ;
172
+ origAddEventListener . apply ( this , [ e , changeFnWrapper ( fn ) , b , d ] ) ;
173
173
} else {
174
174
origAddEventListener . apply ( this , [ e , fn , b , d ] ) ;
175
175
}
176
176
}
177
- } ) ( HTMLInputElement . prototype . addEventListener ) ;
177
+ } ) ( HTMLInputElement . prototype . addEventListener ) ;
178
178
}
179
179
if ( HTMLInputElement . prototype . attachEvent ) {
180
180
HTMLInputElement . prototype . attachEvent = ( function ( origAttachEvent ) {
181
181
return function ( e , fn ) {
182
182
if ( isFileChange ( this , e ) ) {
183
183
wrapFileApi ( this ) ;
184
- origAttachEvent . apply ( this , [ e , changeFnWrapper ( fn ) ] ) ;
184
+ origAttachEvent . apply ( this , [ e , changeFnWrapper ( fn ) ] ) ;
185
185
} else {
186
186
origAttachEvent . apply ( this , [ e , fn ] ) ;
187
187
}
@@ -202,13 +202,15 @@ if (!window.FormData) {
202
202
__isShim : true
203
203
} ;
204
204
} ;
205
-
205
+
206
206
( function ( ) {
207
207
//load FileAPI
208
208
if ( ! window . FileAPI || ! FileAPI . upload ) {
209
- var base = '' , script = document . createElement ( 'script' ) , allScripts = document . getElementsByTagName ( 'script' ) , i , index , src ;
209
+ var base = '' , jsUrl = null , script = document . createElement ( 'script' ) , allScripts = document . getElementsByTagName ( 'script' ) , i , index , src ;
210
210
if ( window . FileAPI && window . FileAPI . jsPath ) {
211
211
base = window . FileAPI . jsPath ;
212
+ } else if ( window . FileAPI && window . FileAPI . jsUrl ) {
213
+ jsUrl = window . FileAPI . jsUrl
212
214
} else {
213
215
for ( i = 0 ; i < allScripts . length ; i ++ ) {
214
216
src = allScripts [ i ] . src ;
@@ -228,8 +230,8 @@ if (!window.FormData) {
228
230
staticPath : base
229
231
}
230
232
}
231
-
232
- script . setAttribute ( 'src' , base + "FileAPI.min.js" ) ;
233
+
234
+ script . setAttribute ( 'src' , jsUrl || base + "FileAPI.min.js" ) ;
233
235
document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( script ) ;
234
236
}
235
237
} ) ( ) ;
@@ -241,7 +243,7 @@ if (!window.FileReader) {
241
243
var _this = this, loadStarted = false;
242
244
this.listeners = {};
243
245
this.addEventListener = function(type, fn) {
244
- _this.listeners[type] = _this.listeners[type] || [];
246
+ _this.listeners[type] = _this.listeners[type] || [];
245
247
_this.listeners[type].push(fn);
246
248
};
247
249
this.removeEventListener = function(type, fn) {
@@ -256,7 +258,7 @@ if (!window.FileReader) {
256
258
}
257
259
};
258
260
this.onabort = this.onerror = this.onload = this.onloadstart = this.onloadend = this.onprogress = null;
259
-
261
+
260
262
function constructEvent(type, evt) {
261
263
var e = {type: type, target: _this, loaded: evt.loaded, total: evt.total, error: evt.error};
262
264
if (evt.result != null) e.target.result = evt.result;
@@ -297,4 +299,4 @@ if (!window.FileReader) {
297
299
}
298
300
}
299
301
*/
300
- } ) ( ) ;
302
+ } ) ( ) ;
0 commit comments