Make WordPress Core

Changeset 22790


Ignore:
Timestamp:
11/21/2012 08:27:49 PM (12 years ago)
Author:
koopersmith
Message:

Media: Make the window-wide uploader a subview of the frame view.

Allows the uploader to leverage the ready event to know when it has been attached to the page.

see #21390.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r22787 r22790  
    10501050                    }
    10511051                });
     1052                this.views.set( '.media-frame-uploader', this.uploader );
    10521053            }
    10531054
     
    10601061
    10611062            media.view.Frame.prototype.render.apply( this, arguments );
    1062 
    1063             // Render the window uploader if it exists.
    1064             if ( this.uploader )
    1065                 this.uploader.render().$el.appendTo( this.$el );
    1066 
    10671063            return this;
    10681064        },
     
    17341730            });
    17351731
    1736             if ( uploader.dropzone ) {
    1737                 // Ensure the dropzone is a jQuery collection.
    1738                 if ( ! (uploader.dropzone instanceof $) )
    1739                     uploader.dropzone = $( uploader.dropzone );
    1740 
    1741                 // Attempt to initialize the uploader whenever the dropzone is hovered.
    1742                 uploader.dropzone.one( 'mouseenter dragenter', _.bind( this.maybeInitUploader, this ) );
    1743             }
    1744         },
    1745 
    1746         render: function() {
    1747             this.maybeInitUploader();
    1748             this.$el.html( this.template( this.options ) );
    1749             return this;
     1732            // Ensure the dropzone is a jQuery collection.
     1733            if ( uploader.dropzone && ! (uploader.dropzone instanceof $) )
     1734                uploader.dropzone = $( uploader.dropzone );
    17501735        },
    17511736
     
    17551740        },
    17561741
    1757         maybeInitUploader: function() {
    1758             var $id, dropzone;
    1759 
    1760             // If the uploader already exists or the body isn't in the DOM, bail.
    1761             if ( this.uploader || ! this.$el.closest('body').length )
     1742        ready: function() {
     1743            var postId = media.view.settings.postId,
     1744                dropzone;
     1745
     1746            // If the uploader already exists, bail.
     1747            if ( this.uploader )
    17621748                return;
    17631749
    1764             $id = $('#post_ID');
    1765             if ( $id.length )
    1766                 this.options.uploader.params.post_id = $id.val();
     1750            if ( postId )
     1751                this.options.uploader.params.post_id = postId;
    17671752
    17681753            this.uploader = new wp.Uploader( this.options.uploader );
  • trunk/wp-includes/media.php

    r22783 r22790  
    14071407        <div class="media-frame-sidebar"></div>
    14081408        <div class="media-frame-toolbar"></div>
     1409        <div class="media-frame-uploader"></div>
    14091410    </script>
    14101411
Note: See TracChangeset for help on using the changeset viewer.