Make WordPress Core

Changeset 28262


Ignore:
Timestamp:
05/06/2014 03:27:02 AM (12 years ago)
Author:
nacin
Message:

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.

Location:
branches/3.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.9

  • branches/3.9/src/wp-includes/js/media-views.js

    r28229 r28262  
    32713271                overContainer: false,
    32723272                overDropzone: false,
     3273                draggingFile: null,
    32733274
    32743275                initialize: function() {
     
    33083309                        supports = supports && !! ( window.File && window.FileList && window.FileReader );
    33093310                        return supports;
     3311                },
     3312
     3313                isDraggingFile: function( event ) {
     3314                        if ( this.draggingFile !== null ) {
     3315                                return this.draggingFile;
     3316                        }
     3317
     3318                        if ( _.isUndefined( event.originalEvent ) || _.isUndefined( event.originalEvent.dataTransfer ) ) {
     3319                                return false;
     3320                        }
     3321
     3322                        this.draggingFile = _.indexOf( event.originalEvent.dataTransfer.types, 'Files' ) > -1 &&
     3323                                _.indexOf( event.originalEvent.dataTransfer.types, 'text/plain' ) === -1;
     3324
     3325                        return this.draggingFile;
    33103326                },
    33113327
     
    33193335                        if ( ! _.isUndefined( e ) ) {
    33203336                                $( e.target ).closest( '.uploader-editor' ).toggleClass( 'droppable', this.overDropzone );
     3337                        }
     3338
     3339                        if ( ! this.overContainer && ! this.overDropzone ) {
     3340                                this.draggingFile = null;
    33213341                        }
    33223342
     
    33843404                },
    33853405
    3386                 containerDragover: function() {
    3387                         if ( this.localDrag ) {
     3406                containerDragover: function( event ) {
     3407                        if ( this.localDrag || ! this.isDraggingFile( event ) ) {
    33883408                                return;
    33893409                        }
     
    34003420                },
    34013421
    3402                 dropzoneDragover: function( e ) {
    3403                         if ( this.localDrag ) {
     3422                dropzoneDragover: function( event ) {
     3423                        if ( this.localDrag || ! this.isDraggingFile( event ) ) {
    34043424                                return;
    34053425                        }
    34063426
    34073427                        this.overDropzone = true;
    3408                         this.refresh( e );
     3428                        this.refresh( event );
    34093429                        return false;
    34103430                },
  • branches/3.9/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

    r28226 r28262  
    318318                                if ( typeof window.jQuery !== 'undefined' ) {
    319319                                        // Trigger the jQuery handlers.
    320                                         window.jQuery( document ).triggerHandler( event.type );
     320                                        window.jQuery( document ).trigger( new window.jQuery.Event( event ) );
    321321                                }
    322322                        });
Note: See TracChangeset for help on using the changeset viewer.