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:
parent
446be3ee40
commit
0015503c26
|
@ -11,7 +11,7 @@ if ( typeof wp === 'undefined' )
|
||||||
* An object that helps create a WordPress uploader using plupload.
|
* An object that helps create a WordPress uploader using plupload.
|
||||||
*
|
*
|
||||||
* @param options - object - The options passed to the new plupload instance.
|
* @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.
|
* - container - The id of uploader container.
|
||||||
* - browser - The id of button to trigger the file select.
|
* - browser - The id of button to trigger the file select.
|
||||||
* - dropzone - The id of file drop target.
|
* - dropzone - The id of file drop target.
|
||||||
|
@ -86,8 +86,7 @@ if ( typeof wp === 'undefined' )
|
||||||
|
|
||||||
// Generate drag/drop helper classes.
|
// Generate drag/drop helper classes.
|
||||||
(function( dropzone, supported ) {
|
(function( dropzone, supported ) {
|
||||||
var sensitivity = 50,
|
var timer, active;
|
||||||
active;
|
|
||||||
|
|
||||||
if ( ! dropzone )
|
if ( ! dropzone )
|
||||||
return;
|
return;
|
||||||
|
@ -100,6 +99,9 @@ if ( typeof wp === 'undefined' )
|
||||||
// 'dragenter' doesn't fire correctly,
|
// 'dragenter' doesn't fire correctly,
|
||||||
// simulate it with a limited 'dragover'
|
// simulate it with a limited 'dragover'
|
||||||
dropzone.bind( 'dragover.wp-uploader', function(){
|
dropzone.bind( 'dragover.wp-uploader', function(){
|
||||||
|
if ( timer )
|
||||||
|
clearTimeout( timer );
|
||||||
|
|
||||||
if ( active )
|
if ( active )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -108,8 +110,15 @@ if ( typeof wp === 'undefined' )
|
||||||
});
|
});
|
||||||
|
|
||||||
dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function(){
|
dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function(){
|
||||||
active = false;
|
// Using an instant timer prevents the drag-over class from
|
||||||
dropzone.removeClass('drag-over');
|
// 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 ));
|
}( this.dropzone, this.supports.dragdrop ));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue