mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
When fetching in media/views/embed/link.js, call abort() on any existing XHRs.
Use `$.ajax` instead of `wp.ajax.send()` to allow this. Pass `this` as `context` to the options to remove the need to bind callbacks. Fixes #32035. git-svn-id: https://develop.svn.wordpress.org/trunk@32460 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4561,28 +4561,39 @@ EmbedLink = wp.media.view.Settings.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this.dfd && 'pending' === this.dfd.state() ) {
|
||||
this.dfd.abort();
|
||||
}
|
||||
|
||||
embed = new wp.shortcode({
|
||||
tag: 'embed',
|
||||
attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ),
|
||||
content: this.model.get('url')
|
||||
});
|
||||
|
||||
wp.ajax.send( 'parse-embed', {
|
||||
data : {
|
||||
this.dfd = $.ajax({
|
||||
type: 'POST',
|
||||
url: wp.ajax.settings.url,
|
||||
context: this,
|
||||
data: {
|
||||
action: 'parse-embed',
|
||||
post_ID: wp.media.view.settings.post.id,
|
||||
shortcode: embed.string()
|
||||
}
|
||||
} )
|
||||
.done( _.bind( this.renderoEmbed, this ) )
|
||||
.fail( _.bind( this.renderFail, this ) );
|
||||
})
|
||||
.done( this.renderoEmbed )
|
||||
.fail( this.renderFail );
|
||||
},
|
||||
|
||||
renderFail: function () {
|
||||
renderFail: function ( response, status ) {
|
||||
if ( 'abort' === status ) {
|
||||
return;
|
||||
}
|
||||
this.$( '.link-text' ).show();
|
||||
},
|
||||
|
||||
renderoEmbed: function( response ) {
|
||||
var html = ( response && response.body ) || '';
|
||||
var html = ( response && response.data && response.data.body ) || '';
|
||||
|
||||
if ( html ) {
|
||||
this.$('.embed-container').show().find('.embed-preview').html( html );
|
||||
|
||||
@@ -45,28 +45,39 @@ EmbedLink = wp.media.view.Settings.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this.dfd && 'pending' === this.dfd.state() ) {
|
||||
this.dfd.abort();
|
||||
}
|
||||
|
||||
embed = new wp.shortcode({
|
||||
tag: 'embed',
|
||||
attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ),
|
||||
content: this.model.get('url')
|
||||
});
|
||||
|
||||
wp.ajax.send( 'parse-embed', {
|
||||
data : {
|
||||
this.dfd = $.ajax({
|
||||
type: 'POST',
|
||||
url: wp.ajax.settings.url,
|
||||
context: this,
|
||||
data: {
|
||||
action: 'parse-embed',
|
||||
post_ID: wp.media.view.settings.post.id,
|
||||
shortcode: embed.string()
|
||||
}
|
||||
} )
|
||||
.done( _.bind( this.renderoEmbed, this ) )
|
||||
.fail( _.bind( this.renderFail, this ) );
|
||||
})
|
||||
.done( this.renderoEmbed )
|
||||
.fail( this.renderFail );
|
||||
},
|
||||
|
||||
renderFail: function () {
|
||||
renderFail: function ( response, status ) {
|
||||
if ( 'abort' === status ) {
|
||||
return;
|
||||
}
|
||||
this.$( '.link-text' ).show();
|
||||
},
|
||||
|
||||
renderoEmbed: function( response ) {
|
||||
var html = ( response && response.body ) || '';
|
||||
var html = ( response && response.data && response.data.body ) || '';
|
||||
|
||||
if ( html ) {
|
||||
this.$('.embed-container').show().find('.embed-preview').html( html );
|
||||
|
||||
Reference in New Issue
Block a user