Make WordPress Core

Ticket #19845: 19845.8.diff

File 19845.8.diff, 3.5 KB (added by azaozz, 11 years ago)
  • src/wp-includes/js/media-views.js

     
    35073507
    35083508                        this.$document.on( 'dragover', _.bind( this.containerDragover, this ) );
    35093509                        this.$document.on( 'dragleave', _.bind( this.containerDragleave, this ) );
     3510                        this.$document.on( 'click', '.wp-editor-wrap .uploader-editor', _.bind( this.hide, this ) );
    35103511
    35113512                        this.initialized = true;
    35123513                        return this;
     
    35203521                        return supports;
    35213522                },
    35223523
     3524                isDraggingFile: function( e ) {
     3525                        if ( _.isUndefined( e.originalEvent ) || _.isUndefined( e.originalEvent.dataTransfer ) ) {
     3526                                return false;
     3527                        }
     3528
     3529                        return _.indexOf( e.originalEvent.dataTransfer.types, 'Files' ) > -1 &&
     3530                                _.indexOf( e.originalEvent.dataTransfer.types, 'text/plain' ) === -1;
     3531                },
     3532
    35233533                refresh: function( e ) {
    35243534                        var dropzone_id;
     3535
    35253536                        for ( dropzone_id in this.dropzones ) {
    35263537                                // Hide the dropzones only if dragging has left the screen.
    35273538                                this.dropzones[ dropzone_id ].toggle( this.overContainer || this.overDropzone );
     
    35563567                        var $wrap = null;
    35573568
    35583569                        this.files = event.originalEvent.dataTransfer.files;
    3559                         if ( this.files.length < 1 )
     3570
     3571                        if ( this.files.length < 1 ) {
    35603572                                return;
     3573                        }
    35613574
    35623575                        this.containerDragleave( event );
    35633576                        this.dropzoneDragleave( event );
     
    35933606                        return this;
    35943607                },
    35953608
    3596                 containerDragover: function() {
     3609                show: function() {
    35973610                        this.overContainer = true;
    35983611                        this.refresh();
    35993612                },
    36003613
    3601                 containerDragleave: function() {
     3614                hide: function() {
    36023615                        this.overContainer = false;
     3616                        this.overDropzone = false;
     3617                        this.refresh();
     3618                },
    36033619
     3620                containerDragover: function( e, show ) {
     3621                        if ( show === 'show' ) {
     3622                                this.show();
     3623                                return;
     3624                        }
     3625
     3626                        if ( ! this.isDraggingFile( e ) ) {
     3627                                return;
     3628                        }
     3629
     3630                        this.overContainer = true;
     3631                        this.refresh( e );
     3632                },
     3633
     3634                containerDragleave: function( e ) {
     3635                        if ( ! this.isDraggingFile( e ) ) {
     3636                                return;
     3637                        }
     3638
     3639                        this.overContainer = false;
    36043640                        // Throttle dragleave because it's called when bouncing from some elements to others.
    3605                         _.delay( _.bind( this.refresh, this ), 50 );
     3641                        _.delay( _.bind( this.refresh, this, e ), 50 );
    36063642                },
    36073643
    36083644                dropzoneDragover: function( e ) {
     3645                        if ( ! this.isDraggingFile( e ) ) {
     3646                                return;
     3647                        }
     3648
    36093649                        this.overDropzone = true;
    36103650                        this.refresh( e );
    36113651                        return false;
     
    36123652                },
    36133653
    36143654                dropzoneDragleave: function( e ) {
     3655                        if ( ! this.isDraggingFile( e ) ) {
     3656                                return;
     3657                        }
     3658
    36153659                        this.overDropzone = false;
    36163660                        _.delay( _.bind( this.refresh, this, e ), 50 );
    36173661                }
  • src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

     
    376376                        });
    377377                }
    378378
    379                 dom.bind( doc, 'dragover', function( event ) {
    380                         if ( typeof window.jQuery !== 'undefined' ) {
     379                dom.bind( doc, 'dragenter', function( event ) {
     380                        if ( typeof window.jQuery !== 'undefined' && event.dataTransfer &&
     381                                tinymce.inArray( event.dataTransfer.types, 'Files' ) > -1 && tinymce.inArray( event.dataTransfer.types, 'text/plain' ) === -1 ) {
    381382                                // Propagate the event to its container for the parent window to catch.
    382                                 window.jQuery( editor.getContainer() ).trigger( event );
     383                                window.jQuery( editor.getContainer() ).trigger( 'dragover', 'show' );
    383384                        }
    384385                });
    385386        });