Make WordPress Core

Changeset 27464


Ignore:
Timestamp:
03/08/2014 01:34:04 AM (13 years ago)
Author:
azaozz
Message:

Limit the drag/drop upload only to newer browsers (IE10+), add a fullscreen dropzone in DFW mode, props kovshenin, see #19845

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/edit.css

    r27403 r27464  
    613613}
    614614
     615.wp-fullscreen-wrap .uploader-editor {
     616        background: rgba( 0, 86, 132, 0.9 );
     617        position: fixed;
     618        z-index: 100050; /* above the editor toolbar */
     619}
     620
    615621.uploader-editor-content {
    616622        border: 1px dashed #fff;
     
    620626        right: 10px;
    621627        bottom: 10px;
    622         pointer-events: none;
    623628}
    624629
    625630#poststuff .uploader-editor-content h3 {
    626         margin: -0.5em 0 0;
    627631        position: absolute;
    628632        top: 50%;
     
    636640        padding: 0;
    637641        display: none;
    638         pointer-events: none;
    639642}
    640643
  • trunk/src/wp-includes/js/media-views.js

    r27454 r27464  
    34243424
    34253425                initialize: function() {
     3426                        this.initialized = false;
     3427
     3428                        // Bail if UA does not support drag'n'drop or File API.
     3429                        if ( ! this.browserSupport() ) {
     3430                                return this;
     3431                        }
     3432
    34263433                        this.$document = $(document);
    34273434                        this.dropzones = [];
     
    34353442                        this.$document.on( 'dragleave', _.bind( this.containerDragleave, this ) );
    34363443
     3444                        this.initialized = true;
    34373445                        return this;
    34383446                },
    34393447
    3440                 refresh: function() {
     3448                browserSupport: function() {
     3449                        var supports = false, div = document.createElement('div');
     3450
     3451                        supports = ( 'draggable' in div ) || ( 'ondragstart' in div && 'ondrop' in div );
     3452                        supports = supports && !! ( window.File && window.FileList && window.FileReader );
     3453                        return supports;
     3454                },
     3455
     3456                refresh: function( e ) {
    34413457                        var dropzone_id;
    34423458                        for ( dropzone_id in this.dropzones ) {
     
    34443460                                this.dropzones[ dropzone_id ].toggle( this.overContainer || this.overDropzone );
    34453461                        }
     3462
     3463                        if ( ! _.isUndefined( e ) ) {
     3464                                $( e.target ).closest( '.uploader-editor' ).toggleClass( 'droppable', this.overDropzone );
     3465                        }
     3466
    34463467                        return this;
    34473468                },
    34483469
    34493470                render: function() {
     3471                        if ( ! this.initialized ) {
     3472                                return this;
     3473                        }
     3474
    34503475                        media.View.prototype.render.apply( this, arguments );
    34513476                        $( '.wp-editor-wrap' ).each( _.bind( this.attach, this ) );
     
    35153540
    35163541                dropzoneDragover: function( e ) {
    3517                         $( e.target ).addClass( 'droppable' );
    35183542                        this.overDropzone = true;
    3519                         _.defer( _.bind( this.refresh, this ) );
     3543                        this.refresh( e );
    35203544                        return false;
    35213545                },
    35223546
    35233547                dropzoneDragleave: function( e ) {
    3524                         $( e.target ).removeClass( 'droppable' );
    35253548                        this.overDropzone = false;
    3526                         this.refresh();
     3549                        _.delay( _.bind( this.refresh, this, e ), 50 );
    35273550                }
    35283551        });
Note: See TracChangeset for help on using the changeset viewer.