wp/wp-includes/js/plupload/wp-plupload.js
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    12 	/**
    12 	/**
    13 	 * A WordPress uploader.
    13 	 * A WordPress uploader.
    14 	 *
    14 	 *
    15 	 * The Plupload library provides cross-browser uploader UI integration.
    15 	 * The Plupload library provides cross-browser uploader UI integration.
    16 	 * This object bridges the Plupload API to integrate uploads into the
    16 	 * This object bridges the Plupload API to integrate uploads into the
    17 	 * WordPress back-end and the WordPress media experience.
    17 	 * WordPress back end and the WordPress media experience.
    18 	 *
    18 	 *
    19 	 * @param {object} options           The options passed to the new plupload instance.
    19 	 * @param {object} options           The options passed to the new plupload instance.
    20 	 * @param {object} options.container The id of uploader container.
    20 	 * @param {object} options.container The id of uploader container.
    21 	 * @param {object} options.browser   The id of button to trigger the file select.
    21 	 * @param {object} options.browser   The id of button to trigger the file select.
    22 	 * @param {object} options.dropzone  The id of file drop target.
    22 	 * @param {object} options.dropzone  The id of file drop target.
   178 
   178 
   179 			self.ready = true;
   179 			self.ready = true;
   180 			$(self).trigger( 'uploader:ready' );
   180 			$(self).trigger( 'uploader:ready' );
   181 		});
   181 		});
   182 
   182 
       
   183 		this.uploader.bind( 'postinit', function( up ) {
       
   184 			up.refresh();
       
   185 			self.init();
       
   186 		});
       
   187 
   183 		this.uploader.init();
   188 		this.uploader.init();
   184 
   189 
   185 		if ( this.browser ) {
   190 		if ( this.browser ) {
   186 			this.browser.on( 'mouseenter', this.refresh );
   191 			this.browser.on( 'mouseenter', this.refresh );
   187 		} else {
   192 		} else {
   191 		}
   196 		}
   192 
   197 
   193 		/**
   198 		/**
   194 		 * After files were filtered and added to the queue, create a model for each.
   199 		 * After files were filtered and added to the queue, create a model for each.
   195 		 *
   200 		 *
   196 		 * @event FilesAdded
       
   197 		 * @param {plupload.Uploader} uploader Uploader instance.
   201 		 * @param {plupload.Uploader} uploader Uploader instance.
   198 		 * @param {Array}             files    Array of file objects that were added to queue by the user.
   202 		 * @param {Array}             files    Array of file objects that were added to queue by the user.
   199 		 */
   203 		 */
   200 		this.uploader.bind( 'FilesAdded', function( up, files ) {
   204 		this.uploader.bind( 'FilesAdded', function( up, files ) {
   201 			_.each( files, function( file ) {
   205 			_.each( files, function( file ) {
   309 
   313 
   310 			error( message, pluploadError, pluploadError.file );
   314 			error( message, pluploadError, pluploadError.file );
   311 			up.refresh();
   315 			up.refresh();
   312 		});
   316 		});
   313 
   317 
   314 		this.uploader.bind( 'PostInit', function() {
       
   315 			self.init();
       
   316 		});
       
   317 	};
   318 	};
   318 
   319 
   319 	// Adds the 'defaults' and 'browser' properties.
   320 	// Adds the 'defaults' and 'browser' properties.
   320 	$.extend( Uploader, _wpPluploadSettings );
   321 	$.extend( Uploader, _wpPluploadSettings );
   321 
   322 
   336 		'FILE_SIZE_ERROR': function( file ) {
   337 		'FILE_SIZE_ERROR': function( file ) {
   337 			return pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);
   338 			return pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);
   338 		}
   339 		}
   339 	};
   340 	};
   340 
   341 
   341 	$.extend( Uploader.prototype, {
   342 	$.extend( Uploader.prototype, /** @lends wp.Uploader.prototype */{
   342 		/**
   343 		/**
   343 		 * Acts as a shortcut to extending the uploader's multipart_params object.
   344 		 * Acts as a shortcut to extending the uploader's multipart_params object.
   344 		 *
   345 		 *
   345 		 * param( key )
   346 		 * param( key )
   346 		 *    Returns the value of the key.
   347 		 *    Returns the value of the key.