Ticket #22714: 22714.embed.diff
| File 22714.embed.diff, 2.7 KB (added by , 13 years ago) |
|---|
-
wp-includes/js/media-views.js
744 744 this.debouncedScan = _.debounce( _.bind( this.scan, this ), this.sensitivity ); 745 745 this.props = new Backbone.Model({ url: '' }); 746 746 this.props.on( 'change:url', this.debouncedScan, this ); 747 this.props.on( 'change:url', this.refresh, this ); 747 748 this.on( 'scan', this.scanImage, this ); 748 749 }, 749 750 … … 774 775 image.src = url; 775 776 }, 776 777 778 refresh: function() { 779 this.frame.toolbar.get().refresh(); 780 }, 781 777 782 reset: function() { 778 783 this.props = new Backbone.Model({ url: '' }); 779 784 780 if ( this. id === this.frame.state().id)781 this. frame.toolbar.get().refresh();785 if ( this.active ) 786 this.refresh(); 782 787 } 783 788 }); 784 789 … … 2208 2213 if ( ! this.options.silent ) 2209 2214 this.render(); 2210 2215 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 ); 2213 2220 }, 2214 2221 2215 2222 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 ); 2218 2227 return media.View.prototype.dispose.apply( this, arguments ); 2219 2228 }, 2220 2229 … … 2278 2287 var requires = button.options.requires, 2279 2288 disabled = false; 2280 2289 2281 if ( requires.selection && ! selection.length )2290 if ( requires.selection && selection && ! selection.length ) 2282 2291 disabled = true; 2283 else if ( requires.library && ! library.length )2292 else if ( requires.library && library && ! library.length ) 2284 2293 disabled = true; 2285 2294 2286 2295 button.model.set( 'disabled', disabled ); … … 2347 2356 media.view.Toolbar.Embed = media.view.Toolbar.Select.extend({ 2348 2357 initialize: function() { 2349 2358 _.defaults( this.options, { 2350 text: l10n.insertIntoPost 2359 text: l10n.insertIntoPost, 2360 requires: false 2351 2361 }); 2352 2362 2353 2363 media.view.Toolbar.Select.prototype.initialize.apply( this, arguments ); 2354 this.controller.state().props.on( 'change:url', this.refresh, this );2355 2364 }, 2356 2365 2357 dispose: function() {2358 this.controller.state().props.off( 'change:url', this.refresh, this );2359 media.view.Toolbar.Select.prototype.dispose.apply( this, arguments );2360 },2361 2362 2366 refresh: function() { 2363 2367 var url = this.controller.state().props.get('url'); 2364 2368 this.get('select').model.set( 'disabled', ! url || /^https?:\/\/$/.test(url) );