Ticket #22662: 22662.diff
| File 22662.diff, 1.5 KB (added by , 13 years ago) |
|---|
-
wp-includes/js/media-views.js
3411 3411 }); 3412 3412 3413 3413 media.view.Settings.prototype.initialize.apply( this, arguments ); 3414 this.model.on( 'change:link', this.update CustomLink, this );3414 this.model.on( 'change:link', this.updateLinkTo, this ); 3415 3415 3416 3416 if ( attachment ) 3417 3417 attachment.on( 'change:uploading', this.render, this ); … … 3435 3435 } 3436 3436 3437 3437 media.view.Settings.prototype.render.call( this ); 3438 this.update CustomLink();3438 this.updateLinkTo(); 3439 3439 return this; 3440 3440 }, 3441 3441 3442 updateCustomLink: function() { 3443 var isCustom = 'custom' === this.model.get('link'), 3444 $input = this.$('.link-to-custom'); 3442 updateLinkTo: function() { 3443 var linkTo = this.model.get('link'), 3444 $input = this.$('.link-to-custom'), 3445 attachment = this.options.attachment; 3445 3446 3446 if ( ! isCustom) {3447 if ( 'none' === linkTo ) { 3447 3448 $input.hide(); 3448 3449 return; 3449 3450 } 3450 3451 3451 3452 $input.show(); 3452 if ( ! this.model.get('linkUrl') ) 3453 3454 if ( 'post' == linkTo ) { 3455 $input.val( attachment.get('link') ); 3456 } else if ( 'file' == linkTo ) { 3457 $input.val( attachment.get('url') ); 3458 } else if ( ! this.model.get('linkUrl') ) { 3453 3459 $input.val('http://'); 3460 } 3454 3461 3462 $input.prop('readonly', 'custom' !== linkTo); 3463 3455 3464 // If the input is visible, focus and select its contents. 3456 3465 if ( $input.is(':visible') ) 3457 3466 $input.focus()[0].select();