mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 08:11:52 +01:00
Drag/drop on the editor to upload: don't trigger the uploader when selected test is being dragged from one window to another. See #27880, for trunk.
Built from https://develop.svn.wordpress.org/trunk@28189 git-svn-id: http://core.svn.wordpress.org/trunk@28019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c621255236
commit
3eb1616925
@ -3270,6 +3270,7 @@
|
|||||||
localDrag: false,
|
localDrag: false,
|
||||||
overContainer: false,
|
overContainer: false,
|
||||||
overDropzone: false,
|
overDropzone: false,
|
||||||
|
draggingFile: null,
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -3309,6 +3310,21 @@
|
|||||||
return supports;
|
return supports;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isDraggingFile: function( event ) {
|
||||||
|
if ( this.draggingFile !== null ) {
|
||||||
|
return this.draggingFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( _.isUndefined( event.originalEvent ) || _.isUndefined( event.originalEvent.dataTransfer ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.draggingFile = _.indexOf( event.originalEvent.dataTransfer.types, 'Files' ) > -1 &&
|
||||||
|
_.indexOf( event.originalEvent.dataTransfer.types, 'text/plain' ) === -1;
|
||||||
|
|
||||||
|
return this.draggingFile;
|
||||||
|
},
|
||||||
|
|
||||||
refresh: function( e ) {
|
refresh: function( e ) {
|
||||||
var dropzone_id;
|
var dropzone_id;
|
||||||
for ( dropzone_id in this.dropzones ) {
|
for ( dropzone_id in this.dropzones ) {
|
||||||
@ -3320,6 +3336,10 @@
|
|||||||
$( e.target ).closest( '.uploader-editor' ).toggleClass( 'droppable', this.overDropzone );
|
$( e.target ).closest( '.uploader-editor' ).toggleClass( 'droppable', this.overDropzone );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! this.overContainer && ! this.overDropzone ) {
|
||||||
|
this.draggingFile = null;
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -3383,8 +3403,8 @@
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
containerDragover: function() {
|
containerDragover: function( event ) {
|
||||||
if ( this.localDrag ) {
|
if ( this.localDrag || ! this.isDraggingFile( event ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3399,13 +3419,13 @@
|
|||||||
_.delay( _.bind( this.refresh, this ), 50 );
|
_.delay( _.bind( this.refresh, this ), 50 );
|
||||||
},
|
},
|
||||||
|
|
||||||
dropzoneDragover: function( e ) {
|
dropzoneDragover: function( event ) {
|
||||||
if ( this.localDrag ) {
|
if ( this.localDrag || ! this.isDraggingFile( event ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.overDropzone = true;
|
this.overDropzone = true;
|
||||||
this.refresh( e );
|
this.refresh( event );
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
2
wp-includes/js/media-views.min.js
vendored
2
wp-includes/js/media-views.min.js
vendored
File diff suppressed because one or more lines are too long
@ -317,7 +317,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
|||||||
dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
|
dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
|
||||||
if ( typeof window.jQuery !== 'undefined' ) {
|
if ( typeof window.jQuery !== 'undefined' ) {
|
||||||
// Trigger the jQuery handlers.
|
// Trigger the jQuery handlers.
|
||||||
window.jQuery( document ).triggerHandler( event.type );
|
window.jQuery( document ).trigger( new window.jQuery.Event( event ) );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue
Block a user