mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
Merge "Advanced Settings: improve displaytitle field"
This commit is contained in:
commit
7b46d105b1
|
@ -84,26 +84,18 @@ ve.ui.MWAdvancedSettingsPage = function VeUiMWAdvancedSettingsPage() {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.displayTitleTouched = false;
|
this.displayTitleTouched = false;
|
||||||
this.enableDisplayTitleCheckbox = new OO.ui.CheckboxInputWidget();
|
this.displayTitleInput = new OO.ui.TextInputWidget();
|
||||||
this.enableDisplayTitleCheckbox.connect( this, { change: 'onEnableDisplayTitleCheckboxChange' } );
|
|
||||||
this.enableDisplayTitleField = new OO.ui.FieldLayout(
|
|
||||||
this.enableDisplayTitleCheckbox,
|
|
||||||
{
|
|
||||||
align: 'inline',
|
|
||||||
label: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle-enable' ),
|
|
||||||
help: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle-help' )
|
|
||||||
}
|
|
||||||
);
|
|
||||||
this.displayTitleInput = new OO.ui.TextInputWidget( {
|
|
||||||
placeholder: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle' )
|
|
||||||
} );
|
|
||||||
this.displayTitleInput.connect( this, { change: 'onDisplayTitleInputChange' } );
|
this.displayTitleInput.connect( this, { change: 'onDisplayTitleInputChange' } );
|
||||||
this.displayTitleField = new OO.ui.FieldLayout(
|
this.displayTitleField = new OO.ui.FieldLayout(
|
||||||
this.displayTitleInput,
|
this.displayTitleInput,
|
||||||
{ align: 'inline' }
|
{
|
||||||
|
align: 'top',
|
||||||
|
label: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle' ),
|
||||||
|
help: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle-help' )
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.advancedSettingsFieldset.addItems( [ this.indexing, this.newEditSectionLink, this.enableDisplayTitleField, this.displayTitleField ] );
|
this.advancedSettingsFieldset.addItems( [ this.indexing, this.newEditSectionLink, this.displayTitleField ] );
|
||||||
|
|
||||||
this.metaItemCheckboxes = [];
|
this.metaItemCheckboxes = [];
|
||||||
if ( mw.config.get( 'wgVariantArticlePath' ) ) {
|
if ( mw.config.get( 'wgVariantArticlePath' ) ) {
|
||||||
|
@ -142,23 +134,9 @@ OO.inheritClass( ve.ui.MWAdvancedSettingsPage, OO.ui.PageLayout );
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle redirect state change events.
|
* Handle display title input change events.
|
||||||
*
|
*
|
||||||
* @param {boolean} value Whether a redirect is to be set for this page
|
* @param {string} value Current value of input widget
|
||||||
*/
|
|
||||||
ve.ui.MWAdvancedSettingsPage.prototype.onEnableDisplayTitleCheckboxChange = function ( value ) {
|
|
||||||
this.displayTitleInput.setDisabled( !value );
|
|
||||||
if ( !value ) {
|
|
||||||
this.displayTitleInput.setValue( '' );
|
|
||||||
this.enableDisplayTitleCheckbox.setSelected( false );
|
|
||||||
}
|
|
||||||
this.displayTitleTouched = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle redirect state change events.
|
|
||||||
*
|
|
||||||
* @param {boolean} value Whether a redirect is to be set for this page
|
|
||||||
*/
|
*/
|
||||||
ve.ui.MWAdvancedSettingsPage.prototype.onDisplayTitleInputChange = function () {
|
ve.ui.MWAdvancedSettingsPage.prototype.onDisplayTitleInputChange = function () {
|
||||||
this.displayTitleTouched = true;
|
this.displayTitleTouched = true;
|
||||||
|
@ -237,9 +215,10 @@ ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( metaList ) {
|
||||||
// Display title items
|
// Display title items
|
||||||
displayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
|
displayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
|
||||||
displayTitle = displayTitleItem && displayTitleItem.getAttribute( 'content' ) || '';
|
displayTitle = displayTitleItem && displayTitleItem.getAttribute( 'content' ) || '';
|
||||||
this.enableDisplayTitleCheckbox.setSelected( !!displayTitleItem );
|
if ( !displayTitle ) {
|
||||||
|
displayTitle = mw.Title.newFromText( mw.config.get( 'wgPageName' ) ).getPrefixedText();
|
||||||
|
}
|
||||||
this.displayTitleInput.setValue( displayTitle );
|
this.displayTitleInput.setValue( displayTitle );
|
||||||
this.displayTitleInput.setDisabled( !displayTitle );
|
|
||||||
this.displayTitleTouched = false;
|
this.displayTitleTouched = false;
|
||||||
|
|
||||||
// Simple checkbox items
|
// Simple checkbox items
|
||||||
|
@ -317,6 +296,9 @@ ve.ui.MWAdvancedSettingsPage.prototype.teardown = function ( data ) {
|
||||||
// Display title items
|
// Display title items
|
||||||
currentDisplayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
|
currentDisplayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
|
||||||
newDisplayTitle = this.displayTitleInput.getValue();
|
newDisplayTitle = this.displayTitleInput.getValue();
|
||||||
|
if ( newDisplayTitle === mw.Title.newFromText( mw.config.get( 'wgPageName' ) ).getPrefixedText() ) {
|
||||||
|
newDisplayTitle = '';
|
||||||
|
}
|
||||||
newDisplayTitleItemData = { type: 'mwDisplayTitle', attributes: { content: newDisplayTitle } };
|
newDisplayTitleItemData = { type: 'mwDisplayTitle', attributes: { content: newDisplayTitle } };
|
||||||
|
|
||||||
// Alter the display title flag iff it's been touched & is actually different
|
// Alter the display title flag iff it's been touched & is actually different
|
||||||
|
|
Loading…
Reference in a new issue