Make WordPress Core

Changeset 27531


Ignore:
Timestamp:
03/14/2014 12:41:12 AM (13 years ago)
Author:
azaozz
Message:

Drag/drop upload: don't trigger on "local" dragging, hide the overlay on click. Props kovshenin, fixes #19845

Location:
trunk/src/wp-includes/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-views.js

    r27530 r27531  
    34763476                template:  media.template( 'uploader-editor' ),
    34773477
     3478                localDrag: false,
     3479                overContainer: false,
     3480                overDropzone: false,
     3481
    34783482                initialize: function() {
     3483                        var self = this;
     3484
    34793485                        this.initialized = false;
    34803486
    … …  
    34913497                        this.$document.on( 'dragover', '.uploader-editor', _.bind( this.dropzoneDragover, this ) );
    34923498                        this.$document.on( 'dragleave', '.uploader-editor', _.bind( this.dropzoneDragleave, this ) );
     3499                        this.$document.on( 'click', '.uploader-editor', _.bind( this.click, this ) );
    34933500
    34943501                        this.$document.on( 'dragover', _.bind( this.containerDragover, this ) );
    34953502                        this.$document.on( 'dragleave', _.bind( this.containerDragleave, this ) );
     3503
     3504                        this.$document.on( 'dragstart dragend drop', function( event ) {
     3505                                self.localDrag = event.type === 'dragstart';
     3506                        });
    34963507
    34973508                        this.initialized = true;
    … …  
    35423553                        var $wrap = null;
    35433554
    3544                         this.files = event.originalEvent.dataTransfer.files;
    3545                         if ( this.files.length < 1 )
    3546                                 return;
    3547 
    35483555                        this.containerDragleave( event );
    35493556                        this.dropzoneDragleave( event );
    35503557
     3558                        this.files = event.originalEvent.dataTransfer.files;
     3559                        if ( this.files.length < 1 ) {
     3560                                return;
     3561                        }
     3562
    35513563                        // Set the active editor to the drop target.
    35523564                        $wrap = $( event.target ).parents( '.wp-editor-wrap' );
    3553                         if ( $wrap.length > 0 ) {
     3565                        if ( $wrap.length > 0 && $wrap[0].id ) {
    35543566                                window.wpActiveEditor = $wrap[0].id.slice( 3, -5 );
    35553567                        }
    … …  
    35813593
    35823594                containerDragover: function() {
     3595                        if ( this.localDrag ) {
     3596                                return;
     3597                        }
     3598
    35833599                        this.overContainer = true;
    35843600                        this.refresh();
    … …  
    35933609
    35943610                dropzoneDragover: function( e ) {
     3611                        if ( this.localDrag ) {
     3612                                return;
     3613                        }
     3614
    35953615                        this.overDropzone = true;
    35963616                        this.refresh( e );
    … …  
    36013621                        this.overDropzone = false;
    36023622                        _.delay( _.bind( this.refresh, this, e ), 50 );
     3623                },
     3624
     3625                click: function( e ) {
     3626                        // In the rare case where the dropzone gets stuck, hide it on click.
     3627                        this.containerDragleave( e );
     3628                        this.dropzoneDragleave( e );
     3629                        this.localDrag = false;
    36033630                }
    36043631        });
  • trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

    r27513 r27531  
    380380                }
    381381
    382                 dom.bind( doc, 'dragover', function( event ) {
     382                dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
    383383                        if ( typeof window.jQuery !== 'undefined' ) {
    384                                 // Propagate the event to its container for the parent window to catch.
    385                                 window.jQuery( editor.getContainer() ).trigger( event );
     384                                // Trigger the jQuery handlers.
     385                                window.jQuery( document ).triggerHandler( event.type );
    386386                        }
    387387                });
Note: See TracChangeset for help on using the changeset viewer.