External Libraries: Revert [46634-46635].

On further investigation, Plupload changed it’s license to a non-GPL compatible license. The newest, GPL compatible version is being used already in Core.

Unprops desrosj.
See #48277.
Built from https://develop.svn.wordpress.org/trunk@46638


git-svn-id: http://core.svn.wordpress.org/trunk@46438 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2019-11-03 17:09:02 +00:00
parent 583e49d95f
commit 44db7e4f6f
9 changed files with 2513 additions and 4107 deletions

View File

@ -461,7 +461,7 @@ jQuery( document ).ready( function( $ ) {
action: 'media-create-image-subsizes', action: 'media-create-image-subsizes',
_wpnonce: wpUploaderInit.multipart_params._wpnonce, _wpnonce: wpUploaderInit.multipart_params._wpnonce,
attachment_id: id, attachment_id: id,
_wp_upload_failed_cleanup: true _wp_upload_failed_cleanup: true,
} }
}); });
@ -489,7 +489,7 @@ jQuery( document ).ready( function( $ ) {
action: 'media-create-image-subsizes', action: 'media-create-image-subsizes',
_wpnonce: wpUploaderInit.multipart_params._wpnonce, _wpnonce: wpUploaderInit.multipart_params._wpnonce,
attachment_id: id, attachment_id: id,
_legacy_support: 'true' _legacy_support: 'true',
} }
}).done( function( response ) { }).done( function( response ) {
var message; var message;
@ -512,7 +512,7 @@ jQuery( document ).ready( function( $ ) {
wpQueueError( pluploadL10n.http_error_image ); wpQueueError( pluploadL10n.http_error_image );
}); });
}; }
// init and set the uploader // init and set the uploader
uploader_init = function() { uploader_init = function() {

View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
/** /**
* Plupload - multi-runtime File Uploader * Plupload - multi-runtime File Uploader
* v2.3.6 * v2.1.9
* *
* Copyright 2013, Moxiecode Systems AB * Copyright 2013, Moxiecode Systems AB
* Released under GPL License. * Released under GPL License.
@ -8,23 +8,8 @@
* License: http://www.plupload.com/license * License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing * Contributing: http://www.plupload.com/contributing
* *
* Date: 2017-11-03 * Date: 2016-05-15
*/ */
;(function (global, factory) {
var extract = function() {
var ctx = {};
factory.apply(ctx, arguments);
return ctx.plupload;
};
if (typeof define === "function" && define.amd) {
define("plupload", ['./moxie'], extract);
} else if (typeof module === "object" && module.exports) {
module.exports = extract(require('./moxie'));
} else {
global.plupload = extract(global.moxie);
}
}(this || window, function(moxie) {
/** /**
* Plupload.js * Plupload.js
* *
@ -35,12 +20,18 @@
* Contributing: http://www.plupload.com/contributing * Contributing: http://www.plupload.com/contributing
*/ */
;(function(exports, o, undef) { /**
* Modified for WordPress, Silverlight and Flash runtimes support was removed.
* See https://core.trac.wordpress.org/ticket/41755.
*/
var delay = window.setTimeout; /*global mOxie:true */
var fileFilters = {};
var u = o.core.utils; ;(function(window, o, undef) {
var Runtime = o.runtime.Runtime;
var delay = window.setTimeout
, fileFilters = {}
;
// convert plupload features to caps acceptable by mOxie // convert plupload features to caps acceptable by mOxie
function normalizeCaps(settings) { function normalizeCaps(settings) {
@ -79,23 +70,22 @@ function normalizeCaps(settings) {
}); });
} else if (features === true) { } else if (features === true) {
// check settings for required features // check settings for required features
if (settings.chunk_size && settings.chunk_size > 0) { if (settings.chunk_size > 0) {
caps.slice_blob = true; caps.slice_blob = true;
} }
if (!plupload.isEmptyObj(settings.resize) || settings.multipart === false) { if (settings.resize.enabled || !settings.multipart) {
caps.send_binary_string = true; caps.send_binary_string = true;
} }
if (settings.http_method) {
caps.use_http_method = settings.http_method;
}
plupload.each(settings, function(value, feature) { plupload.each(settings, function(value, feature) {
resolve(feature, !!value, true); // strict check resolve(feature, !!value, true); // strict check
}); });
} }
// WP: only html runtimes.
settings.runtimes = 'html5,html4';
return caps; return caps;
} }
@ -112,7 +102,7 @@ var plupload = {
* @static * @static
* @final * @final
*/ */
VERSION : '2.3.6', VERSION : '2.1.9',
/** /**
* The state of the queue before it has started and after it has finished * The state of the queue before it has started and after it has finished
@ -214,8 +204,7 @@ var plupload = {
INIT_ERROR : -500, INIT_ERROR : -500,
/** /**
* File size error. If the user selects a file that is too large or is empty it will be blocked and * File size error. If the user selects a file that is too large it will be blocked and an error of this type will be triggered.
* an error of this type will be triggered.
* *
* @property FILE_SIZE_ERROR * @property FILE_SIZE_ERROR
* @static * @static
@ -269,15 +258,6 @@ var plupload = {
*/ */
IMAGE_DIMENSIONS_ERROR : -702, IMAGE_DIMENSIONS_ERROR : -702,
/**
* Expose whole moxie (#1469).
*
* @property moxie
* @type Object
* @final
*/
moxie: o,
/** /**
* Mime type lookup table. * Mime type lookup table.
* *
@ -285,12 +265,12 @@ var plupload = {
* @type Object * @type Object
* @final * @final
*/ */
mimeTypes : u.Mime.mimes, mimeTypes : o.mimes,
/** /**
* In some cases sniffing is the only way around :( * In some cases sniffing is the only way around :(
*/ */
ua: u.Env, ua: o.ua,
/** /**
* Gets the true type of the built-in object (better version of typeof). * Gets the true type of the built-in object (better version of typeof).
@ -301,7 +281,7 @@ var plupload = {
* @param {Object} o Object to check. * @param {Object} o Object to check.
* @return {String} Object [[Class]] * @return {String} Object [[Class]]
*/ */
typeOf: u.Basic.typeOf, typeOf: o.typeOf,
/** /**
* Extends the specified object with another object. * Extends the specified object with another object.
@ -312,7 +292,7 @@ var plupload = {
* @param {Object..} obj Multiple objects to extend with. * @param {Object..} obj Multiple objects to extend with.
* @return {Object} Same as target, the extended object. * @return {Object} Same as target, the extended object.
*/ */
extend : u.Basic.extend, extend : o.extend,
/** /**
* Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers. * Generates an unique ID. This is 99.99% unique since it takes the current time and 5 random numbers.
@ -325,7 +305,7 @@ var plupload = {
* @static * @static
* @return {String} Virtually unique id. * @return {String} Virtually unique id.
*/ */
guid : u.Basic.guid, guid : o.guid,
/** /**
* Get array of DOM Elements by their ids. * Get array of DOM Elements by their ids.
@ -359,7 +339,7 @@ var plupload = {
@param {String} id Identifier of the DOM Element @param {String} id Identifier of the DOM Element
@return {Node} @return {Node}
*/ */
get: u.Dom.get, get: o.get,
/** /**
* Executes the callback function for each item in array/object. If you return false in the * Executes the callback function for each item in array/object. If you return false in the
@ -370,7 +350,7 @@ var plupload = {
* @param {Object} obj Object to iterate. * @param {Object} obj Object to iterate.
* @param {function} callback Callback function to execute for each item. * @param {function} callback Callback function to execute for each item.
*/ */
each : u.Basic.each, each : o.each,
/** /**
* Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields. * Returns the absolute x, y position of an Element. The position will be returned in a object with x, y fields.
@ -381,7 +361,7 @@ var plupload = {
* @param {Element} root Optional root element to stop calculations at. * @param {Element} root Optional root element to stop calculations at.
* @return {object} Absolute position of the specified element object with x, y fields. * @return {object} Absolute position of the specified element object with x, y fields.
*/ */
getPos : u.Dom.getPos, getPos : o.getPos,
/** /**
* Returns the size of the specified node in pixels. * Returns the size of the specified node in pixels.
@ -391,7 +371,7 @@ var plupload = {
* @param {Node} node Node to get the size of. * @param {Node} node Node to get the size of.
* @return {Object} Object with a w and h property. * @return {Object} Object with a w and h property.
*/ */
getSize : u.Dom.getSize, getSize : o.getSize,
/** /**
* Encodes the specified string. * Encodes the specified string.
@ -417,7 +397,7 @@ var plupload = {
* @param {Object} obj Object with length field. * @param {Object} obj Object with length field.
* @return {Array} Array object containing all items. * @return {Array} Array object containing all items.
*/ */
toArray : u.Basic.toArray, toArray : o.toArray,
/** /**
* Find an element in array and return its index if present, otherwise return -1. * Find an element in array and return its index if present, otherwise return -1.
@ -428,21 +408,7 @@ var plupload = {
* @param {Array} array * @param {Array} array
* @return {Int} Index of the element, or -1 if not found * @return {Int} Index of the element, or -1 if not found
*/ */
inArray : u.Basic.inArray, inArray : o.inArray,
/**
Recieve an array of functions (usually async) to call in sequence, each function
receives a callback as first argument that it should call, when it completes. Finally,
after everything is complete, main callback is called. Passing truthy value to the
callback as a first argument will interrupt the sequence and invoke main callback
immediately.
@method inSeries
@static
@param {Array} queue Array of functions to call in sequence
@param {Function} cb Main callback that is called in the end, or in case of error
*/
inSeries: u.Basic.inSeries,
/** /**
* Extends the language pack object with new items. * Extends the language pack object with new items.
@ -452,7 +418,7 @@ var plupload = {
* @param {Object} pack Language pack items to add. * @param {Object} pack Language pack items to add.
* @return {Object} Extended language pack object. * @return {Object} Extended language pack object.
*/ */
addI18n : o.core.I18n.addI18n, addI18n : o.addI18n,
/** /**
* Translates the specified string by checking for the english string in the language pack lookup. * Translates the specified string by checking for the english string in the language pack lookup.
@ -462,15 +428,7 @@ var plupload = {
* @param {String} str String to look for. * @param {String} str String to look for.
* @return {String} Translated string or the input string if it wasn't found. * @return {String} Translated string or the input string if it wasn't found.
*/ */
translate : o.core.I18n.translate, translate : o.translate,
/**
* Pseudo sprintf implementation - simple way to replace tokens with specified values.
*
* @param {String} str String with tokens
* @return {String} String with replaced tokens
*/
sprintf : u.Basic.sprintf,
/** /**
* Checks if object is empty. * Checks if object is empty.
@ -480,7 +438,7 @@ var plupload = {
* @param {Object} obj Object to check. * @param {Object} obj Object to check.
* @return {Boolean} * @return {Boolean}
*/ */
isEmptyObj : u.Basic.isEmptyObj, isEmptyObj : o.isEmptyObj,
/** /**
* Checks if specified DOM element has specified class. * Checks if specified DOM element has specified class.
@ -490,7 +448,7 @@ var plupload = {
* @param {Object} obj DOM element like object to add handler to. * @param {Object} obj DOM element like object to add handler to.
* @param {String} name Class name * @param {String} name Class name
*/ */
hasClass : u.Dom.hasClass, hasClass : o.hasClass,
/** /**
* Adds specified className to specified DOM element. * Adds specified className to specified DOM element.
@ -500,7 +458,7 @@ var plupload = {
* @param {Object} obj DOM element like object to add handler to. * @param {Object} obj DOM element like object to add handler to.
* @param {String} name Class name * @param {String} name Class name
*/ */
addClass : u.Dom.addClass, addClass : o.addClass,
/** /**
* Removes specified className from specified DOM element. * Removes specified className from specified DOM element.
@ -510,7 +468,7 @@ var plupload = {
* @param {Object} obj DOM element like object to add handler to. * @param {Object} obj DOM element like object to add handler to.
* @param {String} name Class name * @param {String} name Class name
*/ */
removeClass : u.Dom.removeClass, removeClass : o.removeClass,
/** /**
* Returns a given computed style of a DOM element. * Returns a given computed style of a DOM element.
@ -520,7 +478,7 @@ var plupload = {
* @param {Object} obj DOM element like object. * @param {Object} obj DOM element like object.
* @param {String} name Style you want to get from the DOM element * @param {String} name Style you want to get from the DOM element
*/ */
getStyle : u.Dom.getStyle, getStyle : o.getStyle,
/** /**
* Adds an event handler to the specified object and store reference to the handler * Adds an event handler to the specified object and store reference to the handler
@ -533,7 +491,7 @@ var plupload = {
* @param {Function} callback Function to call when event occurs. * @param {Function} callback Function to call when event occurs.
* @param {String} (optional) key that might be used to add specifity to the event record. * @param {String} (optional) key that might be used to add specifity to the event record.
*/ */
addEvent : u.Events.addEvent, addEvent : o.addEvent,
/** /**
* Remove event handler from the specified object. If third argument (callback) * Remove event handler from the specified object. If third argument (callback)
@ -545,7 +503,7 @@ var plupload = {
* @param {String} name Name of event listener to remove. * @param {String} name Name of event listener to remove.
* @param {Function|String} (optional) might be a callback or unique key to match. * @param {Function|String} (optional) might be a callback or unique key to match.
*/ */
removeEvent: u.Events.removeEvent, removeEvent: o.removeEvent,
/** /**
* Remove all kind of events from the specified object * Remove all kind of events from the specified object
@ -555,7 +513,7 @@ var plupload = {
* @param {Object} obj DOM element to remove event listeners from. * @param {Object} obj DOM element to remove event listeners from.
* @param {String} (optional) unique key to match, when removing events. * @param {String} (optional) unique key to match, when removing events.
*/ */
removeAllEvents: u.Events.removeAllEvents, removeAllEvents: o.removeAllEvents,
/** /**
* Cleans the specified name from national characters (diacritics). The result will be a name with only a-z, 0-9 and _. * Cleans the specified name from national characters (diacritics). The result will be a name with only a-z, 0-9 and _.
@ -667,7 +625,7 @@ var plupload = {
* @param {String|Number} size String to parse or number to just pass through. * @param {String|Number} size String to parse or number to just pass through.
* @return {Number} Size in bytes. * @return {Number} Size in bytes.
*/ */
parseSize : u.Basic.parseSizeStr, parseSize : o.parseSizeStr,
/** /**
@ -684,7 +642,7 @@ var plupload = {
var up, runtime; var up, runtime;
up = new plupload.Uploader(config); up = new plupload.Uploader(config);
runtime = Runtime.thatCan(up.getOption().required_features, runtimes || config.runtimes); runtime = o.Runtime.thatCan(up.getOption().required_features, runtimes || config.runtimes);
up.destroy(); up.destroy();
return runtime; return runtime;
}, },
@ -759,19 +717,6 @@ plupload.addFileFilter('prevent_duplicates', function(value, file, cb) {
cb(true); cb(true);
}); });
plupload.addFileFilter('prevent_empty', function(value, file, cb) {
if (value && !file.size && file.size !== undef) {
this.trigger('Error', {
code : plupload.FILE_SIZE_ERROR,
message : plupload.translate('File size error.'),
file : file
});
cb(false);
} else {
cb(true);
}
});
/** /**
@class Uploader @class Uploader
@ -779,18 +724,18 @@ plupload.addFileFilter('prevent_empty', function(value, file, cb) {
@param {Object} settings For detailed information about each option check documentation. @param {Object} settings For detailed information about each option check documentation.
@param {String|DOMElement} settings.browse_button id of the DOM element or DOM element itself to use as file dialog trigger. @param {String|DOMElement} settings.browse_button id of the DOM element or DOM element itself to use as file dialog trigger.
@param {String} settings.url URL of the server-side upload handler.
@param {Number|String} [settings.chunk_size=0] Chunk size in bytes to slice the file into. Shorcuts with b, kb, mb, gb, tb suffixes also supported. `e.g. 204800 or "204800b" or "200kb"`. By default - disabled. @param {Number|String} [settings.chunk_size=0] Chunk size in bytes to slice the file into. Shorcuts with b, kb, mb, gb, tb suffixes also supported. `e.g. 204800 or "204800b" or "200kb"`. By default - disabled.
@param {Boolean} [settings.send_chunk_number=true] Whether to send chunks and chunk numbers, or total and offset bytes.
@param {String|DOMElement} [settings.container] id of the DOM element or DOM element itself that will be used to wrap uploader structures. Defaults to immediate parent of the `browse_button` element. @param {String|DOMElement} [settings.container] id of the DOM element or DOM element itself that will be used to wrap uploader structures. Defaults to immediate parent of the `browse_button` element.
@param {String|DOMElement} [settings.drop_element] id of the DOM element or DOM element itself to use as a drop zone for Drag-n-Drop. @param {String|DOMElement} [settings.drop_element] id of the DOM element or DOM element itself to use as a drop zone for Drag-n-Drop.
@param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message. @param {String} [settings.file_data_name="file"] Name for the file field in Multipart formated message.
@param {Object} [settings.filters={}] Set of file type filters. @param {Object} [settings.filters={}] Set of file type filters.
@param {String|Number} [settings.filters.max_file_size=0] Maximum file size that the user can pick, in bytes. Optionally supports b, kb, mb, gb, tb suffixes. `e.g. "10mb" or "1gb"`. By default - not set. Dispatches `plupload.FILE_SIZE_ERROR`.
@param {Array} [settings.filters.mime_types=[]] List of file types to accept, each one defined by title and list of extensions. `e.g. {title : "Image files", extensions : "jpg,jpeg,gif,png"}`. Dispatches `plupload.FILE_EXTENSION_ERROR` @param {Array} [settings.filters.mime_types=[]] List of file types to accept, each one defined by title and list of extensions. `e.g. {title : "Image files", extensions : "jpg,jpeg,gif,png"}`. Dispatches `plupload.FILE_EXTENSION_ERROR`
@param {String|Number} [settings.filters.max_file_size=0] Maximum file size that the user can pick, in bytes. Optionally supports b, kb, mb, gb, tb suffixes. `e.g. "10mb" or "1gb"`. By default - not set. Dispatches `plupload.FILE_SIZE_ERROR`.
@param {Boolean} [settings.filters.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`. @param {Boolean} [settings.filters.prevent_duplicates=false] Do not let duplicates into the queue. Dispatches `plupload.FILE_DUPLICATE_ERROR`.
@param {Boolean} [settings.filters.prevent_empty=true] Do not let empty files into the queue (IE10 is known to hang for example when trying to upload such). Dispatches `plupload.FILE_SIZE_ERROR`. @param {String} [settings.flash_swf_url] URL of the Flash swf. (Not used in WordPress)
@param {String} [settings.flash_swf_url] URL of the Flash swf.
@param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs. @param {Object} [settings.headers] Custom headers to send with the upload. Hash of name/value pairs.
@param {String} [settings.http_method="POST"] HTTP method to use during upload (only PUT or POST allowed).
@param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event. @param {Number} [settings.max_retries=0] How many times to retry the chunk or file, before triggering Error event.
@param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message. @param {Boolean} [settings.multipart=true] Whether to send file and additional parameters as Multipart formated message.
@param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload. @param {Object} [settings.multipart_params] Hash of key/value pairs to send with every file upload.
@ -801,13 +746,10 @@ plupload.addFileFilter('prevent_empty', function(value, file, cb) {
@param {Number} [settings.resize.height] If image is bigger, it will be resized. @param {Number} [settings.resize.height] If image is bigger, it will be resized.
@param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100). @param {Number} [settings.resize.quality=90] Compression quality for jpegs (1-100).
@param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally. @param {Boolean} [settings.resize.crop=false] Whether to crop images to exact dimensions. By default they will be resized proportionally.
@param {String} [settings.runtimes="html5,flash,silverlight,html4"] Comma separated list of runtimes, that Plupload will try in turn, moving to the next if previous fails. @param {String} [settings.runtimes="html5,html4"] Comma separated list of runtimes, that Plupload will try in turn, moving to the next if previous fails.
@param {String} [settings.silverlight_xap_url] URL of the Silverlight xap. @param {String} [settings.silverlight_xap_url] URL of the Silverlight xap. (Not used in WordPress)
@param {Boolean} [settings.send_chunk_number=true] Whether to send chunks and chunk numbers, or total and offset bytes.
@param {Boolean} [settings.send_file_name=true] Whether to send file name as additional argument - 'name' (required for chunked uploads and some other cases where file name cannot be sent via normal ways).
@param {String} settings.url URL of the server-side upload handler.
@param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files. @param {Boolean} [settings.unique_names=false] If true will generate unique filenames for uploaded files.
@param {Boolean} [settings.send_file_name=true] Whether to send file name as additional argument - 'name' (required for chunked uploads and some other cases where file name cannot be sent via normal ways).
*/ */
plupload.Uploader = function(options) { plupload.Uploader = function(options) {
/** /**
@ -914,18 +856,6 @@ plupload.Uploader = function(options) {
@param {plupload.File} file File that is currently being uploaded. @param {plupload.File} file File that is currently being uploaded.
*/ */
/**
* Fires just before a chunk is uploaded. This event enables you to override settings
* on the uploader instance before the chunk is uploaded.
*
* @event BeforeChunkUpload
* @param {plupload.Uploader} uploader Uploader instance sending the event.
* @param {plupload.File} file File to be uploaded.
* @param {Object} args POST params to be sent.
* @param {Blob} chunkBlob Current blob.
* @param {offset} offset Current offset.
*/
/** /**
Fires when file chunk is uploaded. Fires when file chunk is uploaded.
@ -1027,8 +957,6 @@ plupload.Uploader = function(options) {
function calc() { function calc() {
var i, file; var i, file;
var loaded;
var loadedDuringCurrentSession = 0;
// Reset stats // Reset stats
total.reset(); total.reset();
@ -1043,13 +971,7 @@ plupload.Uploader = function(options) {
// Since we cannot predict file size after resize, we do opposite and // Since we cannot predict file size after resize, we do opposite and
// interpolate loaded amount to match magnitude of total // interpolate loaded amount to match magnitude of total
loaded = file.loaded * file.origSize / file.size; total.loaded += file.loaded * file.origSize / file.size;
if (!file.completeTimestamp || file.completeTimestamp > startTime) {
loadedDuringCurrentSession += loaded;
}
total.loaded += loaded;
} else { } else {
total.size = undef; total.size = undef;
} }
@ -1067,7 +989,7 @@ plupload.Uploader = function(options) {
if (total.size === undef) { if (total.size === undef) {
total.percent = files.length > 0 ? Math.ceil(total.uploaded / files.length * 100) : 0; total.percent = files.length > 0 ? Math.ceil(total.uploaded / files.length * 100) : 0;
} else { } else {
total.bytesPerSec = Math.ceil(loadedDuringCurrentSession / ((+new Date() - startTime || 1) / 1000.0)); total.bytesPerSec = Math.ceil(total.loaded / ((+new Date() - startTime || 1) / 1000.0));
total.percent = total.size > 0 ? Math.ceil(total.loaded / total.size * 100) : 0; total.percent = total.size > 0 ? Math.ceil(total.loaded / total.size * 100) : 0;
} }
} }
@ -1082,6 +1004,17 @@ plupload.Uploader = function(options) {
} }
function runtimeCan(file, cap) {
if (file.ruid) {
var info = o.Runtime.getInfo(file.ruid);
if (info) {
return info.can(cap);
}
}
return false;
}
function bindEventListeners() { function bindEventListeners() {
this.bind('FilesAdded FilesRemoved', function(up) { this.bind('FilesAdded FilesRemoved', function(up) {
up.trigger('QueueChanged'); up.trigger('QueueChanged');
@ -1115,9 +1048,7 @@ plupload.Uploader = function(options) {
var options = { var options = {
runtime_order: settings.runtimes, runtime_order: settings.runtimes,
required_caps: settings.required_features, required_caps: settings.required_features,
preferred_caps: preferred_caps, preferred_caps: preferred_caps
swf_url: settings.flash_swf_url,
xap_url: settings.silverlight_xap_url
}; };
// add runtime specific options if any // add runtime specific options if any
@ -1131,7 +1062,7 @@ plupload.Uploader = function(options) {
if (settings.browse_button) { if (settings.browse_button) {
plupload.each(settings.browse_button, function(el) { plupload.each(settings.browse_button, function(el) {
queue.push(function(cb) { queue.push(function(cb) {
var fileInput = new o.file.FileInput(plupload.extend({}, options, { var fileInput = new o.FileInput(plupload.extend({}, options, {
accept: settings.filters.mime_types, accept: settings.filters.mime_types,
name: settings.file_data_name, name: settings.file_data_name,
multiple: settings.multi_selection, multiple: settings.multi_selection,
@ -1140,10 +1071,10 @@ plupload.Uploader = function(options) {
})); }));
fileInput.onready = function() { fileInput.onready = function() {
var info = Runtime.getInfo(this.ruid); var info = o.Runtime.getInfo(this.ruid);
// for backward compatibility // for backward compatibility
plupload.extend(self.features, { o.extend(self.features, {
chunks: info.can('slice_blob'), chunks: info.can('slice_blob'),
multipart: info.can('send_multipart'), multipart: info.can('send_multipart'),
multi_selection: info.can('select_multiple') multi_selection: info.can('select_multiple')
@ -1162,17 +1093,17 @@ plupload.Uploader = function(options) {
if (!disabled) { if (!disabled) {
if (settings.browse_button_hover) { if (settings.browse_button_hover) {
if ('mouseenter' === e.type) { if ('mouseenter' === e.type) {
plupload.addClass(el, settings.browse_button_hover); o.addClass(el, settings.browse_button_hover);
} else if ('mouseleave' === e.type) { } else if ('mouseleave' === e.type) {
plupload.removeClass(el, settings.browse_button_hover); o.removeClass(el, settings.browse_button_hover);
} }
} }
if (settings.browse_button_active) { if (settings.browse_button_active) {
if ('mousedown' === e.type) { if ('mousedown' === e.type) {
plupload.addClass(el, settings.browse_button_active); o.addClass(el, settings.browse_button_active);
} else if ('mouseup' === e.type) { } else if ('mouseup' === e.type) {
plupload.removeClass(el, settings.browse_button_active); o.removeClass(el, settings.browse_button_active);
} }
} }
} }
@ -1196,15 +1127,15 @@ plupload.Uploader = function(options) {
if (settings.drop_element) { if (settings.drop_element) {
plupload.each(settings.drop_element, function(el) { plupload.each(settings.drop_element, function(el) {
queue.push(function(cb) { queue.push(function(cb) {
var fileDrop = new o.file.FileDrop(plupload.extend({}, options, { var fileDrop = new o.FileDrop(plupload.extend({}, options, {
drop_zone: el drop_zone: el
})); }));
fileDrop.onready = function() { fileDrop.onready = function() {
var info = Runtime.getInfo(this.ruid); var info = o.Runtime.getInfo(this.ruid);
// for backward compatibility // for backward compatibility
plupload.extend(self.features, { o.extend(self.features, {
chunks: info.can('slice_blob'), chunks: info.can('slice_blob'),
multipart: info.can('send_multipart'), multipart: info.can('send_multipart'),
dragdrop: info.can('drag_and_drop') dragdrop: info.can('drag_and_drop')
@ -1230,7 +1161,7 @@ plupload.Uploader = function(options) {
} }
plupload.inSeries(queue, function() { o.inSeries(queue, function() {
if (typeof(cb) === 'function') { if (typeof(cb) === 'function') {
cb(inited); cb(inited);
} }
@ -1238,8 +1169,8 @@ plupload.Uploader = function(options) {
} }
function resizeImage(blob, params, runtimeOptions, cb) { function resizeImage(blob, params, cb) {
var img = new o.image.Image(); var img = new o.Image();
try { try {
img.onload = function() { img.onload = function() {
@ -1251,25 +1182,22 @@ plupload.Uploader = function(options) {
!params.crop !params.crop
) { ) {
this.destroy(); this.destroy();
cb(blob); return cb(blob);
} else { }
// otherwise downsize // otherwise downsize
img.downsize(params.width, params.height, params.crop, params.preserve_headers); img.downsize(params.width, params.height, params.crop, params.preserve_headers);
}
}; };
img.onresize = function() { img.onresize = function() {
var resizedBlob = this.getAsBlob(blob.type, params.quality); cb(this.getAsBlob(blob.type, params.quality));
this.destroy(); this.destroy();
cb(resizedBlob);
}; };
img.bind('error runtimeerror', function() { img.onerror = function() {
this.destroy();
cb(blob); cb(blob);
}); };
img.load(blob, runtimeOptions); img.load(blob);
} catch(ex) { } catch(ex) {
cb(blob); cb(blob);
} }
@ -1303,10 +1231,6 @@ plupload.Uploader = function(options) {
} }
break; break;
case 'http_method':
settings[option] = value.toUpperCase() === 'PUT' ? 'PUT' : 'POST';
break;
case 'unique_names': case 'unique_names':
settings[option] = value; settings[option] = value;
if (value) { if (value) {
@ -1330,11 +1254,7 @@ plupload.Uploader = function(options) {
// if file format filters are being updated, regenerate the matching expressions // if file format filters are being updated, regenerate the matching expressions
if (value.mime_types) { if (value.mime_types) {
if (plupload.typeOf(value.mime_types) === 'string') { settings.filters.mime_types.regexp = (function(filters) {
value.mime_types = o.core.utils.Mime.mimes2extList(value.mime_types);
}
value.mime_types.regexp = (function(filters) {
var extensionsRegExp = []; var extensionsRegExp = [];
plupload.each(filters, function(filter) { plupload.each(filters, function(filter) {
@ -1348,20 +1268,17 @@ plupload.Uploader = function(options) {
}); });
return new RegExp('(' + extensionsRegExp.join('|') + ')$', 'i'); return new RegExp('(' + extensionsRegExp.join('|') + ')$', 'i');
}(value.mime_types)); }(settings.filters.mime_types));
settings.filters.mime_types = value.mime_types;
} }
break; break;
case 'resize': case 'resize':
if (value) { if (init) {
settings.resize = plupload.extend({ plupload.extend(settings.resize, value, {
preserve_headers: true, enabled: true
crop: false });
}, value);
} else { } else {
settings.resize = false; settings.resize = value;
} }
break; break;
@ -1380,8 +1297,6 @@ plupload.Uploader = function(options) {
case 'runtimes': case 'runtimes':
case 'multi_selection': case 'multi_selection':
case 'flash_swf_url':
case 'silverlight_xap_url':
settings[option] = value; settings[option] = value;
if (!init) { if (!init) {
reinitRequired = true; reinitRequired = true;
@ -1418,7 +1333,7 @@ plupload.Uploader = function(options) {
initControls.call(self, settings, function(inited) { initControls.call(self, settings, function(inited) {
if (inited) { if (inited) {
self.runtime = Runtime.getInfo(getRUID()).type; self.runtime = o.Runtime.getInfo(getRUID()).type;
self.trigger('Init', { runtime: self.runtime }); self.trigger('Init', { runtime: self.runtime });
self.trigger('PostInit'); self.trigger('PostInit');
} else { } else {
@ -1446,20 +1361,13 @@ plupload.Uploader = function(options) {
function onUploadFile(up, file) { function onUploadFile(up, file) {
var url = up.settings.url; var url = up.settings.url
var chunkSize = up.settings.chunk_size; , chunkSize = up.settings.chunk_size
var retries = up.settings.max_retries; , retries = up.settings.max_retries
var features = up.features; , features = up.features
var offset = 0; , offset = 0
var blob; , blob
;
var runtimeOptions = {
runtime_order: up.settings.runtimes,
required_caps: up.settings.required_features,
preferred_caps: preferred_caps,
swf_url: up.settings.flash_swf_url,
xap_url: up.settings.silverlight_xap_url
};
// make sure we start at a predictable offset // make sure we start at a predictable offset
if (file.loaded) { if (file.loaded) {
@ -1484,7 +1392,7 @@ plupload.Uploader = function(options) {
} }
function uploadNextChunk() { function uploadNextChunk() {
var chunkBlob, args = {}, curChunkSize; var chunkBlob, formData, args = {}, curChunkSize;
// make sure that file wasn't cancelled and upload is not stopped in general // make sure that file wasn't cancelled and upload is not stopped in general
if (file.status !== plupload.UPLOADING || up.state === plupload.STOPPED) { if (file.status !== plupload.UPLOADING || up.state === plupload.STOPPED) {
@ -1516,15 +1424,7 @@ plupload.Uploader = function(options) {
} }
} }
if (up.trigger('BeforeChunkUpload', file, args, chunkBlob, offset)) { xhr = new o.XMLHttpRequest();
uploadChunk(args, chunkBlob, curChunkSize);
}
}
function uploadChunk(args, chunkBlob, curChunkSize) {
var formData;
xhr = new o.xhr.XMLHttpRequest();
// Do we have upload progress support // Do we have upload progress support
if (xhr.upload) { if (xhr.upload) {
@ -1536,7 +1436,7 @@ plupload.Uploader = function(options) {
xhr.onload = function() { xhr.onload = function() {
// check if upload made itself through // check if upload made itself through
if (xhr.status < 200 || xhr.status >= 400) { if (xhr.status >= 400) {
handleError(); handleError();
return; return;
} }
@ -1559,7 +1459,7 @@ plupload.Uploader = function(options) {
}); });
// stock Android browser doesn't fire upload progress events, but in chunking mode we can fake them // stock Android browser doesn't fire upload progress events, but in chunking mode we can fake them
if (plupload.ua.browser === 'Android Browser') { if (o.Env.browser === 'Android Browser') {
// doesn't harm in general, but is not required anywhere else // doesn't harm in general, but is not required anywhere else
up.trigger('UploadProgress', file); up.trigger('UploadProgress', file);
} }
@ -1580,7 +1480,6 @@ plupload.Uploader = function(options) {
up.trigger('UploadProgress', file); up.trigger('UploadProgress', file);
file.status = plupload.DONE; file.status = plupload.DONE;
file.completeTimestamp = +new Date();
up.trigger('FileUploaded', file, { up.trigger('FileUploaded', file, {
response : xhr.responseText, response : xhr.responseText,
@ -1599,18 +1498,19 @@ plupload.Uploader = function(options) {
xhr.onloadend = function() { xhr.onloadend = function() {
this.destroy(); this.destroy();
xhr = null;
}; };
// Build multipart request // Build multipart request
if (up.settings.multipart && features.multipart) { if (up.settings.multipart && features.multipart) {
xhr.open(up.settings.http_method, url, true); xhr.open("post", url, true);
// Set custom headers // Set custom headers
plupload.each(up.settings.headers, function(value, name) { plupload.each(up.settings.headers, function(value, name) {
xhr.setRequestHeader(name, value); xhr.setRequestHeader(name, value);
}); });
formData = new o.xhr.FormData(); formData = new o.FormData();
// Add multipart params // Add multipart params
plupload.each(plupload.extend(args, up.settings.multipart_params), function(value, name) { plupload.each(plupload.extend(args, up.settings.multipart_params), function(value, name) {
@ -1619,34 +1519,38 @@ plupload.Uploader = function(options) {
// Add file and send it // Add file and send it
formData.append(up.settings.file_data_name, chunkBlob); formData.append(up.settings.file_data_name, chunkBlob);
xhr.send(formData, runtimeOptions); xhr.send(formData, {
runtime_order: up.settings.runtimes,
required_caps: up.settings.required_features,
preferred_caps: preferred_caps
});
} else { } else {
// if no multipart, send as binary stream // if no multipart, send as binary stream
url = plupload.buildUrl(up.settings.url, plupload.extend(args, up.settings.multipart_params)); url = plupload.buildUrl(up.settings.url, plupload.extend(args, up.settings.multipart_params));
xhr.open(up.settings.http_method, url, true); xhr.open("post", url, true);
xhr.setRequestHeader('Content-Type', 'application/octet-stream'); // Binary stream header
// Set custom headers // Set custom headers
plupload.each(up.settings.headers, function(value, name) { plupload.each(up.settings.headers, function(value, name) {
xhr.setRequestHeader(name, value); xhr.setRequestHeader(name, value);
}); });
// do not set Content-Type, if it was defined previously (see #1203) xhr.send(chunkBlob, {
if (!xhr.hasRequestHeader('Content-Type')) { runtime_order: up.settings.runtimes,
xhr.setRequestHeader('Content-Type', 'application/octet-stream'); // Binary stream header required_caps: up.settings.required_features,
} preferred_caps: preferred_caps
});
xhr.send(chunkBlob, runtimeOptions);
} }
} }
blob = file.getSource(); blob = file.getSource();
// Start uploading chunks // Start uploading chunks
if (!plupload.isEmptyObj(up.settings.resize) && plupload.inArray(blob.type, ['image/jpeg', 'image/png']) !== -1) { if (up.settings.resize.enabled && runtimeCan(blob, 'send_binary_string') && !!~o.inArray(blob.type, ['image/jpeg', 'image/png'])) {
// Resize if required // Resize if required
resizeImage(blob, up.settings.resize, runtimeOptions, function(resizedBlob) { resizeImage.call(this, blob, up.settings.resize, function(resizedBlob) {
blob = resizedBlob; blob = resizedBlob;
file.size = resizedBlob.size; file.size = resizedBlob.size;
uploadNextChunk(); uploadNextChunk();
@ -1703,7 +1607,6 @@ plupload.Uploader = function(options) {
// Set failed status if an error occured on a file // Set failed status if an error occured on a file
else if (err.code === plupload.HTTP_ERROR) { else if (err.code === plupload.HTTP_ERROR) {
err.file.status = plupload.FAILED; err.file.status = plupload.FAILED;
err.file.completeTimestamp = +new Date();
calcFile(err.file); calcFile(err.file);
// Upload next file but detach it from the error event // Upload next file but detach it from the error event
@ -1750,24 +1653,24 @@ plupload.Uploader = function(options) {
// Default settings // Default settings
settings = { settings = {
runtimes: o.Runtime.order,
max_retries: 0,
chunk_size: 0, chunk_size: 0,
multipart: true,
multi_selection: true,
file_data_name: 'file', file_data_name: 'file',
filters: { filters: {
mime_types: [], mime_types: [],
max_file_size: 0,
prevent_duplicates: false, prevent_duplicates: false,
prevent_empty: true max_file_size: 0
},
resize: {
enabled: false,
preserve_headers: true,
crop: false
}, },
flash_swf_url: 'js/Moxie.swf',
http_method: 'POST',
max_retries: 0,
multipart: true,
multi_selection: true,
resize: false,
runtimes: Runtime.order,
send_file_name: true, send_file_name: true,
send_chunk_number: true, send_chunk_number: true
silverlight_xap_url: 'js/Moxie.xap'
}; };
@ -1865,7 +1768,7 @@ plupload.Uploader = function(options) {
if (self.getOption(el) === null) { if (self.getOption(el) === null) {
err = { err = {
code : plupload.INIT_ERROR, code : plupload.INIT_ERROR,
message : plupload.sprintf(plupload.translate("%s specified, but cannot be found."), el) message : plupload.translate("'%' specified, but cannot be found.")
} }
return false; return false;
} }
@ -1879,7 +1782,7 @@ plupload.Uploader = function(options) {
if (!settings.browse_button && !settings.drop_element) { if (!settings.browse_button && !settings.drop_element) {
return self.trigger('Error', { return self.trigger('Error', {
code : plupload.INIT_ERROR, code : plupload.INIT_ERROR,
message : plupload.translate("You must specify either browse_button or drop_element.") message : plupload.translate("You must specify either 'browse_button' or 'drop_element'.")
}); });
} }
@ -1895,7 +1798,7 @@ plupload.Uploader = function(options) {
} }
if (inited) { if (inited) {
self.runtime = Runtime.getInfo(getRUID()).type; self.runtime = o.Runtime.getInfo(getRUID()).type;
self.trigger('Init', { runtime: self.runtime }); self.trigger('Init', { runtime: self.runtime });
self.trigger('PostInit'); self.trigger('PostInit');
} else { } else {
@ -2030,7 +1933,7 @@ plupload.Uploader = function(options) {
function filterFile(file, cb) { function filterFile(file, cb) {
var queue = []; var queue = [];
plupload.each(self.settings.filters, function(rule, name) { o.each(self.settings.filters, function(rule, name) {
if (fileFilters[name]) { if (fileFilters[name]) {
queue.push(function(cb) { queue.push(function(cb) {
fileFilters[name].call(self, rule, file, function(res) { fileFilters[name].call(self, rule, file, function(res) {
@ -2039,19 +1942,19 @@ plupload.Uploader = function(options) {
}); });
} }
}); });
plupload.inSeries(queue, cb); o.inSeries(queue, cb);
} }
/** /**
* @method resolveFile * @method resolveFile
* @private * @private
* @param {moxie.file.File|moxie.file.Blob|plupload.File|File|Blob|input[type="file"]} file * @param {o.File|o.Blob|plupload.File|File|Blob|input[type="file"]} file
*/ */
function resolveFile(file) { function resolveFile(file) {
var type = plupload.typeOf(file); var type = o.typeOf(file);
// moxie.file.File // o.File
if (file instanceof o.file.File) { if (file instanceof o.File) {
if (!file.ruid && !file.isDetached()) { if (!file.ruid && !file.isDetached()) {
if (!ruid) { // weird case if (!ruid) { // weird case
return false; return false;
@ -2061,8 +1964,8 @@ plupload.Uploader = function(options) {
} }
resolveFile(new plupload.File(file)); resolveFile(new plupload.File(file));
} }
// moxie.file.Blob // o.Blob
else if (file instanceof o.file.Blob) { else if (file instanceof o.Blob) {
resolveFile(file.getSource()); resolveFile(file.getSource());
file.destroy(); file.destroy();
} }
@ -2088,18 +1991,18 @@ plupload.Uploader = function(options) {
}); });
} }
// native File or blob // native File or blob
else if (plupload.inArray(type, ['file', 'blob']) !== -1) { else if (o.inArray(type, ['file', 'blob']) !== -1) {
resolveFile(new o.file.File(null, file)); resolveFile(new o.File(null, file));
} }
// input[type="file"] // input[type="file"]
else if (type === 'node' && plupload.typeOf(file.files) === 'filelist') { else if (type === 'node' && o.typeOf(file.files) === 'filelist') {
// if we are dealing with input[type="file"] // if we are dealing with input[type="file"]
plupload.each(file.files, resolveFile); o.each(file.files, resolveFile);
} }
// mixed array of any supported types (see above) // mixed array of any supported types (see above)
else if (type === 'array') { else if (type === 'array') {
fileName = null; // should never happen, but unset anyway to avoid funny situations fileName = null; // should never happen, but unset anyway to avoid funny situations
plupload.each(file, resolveFile); o.each(file, resolveFile);
} }
} }
@ -2108,7 +2011,7 @@ plupload.Uploader = function(options) {
resolveFile(file); resolveFile(file);
if (queue.length) { if (queue.length) {
plupload.inSeries(queue, function() { o.inSeries(queue, function() {
// if any files left after filtration, trigger FilesAdded // if any files left after filtration, trigger FilesAdded
if (filesAdded.length) { if (filesAdded.length) {
self.trigger("FilesAdded", filesAdded); self.trigger("FilesAdded", filesAdded);
@ -2134,12 +2037,11 @@ plupload.Uploader = function(options) {
}, },
/** /**
* Removes part of the queue and returns the files removed. This will also trigger the * Removes part of the queue and returns the files removed. This will also trigger the FilesRemoved and QueueChanged events.
* FilesRemoved and QueueChanged events.
* *
* @method splice * @method splice
* @param {Number} [start=0] Start index to remove from. * @param {Number} start (Optional) Start index to remove from.
* @param {Number} [length] Number of files to remove (defaults to number of files in the queue). * @param {Number} length (Optional) Lengh of items to remove.
* @return {Array} Array of files that was removed. * @return {Array} Array of files that was removed.
*/ */
splice : function(start, length) { splice : function(start, length) {
@ -2260,7 +2162,7 @@ plupload.Uploader = function(options) {
}); });
}; };
plupload.Uploader.prototype = o.core.EventTarget.instance; plupload.Uploader.prototype = o.EventTarget.instance;
/** /**
* Constructs a new file instance. * Constructs a new file instance.
@ -2303,22 +2205,13 @@ plupload.File = (function() {
*/ */
type: file.type || '', type: file.type || '',
/**
* Relative path to the file inside a directory
*
* @property relativePath
* @type String
* @default ''
*/
relativePath: file.relativePath || '',
/** /**
* File size in bytes (may change after client-side manupilation). * File size in bytes (may change after client-side manupilation).
* *
* @property size * @property size
* @type Number * @type Number
*/ */
size: file.fileSize || file.size, size: file.size || file.fileSize,
/** /**
* Original file size in bytes. * Original file size in bytes.
@ -2326,7 +2219,7 @@ plupload.File = (function() {
* @property origSize * @property origSize
* @type Number * @type Number
*/ */
origSize: file.fileSize || file.size, origSize: file.size || file.fileSize,
/** /**
* Number of bytes uploaded of the files total size. * Number of bytes uploaded of the files total size.
@ -2361,15 +2254,6 @@ plupload.File = (function() {
*/ */
lastModifiedDate: file.lastModifiedDate || (new Date()).toLocaleString(), // Thu Aug 23 2012 19:40:00 GMT+0400 (GET) lastModifiedDate: file.lastModifiedDate || (new Date()).toLocaleString(), // Thu Aug 23 2012 19:40:00 GMT+0400 (GET)
/**
* Set when file becomes plupload.DONE or plupload.FAILED. Is used to calculate proper plupload.QueueProgress.bytesPerSec.
* @private
* @property completeTimestamp
* @type {Number}
*/
completeTimestamp: 0,
/** /**
* Returns native window.File object, when it's available. * Returns native window.File object, when it's available.
* *
@ -2378,7 +2262,7 @@ plupload.File = (function() {
*/ */
getNative: function() { getNative: function() {
var file = this.getSource().getSource(); var file = this.getSource().getSource();
return plupload.inArray(plupload.typeOf(file), ['blob', 'file']) !== -1 ? file : null; return o.inArray(o.typeOf(file), ['blob', 'file']) !== -1 ? file : null;
}, },
/** /**
@ -2490,8 +2374,6 @@ plupload.File = (function() {
}; };
}; };
exports.plupload = plupload; window.plupload = plupload;
}(this, moxie)); }(window, mOxie));
}));

File diff suppressed because one or more lines are too long

View File

@ -5,8 +5,6 @@
*/ */
window.wp = window.wp || {}; window.wp = window.wp || {};
// Suppress warning about Uploader function's unused "isIE" argument:
/* jshint unused:false */
( function( exports, $ ) { ( function( exports, $ ) {
var Uploader; var Uploader;
@ -145,13 +143,13 @@ window.wp = window.wp || {};
// Do a cleanup then tell the user to scale down the image and upload it again. // Do a cleanup then tell the user to scale down the image and upload it again.
$.ajax({ $.ajax({
type: 'post', type: 'post',
url: ajaxurl, // jshint ignore:line url: ajaxurl,
dataType: 'json', dataType: 'json',
data: { data: {
action: 'media-create-image-subsizes', action: 'media-create-image-subsizes',
_wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce, _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce,
attachment_id: id, attachment_id: id,
_wp_upload_failed_cleanup: true _wp_upload_failed_cleanup: true,
} }
}); });
@ -168,12 +166,12 @@ window.wp = window.wp || {};
// Another request to try to create the missing image sub-sizes. // Another request to try to create the missing image sub-sizes.
$.ajax({ $.ajax({
type: 'post', type: 'post',
url: ajaxurl, // jshint ignore:line url: ajaxurl,
dataType: 'json', dataType: 'json',
data: { data: {
action: 'media-create-image-subsizes', action: 'media-create-image-subsizes',
_wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce, _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce,
attachment_id: id attachment_id: id,
} }
}).done( function( response ) { }).done( function( response ) {
if ( response.success ) { if ( response.success ) {
@ -194,7 +192,7 @@ window.wp = window.wp || {};
error( message, data, file, 'no-retry' ); error( message, data, file, 'no-retry' );
}); });
}; }
/** /**
* Custom error callback. * Custom error callback.
@ -258,7 +256,7 @@ window.wp = window.wp || {};
} }
self.success( file.attachment ); self.success( file.attachment );
}; }
/** /**
* After the Uploader has been initialized, initialize some behaviors for the dropzone. * After the Uploader has been initialized, initialize some behaviors for the dropzone.
@ -462,7 +460,7 @@ window.wp = window.wp || {};
} }
return pluploadL10n.http_error; return pluploadL10n.http_error;
} },
}; };
$.extend( Uploader.prototype, /** @lends wp.Uploader.prototype */{ $.extend( Uploader.prototype, /** @lends wp.Uploader.prototype */{

View File

@ -1252,11 +1252,11 @@ function wp_default_scripts( &$scripts ) {
'error_uploading' => __( '&#8220;%s&#8221; has failed to upload.' ), 'error_uploading' => __( '&#8220;%s&#8221; has failed to upload.' ),
); );
$scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.5.7' ); $scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' );
$scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.3.6' ); $scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.1.9' );
// Back compat handles: // Back compat handles:
foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) { foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) {
$scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.3.6' ); $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' );
} }
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) ); $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) );

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.4-alpha-46637'; $wp_version = '5.4-alpha-46638';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.