mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-13 06:07:23 +01:00
Drag/drop on the editor to upload: don't trigger the uploader when selected text is being dragged from one window to another.
Merges [28189] to the 3.9 branch. props azaozz. fixes #27880. Built from https://develop.svn.wordpress.org/branches/3.9@28262 git-svn-id: http://core.svn.wordpress.org/branches/3.9@28090 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f2512c50eb
commit
c85dc97274
@ -3270,6 +3270,7 @@
|
||||
localDrag: false,
|
||||
overContainer: false,
|
||||
overDropzone: false,
|
||||
draggingFile: null,
|
||||
|
||||
initialize: function() {
|
||||
var self = this;
|
||||
@ -3309,6 +3310,21 @@
|
||||
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 ) {
|
||||
var dropzone_id;
|
||||
for ( dropzone_id in this.dropzones ) {
|
||||
@ -3320,6 +3336,10 @@
|
||||
$( e.target ).closest( '.uploader-editor' ).toggleClass( 'droppable', this.overDropzone );
|
||||
}
|
||||
|
||||
if ( ! this.overContainer && ! this.overDropzone ) {
|
||||
this.draggingFile = null;
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
@ -3383,8 +3403,8 @@
|
||||
return this;
|
||||
},
|
||||
|
||||
containerDragover: function() {
|
||||
if ( this.localDrag ) {
|
||||
containerDragover: function( event ) {
|
||||
if ( this.localDrag || ! this.isDraggingFile( event ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3399,13 +3419,13 @@
|
||||
_.delay( _.bind( this.refresh, this ), 50 );
|
||||
},
|
||||
|
||||
dropzoneDragover: function( e ) {
|
||||
if ( this.localDrag ) {
|
||||
dropzoneDragover: function( event ) {
|
||||
if ( this.localDrag || ! this.isDraggingFile( event ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.overDropzone = true;
|
||||
this.refresh( e );
|
||||
this.refresh( event );
|
||||
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 ) {
|
||||
if ( typeof window.jQuery !== 'undefined' ) {
|
||||
// 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