2013-11-15 20:36:53 +00:00
|
|
|
|
/*!
|
|
|
|
|
* VisualEditor user interface MWAdvancedSettingsPage class.
|
|
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
2013-11-15 20:36:53 +00:00
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* MediaWiki meta dialog advanced settings page.
|
|
|
|
|
*
|
|
|
|
|
* @class
|
|
|
|
|
* @extends OO.ui.PageLayout
|
|
|
|
|
*
|
|
|
|
|
* @constructor
|
|
|
|
|
* @param {string} name Unique symbolic name of page
|
|
|
|
|
* @param {Object} [config] Configuration options
|
2017-02-16 01:56:03 +00:00
|
|
|
|
* @cfg {jQuery} [$overlay] Overlay to render dropdowns in
|
2013-11-15 20:36:53 +00:00
|
|
|
|
*/
|
2017-02-16 01:56:03 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage = function VeUiMWAdvancedSettingsPage( name, config ) {
|
2014-04-15 14:09:48 +00:00
|
|
|
|
var advancedSettingsPage = this;
|
|
|
|
|
|
2013-11-15 20:36:53 +00:00
|
|
|
|
// Parent constructor
|
2016-08-22 21:44:59 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage.super.apply( this, arguments );
|
2013-11-15 20:36:53 +00:00
|
|
|
|
|
|
|
|
|
// Properties
|
2014-04-04 17:42:13 +00:00
|
|
|
|
this.metaList = null;
|
2013-11-15 20:36:53 +00:00
|
|
|
|
this.indexingOptionTouched = false;
|
2013-11-15 20:50:15 +00:00
|
|
|
|
this.newSectionEditLinkOptionTouched = false;
|
|
|
|
|
|
2013-11-15 20:36:53 +00:00
|
|
|
|
this.advancedSettingsFieldset = new OO.ui.FieldsetLayout( {
|
2014-08-22 20:50:48 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-advancedsettings-label' ),
|
2018-09-08 02:46:12 +00:00
|
|
|
|
icon: 'settings'
|
2013-11-15 20:36:53 +00:00
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
// Initialization
|
|
|
|
|
|
|
|
|
|
// Indexing items
|
2014-02-20 03:32:50 +00:00
|
|
|
|
this.indexing = new OO.ui.FieldLayout(
|
2015-04-09 23:47:15 +00:00
|
|
|
|
new OO.ui.ButtonSelectWidget()
|
2014-02-20 03:32:50 +00:00
|
|
|
|
.addItems( [
|
2014-11-22 01:40:00 +00:00
|
|
|
|
new OO.ui.ButtonOptionWidget( {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
data: 'mw:PageProp/index',
|
2014-11-22 01:40:00 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-index-force' )
|
|
|
|
|
} ),
|
|
|
|
|
new OO.ui.ButtonOptionWidget( {
|
|
|
|
|
data: 'default',
|
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-index-default' )
|
|
|
|
|
} ),
|
|
|
|
|
new OO.ui.ButtonOptionWidget( {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
data: 'mw:PageProp/noindex',
|
2014-11-22 01:40:00 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-index-disable' )
|
|
|
|
|
} )
|
2014-02-20 03:32:50 +00:00
|
|
|
|
] )
|
2014-08-22 20:50:48 +00:00
|
|
|
|
.connect( this, { select: 'onIndexingOptionChange' } ),
|
2014-02-20 03:32:50 +00:00
|
|
|
|
{
|
2017-02-16 01:56:03 +00:00
|
|
|
|
$overlay: config.$overlay,
|
2014-08-22 20:50:48 +00:00
|
|
|
|
align: 'top',
|
2014-09-15 01:18:03 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-index-label' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-index-help' )
|
2014-02-20 03:32:50 +00:00
|
|
|
|
}
|
2013-11-15 20:36:53 +00:00
|
|
|
|
);
|
|
|
|
|
|
2013-11-15 20:50:15 +00:00
|
|
|
|
// New edit section link items
|
2014-02-20 03:32:50 +00:00
|
|
|
|
this.newEditSectionLink = new OO.ui.FieldLayout(
|
2015-04-09 23:47:15 +00:00
|
|
|
|
new OO.ui.ButtonSelectWidget()
|
2014-02-20 03:32:50 +00:00
|
|
|
|
.addItems( [
|
2014-11-22 01:40:00 +00:00
|
|
|
|
new OO.ui.ButtonOptionWidget( {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
data: 'mw:PageProp/newsectionlink',
|
2014-11-22 01:40:00 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-newsectioneditlink-force' )
|
|
|
|
|
} ),
|
|
|
|
|
new OO.ui.ButtonOptionWidget( {
|
|
|
|
|
data: 'default',
|
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-newsectioneditlink-default' )
|
|
|
|
|
} ),
|
|
|
|
|
new OO.ui.ButtonOptionWidget( {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
data: 'mw:PageProp/nonewsectionlink',
|
2014-11-22 01:40:00 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-newsectioneditlink-disable' )
|
|
|
|
|
} )
|
2014-02-20 03:32:50 +00:00
|
|
|
|
] )
|
2014-08-22 20:50:48 +00:00
|
|
|
|
.connect( this, { select: 'onNewSectionEditLinkOptionChange' } ),
|
2014-02-20 03:32:50 +00:00
|
|
|
|
{
|
2017-02-16 01:56:03 +00:00
|
|
|
|
$overlay: config.$overlay,
|
2014-08-22 20:50:48 +00:00
|
|
|
|
align: 'top',
|
2014-09-15 01:18:03 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-newsectioneditlink-label' ),
|
2019-02-20 20:23:43 +00:00
|
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
2014-11-26 21:18:34 +00:00
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-newsectioneditlink-help', $( '#ca-edit' ).text() )
|
2014-02-20 03:32:50 +00:00
|
|
|
|
}
|
2013-11-15 20:50:15 +00:00
|
|
|
|
);
|
|
|
|
|
|
2014-04-22 21:07:13 +00:00
|
|
|
|
this.displayTitleTouched = false;
|
2017-01-25 17:21:09 +00:00
|
|
|
|
this.displayTitleInput = new OO.ui.TextInputWidget();
|
2014-08-22 20:50:48 +00:00
|
|
|
|
this.displayTitleInput.connect( this, { change: 'onDisplayTitleInputChange' } );
|
2014-04-22 21:07:13 +00:00
|
|
|
|
this.displayTitleField = new OO.ui.FieldLayout(
|
|
|
|
|
this.displayTitleInput,
|
2017-01-25 17:21:09 +00:00
|
|
|
|
{
|
2017-02-16 01:56:03 +00:00
|
|
|
|
$overlay: config.$overlay,
|
2017-01-25 17:21:09 +00:00
|
|
|
|
align: 'top',
|
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle-help' )
|
|
|
|
|
}
|
2014-04-22 21:07:13 +00:00
|
|
|
|
);
|
|
|
|
|
|
2017-01-25 17:21:09 +00:00
|
|
|
|
this.advancedSettingsFieldset.addItems( [ this.indexing, this.newEditSectionLink, this.displayTitleField ] );
|
2014-04-22 21:07:13 +00:00
|
|
|
|
|
2014-04-15 14:09:48 +00:00
|
|
|
|
this.metaItemCheckboxes = [];
|
|
|
|
|
if ( mw.config.get( 'wgVariantArticlePath' ) ) {
|
|
|
|
|
this.metaItemCheckboxes.push(
|
|
|
|
|
{
|
|
|
|
|
metaName: 'mwNoContentConvert',
|
2014-09-15 01:18:03 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-nocontentconvert-label' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-nocontentconvert-help' )
|
2014-04-15 14:09:48 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
metaName: 'mwNoTitleConvert',
|
2014-09-15 01:18:03 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-notitleconvert-label' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-notitleconvert-help' )
|
2014-04-15 14:09:48 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-25 11:47:28 +00:00
|
|
|
|
this.metaItemCheckboxes.forEach( function ( metaItemCheckbox ) {
|
|
|
|
|
metaItemCheckbox.fieldLayout = new OO.ui.FieldLayout(
|
2015-04-09 23:47:15 +00:00
|
|
|
|
new OO.ui.CheckboxInputWidget(),
|
2014-04-15 14:09:48 +00:00
|
|
|
|
{
|
2017-02-16 01:56:03 +00:00
|
|
|
|
$overlay: config.$overlay,
|
2014-08-22 20:50:48 +00:00
|
|
|
|
align: 'inline',
|
2019-02-25 11:47:28 +00:00
|
|
|
|
label: metaItemCheckbox.label,
|
|
|
|
|
help: metaItemCheckbox.help
|
2014-04-15 14:09:48 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
2019-02-25 11:47:28 +00:00
|
|
|
|
advancedSettingsPage.advancedSettingsFieldset.addItems( [ metaItemCheckbox.fieldLayout ] );
|
2014-04-15 14:09:48 +00:00
|
|
|
|
} );
|
|
|
|
|
|
2013-11-15 20:36:53 +00:00
|
|
|
|
this.$element.append( this.advancedSettingsFieldset.$element );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWAdvancedSettingsPage, OO.ui.PageLayout );
|
|
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
2014-04-22 21:07:13 +00:00
|
|
|
|
/**
|
2017-01-25 17:21:09 +00:00
|
|
|
|
* Handle display title input change events.
|
2014-04-22 21:07:13 +00:00
|
|
|
|
*
|
2017-01-25 17:21:09 +00:00
|
|
|
|
* @param {string} value Current value of input widget
|
2014-04-22 21:07:13 +00:00
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.onDisplayTitleInputChange = function () {
|
|
|
|
|
this.displayTitleTouched = true;
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-15 20:36:53 +00:00
|
|
|
|
/**
|
|
|
|
|
* @inheritdoc
|
|
|
|
|
*/
|
2021-09-15 10:10:56 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.setupOutlineItem = function () {
|
|
|
|
|
this.outlineItem
|
|
|
|
|
.setIcon( 'settings' )
|
|
|
|
|
.setLabel( ve.msg( 'visualeditor-dialog-meta-advancedsettings-section' ) );
|
2013-11-15 20:36:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Indexing option methods */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle indexing option state change events.
|
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.onIndexingOptionChange = function () {
|
|
|
|
|
this.indexingOptionTouched = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2014-04-15 14:09:48 +00:00
|
|
|
|
* Get the first meta item of a given name
|
2013-11-15 20:36:53 +00:00
|
|
|
|
*
|
2014-04-15 14:09:48 +00:00
|
|
|
|
* @param {string} name Name of the meta item
|
2015-08-19 18:09:34 +00:00
|
|
|
|
* @return {Object|null} Meta item, if any
|
2013-11-15 20:36:53 +00:00
|
|
|
|
*/
|
2014-04-15 14:09:48 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.getMetaItem = function ( name ) {
|
2015-08-19 17:33:02 +00:00
|
|
|
|
return this.metaList.getItemsInGroup( name )[ 0 ] || null;
|
2013-11-15 20:36:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
2013-11-15 20:50:15 +00:00
|
|
|
|
/* New edit section link option methods */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle new edit section link change events.
|
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.onNewSectionEditLinkOptionChange = function () {
|
|
|
|
|
this.newSectionEditLinkOptionTouched = true;
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-15 20:36:53 +00:00
|
|
|
|
/**
|
|
|
|
|
* Setup settings page.
|
|
|
|
|
*
|
2014-04-04 17:42:13 +00:00
|
|
|
|
* @param {ve.dm.MetaList} metaList Meta list
|
2021-09-11 08:05:31 +00:00
|
|
|
|
* @param {Object} config
|
2019-02-25 12:04:03 +00:00
|
|
|
|
* @param {Object} [config.data] Dialog setup data
|
2022-02-14 15:18:57 +00:00
|
|
|
|
* @param {boolean} [config.isReadOnly=false] Dialog is in read-only mode
|
2018-10-30 18:53:43 +00:00
|
|
|
|
* @return {jQuery.Promise}
|
2013-11-15 20:36:53 +00:00
|
|
|
|
*/
|
2019-02-25 12:04:03 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( metaList, config ) {
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var advancedSettingsPage = this;
|
2013-11-15 20:36:53 +00:00
|
|
|
|
|
2015-08-19 18:05:01 +00:00
|
|
|
|
this.metaList = metaList;
|
|
|
|
|
|
2013-11-15 20:36:53 +00:00
|
|
|
|
// Indexing items
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var indexingField = this.indexing.getField();
|
|
|
|
|
var indexingOption = this.getMetaItem( 'mwIndex' );
|
|
|
|
|
var indexingType = indexingOption && indexingOption.getAttribute( 'property' ) || 'default';
|
2019-02-25 12:04:03 +00:00
|
|
|
|
indexingField
|
|
|
|
|
.selectItemByData( indexingType )
|
|
|
|
|
.setDisabled( config.isReadOnly );
|
2013-11-15 20:36:53 +00:00
|
|
|
|
this.indexingOptionTouched = false;
|
2013-11-15 20:50:15 +00:00
|
|
|
|
|
|
|
|
|
// New section edit link items
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var newSectionEditField = this.newEditSectionLink.getField();
|
|
|
|
|
var newSectionEditLinkOption = this.getMetaItem( 'mwNewSectionEdit' );
|
|
|
|
|
var newSectionEditLinkType = newSectionEditLinkOption && newSectionEditLinkOption.getAttribute( 'property' ) || 'default';
|
2019-02-25 12:04:03 +00:00
|
|
|
|
newSectionEditField
|
|
|
|
|
.selectItemByData( newSectionEditLinkType )
|
|
|
|
|
.setDisabled( config.isReadOnly );
|
2013-11-15 20:50:15 +00:00
|
|
|
|
this.newSectionEditLinkOptionTouched = false;
|
2014-04-15 14:09:48 +00:00
|
|
|
|
|
2015-08-19 18:05:01 +00:00
|
|
|
|
// Display title items
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var displayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
|
|
|
|
|
var displayTitle = displayTitleItem && displayTitleItem.getAttribute( 'content' ) || '';
|
2017-01-25 17:21:09 +00:00
|
|
|
|
if ( !displayTitle ) {
|
2018-05-04 13:30:10 +00:00
|
|
|
|
displayTitle = mw.Title.newFromText( ve.init.target.getPageName() ).getPrefixedText();
|
2017-01-25 17:21:09 +00:00
|
|
|
|
}
|
2019-02-25 12:04:03 +00:00
|
|
|
|
this.displayTitleInput
|
|
|
|
|
.setValue( displayTitle )
|
|
|
|
|
.setReadOnly( config.isReadOnly );
|
2014-04-22 21:07:13 +00:00
|
|
|
|
this.displayTitleTouched = false;
|
|
|
|
|
|
2014-04-15 14:09:48 +00:00
|
|
|
|
// Simple checkbox items
|
2019-02-25 11:47:28 +00:00
|
|
|
|
this.metaItemCheckboxes.forEach( function ( metaItemCheckbox ) {
|
|
|
|
|
var isSelected = !!advancedSettingsPage.getMetaItem( metaItemCheckbox.metaName );
|
2019-02-25 12:04:03 +00:00
|
|
|
|
metaItemCheckbox.fieldLayout.getField()
|
|
|
|
|
.setSelected( isSelected )
|
|
|
|
|
.setDisabled( config.isReadOnly );
|
2014-04-15 14:09:48 +00:00
|
|
|
|
} );
|
2018-10-30 18:53:43 +00:00
|
|
|
|
|
2019-11-02 05:06:28 +00:00
|
|
|
|
return ve.createDeferred().resolve().promise();
|
2013-11-15 20:36:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tear down settings page.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} [data] Dialog tear down data
|
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.teardown = function ( data ) {
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var advancedSettingsPage = this;
|
2015-08-19 18:05:01 +00:00
|
|
|
|
|
2013-11-15 20:36:53 +00:00
|
|
|
|
// Data initialization
|
|
|
|
|
data = data || {};
|
2019-02-19 17:08:38 +00:00
|
|
|
|
if ( data.action !== 'done' ) {
|
2015-07-30 23:21:52 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2013-11-15 20:36:53 +00:00
|
|
|
|
|
2015-08-19 18:05:01 +00:00
|
|
|
|
// Indexing items
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var currentIndexingItem = this.getMetaItem( 'mwIndex' );
|
|
|
|
|
var newIndexingData = this.indexing.getField().findSelectedItem();
|
2013-11-15 20:36:53 +00:00
|
|
|
|
|
|
|
|
|
// Alter the indexing option flag iff it's been touched & is actually different
|
|
|
|
|
if ( this.indexingOptionTouched ) {
|
|
|
|
|
if ( newIndexingData.data === 'default' ) {
|
|
|
|
|
if ( currentIndexingItem ) {
|
|
|
|
|
currentIndexingItem.remove();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var newIndexingItem = { type: 'mwIndex', attributes: { property: newIndexingData.data } };
|
2017-04-07 00:55:45 +00:00
|
|
|
|
|
2013-11-15 20:36:53 +00:00
|
|
|
|
if ( !currentIndexingItem ) {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
this.metaList.insertMeta( newIndexingItem );
|
|
|
|
|
} else if ( currentIndexingItem.getAttribute( 'property' ) !== newIndexingData.data ) {
|
2013-11-15 20:36:53 +00:00
|
|
|
|
currentIndexingItem.replaceWith(
|
2017-04-07 00:55:45 +00:00
|
|
|
|
ve.extendObject( true, {}, currentIndexingItem.getElement(), newIndexingItem )
|
2013-11-15 20:36:53 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-19 18:05:01 +00:00
|
|
|
|
// New section edit link items
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var currentNewSectionEditLinkItem = this.getMetaItem( 'mwNewSectionEdit' );
|
|
|
|
|
var newNewSectionEditLinkData = this.newEditSectionLink.getField().findSelectedItem();
|
2015-08-19 18:05:01 +00:00
|
|
|
|
|
2013-11-15 20:50:15 +00:00
|
|
|
|
// Alter the new section edit option flag iff it's been touched & is actually different
|
|
|
|
|
if ( this.newSectionEditLinkOptionTouched ) {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
if ( newNewSectionEditLinkData.data === 'default' ) {
|
2013-11-15 20:50:15 +00:00
|
|
|
|
if ( currentNewSectionEditLinkItem ) {
|
|
|
|
|
currentNewSectionEditLinkItem.remove();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var newNewSectionEditLinkItem = { type: 'mwNewSectionEdit', attributes: { property: newNewSectionEditLinkData.data } };
|
2017-04-07 00:55:45 +00:00
|
|
|
|
|
2013-11-15 20:50:15 +00:00
|
|
|
|
if ( !currentNewSectionEditLinkItem ) {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
this.metaList.insertMeta( newNewSectionEditLinkItem );
|
|
|
|
|
} else if ( currentNewSectionEditLinkItem.getAttribute( 'property' ) !== newNewSectionEditLinkData.data ) {
|
2013-11-15 20:50:15 +00:00
|
|
|
|
currentNewSectionEditLinkItem.replaceWith(
|
2017-04-07 00:55:45 +00:00
|
|
|
|
ve.extendObject( true, {}, currentNewSectionEditLinkItem.getElement(), newNewSectionEditLinkItem )
|
2013-11-15 20:50:15 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-04 17:42:13 +00:00
|
|
|
|
|
2015-08-19 18:05:01 +00:00
|
|
|
|
// Display title items
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var currentDisplayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
|
|
|
|
|
var newDisplayTitle = this.displayTitleInput.getValue();
|
2018-05-04 13:30:10 +00:00
|
|
|
|
if ( newDisplayTitle === mw.Title.newFromText( ve.init.target.getPageName() ).getPrefixedText() ) {
|
2017-01-25 17:21:09 +00:00
|
|
|
|
newDisplayTitle = '';
|
|
|
|
|
}
|
2022-02-21 18:07:07 +00:00
|
|
|
|
var newDisplayTitleItem = { type: 'mwDisplayTitle', attributes: { content: newDisplayTitle } };
|
2015-08-19 18:05:01 +00:00
|
|
|
|
|
|
|
|
|
// Alter the display title flag iff it's been touched & is actually different
|
2014-04-22 21:07:13 +00:00
|
|
|
|
if ( this.displayTitleTouched ) {
|
|
|
|
|
if ( currentDisplayTitleItem ) {
|
|
|
|
|
if ( newDisplayTitle ) {
|
|
|
|
|
if ( currentDisplayTitleItem.getAttribute( 'content' ) !== newDisplayTitle ) {
|
|
|
|
|
// There was a display title and is a new one, but they differ, so replace
|
|
|
|
|
currentDisplayTitleItem.replaceWith(
|
|
|
|
|
ve.extendObject( true, {},
|
|
|
|
|
currentDisplayTitleItem.getElement(),
|
2017-04-07 00:55:45 +00:00
|
|
|
|
newDisplayTitleItem
|
2017-07-18 11:55:33 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
2014-04-22 21:07:13 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// There was a display title and is no new one, so remove
|
|
|
|
|
currentDisplayTitleItem.remove();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ( newDisplayTitle ) {
|
|
|
|
|
// There's no existing display title but there is a new one, so create
|
2018-02-12 19:26:53 +00:00
|
|
|
|
// HACK: Putting this at position 0 so that it works – T63862
|
|
|
|
|
this.metaList.insertMeta( newDisplayTitleItem, 0 );
|
2014-04-22 21:07:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-25 11:47:28 +00:00
|
|
|
|
this.metaItemCheckboxes.forEach( function ( metaItemCheckbox ) {
|
|
|
|
|
var currentItem = advancedSettingsPage.getMetaItem( metaItemCheckbox.metaName ),
|
|
|
|
|
isSelected = metaItemCheckbox.fieldLayout.getField().isSelected();
|
2014-04-15 14:09:48 +00:00
|
|
|
|
|
2014-12-09 21:01:13 +00:00
|
|
|
|
if ( currentItem && !isSelected ) {
|
2014-04-15 14:09:48 +00:00
|
|
|
|
currentItem.remove();
|
2014-12-09 21:01:13 +00:00
|
|
|
|
} else if ( !currentItem && isSelected ) {
|
2019-02-25 11:47:28 +00:00
|
|
|
|
advancedSettingsPage.metaList.insertMeta( { type: metaItemCheckbox.metaName } );
|
2014-04-15 14:09:48 +00:00
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
2014-04-04 17:42:13 +00:00
|
|
|
|
this.metaList = null;
|
2013-11-15 20:36:53 +00:00
|
|
|
|
};
|
2018-10-28 19:18:40 +00:00
|
|
|
|
|
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.getFieldsets = function () {
|
|
|
|
|
return [
|
|
|
|
|
this.advancedSettingsFieldset
|
|
|
|
|
];
|
|
|
|
|
};
|