Make WordPress Core

Ticket #19845: 19845.9.diff

File 19845.9.diff, 3.0 KB (added by kovshenin, 11 years ago)
  • src/wp-includes/js/media-views.js

     
    34753475                className: 'uploader-editor',
    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
    34813487                        // Bail if UA does not support drag'n'drop or File API.
     
    34903496                        this.$document.on( 'drop', '.uploader-editor', _.bind( this.drop, this ) );
    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 ) );
    34963503
     3504                        this.$document.on( 'dragstart', function() {
     3505                                self.localDrag = true;
     3506                        });
     3507
     3508                        this.$document.on( 'dragend drop', function() {
     3509                                self.localDrag = false;
     3510                        });
     3511
    34973512                        this.initialized = true;
    34983513                        return this;
    34993514                },
     
    35413556                drop: function( event ) {
    35423557                        var $wrap = null;
    35433558
     3559                        this.containerDragleave( event );
     3560                        this.dropzoneDragleave( event );
     3561
    35443562                        this.files = event.originalEvent.dataTransfer.files;
    35453563                        if ( this.files.length < 1 )
    35463564                                return;
    35473565
    3548                         this.containerDragleave( event );
    3549                         this.dropzoneDragleave( event );
    3550 
    35513566                        // Set the active editor to the drop target.
    35523567                        $wrap = $( event.target ).parents( '.wp-editor-wrap' );
    35533568                        if ( $wrap.length > 0 ) {
     
    35803595                },
    35813596
    35823597                containerDragover: function() {
     3598                        if ( this.localDrag ) {
     3599                                return;
     3600                        }
     3601
    35833602                        this.overContainer = true;
    35843603                        this.refresh();
    35853604                },
     
    35923611                },
    35933612
    35943613                dropzoneDragover: function( e ) {
     3614                        if ( this.localDrag ) {
     3615                                return;
     3616                        }
     3617
    35953618                        this.overDropzone = true;
    35963619                        this.refresh( e );
    35973620                        return false;
     
    36003623                dropzoneDragleave: function( e ) {
    36013624                        this.overDropzone = false;
    36023625                        _.delay( _.bind( this.refresh, this, e ), 50 );
     3626                },
     3627
     3628                click: function( e ) {
     3629                        // In the rare case where the dropzone gets stuck, hide it on click.
     3630                        this.containerDragleave( e );
     3631                        this.dropzoneDragleave( e );
    36033632                }
    36043633        });
    36053634
  • src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

     
    379379                        });
    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' ) {
    384384                                // Propagate the event to its container for the parent window to catch.
    385385                                window.jQuery( editor.getContainer() ).trigger( event );