Make WordPress Core

Changeset 23028


Ignore:
Timestamp:
12/04/2012 05:45:24 PM (14 years ago)
Author:
markjaquith
Message:

Update toolbars for Embed screen. Fixes JS error. props koopersmith. fixes #22714

File:
1 edited

Legend:

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

    r23024 r23028  
    745745                        this.props = new Backbone.Model({ url: '' });
    746746                        this.props.on( 'change:url', this.debouncedScan, this );
     747                        this.props.on( 'change:url', this.refresh, this );
    747748                        this.on( 'scan', this.scanImage, this );
    748749                },
     
    775776                },
    776777
     778                refresh: function() {
     779                        this.frame.toolbar.get().refresh();
     780                },
     781
    777782                reset: function() {
    778783                        this.props = new Backbone.Model({ url: '' });
    779784
    780                         if ( this.id === this.frame.state().id )
    781                                 this.frame.toolbar.get().refresh();
     785                        if ( this.active )
     786                                this.refresh();
    782787                }
    783788        });
     
    22092214                                this.render();
    22102215
    2211                         selection.on( 'add remove reset', this.refresh, this );
    2212                         library.on( 'add remove reset', this.refresh, this );
     2216                        if ( selection )
     2217                                selection.on( 'add remove reset', this.refresh, this );
     2218                        if ( library )
     2219                                library.on( 'add remove reset', this.refresh, this );
    22132220                },
    22142221
    22152222                dispose: function() {
    2216                         this.selection.off( null, null, this );
    2217                         this.library.off( null, null, this );
     2223                        if ( this.selection )
     2224                                this.selection.off( null, null, this );
     2225                        if ( this.library )
     2226                                this.library.off( null, null, this );
    22182227                        return media.View.prototype.dispose.apply( this, arguments );
    22192228                },
     
    22792288                                        disabled = false;
    22802289
    2281                                 if ( requires.selection && ! selection.length )
     2290                                if ( requires.selection && selection && ! selection.length )
    22822291                                        disabled = true;
    2283                                 else if ( requires.library && ! library.length )
     2292                                else if ( requires.library && library && ! library.length )
    22842293                                        disabled = true;
    22852294
     
    23482357                initialize: function() {
    23492358                        _.defaults( this.options, {
    2350                                 text: l10n.insertIntoPost
     2359                                text: l10n.insertIntoPost,
     2360                                requires: false
    23512361                        });
    23522362
    23532363                        media.view.Toolbar.Select.prototype.initialize.apply( this, arguments );
    2354                         this.controller.state().props.on( 'change:url', this.refresh, this );
    2355                 },
    2356 
    2357                 dispose: function() {
    2358                         this.controller.state().props.off( 'change:url', this.refresh, this );
    2359                         media.view.Toolbar.Select.prototype.dispose.apply( this, arguments );
    23602364                },
    23612365
Note: See TracChangeset for help on using the changeset viewer.