<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[46634] trunk: External Libraries: Update Plupload from 2.1.9 to 2.3.6.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/46634">46634</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/46634","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>desrosj</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-11-03 15:29:46 +0000 (Sun, 03 Nov 2019)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>External Libraries: Update Plupload from 2.1.9 to 2.3.6.
This change also updates the MoxieJS dependency from 1.3.5 to 1.5.7, converts Plupload to a dependency in NPM, and integrates all relevant parts into the build process.
For a full list of upstream changes, see https://github.com/moxiecode/plupload/compare/v2.1.9...v2.3.6.
Props desrosj, hareesh-pillai.
Fixes <a href="https://core.trac.wordpress.org/ticket/48277">#48277</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkGruntfilejs">trunk/Gruntfile.js</a></li>
<li><a href="#trunkpackagelockjson">trunk/package-lock.json</a></li>
<li><a href="#trunkpackagejson">trunk/package.json</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/src/js/_enqueues/wp/plupload/</li>
<li><a href="#trunksrcjs_enqueueswppluploadhandlersjs">trunk/src/js/_enqueues/wp/plupload/handlers.js</a></li>
<li><a href="#trunksrcjs_enqueueswppluploadwppluploadjs">trunk/src/js/_enqueues/wp/plupload/wp-plupload.js</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li>trunk/src/js/_enqueues/vendor/plupload/</li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#trunk">trunk/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: trunk
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- trunk 2019-11-03 10:54:39 UTC (rev 46633)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ trunk 2019-11-03 15:29:46 UTC (rev 46634)
</ins><a id="trunk"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: trunk</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnignore"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:ignore</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> jsdoc
</span><span class="cx" style="display: block; padding: 0 10px"> vendor
</span><span class="cx" style="display: block; padding: 0 10px"> docker-compose.override.yml
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+48277.dif
</ins><a id="trunkGruntfilejs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/Gruntfile.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/Gruntfile.js 2019-11-03 10:54:39 UTC (rev 46633)
+++ trunk/Gruntfile.js 2019-11-03 15:29:46 UTC (rev 46634)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -167,6 +167,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/jquery/jquery-migrate.min.js' ]: [ './node_modules/jquery-migrate/dist/jquery-migrate.min.js' ],
</span><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/jquery/jquery.form.js' ]: [ './node_modules/jquery-form/src/jquery.form.js' ],
</span><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/masonry.min.js' ]: [ './node_modules/masonry-layout/dist/masonry.pkgd.min.js' ],
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ [ WORKING_DIR + 'wp-includes/js/plupload/moxie.js' ]: [ './node_modules/plupload/js/moxie.js' ],
+ [ WORKING_DIR + 'wp-includes/js/plupload/plupload.js' ]: [ './node_modules/plupload/js/plupload.dev.js' ],
</ins><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/twemoji.js' ]: [ './node_modules/twemoji/dist/twemoji.js' ],
</span><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/underscore.js' ]: [ './node_modules/underscore/underscore.js' ],
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -294,6 +296,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/heartbeat.js' ]: [ './src/js/_enqueues/wp/heartbeat.js' ],
</span><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/mce-view.js' ]: [ './src/js/_enqueues/wp/mce-view.js' ],
</span><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/media-editor.js' ]: [ './src/js/_enqueues/wp/media/editor.js' ],
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ [ WORKING_DIR + 'wp-includes/js/plupload/handlers.js' ]: [ './src/js/_enqueues/wp/plupload/handlers.js' ],
+ [ WORKING_DIR + 'wp-includes/js/plupload/wp-plupload.js' ]: [ './src/js/_enqueues/wp/plupload/wp-plupload.js' ],
</ins><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/quicktags.js' ]: [ './src/js/_enqueues/lib/quicktags.js' ],
</span><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/shortcode.js' ]: [ './src/js/_enqueues/wp/shortcode.js' ],
</span><span class="cx" style="display: block; padding: 0 10px"> [ WORKING_DIR + 'wp-includes/js/utils.js' ]: [ './src/js/_enqueues/lib/cookies.js' ],
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1075,6 +1079,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> dest: SOURCE_DIR + 'wp-includes/'
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> ]
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ },
+ plupload: {
+ options: {
+ patterns: [
+ {
+ match: /;var MXI_DEBUG = true;/g,
+ replacement: function () {
+ return ';var MXI_DEBUG = false;';
+ }
+ }
+ ]
+ },
+ files: [
+ {
+ expand: true,
+ flatten: true,
+ src: [
+ 'build/wp-includes/js/plupload/moxie.js'
+ ],
+ dest: 'build/wp-includes/js/plupload/'
+ }
+ ]
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> _watch: {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1352,6 +1378,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'webpack:prod',
</span><span class="cx" style="display: block; padding: 0 10px"> 'webpack:dev',
</span><span class="cx" style="display: block; padding: 0 10px"> 'copy:js',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'replace:plupload',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'file_append',
</span><span class="cx" style="display: block; padding: 0 10px"> 'uglify:all',
</span><span class="cx" style="display: block; padding: 0 10px"> 'concat:tinymce',
</span></span></pre></div>
<a id="trunkpackagelockjson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/package-lock.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/package-lock.json 2019-11-03 10:54:39 UTC (rev 46633)
+++ trunk/package-lock.json 2019-11-03 15:29:46 UTC (rev 46634)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15784,6 +15784,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "plupload": {
+ "version": "2.3.6",
+ "resolved": "https://registry.npmjs.org/plupload/-/plupload-2.3.6.tgz",
+ "integrity": "sha1-Jgis9zXV6NuDJIck142BdXu0OGY="
+ },
</ins><span class="cx" style="display: block; padding: 0 10px"> "plur": {
</span><span class="cx" style="display: block; padding: 0 10px"> "version": "3.1.1",
</span><span class="cx" style="display: block; padding: 0 10px"> "resolved": "https://registry.npmjs.org/plur/-/plur-3.1.1.tgz",
</span></span></pre></div>
<a id="trunkpackagejson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/package.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/package.json 2019-11-03 10:54:39 UTC (rev 46633)
+++ trunk/package.json 2019-11-03 15:29:46 UTC (rev 46634)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -125,6 +125,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "lodash": "4.17.15",
</span><span class="cx" style="display: block; padding: 0 10px"> "masonry-layout": "3.3.2",
</span><span class="cx" style="display: block; padding: 0 10px"> "moment": "2.22.2",
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "plupload": "2.3.6",
</ins><span class="cx" style="display: block; padding: 0 10px"> "polyfill-library": "3.27.4",
</span><span class="cx" style="display: block; padding: 0 10px"> "react": "16.9.0",
</span><span class="cx" style="display: block; padding: 0 10px"> "react-dom": "16.9.0",
</span></span></pre></div>
<a id="trunksrcjs_enqueueswppluploadhandlersjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/_enqueues/wp/plupload/handlers.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/wp/plupload/handlers.js (rev 0)
+++ trunk/src/js/_enqueues/wp/plupload/handlers.js 2019-11-03 15:29:46 UTC (rev 46634)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,608 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting, shortform */
+var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init;
+
+// progress and success handlers for media multi uploads
+function fileQueued( fileObj ) {
+ // Get rid of unused form
+ jQuery( '.media-blank' ).remove();
+
+ var items = jQuery( '#media-items' ).children(), postid = post_id || 0;
+
+ // Collapse a single item
+ if ( items.length == 1 ) {
+ items.removeClass( 'open' ).find( '.slidetoggle' ).slideUp( 200 );
+ }
+ // Create a progress bar containing the filename
+ jQuery( '<div class="media-item">' )
+ .attr( 'id', 'media-item-' + fileObj.id )
+ .addClass( 'child-of-' + postid )
+ .append( '<div class="progress"><div class="percent">0%</div><div class="bar"></div></div>',
+ jQuery( '<div class="filename original">' ).text( ' ' + fileObj.name ) )
+ .appendTo( jQuery( '#media-items' ) );
+
+ // Disable submit
+ jQuery( '#insert-gallery' ).prop( 'disabled', true );
+}
+
+function uploadStart() {
+ try {
+ if ( typeof topWin.tb_remove != 'undefined' )
+ topWin.jQuery( '#TB_overlay' ).unbind( 'click', topWin.tb_remove );
+ } catch( e ){}
+
+ return true;
+}
+
+function uploadProgress( up, file ) {
+ var item = jQuery( '#media-item-' + file.id );
+
+ jQuery( '.bar', item ).width( ( 200 * file.loaded ) / file.size );
+ jQuery( '.percent', item ).html( file.percent + '%' );
+}
+
+// check to see if a large file failed to upload
+function fileUploading( up, file ) {
+ var hundredmb = 100 * 1024 * 1024,
+ max = parseInt( up.settings.max_file_size, 10 );
+
+ if ( max > hundredmb && file.size > hundredmb ) {
+ setTimeout( function() {
+ if ( file.status < 3 && file.loaded === 0 ) { // not uploading
+ wpFileError( file, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
+ up.stop(); // stops the whole queue
+ up.removeFile( file );
+ up.start(); // restart the queue
+ }
+ }, 10000 ); // wait for 10 sec. for the file to start uploading
+ }
+}
+
+function updateMediaForm() {
+ var items = jQuery( '#media-items' ).children();
+
+ // Just one file, no need for collapsible part
+ if ( items.length == 1 ) {
+ items.addClass( 'open' ).find( '.slidetoggle' ).show();
+ jQuery( '.insert-gallery' ).hide();
+ } else if ( items.length > 1 ) {
+ items.removeClass( 'open' );
+ // Only show Gallery/Playlist buttons when there are at least two files.
+ jQuery( '.insert-gallery' ).show();
+ }
+
+ // Only show Save buttons when there is at least one file.
+ if ( items.not( '.media-blank' ).length > 0 )
+ jQuery( '.savebutton' ).show();
+ else
+ jQuery( '.savebutton' ).hide();
+}
+
+function uploadSuccess( fileObj, serverData ) {
+ var item = jQuery( '#media-item-' + fileObj.id );
+
+ // on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag
+ if ( typeof serverData === 'string' ) {
+ serverData = serverData.replace( /^<pre>(\d+)<\/pre>$/, '$1' );
+
+ // if async-upload returned an error message, place it in the media item div and return
+ if ( /media-upload-error|error-div/.test( serverData ) ) {
+ item.html( serverData );
+ return;
+ }
+ }
+
+ item.find( '.percent' ).html( pluploadL10n.crunching );
+
+ prepareMediaItem( fileObj, serverData );
+ updateMediaForm();
+
+ // Increment the counter.
+ if ( post_id && item.hasClass( 'child-of-' + post_id ) ) {
+ jQuery( '#attachments-count' ).text( 1 * jQuery( '#attachments-count' ).text() + 1 );
+ }
+}
+
+function setResize( arg ) {
+ if ( arg ) {
+ if ( window.resize_width && window.resize_height ) {
+ uploader.settings.resize = {
+ enabled: true,
+ width: window.resize_width,
+ height: window.resize_height,
+ quality: 100
+ };
+ } else {
+ uploader.settings.multipart_params.image_resize = true;
+ }
+ } else {
+ delete( uploader.settings.multipart_params.image_resize );
+ }
+}
+
+function prepareMediaItem( fileObj, serverData ) {
+ var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery( '#media-item-' + fileObj.id );
+ if ( f == 2 && shortform > 2 )
+ f = shortform;
+
+ try {
+ if ( typeof topWin.tb_remove != 'undefined' )
+ topWin.jQuery( '#TB_overlay' ).click( topWin.tb_remove );
+ } catch( e ){}
+
+ if ( isNaN( serverData ) || !serverData ) { // Old style: Append the HTML returned by the server -- thumbnail and form inputs
+ item.append( serverData );
+ prepareMediaItemInit( fileObj );
+ } else { // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
+ item.load( 'async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit( fileObj );updateMediaForm();});
+ }
+}
+
+function prepareMediaItemInit( fileObj ) {
+ var item = jQuery( '#media-item-' + fileObj.id );
+ // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
+ jQuery( '.thumbnail', item ).clone().attr( 'class', 'pinkynail toggle' ).prependTo( item );
+
+ // Replace the original filename with the new (unique) one assigned during upload
+ jQuery( '.filename.original', item ).replaceWith( jQuery( '.filename.new', item ) );
+
+ // Bind AJAX to the new Delete button
+ jQuery( 'a.delete', item ).click( function(){
+ // Tell the server to delete it. TODO: handle exceptions
+ jQuery.ajax({
+ url: ajaxurl,
+ type: 'post',
+ success: deleteSuccess,
+ error: deleteError,
+ id: fileObj.id,
+ data: {
+ id : this.id.replace(/[^0-9]/g, '' ),
+ action : 'trash-post',
+ _ajax_nonce : this.href.replace(/^.*wpnonce=/,'' )
+ }
+ });
+ return false;
+ });
+
+ // Bind AJAX to the new Undo button
+ jQuery( 'a.undo', item ).click( function(){
+ // Tell the server to untrash it. TODO: handle exceptions
+ jQuery.ajax({
+ url: ajaxurl,
+ type: 'post',
+ id: fileObj.id,
+ data: {
+ id : this.id.replace(/[^0-9]/g,'' ),
+ action: 'untrash-post',
+ _ajax_nonce: this.href.replace(/^.*wpnonce=/,'' )
+ },
+ success: function( ){
+ var type,
+ item = jQuery( '#media-item-' + fileObj.id );
+
+ if ( type = jQuery( '#type-of-' + fileObj.id ).val() )
+ jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text()-0+1 );
+
+ if ( post_id && item.hasClass( 'child-of-'+post_id ) )
+ jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text()-0+1 );
+
+ jQuery( '.filename .trashnotice', item ).remove();
+ jQuery( '.filename .title', item ).css( 'font-weight','normal' );
+ jQuery( 'a.undo', item ).addClass( 'hidden' );
+ jQuery( '.menu_order_input', item ).show();
+ item.css( {backgroundColor:'#ceb'} ).animate( {backgroundColor: '#fff'}, { queue: false, duration: 500, complete: function(){ jQuery( this ).css({backgroundColor:''}); } }).removeClass( 'undo' );
+ }
+ });
+ return false;
+ });
+
+ // Open this item if it says to start open (e.g. to display an error)
+ jQuery( '#media-item-' + fileObj.id + '.startopen' ).removeClass( 'startopen' ).addClass( 'open' ).find( 'slidetoggle' ).fadeIn();
+}
+
+// generic error message
+function wpQueueError( message ) {
+ jQuery( '#media-upload-error' ).show().html( '<div class="error"><p>' + message + '</p></div>' );
+}
+
+// file-specific error messages
+function wpFileError( fileObj, message ) {
+ itemAjaxError( fileObj.id, message );
+}
+
+function itemAjaxError( id, message ) {
+ var item = jQuery( '#media-item-' + id ), filename = item.find( '.filename' ).text(), last_err = item.data( 'last-err' );
+
+ if ( last_err == id ) // prevent firing an error for the same file twice
+ return;
+
+ item.html( '<div class="error-div">' +
+ '<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>' +
+ '<strong>' + pluploadL10n.error_uploading.replace( '%s', jQuery.trim( filename )) + '</strong> ' +
+ message +
+ '</div>' ).data( 'last-err', id );
+}
+
+function deleteSuccess( data ) {
+ var type, id, item;
+ if ( data == '-1' )
+ return itemAjaxError( this.id, 'You do not have permission. Has your session expired?' );
+
+ if ( data == '0' )
+ return itemAjaxError( this.id, 'Could not be deleted. Has it been deleted already?' );
+
+ id = this.id;
+ item = jQuery( '#media-item-' + id );
+
+ // Decrement the counters.
+ if ( type = jQuery( '#type-of-' + id ).val() )
+ jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text() - 1 );
+
+ if ( post_id && item.hasClass( 'child-of-'+post_id ) )
+ jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text() - 1 );
+
+ if ( jQuery( 'form.type-form #media-items' ).children().length == 1 && jQuery( '.hidden', '#media-items' ).length > 0 ) {
+ jQuery( '.toggle' ).toggle();
+ jQuery( '.slidetoggle' ).slideUp( 200 ).siblings().removeClass( 'hidden' );
+ }
+
+ // Vanish it.
+ jQuery( '.toggle', item ).toggle();
+ jQuery( '.slidetoggle', item ).slideUp( 200 ).siblings().removeClass( 'hidden' );
+ item.css( {backgroundColor:'#faa'} ).animate( {backgroundColor:'#f4f4f4'}, {queue:false, duration:500} ).addClass( 'undo' );
+
+ jQuery( '.filename:empty', item ).remove();
+ jQuery( '.filename .title', item ).css( 'font-weight','bold' );
+ jQuery( '.filename', item ).append( '<span class="trashnotice"> ' + pluploadL10n.deleted + ' </span>' ).siblings( 'a.toggle' ).hide();
+ jQuery( '.filename', item ).append( jQuery( 'a.undo', item ).removeClass( 'hidden' ) );
+ jQuery( '.menu_order_input', item ).hide();
+
+ return;
+}
+
+function deleteError() {
+}
+
+function uploadComplete() {
+ jQuery( '#insert-gallery' ).prop( 'disabled', false );
+}
+
+function switchUploader( s ) {
+ if ( s ) {
+ deleteUserSetting( 'uploader' );
+ jQuery( '.media-upload-form' ).removeClass( 'html-uploader' );
+
+ if ( typeof( uploader ) == 'object' )
+ uploader.refresh();
+ } else {
+ setUserSetting( 'uploader', '1' ); // 1 == html uploader
+ jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
+ }
+}
+
+function uploadError( fileObj, errorCode, message, up ) {
+ var hundredmb = 100 * 1024 * 1024, max;
+
+ switch ( errorCode ) {
+ case plupload.FAILED:
+ wpFileError( fileObj, pluploadL10n.upload_failed );
+ break;
+ case plupload.FILE_EXTENSION_ERROR:
+ wpFileExtensionError( up, fileObj, pluploadL10n.invalid_filetype );
+ break;
+ case plupload.FILE_SIZE_ERROR:
+ uploadSizeError( up, fileObj );
+ break;
+ case plupload.IMAGE_FORMAT_ERROR:
+ wpFileError( fileObj, pluploadL10n.not_an_image );
+ break;
+ case plupload.IMAGE_MEMORY_ERROR:
+ wpFileError( fileObj, pluploadL10n.image_memory_exceeded );
+ break;
+ case plupload.IMAGE_DIMENSIONS_ERROR:
+ wpFileError( fileObj, pluploadL10n.image_dimensions_exceeded );
+ break;
+ case plupload.GENERIC_ERROR:
+ wpQueueError( pluploadL10n.upload_failed );
+ break;
+ case plupload.IO_ERROR:
+ max = parseInt( up.settings.filters.max_file_size, 10 );
+
+ if ( max > hundredmb && fileObj.size > hundredmb ) {
+ wpFileError( fileObj, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
+ } else {
+ wpQueueError( pluploadL10n.io_error );
+ }
+
+ break;
+ case plupload.HTTP_ERROR:
+ wpQueueError( pluploadL10n.http_error );
+ break;
+ case plupload.INIT_ERROR:
+ jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
+ break;
+ case plupload.SECURITY_ERROR:
+ wpQueueError( pluploadL10n.security_error );
+ break;
+ /* case plupload.UPLOAD_ERROR.UPLOAD_STOPPED:
+ case plupload.UPLOAD_ERROR.FILE_CANCELLED:
+ jQuery( '#media-item-' + fileObj.id ).remove();
+ break;*/
+ default:
+ wpFileError( fileObj, pluploadL10n.default_error );
+ }
+}
+
+function uploadSizeError( up, file ) {
+ var message, errorDiv;
+
+ message = pluploadL10n.file_exceeds_size_limit.replace( '%s', file.name );
+
+ // Construct the error div.
+ errorDiv = jQuery( '<div />' )
+ .attr( {
+ 'id': 'media-item-' + file.id,
+ 'class': 'media-item error'
+ } )
+ .append(
+ jQuery( '<p />' )
+ .text( message )
+ );
+
+ // Append the error.
+ jQuery( '#media-items' ).append( errorDiv );
+ up.removeFile( file );
+}
+
+function wpFileExtensionError( up, file, message ) {
+ jQuery( '#media-items' ).append( '<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>' );
+ up.removeFile( file );
+}
+
+jQuery( document ).ready( function( $ ) {
+ var tryAgainCount = {};
+ var tryAgain;
+
+ $( '.media-upload-form' ).bind( 'click.uploader', function( e ) {
+ var target = $( e.target ), tr, c;
+
+ if ( target.is( 'input[type="radio"]' ) ) { // remember the last used image size and alignment
+ tr = target.closest( 'tr' );
+
+ if ( tr.hasClass( 'align' ) )
+ setUserSetting( 'align', target.val() );
+ else if ( tr.hasClass( 'image-size' ) )
+ setUserSetting( 'imgsize', target.val() );
+
+ } else if ( target.is( 'button.button' ) ) { // remember the last used image link url
+ c = e.target.className || '';
+ c = c.match( /url([^ '"]+)/ );
+
+ if ( c && c[1] ) {
+ setUserSetting( 'urlbutton', c[1] );
+ target.siblings( '.urlfield' ).val( target.data( 'link-url' ) );
+ }
+ } else if ( target.is( 'a.dismiss' ) ) {
+ target.parents( '.media-item' ).fadeOut( 200, function() {
+ $( this ).remove();
+ } );
+ } else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // switch uploader to html4
+ $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', 'none' );
+ switchUploader( 0 );
+ e.preventDefault();
+ } else if ( target.is( '.upload-html-bypass a' ) ) { // switch uploader to multi-file
+ $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', '' );
+ switchUploader( 1 );
+ e.preventDefault();
+ } else if ( target.is( 'a.describe-toggle-on' ) ) { // Show
+ target.parent().addClass( 'open' );
+ target.siblings( '.slidetoggle' ).fadeIn( 250, function() {
+ var S = $( window ).scrollTop(),
+ H = $( window ).height(),
+ top = $( this ).offset().top,
+ h = $( this ).height(),
+ b,
+ B;
+
+ if ( H && top && h ) {
+ b = top + h;
+ B = S + H;
+
+ if ( b > B ) {
+ if ( b - B < top - S )
+ window.scrollBy( 0, ( b - B ) + 10 );
+ else
+ window.scrollBy( 0, top - S - 40 );
+ }
+ }
+ } );
+
+ e.preventDefault();
+ } else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide
+ target.siblings( '.slidetoggle' ).fadeOut( 250, function() {
+ target.parent().removeClass( 'open' );
+ } );
+
+ e.preventDefault();
+ }
+ });
+
+ // Attempt to create image sub-sizes when an image was uploaded successfully
+ // but the server responded with an HTTP 5xx error.
+ tryAgain = function( up, error ) {
+ var file = error.file;
+ var times;
+ var id;
+
+ if ( ! error || ! error.responseHeaders ) {
+ wpQueueError( pluploadL10n.http_error_image );
+ return;
+ }
+
+ id = error.responseHeaders.match( /x-wp-upload-attachment-id:\s*(\d+)/i );
+
+ if ( id && id[1] ) {
+ id = id[1];
+ } else {
+ wpQueueError( pluploadL10n.http_error_image );
+ return;
+ }
+
+ times = tryAgainCount[ file.id ];
+
+ if ( times && times > 4 ) {
+ // The file may have been uploaded and attachment post created,
+ // but post-processing and resizing failed...
+ // Do a cleanup then tell the user to scale down the image and upload it again.
+ $.ajax({
+ type: 'post',
+ url: ajaxurl,
+ dataType: 'json',
+ data: {
+ action: 'media-create-image-subsizes',
+ _wpnonce: wpUploaderInit.multipart_params._wpnonce,
+ attachment_id: id,
+ _wp_upload_failed_cleanup: true
+ }
+ });
+
+ if ( error.message && ( error.status < 500 || error.status >= 600 ) ) {
+ wpQueueError( error.message );
+ } else {
+ wpQueueError( pluploadL10n.http_error_image );
+ }
+
+ return;
+ }
+
+ if ( ! times ) {
+ tryAgainCount[ file.id ] = 1;
+ } else {
+ tryAgainCount[ file.id ] = ++times;
+ }
+
+ // Try to create the missing image sizes.
+ $.ajax({
+ type: 'post',
+ url: ajaxurl,
+ dataType: 'json',
+ data: {
+ action: 'media-create-image-subsizes',
+ _wpnonce: wpUploaderInit.multipart_params._wpnonce,
+ attachment_id: id,
+ _legacy_support: 'true'
+ }
+ }).done( function( response ) {
+ var message;
+
+ if ( response.success ) {
+ uploadSuccess( file, response.data.id );
+ } else {
+ if ( response.data && response.data.message ) {
+ message = response.data.message;
+ }
+
+ wpQueueError( message || pluploadL10n.http_error_image );
+ }
+ }).fail( function( jqXHR ) {
+ // If another HTTP 5xx error, try try again...
+ if ( jqXHR.status >= 500 && jqXHR.status < 600 ) {
+ tryAgain( up, error );
+ return;
+ }
+
+ wpQueueError( pluploadL10n.http_error_image );
+ });
+ };
+
+ // init and set the uploader
+ uploader_init = function() {
+ uploader = new plupload.Uploader( wpUploaderInit );
+
+ $( '#image_resize' ).bind( 'change', function() {
+ var arg = $( this ).prop( 'checked' );
+
+ setResize( arg );
+
+ if ( arg )
+ setUserSetting( 'upload_resize', '1' );
+ else
+ deleteUserSetting( 'upload_resize' );
+ });
+
+ uploader.bind( 'Init', function( up ) {
+ var uploaddiv = $( '#plupload-upload-ui' );
+
+ setResize( getUserSetting( 'upload_resize', false ) );
+
+ if ( up.features.dragdrop && ! $( document.body ).hasClass( 'mobile' ) ) {
+ uploaddiv.addClass( 'drag-drop' );
+
+ $( '#drag-drop-area' ).on( 'dragover.wp-uploader', function() { // dragenter doesn't fire right :(
+ uploaddiv.addClass( 'drag-over' );
+ }).on( 'dragleave.wp-uploader, drop.wp-uploader', function() {
+ uploaddiv.removeClass( 'drag-over' );
+ });
+ } else {
+ uploaddiv.removeClass( 'drag-drop' );
+ $( '#drag-drop-area' ).off( '.wp-uploader' );
+ }
+
+ if ( up.runtime === 'html4' ) {
+ $( '.upload-flash-bypass' ).hide();
+ }
+ });
+
+ uploader.bind( 'postinit', function( up ) {
+ up.refresh();
+ });
+
+ uploader.init();
+
+ uploader.bind( 'FilesAdded', function( up, files ) {
+ $( '#media-upload-error' ).empty();
+ uploadStart();
+
+ plupload.each( files, function( file ) {
+ fileQueued( file );
+ });
+
+ up.refresh();
+ up.start();
+ });
+
+ uploader.bind( 'UploadFile', function( up, file ) {
+ fileUploading( up, file );
+ });
+
+ uploader.bind( 'UploadProgress', function( up, file ) {
+ uploadProgress( up, file );
+ });
+
+ uploader.bind( 'Error', function( up, error ) {
+ var isImage = error.file && error.file.type && error.file.type.indexOf( 'image/' ) === 0;
+ var status = error && error.status;
+
+ // If the file is an image and the error is HTTP 5xx try to create sub-sizes again.
+ if ( isImage && status >= 500 && status < 600 ) {
+ tryAgain( up, error );
+ return;
+ }
+
+ uploadError( error.file, error.code, error.message, up );
+ up.refresh();
+ });
+
+ uploader.bind( 'FileUploaded', function( up, file, response ) {
+ uploadSuccess( file, response.response );
+ });
+
+ uploader.bind( 'UploadComplete', function() {
+ uploadComplete();
+ });
+ };
+
+ if ( typeof( wpUploaderInit ) == 'object' ) {
+ uploader_init();
+ }
+
+});
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/_enqueues/wp/plupload/handlers.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcjs_enqueueswppluploadwppluploadjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/_enqueues/wp/plupload/wp-plupload.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/_enqueues/wp/plupload/wp-plupload.js (rev 0)
+++ trunk/src/js/_enqueues/wp/plupload/wp-plupload.js 2019-11-03 15:29:46 UTC (rev 46634)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,551 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* global pluploadL10n, plupload, _wpPluploadSettings */
+
+/**
+ * @namespace wp
+ */
+window.wp = window.wp || {};
+
+// Suppress warning about Uploader function's unused "isIE" argument:
+/* jshint unused:false */
+( function( exports, $ ) {
+ var Uploader;
+
+ if ( typeof _wpPluploadSettings === 'undefined' ) {
+ return;
+ }
+
+ /**
+ * A WordPress uploader.
+ *
+ * The Plupload library provides cross-browser uploader UI integration.
+ * This object bridges the Plupload API to integrate uploads into the
+ * WordPress back end and the WordPress media experience.
+ *
+ * @class
+ * @memberOf wp
+ * @alias wp.Uploader
+ *
+ * @param {object} options The options passed to the new plupload instance.
+ * @param {object} options.container The id of uploader container.
+ * @param {object} options.browser The id of button to trigger the file select.
+ * @param {object} options.dropzone The id of file drop target.
+ * @param {object} options.plupload An object of parameters to pass to the plupload instance.
+ * @param {object} options.params An object of parameters to pass to $_POST when uploading the file.
+ * Extends this.plupload.multipart_params under the hood.
+ */
+ Uploader = function( options ) {
+ var self = this,
+ isIE, // not used, back-compat
+ elements = {
+ container: 'container',
+ browser: 'browse_button',
+ dropzone: 'drop_element'
+ },
+ tryAgainCount = {},
+ tryAgain,
+ key,
+ error,
+ fileUploaded;
+
+ this.supports = {
+ upload: Uploader.browser.supported
+ };
+
+ this.supported = this.supports.upload;
+
+ if ( ! this.supported ) {
+ return;
+ }
+
+ // Arguments to send to pluplad.Uploader().
+ // Use deep extend to ensure that multipart_params and other objects are cloned.
+ this.plupload = $.extend( true, { multipart_params: {} }, Uploader.defaults );
+ this.container = document.body; // Set default container.
+
+ // Extend the instance with options.
+ //
+ // Use deep extend to allow options.plupload to override individual
+ // default plupload keys.
+ $.extend( true, this, options );
+
+ // Proxy all methods so this always refers to the current instance.
+ for ( key in this ) {
+ if ( $.isFunction( this[ key ] ) ) {
+ this[ key ] = $.proxy( this[ key ], this );
+ }
+ }
+
+ // Ensure all elements are jQuery elements and have id attributes,
+ // then set the proper plupload arguments to the ids.
+ for ( key in elements ) {
+ if ( ! this[ key ] ) {
+ continue;
+ }
+
+ this[ key ] = $( this[ key ] ).first();
+
+ if ( ! this[ key ].length ) {
+ delete this[ key ];
+ continue;
+ }
+
+ if ( ! this[ key ].prop('id') ) {
+ this[ key ].prop( 'id', '__wp-uploader-id-' + Uploader.uuid++ );
+ }
+
+ this.plupload[ elements[ key ] ] = this[ key ].prop('id');
+ }
+
+ // If the uploader has neither a browse button nor a dropzone, bail.
+ if ( ! ( this.browser && this.browser.length ) && ! ( this.dropzone && this.dropzone.length ) ) {
+ return;
+ }
+
+ // Initialize the plupload instance.
+ this.uploader = new plupload.Uploader( this.plupload );
+ delete this.plupload;
+
+ // Set default params and remove this.params alias.
+ this.param( this.params || {} );
+ delete this.params;
+
+ /**
+ * Attempt to create image sub-sizes when an image was uploaded successfully
+ * but the server responded with HTTP 5xx error.
+ *
+ * @since 5.3.0
+ *
+ * @param {string} message Error message.
+ * @param {object} data Error data from Plupload.
+ * @param {plupload.File} file File that was uploaded.
+ */
+ tryAgain = function( message, data, file ) {
+ var times;
+ var id;
+
+ if ( ! data || ! data.responseHeaders ) {
+ error( pluploadL10n.http_error_image, data, file, 'no-retry' );
+ return;
+ }
+
+ id = data.responseHeaders.match( /x-wp-upload-attachment-id:\s*(\d+)/i );
+
+ if ( id && id[1] ) {
+ id = id[1];
+ } else {
+ error( pluploadL10n.http_error_image, data, file, 'no-retry' );
+ return;
+ }
+
+ times = tryAgainCount[ file.id ];
+
+ if ( times && times > 4 ) {
+ // The file may have been uploaded and attachment post created,
+ // but post-processing and resizing failed...
+ // Do a cleanup then tell the user to scale down the image and upload it again.
+ $.ajax({
+ type: 'post',
+ url: ajaxurl, // jshint ignore:line
+ dataType: 'json',
+ data: {
+ action: 'media-create-image-subsizes',
+ _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce,
+ attachment_id: id,
+ _wp_upload_failed_cleanup: true
+ }
+ });
+
+ error( message, data, file, 'no-retry' );
+ return;
+ }
+
+ if ( ! times ) {
+ tryAgainCount[ file.id ] = 1;
+ } else {
+ tryAgainCount[ file.id ] = ++times;
+ }
+
+ // Another request to try to create the missing image sub-sizes.
+ $.ajax({
+ type: 'post',
+ url: ajaxurl, // jshint ignore:line
+ dataType: 'json',
+ data: {
+ action: 'media-create-image-subsizes',
+ _wpnonce: _wpPluploadSettings.defaults.multipart_params._wpnonce,
+ attachment_id: id
+ }
+ }).done( function( response ) {
+ if ( response.success ) {
+ fileUploaded( self.uploader, file, response );
+ } else {
+ if ( response.data && response.data.message ) {
+ message = response.data.message;
+ }
+
+ error( message, data, file, 'no-retry' );
+ }
+ }).fail( function( jqXHR ) {
+ // If another HTTP 5xx error, try try again...
+ if ( jqXHR.status >= 500 && jqXHR.status < 600 ) {
+ tryAgain( message, data, file );
+ return;
+ }
+
+ error( message, data, file, 'no-retry' );
+ });
+ };
+
+ /**
+ * Custom error callback.
+ *
+ * Add a new error to the errors collection, so other modules can track
+ * and display errors. @see wp.Uploader.errors.
+ *
+ * @param {string} message Error message.
+ * @param {object} data Error data from Plupload.
+ * @param {plupload.File} file File that was uploaded.
+ * @param {string} retry Whether to try again to create image sub-sizes. Passing 'no-retry' will prevent it.
+ */
+ error = function( message, data, file, retry ) {
+ var isImage = file.type && file.type.indexOf( 'image/' ) === 0;
+ var status = data && data.status;
+
+ // If the file is an image and the error is HTTP 5xx try to create sub-sizes again.
+ if ( retry !== 'no-retry' && isImage && status >= 500 && status < 600 ) {
+ tryAgain( message, data, file );
+ return;
+ }
+
+ if ( file.attachment ) {
+ file.attachment.destroy();
+ }
+
+ Uploader.errors.unshift({
+ message: message || pluploadL10n.default_error,
+ data: data,
+ file: file
+ });
+
+ self.error( message, data, file );
+ };
+
+ /**
+ * After a file is successfully uploaded, update its model.
+ *
+ * @param {plupload.Uploader} up Uploader instance.
+ * @param {plupload.File} file File that was uploaded.
+ * @param {Object} response Object with response properties.
+ */
+ fileUploaded = function( up, file, response ) {
+ var complete;
+
+ // Remove the "uploading" UI elements
+ _.each( ['file','loaded','size','percent'], function( key ) {
+ file.attachment.unset( key );
+ } );
+
+ file.attachment.set( _.extend( response.data, { uploading: false } ) );
+
+ wp.media.model.Attachment.get( response.data.id, file.attachment );
+
+ complete = Uploader.queue.all( function( attachment ) {
+ return ! attachment.get( 'uploading' );
+ });
+
+ if ( complete ) {
+ Uploader.queue.reset();
+ }
+
+ self.success( file.attachment );
+ };
+
+ /**
+ * After the Uploader has been initialized, initialize some behaviors for the dropzone.
+ *
+ * @param {plupload.Uploader} uploader Uploader instance.
+ */
+ this.uploader.bind( 'init', function( uploader ) {
+ var timer, active, dragdrop,
+ dropzone = self.dropzone;
+
+ dragdrop = self.supports.dragdrop = uploader.features.dragdrop && ! Uploader.browser.mobile;
+
+ // Generate drag/drop helper classes.
+ if ( ! dropzone ) {
+ return;
+ }
+
+ dropzone.toggleClass( 'supports-drag-drop', !! dragdrop );
+
+ if ( ! dragdrop ) {
+ return dropzone.unbind('.wp-uploader');
+ }
+
+ // 'dragenter' doesn't fire correctly, simulate it with a limited 'dragover'.
+ dropzone.bind( 'dragover.wp-uploader', function() {
+ if ( timer ) {
+ clearTimeout( timer );
+ }
+
+ if ( active ) {
+ return;
+ }
+
+ dropzone.trigger('dropzone:enter').addClass('drag-over');
+ active = true;
+ });
+
+ dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function() {
+ // Using an instant timer prevents the drag-over class from
+ // being quickly removed and re-added when elements inside the
+ // dropzone are repositioned.
+ //
+ // @see https://core.trac.wordpress.org/ticket/21705
+ timer = setTimeout( function() {
+ active = false;
+ dropzone.trigger('dropzone:leave').removeClass('drag-over');
+ }, 0 );
+ });
+
+ self.ready = true;
+ $(self).trigger( 'uploader:ready' );
+ });
+
+ this.uploader.bind( 'postinit', function( up ) {
+ up.refresh();
+ self.init();
+ });
+
+ this.uploader.init();
+
+ if ( this.browser ) {
+ this.browser.on( 'mouseenter', this.refresh );
+ } else {
+ this.uploader.disableBrowse( true );
+ // If HTML5 mode, hide the auto-created file container.
+ $('#' + this.uploader.id + '_html5_container').hide();
+ }
+
+ /**
+ * After files were filtered and added to the queue, create a model for each.
+ *
+ * @param {plupload.Uploader} up Uploader instance.
+ * @param {Array} files Array of file objects that were added to queue by the user.
+ */
+ this.uploader.bind( 'FilesAdded', function( up, files ) {
+ _.each( files, function( file ) {
+ var attributes, image;
+
+ // Ignore failed uploads.
+ if ( plupload.FAILED === file.status ) {
+ return;
+ }
+
+ // Generate attributes for a new `Attachment` model.
+ attributes = _.extend({
+ file: file,
+ uploading: true,
+ date: new Date(),
+ filename: file.name,
+ menuOrder: 0,
+ uploadedTo: wp.media.model.settings.post.id
+ }, _.pick( file, 'loaded', 'size', 'percent' ) );
+
+ // Handle early mime type scanning for images.
+ image = /(?:jpe?g|png|gif)$/i.exec( file.name );
+
+ // For images set the model's type and subtype attributes.
+ if ( image ) {
+ attributes.type = 'image';
+
+ // `jpeg`, `png` and `gif` are valid subtypes.
+ // `jpg` is not, so map it to `jpeg`.
+ attributes.subtype = ( 'jpg' === image[0] ) ? 'jpeg' : image[0];
+ }
+
+ // Create a model for the attachment, and add it to the Upload queue collection
+ // so listeners to the upload queue can track and display upload progress.
+ file.attachment = wp.media.model.Attachment.create( attributes );
+ Uploader.queue.add( file.attachment );
+
+ self.added( file.attachment );
+ });
+
+ up.refresh();
+ up.start();
+ });
+
+ this.uploader.bind( 'UploadProgress', function( up, file ) {
+ file.attachment.set( _.pick( file, 'loaded', 'percent' ) );
+ self.progress( file.attachment );
+ });
+
+ /**
+ * After a file is successfully uploaded, update its model.
+ *
+ * @param {plupload.Uploader} up Uploader instance.
+ * @param {plupload.File} file File that was uploaded.
+ * @param {Object} response Object with response properties.
+ * @return {mixed}
+ */
+ this.uploader.bind( 'FileUploaded', function( up, file, response ) {
+
+ try {
+ response = JSON.parse( response.response );
+ } catch ( e ) {
+ return error( pluploadL10n.default_error, e, file );
+ }
+
+ if ( ! _.isObject( response ) || _.isUndefined( response.success ) ) {
+ return error( pluploadL10n.default_error, null, file );
+ } else if ( ! response.success ) {
+ return error( response.data && response.data.message, response.data, file );
+ }
+
+ // Success. Update the UI with the new attachment.
+ fileUploaded( up, file, response );
+ });
+
+ /**
+ * When plupload surfaces an error, send it to the error handler.
+ *
+ * @param {plupload.Uploader} up Uploader instance.
+ * @param {Object} pluploadError Contains code, message and sometimes file and other details.
+ */
+ this.uploader.bind( 'Error', function( up, pluploadError ) {
+ var message = pluploadL10n.default_error,
+ key;
+
+ // Check for plupload errors.
+ for ( key in Uploader.errorMap ) {
+ if ( pluploadError.code === plupload[ key ] ) {
+ message = Uploader.errorMap[ key ];
+
+ if ( _.isFunction( message ) ) {
+ message = message( pluploadError.file, pluploadError );
+ }
+
+ break;
+ }
+ }
+
+ error( message, pluploadError, pluploadError.file );
+ up.refresh();
+ });
+
+ };
+
+ // Adds the 'defaults' and 'browser' properties.
+ $.extend( Uploader, _wpPluploadSettings );
+
+ Uploader.uuid = 0;
+
+ // Map Plupload error codes to user friendly error messages.
+ Uploader.errorMap = {
+ 'FAILED': pluploadL10n.upload_failed,
+ 'FILE_EXTENSION_ERROR': pluploadL10n.invalid_filetype,
+ 'IMAGE_FORMAT_ERROR': pluploadL10n.not_an_image,
+ 'IMAGE_MEMORY_ERROR': pluploadL10n.image_memory_exceeded,
+ 'IMAGE_DIMENSIONS_ERROR': pluploadL10n.image_dimensions_exceeded,
+ 'GENERIC_ERROR': pluploadL10n.upload_failed,
+ 'IO_ERROR': pluploadL10n.io_error,
+ 'SECURITY_ERROR': pluploadL10n.security_error,
+
+ 'FILE_SIZE_ERROR': function( file ) {
+ return pluploadL10n.file_exceeds_size_limit.replace( '%s', file.name );
+ },
+
+ 'HTTP_ERROR': function( file ) {
+ if ( file.type && file.type.indexOf( 'image/' ) === 0 ) {
+ return pluploadL10n.http_error_image;
+ }
+
+ return pluploadL10n.http_error;
+ }
+ };
+
+ $.extend( Uploader.prototype, /** @lends wp.Uploader.prototype */{
+ /**
+ * Acts as a shortcut to extending the uploader's multipart_params object.
+ *
+ * param( key )
+ * Returns the value of the key.
+ *
+ * param( key, value )
+ * Sets the value of a key.
+ *
+ * param( map )
+ * Sets values for a map of data.
+ */
+ param: function( key, value ) {
+ if ( arguments.length === 1 && typeof key === 'string' ) {
+ return this.uploader.settings.multipart_params[ key ];
+ }
+
+ if ( arguments.length > 1 ) {
+ this.uploader.settings.multipart_params[ key ] = value;
+ } else {
+ $.extend( this.uploader.settings.multipart_params, key );
+ }
+ },
+
+ /**
+ * Make a few internal event callbacks available on the wp.Uploader object
+ * to change the Uploader internals if absolutely necessary.
+ */
+ init: function() {},
+ error: function() {},
+ success: function() {},
+ added: function() {},
+ progress: function() {},
+ complete: function() {},
+ refresh: function() {
+ var node, attached, container, id;
+
+ if ( this.browser ) {
+ node = this.browser[0];
+
+ // Check if the browser node is in the DOM.
+ while ( node ) {
+ if ( node === document.body ) {
+ attached = true;
+ break;
+ }
+ node = node.parentNode;
+ }
+
+ // If the browser node is not attached to the DOM, use a
+ // temporary container to house it, as the browser button
+ // shims require the button to exist in the DOM at all times.
+ if ( ! attached ) {
+ id = 'wp-uploader-browser-' + this.uploader.id;
+
+ container = $( '#' + id );
+ if ( ! container.length ) {
+ container = $('<div class="wp-uploader-browser" />').css({
+ position: 'fixed',
+ top: '-1000px',
+ left: '-1000px',
+ height: 0,
+ width: 0
+ }).attr( 'id', 'wp-uploader-browser-' + this.uploader.id ).appendTo('body');
+ }
+
+ container.append( this.browser );
+ }
+ }
+
+ this.uploader.refresh();
+ }
+ });
+
+ // Create a collection of attachments in the upload queue,
+ // so that other modules can track and display upload progress.
+ Uploader.queue = new wp.media.model.Attachments( [], { query: false });
+
+ // Create a collection to collect errors incurred while attempting upload.
+ Uploader.errors = new Backbone.Collection();
+
+ exports.Uploader = Uploader;
+})( wp, jQuery );
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/_enqueues/wp/plupload/wp-plupload.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2019-11-03 10:54:39 UTC (rev 46633)
+++ trunk/src/wp-includes/script-loader.php 2019-11-03 15:29:46 UTC (rev 46634)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1252,11 +1252,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'error_uploading' => __( '“%s” has failed to upload.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $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.1.9' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.5.7' );
+ $scripts->add( 'plupload', "/wp-includes/js/plupload/plupload$suffix.js", array( 'moxiejs' ), '2.3.6' );
</ins><span class="cx" style="display: block; padding: 0 10px"> // Back compat handles:
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( array( 'all', 'html5', 'flash', 'silverlight', 'html4' ) as $handle ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.1.1' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $scripts->add( "plupload-$handle", false, array( 'plupload' ), '2.3.6' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array( 'plupload', 'jquery' ) );
</span></span></pre>
</div>
</div>
</body>
</html>