mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +00:00
De-duplicate and fix updating of file link in media dialog
Bug: T198565 Change-Id: I7d06d3316b317fb85edb9461080f5f2e5cd439fe
This commit is contained in:
parent
dd794ddd40
commit
6bf9210abe
|
@ -897,18 +897,7 @@ ve.ui.MWMediaDialog.prototype.confirmSelectedImage = function () {
|
|||
},
|
||||
info
|
||||
);
|
||||
// Update filename
|
||||
this.filenameFieldset.setLabel(
|
||||
$( '<span>' ).append(
|
||||
document.createTextNode( this.imageModel.getFilename() + ' ' ),
|
||||
$( '<a>' )
|
||||
.addClass( 'visualeditor-dialog-media-content-description-link' )
|
||||
.attr( 'href', ve.resolveUrl( title, this.getFragment().getDocument().getHtmlDocument() ) )
|
||||
.attr( 'target', '_blank' )
|
||||
.attr( 'rel', 'noopener' )
|
||||
.text( ve.msg( 'visualeditor-dialog-media-content-description-link' ) )
|
||||
)
|
||||
);
|
||||
this.updateFilenameFieldset();
|
||||
}
|
||||
|
||||
// Cache
|
||||
|
@ -927,6 +916,23 @@ ve.ui.MWMediaDialog.prototype.confirmSelectedImage = function () {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the filename fieldset (link to media page)
|
||||
*/
|
||||
ve.ui.MWMediaDialog.prototype.updateFilenameFieldset = function () {
|
||||
this.filenameFieldset.setLabel(
|
||||
$( '<span>' ).append(
|
||||
document.createTextNode( this.imageModel.getFilename() + ' ' ),
|
||||
$( '<a>' )
|
||||
.addClass( 'visualeditor-dialog-media-content-description-link' )
|
||||
.attr( 'href', ve.resolveUrl( this.imageModel.getResourceName(), this.getFragment().getDocument().getHtmlDocument() ) )
|
||||
.attr( 'target', '_blank' )
|
||||
.attr( 'rel', 'noopener' )
|
||||
.text( ve.msg( 'visualeditor-dialog-media-content-description-link' ) )
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle image model alignment change
|
||||
*
|
||||
|
@ -1207,17 +1213,7 @@ ve.ui.MWMediaDialog.prototype.attachImageModel = function () {
|
|||
this.isSettingUpModel = true;
|
||||
|
||||
// Filename
|
||||
this.filenameFieldset.setLabel(
|
||||
$( '<span>' ).append(
|
||||
document.createTextNode( this.imageModel.getFilename() + ' ' ),
|
||||
$( '<a>' )
|
||||
.addClass( 'visualeditor-dialog-media-content-description-link' )
|
||||
.attr( 'href', ve.resolveUrl( this.imageModel.getResourceName(), this.getFragment().getDocument().getHtmlDocument() ) )
|
||||
.attr( 'target', '_blank' )
|
||||
.attr( 'rel', 'noopener' )
|
||||
.text( ve.msg( 'visualeditor-dialog-media-content-description-link' ) )
|
||||
)
|
||||
);
|
||||
this.updateFilenameFieldset();
|
||||
|
||||
// Size widget
|
||||
this.sizeErrorLabel.toggle( false );
|
||||
|
|
Loading…
Reference in a new issue