From 86203fa6bf866ce1443727d77175abbc96264601 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 5 Dec 2012 04:43:51 +0000 Subject: [PATCH] Clear the From URL view in the media modal after inserting an image. Improve button enable checks. Props koopersmith fixes #22740 git-svn-id: https://develop.svn.wordpress.org/trunk@23065 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-views.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 5760fe827d..de7f745154 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -786,7 +786,7 @@ }, reset: function() { - this.props = new Backbone.Model({ url: '' }); + this.props.clear().set({ url: '' }); if ( this.active ) this.refresh(); @@ -2422,7 +2422,7 @@ refresh: function() { var url = this.controller.state().props.get('url'); - this.get('select').model.set( 'disabled', ! url || /^https?:\/\/$/.test(url) ); + this.get('select').model.set( 'disabled', ! url || url === 'http://' ); media.view.Toolbar.Select.prototype.refresh.apply( this, arguments ); } @@ -3772,11 +3772,14 @@ this.model.on( 'change', this.updateChanges, this ); }, - render: function() { - this.$el.html( this.template( _.defaults({ + prepare: function() { + return _.defaults({ model: this.model.toJSON() - }, this.options ) ) ); + }, this.options ); + }, + render: function() { + media.View.prototype.render.apply( this, arguments ); // Select the correct values. _( this.model.attributes ).chain().keys().each( this.update, this ); return this; @@ -4026,23 +4029,16 @@ model: this.model.props }).render(); - this._settings = new media.View(); + this.views.set([ this.url ]); this.refresh(); this.model.on( 'change:type', this.refresh, this ); }, - render: function() { - this.$el.html([ this.url.el, this._settings.el ]); - this.url.focus(); - this.views.render(); - return this; - }, - settings: function( view ) { - view.render(); - this._settings.$el.replaceWith( view.$el ); - this._settings.remove(); + if ( this._settings ) + this._settings.remove(); this._settings = view; + this.views.add( view ); }, refresh: function() { @@ -4096,9 +4092,14 @@ return; this.input.value = this.model.get('url') || 'http://'; + media.View.prototype.render.apply( this, arguments ); return this; }, + ready: function() { + this.focus(); + }, + url: function( event ) { this.model.set( 'url', event.target.value ); },