#2284 jQuery Fileupload 업데이트

- 9.22.0
This commit is contained in:
bnu 2018-08-17 16:13:19 +09:00 committed by Kijin Sung
parent cb66b4e5df
commit d9a7b89a74
19 changed files with 863 additions and 593 deletions

View file

@ -0,0 +1,21 @@
MIT License
Copyright © 2010 Sebastian Tschan, https://blueimp.net
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,20 +1,20 @@
@charset "UTF-8"; @charset "UTF-8";
/* /*
* jQuery File Upload Plugin NoScript CSS 1.2.0 * jQuery File Upload Plugin NoScript CSS
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2013, Sebastian Tschan * Copyright 2013, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
.fileinput-button input { .fileinput-button input {
position: static; position: static;
opacity: 1; opacity: 1;
filter: none; filter: none;
font-size: inherit; font-size: inherit !important;
direction: inherit; direction: inherit;
} }
.fileinput-button span { .fileinput-button span {

View file

@ -1,13 +1,13 @@
@charset "UTF-8"; @charset "UTF-8";
/* /*
* jQuery File Upload UI Plugin NoScript CSS 8.8.5 * jQuery File Upload UI Plugin NoScript CSS
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2012, Sebastian Tschan * Copyright 2012, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
.fileinput-button i, .fileinput-button i,

View file

@ -1,13 +1,13 @@
@charset "UTF-8"; @charset "UTF-8";
/* /*
* jQuery File Upload UI Plugin CSS 9.0.0 * jQuery File Upload UI Plugin CSS
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2010, Sebastian Tschan * Copyright 2010, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
.fileupload-buttonbar .btn, .fileupload-buttonbar .btn,

View file

@ -1,18 +1,19 @@
@charset "UTF-8"; @charset "UTF-8";
/* /*
* jQuery File Upload Plugin CSS 1.3.0 * jQuery File Upload Plugin CSS
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2013, Sebastian Tschan * Copyright 2013, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
.fileinput-button { .fileinput-button {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
display: inline-block;
} }
.fileinput-button input { .fileinput-button input {
position: absolute; position: absolute;
@ -21,7 +22,7 @@
margin: 0; margin: 0;
opacity: 0; opacity: 0;
-ms-filter: 'alpha(opacity=0)'; -ms-filter: 'alpha(opacity=0)';
font-size: 200px; font-size: 200px !important;
direction: ltr; direction: ltr;
cursor: pointer; cursor: pointer;
} }

View file

@ -1,18 +1,18 @@
/* /*
* jQuery File Upload Plugin Angular JS Example 1.2.1 * jQuery File Upload Plugin Angular JS Example
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2013, Sebastian Tschan * Copyright 2013, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* jshint nomen:false */ /* jshint nomen:false */
/* global window, angular */ /* global window, angular */
(function () { ;(function () {
'use strict'; 'use strict';
var isOnGitHub = window.location.hostname === 'blueimp.github.io', var isOnGitHub = window.location.hostname === 'blueimp.github.io',

View file

@ -1,17 +1,17 @@
/* /*
* jQuery postMessage Transport Plugin 1.1.2 * jQuery postMessage Transport Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2011, Sebastian Tschan * Copyright 2011, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* global define, require, window, document */ /* global define, require, window, document */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
@ -64,6 +64,12 @@
loc = $('<a>').prop('href', options.postMessage)[0], loc = $('<a>').prop('href', options.postMessage)[0],
target = loc.protocol + '//' + loc.host, target = loc.protocol + '//' + loc.host,
xhrUpload = options.xhr().upload; xhrUpload = options.xhr().upload;
// IE always includes the port for the host property of a link
// element, but not in the location.host or origin property for the
// default http port 80 and https port 443, so we strip it:
if (/^(http:\/\/.+:80)|(https:\/\/.+:443)$/.test(target)) {
target = target.replace(/:(80|443)$/, '');
}
return { return {
send: function (_, completeCallback) { send: function (_, completeCallback) {
counter += 1; counter += 1;

View file

@ -1,12 +1,12 @@
/* /*
* jQuery XDomainRequest Transport Plugin 1.1.4 * jQuery XDomainRequest Transport Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2011, Sebastian Tschan * Copyright 2011, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
* *
* Based on Julian Aubourg's ajaxHooks xdr.js: * Based on Julian Aubourg's ajaxHooks xdr.js:
* https://github.com/jaubourg/ajaxHooks/ * https://github.com/jaubourg/ajaxHooks/
@ -14,7 +14,7 @@
/* global define, require, window, XDomainRequest */ /* global define, require, window, XDomainRequest */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:

View file

@ -1,18 +1,18 @@
/* /*
* jQuery File Upload AngularJS Plugin 2.2.0 * jQuery File Upload AngularJS Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2013, Sebastian Tschan * Copyright 2013, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* jshint nomen:false */ /* jshint nomen:false */
/* global define, angular */ /* global define, angular, require */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
@ -24,6 +24,16 @@
'./jquery.fileupload-video', './jquery.fileupload-video',
'./jquery.fileupload-validate' './jquery.fileupload-validate'
], factory); ], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS:
factory(
require('jquery'),
require('angular'),
require('./jquery.fileupload-image'),
require('./jquery.fileupload-audio'),
require('./jquery.fileupload-video'),
require('./jquery.fileupload-validate')
);
} else { } else {
factory(); factory();
} }
@ -91,7 +101,7 @@
angular.forEach(data.files, function (file) { angular.forEach(data.files, function (file) {
filesCopy.push(file); filesCopy.push(file);
}); });
scope.$apply(function () { scope.$parent.$applyAsync(function () {
addFileMethods(scope, data); addFileMethods(scope, data);
var method = scope.option('prependFiles') ? var method = scope.option('prependFiles') ?
'unshift' : 'push'; 'unshift' : 'push';
@ -100,7 +110,7 @@
data.process(function () { data.process(function () {
return scope.process(data); return scope.process(data);
}).always(function () { }).always(function () {
scope.$apply(function () { scope.$parent.$applyAsync(function () {
addFileMethods(scope, data); addFileMethods(scope, data);
scope.replace(filesCopy, data.files); scope.replace(filesCopy, data.files);
}); });
@ -112,12 +122,6 @@
} }
}); });
}, },
progress: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
data.scope.$apply();
},
done: function (e, data) { done: function (e, data) {
if (e.isDefaultPrevented()) { if (e.isDefaultPrevented()) {
return false; return false;
@ -197,8 +201,8 @@
// The FileUploadController initializes the fileupload widget and // The FileUploadController initializes the fileupload widget and
// provides scope methods to control the File Upload functionality: // provides scope methods to control the File Upload functionality:
.controller('FileUploadController', [ .controller('FileUploadController', [
'$scope', '$element', '$attrs', '$window', 'fileUpload', '$scope', '$element', '$attrs', '$window', 'fileUpload','$q',
function ($scope, $element, $attrs, $window, fileUpload) { function ($scope, $element, $attrs, $window, fileUpload, $q) {
var uploadMethods = { var uploadMethods = {
progress: function () { progress: function () {
return $element.fileupload('progress'); return $element.fileupload('progress');
@ -260,19 +264,21 @@
$scope.applyOnQueue = function (method) { $scope.applyOnQueue = function (method) {
var list = this.queue.slice(0), var list = this.queue.slice(0),
i, i,
file; file,
promises = [];
for (i = 0; i < list.length; i += 1) { for (i = 0; i < list.length; i += 1) {
file = list[i]; file = list[i];
if (file[method]) { if (file[method]) {
file[method](); promises.push(file[method]());
} }
} }
return $q.all(promises);
}; };
$scope.submit = function () { $scope.submit = function () {
this.applyOnQueue('$submit'); return this.applyOnQueue('$submit');
}; };
$scope.cancel = function () { $scope.cancel = function () {
this.applyOnQueue('$cancel'); return this.applyOnQueue('$cancel');
}; };
// Add upload methods to the scope: // Add upload methods to the scope:
angular.extend($scope, uploadMethods); angular.extend($scope, uploadMethods);
@ -320,9 +326,11 @@
'fileuploadprocessalways', 'fileuploadprocessalways',
'fileuploadprocessstop' 'fileuploadprocessstop'
].join(' '), function (e, data) { ].join(' '), function (e, data) {
if ($scope.$emit(e.type, data).defaultPrevented) { $scope.$parent.$applyAsync(function () {
e.preventDefault(); if ($scope.$emit(e.type, data).defaultPrevented) {
} e.preventDefault();
}
});
}).on('remove', function () { }).on('remove', function () {
// Remove upload methods from the scope, // Remove upload methods from the scope,
// when the widget is removed: // when the widget is removed:

View file

@ -1,18 +1,18 @@
/* /*
* jQuery File Upload Audio Preview Plugin 1.0.4 * jQuery File Upload Audio Preview Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2013, Sebastian Tschan * Copyright 2013, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* jshint nomen:false */ /* jshint nomen:false */
/* global define, require, window, document */ /* global define, require, window, document */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
@ -25,7 +25,8 @@
// Node/CommonJS: // Node/CommonJS:
factory( factory(
require('jquery'), require('jquery'),
require('load-image') require('blueimp-load-image/js/load-image'),
require('./jquery.fileupload-process')
); );
} else { } else {
// Browser globals: // Browser globals:

View file

@ -1,18 +1,18 @@
/* /*
* jQuery File Upload Image Preview & Resize Plugin 1.7.3 * jQuery File Upload Image Preview & Resize Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2013, Sebastian Tschan * Copyright 2013, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* jshint nomen:false */ /* jshint nomen:false */
/* global define, require, window, Blob */ /* global define, require, window, Blob */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
@ -20,8 +20,8 @@
'jquery', 'jquery',
'load-image', 'load-image',
'load-image-meta', 'load-image-meta',
'load-image-scale',
'load-image-exif', 'load-image-exif',
'load-image-ios',
'canvas-to-blob', 'canvas-to-blob',
'./jquery.fileupload-process' './jquery.fileupload-process'
], factory); ], factory);
@ -29,7 +29,12 @@
// Node/CommonJS: // Node/CommonJS:
factory( factory(
require('jquery'), require('jquery'),
require('load-image') require('blueimp-load-image/js/load-image'),
require('blueimp-load-image/js/load-image-meta'),
require('blueimp-load-image/js/load-image-scale'),
require('blueimp-load-image/js/load-image-exif'),
require('blueimp-canvas-to-blob'),
require('./jquery.fileupload-process')
); );
} else { } else {
// Browser globals: // Browser globals:

View file

@ -1,25 +1,31 @@
/* /*
* jQuery File Upload jQuery UI Plugin 8.7.2 * jQuery File Upload jQuery UI Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2013, Sebastian Tschan * Copyright 2013, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* jshint nomen:false */ /* jshint nomen:false */
/* global define, require, window */ /* global define, require, window */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
define(['jquery', './jquery.fileupload-ui'], factory); define([
'jquery',
'./jquery.fileupload-ui'
], factory);
} else if (typeof exports === 'object') { } else if (typeof exports === 'object') {
// Node/CommonJS: // Node/CommonJS:
factory(require('jquery')); factory(
require('jquery'),
require('./jquery.fileupload-ui')
);
} else { } else {
// Browser globals: // Browser globals:
factory(window.jQuery); factory(window.jQuery);

View file

@ -1,18 +1,18 @@
/* /*
* jQuery File Upload Processing Plugin 1.3.1 * jQuery File Upload Processing Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2012, Sebastian Tschan * Copyright 2012, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* jshint nomen:false */ /* jshint nomen:false */
/* global define, require, window */ /* global define, require, window */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
@ -22,7 +22,10 @@
], factory); ], factory);
} else if (typeof exports === 'object') { } else if (typeof exports === 'object') {
// Node/CommonJS: // Node/CommonJS:
factory(require('jquery')); factory(
require('jquery'),
require('./jquery.fileupload')
);
} else { } else {
// Browser globals: // Browser globals:
factory( factory(
@ -84,7 +87,7 @@
settings settings
); );
}; };
chain = chain.pipe(func, settings.always && func); chain = chain.then(func, settings.always && func);
}); });
chain chain
.done(function () { .done(function () {
@ -151,7 +154,7 @@
}; };
opts.index = index; opts.index = index;
that._processing += 1; that._processing += 1;
that._processingQueue = that._processingQueue.pipe(func, func) that._processingQueue = that._processingQueue.then(func, func)
.always(function () { .always(function () {
that._processing -= 1; that._processing -= 1;
if (that._processing === 0) { if (that._processing === 0) {

View file

@ -1,24 +1,24 @@
/* /*
* jQuery File Upload User Interface Plugin 9.6.1 * jQuery File Upload User Interface Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2010, Sebastian Tschan * Copyright 2010, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* jshint nomen:false */ /* jshint nomen:false */
/* global define, require, window */ /* global define, require, window */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
define([ define([
'jquery', 'jquery',
'tmpl', 'blueimp-tmpl',
'./jquery.fileupload-image', './jquery.fileupload-image',
'./jquery.fileupload-audio', './jquery.fileupload-audio',
'./jquery.fileupload-video', './jquery.fileupload-video',
@ -28,7 +28,11 @@
// Node/CommonJS: // Node/CommonJS:
factory( factory(
require('jquery'), require('jquery'),
require('tmpl') require('blueimp-tmpl'),
require('./jquery.fileupload-image'),
require('./jquery.fileupload-audio'),
require('./jquery.fileupload-video'),
require('./jquery.fileupload-validate')
); );
} else { } else {
// Browser globals: // Browser globals:

View file

@ -1,17 +1,17 @@
/* /*
* jQuery File Upload Validation Plugin 1.1.3 * jQuery File Upload Validation Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2013, Sebastian Tschan * Copyright 2013, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* global define, require, window */ /* global define, require, window */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
@ -21,7 +21,10 @@
], factory); ], factory);
} else if (typeof exports === 'object') { } else if (typeof exports === 'object') {
// Node/CommonJS: // Node/CommonJS:
factory(require('jquery')); factory(
require('jquery'),
require('./jquery.fileupload-process')
);
} else { } else {
// Browser globals: // Browser globals:
factory( factory(

View file

@ -1,18 +1,18 @@
/* /*
* jQuery File Upload Video Preview Plugin 1.0.4 * jQuery File Upload Video Preview Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2013, Sebastian Tschan * Copyright 2013, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* jshint nomen:false */ /* jshint nomen:false */
/* global define, require, window, document */ /* global define, require, window, document */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
@ -25,7 +25,8 @@
// Node/CommonJS: // Node/CommonJS:
factory( factory(
require('jquery'), require('jquery'),
require('load-image') require('blueimp-load-image/js/load-image'),
require('./jquery.fileupload-process')
); );
} else { } else {
// Browser globals: // Browser globals:

View file

@ -1,24 +1,24 @@
/* /*
* jQuery File Upload Plugin 5.42.3 * jQuery File Upload Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2010, Sebastian Tschan * Copyright 2010, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* jshint nomen:false */ /* jshint nomen:false */
/* global define, require, window, document, location, Blob, FormData */ /* global define, require, window, document, location, Blob, FormData */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
define([ define([
'jquery', 'jquery',
'jquery.ui.widget' 'jquery-ui/ui/widget'
], factory); ], factory);
} else if (typeof exports === 'object') { } else if (typeof exports === 'object') {
// Node/CommonJS: // Node/CommonJS:
@ -43,7 +43,7 @@
'|(Kindle/(1\\.0|2\\.[05]|3\\.0))' '|(Kindle/(1\\.0|2\\.[05]|3\\.0))'
).test(window.navigator.userAgent) || ).test(window.navigator.userAgent) ||
// Feature detection for all other devices: // Feature detection for all other devices:
$('<input type="file">').prop('disabled')); $('<input type="file"/>').prop('disabled'));
// The FileReader API is not actually used, but works as feature detection, // The FileReader API is not actually used, but works as feature detection,
// as some Safari versions (5?) support XHR file uploads via the FormData API, // as some Safari versions (5?) support XHR file uploads via the FormData API,
@ -453,7 +453,7 @@
} }
if (!multipart || options.blob || !this._isInstanceOf('File', file)) { if (!multipart || options.blob || !this._isInstanceOf('File', file)) {
options.headers['Content-Disposition'] = 'attachment; filename="' + options.headers['Content-Disposition'] = 'attachment; filename="' +
encodeURI(file.name) + '"'; encodeURI(file.uploadName || file.name) + '"';
} }
if (!multipart) { if (!multipart) {
options.contentType = file.type || 'application/octet-stream'; options.contentType = file.type || 'application/octet-stream';
@ -489,7 +489,11 @@
}); });
} }
if (options.blob) { if (options.blob) {
formData.append(paramName, options.blob, file.name); formData.append(
paramName,
options.blob,
file.uploadName || file.name
);
} else { } else {
$.each(options.files, function (index, file) { $.each(options.files, function (index, file) {
// This check allows the tests to run with // This check allows the tests to run with
@ -652,7 +656,7 @@
data.process = function (resolveFunc, rejectFunc) { data.process = function (resolveFunc, rejectFunc) {
if (resolveFunc || rejectFunc) { if (resolveFunc || rejectFunc) {
data._processQueue = this._processQueue = data._processQueue = this._processQueue =
(this._processQueue || getPromise([this])).pipe( (this._processQueue || getPromise([this])).then(
function () { function () {
if (data.errorThrown) { if (data.errorThrown) {
return $.Deferred() return $.Deferred()
@ -660,7 +664,7 @@
} }
return getPromise(arguments); return getPromise(arguments);
} }
).pipe(resolveFunc, rejectFunc); ).then(resolveFunc, rejectFunc);
} }
return this._processQueue || getPromise([this]); return this._processQueue || getPromise([this]);
}; };
@ -730,7 +734,7 @@
promise = dfd.promise(), promise = dfd.promise(),
jqXHR, jqXHR,
upload; upload;
if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) || if (!(this._isXHRUpload(options) && slice && (ub || ($.type(mcs) === 'function' ? mcs(options) : mcs) < fs)) ||
options.data) { options.data) {
return false; return false;
} }
@ -753,7 +757,7 @@
o.blob = slice.call( o.blob = slice.call(
file, file,
ub, ub,
ub + mcs, ub + ($.type(mcs) === 'function' ? mcs(o) : mcs),
file.type file.type
); );
// Store the current chunk size, as the blob itself // Store the current chunk size, as the blob itself
@ -945,9 +949,9 @@
if (this.options.limitConcurrentUploads > 1) { if (this.options.limitConcurrentUploads > 1) {
slot = $.Deferred(); slot = $.Deferred();
this._slots.push(slot); this._slots.push(slot);
pipe = slot.pipe(send); pipe = slot.then(send);
} else { } else {
this._sequence = this._sequence.pipe(send, send); this._sequence = this._sequence.then(send, send);
pipe = this._sequence; pipe = this._sequence;
} }
// Return the piped Promise object, enhanced with an abort method, // Return the piped Promise object, enhanced with an abort method,
@ -1046,13 +1050,19 @@
_replaceFileInput: function (data) { _replaceFileInput: function (data) {
var input = data.fileInput, var input = data.fileInput,
inputClone = input.clone(true); inputClone = input.clone(true),
restoreFocus = input.is(document.activeElement);
// Add a reference for the new cloned file input to the data argument: // Add a reference for the new cloned file input to the data argument:
data.fileInputClone = inputClone; data.fileInputClone = inputClone;
$('<form></form>').append(inputClone)[0].reset(); $('<form></form>').append(inputClone)[0].reset();
// Detaching allows to insert the fileInput on another form // Detaching allows to insert the fileInput on another form
// without loosing the file input value: // without loosing the file input value:
input.after(inputClone).detach(); input.after(inputClone).detach();
// If the fileInput had focus before it was detached,
// restore focus to the inputClone.
if (restoreFocus) {
inputClone.focus();
}
// Avoid memory leaks with the detached file input: // Avoid memory leaks with the detached file input:
$.cleanData(input.unbind('remove')); $.cleanData(input.unbind('remove'));
// Replace the original file input element in the fileInput // Replace the original file input element in the fileInput
@ -1074,6 +1084,8 @@
_handleFileTreeEntry: function (entry, path) { _handleFileTreeEntry: function (entry, path) {
var that = this, var that = this,
dfd = $.Deferred(), dfd = $.Deferred(),
entries = [],
dirReader,
errorHandler = function (e) { errorHandler = function (e) {
if (e && !e.entry) { if (e && !e.entry) {
e.entry = entry; e.entry = entry;
@ -1101,8 +1113,7 @@
readEntries(); readEntries();
} }
}, errorHandler); }, errorHandler);
}, };
dirReader, entries = [];
path = path || ''; path = path || '';
if (entry.isFile) { if (entry.isFile) {
if (entry._file) { if (entry._file) {
@ -1119,7 +1130,7 @@
dirReader = entry.createReader(); dirReader = entry.createReader();
readEntries(); readEntries();
} else { } else {
// Return an empy list for file system items // Return an empty list for file system items
// other than files or directories: // other than files or directories:
dfd.resolve([]); dfd.resolve([]);
} }
@ -1133,7 +1144,7 @@
$.map(entries, function (entry) { $.map(entries, function (entry) {
return that._handleFileTreeEntry(entry, path); return that._handleFileTreeEntry(entry, path);
}) })
).pipe(function () { ).then(function () {
return Array.prototype.concat.apply( return Array.prototype.concat.apply(
[], [],
arguments arguments
@ -1202,7 +1213,7 @@
return $.when.apply( return $.when.apply(
$, $,
$.map(fileInput, this._getSingleFileInputFiles) $.map(fileInput, this._getSingleFileInputFiles)
).pipe(function () { ).then(function () {
return Array.prototype.concat.apply( return Array.prototype.concat.apply(
[], [],
arguments arguments
@ -1305,6 +1316,10 @@
this._off(this.options.fileInput, 'change'); this._off(this.options.fileInput, 'change');
}, },
_destroy: function () {
this._destroyEventHandlers();
},
_setOption: function (key, value) { _setOption: function (key, value) {
var reinit = $.inArray(key, this._specialOptions) !== -1; var reinit = $.inArray(key, this._specialOptions) !== -1;
if (reinit) { if (reinit) {

View file

@ -1,17 +1,17 @@
/* /*
* jQuery Iframe Transport Plugin 1.8.3 * jQuery Iframe Transport Plugin
* https://github.com/blueimp/jQuery-File-Upload * https://github.com/blueimp/jQuery-File-Upload
* *
* Copyright 2011, Sebastian Tschan * Copyright 2011, Sebastian Tschan
* https://blueimp.net * https://blueimp.net
* *
* Licensed under the MIT license: * Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT * https://opensource.org/licenses/MIT
*/ */
/* global define, require, window, document */ /* global define, require, window, document, JSON */
(function (factory) { ;(function (factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
@ -27,7 +27,14 @@
'use strict'; 'use strict';
// Helper variable to create unique names for the transport iframes: // Helper variable to create unique names for the transport iframes:
var counter = 0; var counter = 0,
jsonAPI = $,
jsonParse = 'parseJSON';
if ('JSON' in window && 'parse' in JSON) {
jsonAPI = JSON;
jsonParse = 'parse';
}
// The iframe transport accepts four additional options: // The iframe transport accepts four additional options:
// options.fileInput: a jQuery collection of file input fields // options.fileInput: a jQuery collection of file input fields
@ -197,7 +204,7 @@
return iframe && $(iframe[0].body).text(); return iframe && $(iframe[0].body).text();
}, },
'iframe json': function (iframe) { 'iframe json': function (iframe) {
return iframe && $.parseJSON($(iframe[0].body).text()); return iframe && jsonAPI[jsonParse]($(iframe[0].body).text());
}, },
'iframe html': function (iframe) { 'iframe html': function (iframe) {
return iframe && $(iframe[0].body).html(); return iframe && $(iframe[0].body).html();

File diff suppressed because it is too large Load diff