Make WordPress Core

Changeset 22945


Ignore:
Timestamp:
11/30/2012 06:01:47 AM (11 years ago)
Author:
ryan
Message:

Improve switching between browser and upload state.

Props koopersmith
fixes #22628

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r22923 r22945  
    727727}
    728728
    729 .attachments-browser .attachments {
     729.attachments-browser .attachments,
     730.attachments-browser .uploader-inline {
    730731    position: absolute;
    731732    top: 50px;
     
    932933}
    933934
    934 .region-content.uploader-inline {
     935.media-frame .uploader-inline {
    935936    margin: 20px;
    936937    padding: 20px;
     
    13741375
    13751376    .attachments-browser .attachments,
     1377    .attachments-browser .uploader-inline,
    13761378    .attachments-browser .media-toolbar {
    13771379        right: 180px;
  • trunk/wp-includes/js/media-views.js

    r22938 r22945  
    263263            toolbar:    'main-attachments',
    264264            sidebar:    'settings',
     265            content:    'browse',
    265266            searchable: true,
    266267            filterable: false,
     
    305306            selection.on( 'add remove reset', this.refreshSelection, this );
    306307
    307             this._updateEmpty();
    308             library.on( 'add remove reset', this._updateEmpty, this );
    309             this.on( 'change:empty', this.refresh, this );
    310308            this.refresh();
    311 
    312 
    313309            this.on( 'insert', this._insertDisplaySettings, this );
    314310        },
    315311
    316312        deactivate: function() {
    317             this.off( 'change:empty', this.refresh, this );
    318             this.get('library').off( 'add remove reset', this._updateEmpty, this );
    319 
    320313            // Unbind all event handlers that use this state as the context
    321314            // from the selection.
     
    335328        },
    336329
    337         content: function() {
    338             var frame = this.frame;
    339 
    340             if ( this.get('empty') ) {
    341                 // Attempt to fetch any Attachments we don't already have.
    342                 this.get('library').more();
    343 
    344                 // In the meantime, render an inline uploader.
    345                 frame.content.mode('upload');
    346             } else {
    347                 // Browse our library of attachments.
    348                 frame.content.mode('browse');
    349             }
    350         },
    351 
    352330        refresh: function() {
    353             this.frame.$el.toggleClass( 'hide-toolbar', this.get('empty') );
    354331            this.content();
    355332            this.refreshSelection();
     
    388365            setUserSetting( 'imgsize', display.size );
    389366            setUserSetting( 'urlbutton', display.link );
    390         },
    391 
    392         _updateEmpty: function() {
    393             var library = this.get('library'),
    394                 props = library.props;
    395 
    396             // If we're filtering the library, bail.
    397             if ( this.get('filterable') && ( props.get('type') || props.get('parent') ) )
    398                 return;
    399 
    400             this.set( 'empty', ! library.length && ! library.props.get('search') );
    401367        },
    402368
     
    525491            sortable:   true,
    526492            searchable: false,
    527             toolbar:    'gallery-edit'
     493            toolbar:    'gallery-edit',
     494            content:    'browse'
    528495        },
    529496
     
    13011268        browseContent: function() {
    13021269            var state = this.state();
     1270
     1271            this.$el.removeClass('hide-toolbar');
    13031272
    13041273            // Browse our library of attachments.
     
    30182987
    30192988            this.createToolbar();
    3020             this.createAttachments();
     2989            this.updateContent();
    30212990            this.createSidebar();
     2991
     2992            this.collection.on( 'add remove reset', this.updateContent, this );
    30222993        },
    30232994
     
    30673038        },
    30683039
     3040        updateContent: function() {
     3041            var view = this;
     3042
     3043            if( ! this.attachments )
     3044                this.createAttachments();
     3045
     3046            if ( ! this.collection.length ) {
     3047                this.collection.more().done( function() {
     3048                    if ( ! view.collection.length )
     3049                        view.createUploader();
     3050                });
     3051            }
     3052        },
     3053
     3054        createUploader: function() {
     3055            if ( this.attachments ) {
     3056                this.attachments.remove();
     3057                delete this.attachments;
     3058            }
     3059
     3060            this.uploader = new media.view.UploaderInline({
     3061                controller: this.controller
     3062            });
     3063
     3064            this.views.add( this.uploader );
     3065        },
     3066
    30693067        createAttachments: function() {
     3068            if ( this.uploader ) {
     3069                this.uploader.remove();
     3070                delete this.uploader;
     3071            }
     3072
    30703073            this.attachments = new media.view.Attachments({
    30713074                controller: this.controller,
Note: See TracChangeset for help on using the changeset viewer.