Allow elements within a wp.Uploader dropzone to be repositioned when the drag-over class is added. fixes #21705.

git-svn-id: http://core.svn.wordpress.org/trunk@21630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-08-27 22:20:23 +00:00
parent 446be3ee40
commit 0015503c26
1 changed files with 14 additions and 5 deletions

View File

@ -11,7 +11,7 @@ if ( typeof wp === 'undefined' )
* An object that helps create a WordPress uploader using plupload.
*
* @param options - object - The options passed to the new plupload instance.
* Requires the following parameters:
* Accepts the following parameters:
* - container - The id of uploader container.
* - browser - The id of button to trigger the file select.
* - dropzone - The id of file drop target.
@ -86,8 +86,7 @@ if ( typeof wp === 'undefined' )
// Generate drag/drop helper classes.
(function( dropzone, supported ) {
var sensitivity = 50,
active;
var timer, active;
if ( ! dropzone )
return;
@ -100,6 +99,9 @@ if ( typeof wp === 'undefined' )
// 'dragenter' doesn't fire correctly,
// simulate it with a limited 'dragover'
dropzone.bind( 'dragover.wp-uploader', function(){
if ( timer )
clearTimeout( timer );
if ( active )
return;
@ -108,8 +110,15 @@ if ( typeof wp === 'undefined' )
});
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 http://core.trac.wordpress.org/ticket/21705
timer = setTimeout( function() {
active = false;
dropzone.removeClass('drag-over');
}, 0 );
});
}( this.dropzone, this.supports.dragdrop ));