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.

git-svn-id: https://develop.svn.wordpress.org/trunk@28189 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-04-23 20:34:43 +00:00
parent 67a0a4fd14
commit c602aac562
2 changed files with 26 additions and 6 deletions

View File

@ -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;
},

View File

@ -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 ) );
}
});
}