2013-11-15 20:36:53 +00:00
|
|
|
|
/*!
|
|
|
|
|
* VisualEditor user interface MWAdvancedSettingsPage class.
|
|
|
|
|
*
|
2018-01-03 00:54:47 +00:00
|
|
|
|
* @copyright 2011-2018 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' ),
|
|
|
|
|
icon: 'advanced'
|
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' ),
|
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
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.each( this.metaItemCheckboxes, function () {
|
|
|
|
|
this.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',
|
2017-02-16 01:19:09 +00:00
|
|
|
|
label: this.label,
|
|
|
|
|
help: this.help
|
2014-04-15 14:09:48 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
advancedSettingsPage.advancedSettingsFieldset.addItems( [ this.fieldLayout ] );
|
|
|
|
|
} );
|
|
|
|
|
|
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
|
|
|
|
|
*/
|
2016-08-22 21:44:59 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.setOutlineItem = function () {
|
2013-11-15 20:36:53 +00:00
|
|
|
|
// Parent method
|
2016-08-22 21:44:59 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage.super.prototype.setOutlineItem.apply( this, arguments );
|
2013-11-15 20:36:53 +00:00
|
|
|
|
|
|
|
|
|
if ( this.outlineItem ) {
|
|
|
|
|
this.outlineItem
|
|
|
|
|
.setIcon( 'advanced' )
|
|
|
|
|
.setLabel( ve.msg( 'visualeditor-dialog-meta-advancedsettings-section' ) );
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* 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
|
2013-11-15 20:36:53 +00:00
|
|
|
|
* @param {Object} [data] Dialog setup data
|
|
|
|
|
*/
|
2014-04-04 17:42:13 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( metaList ) {
|
2015-08-19 18:05:01 +00:00
|
|
|
|
var indexingField, indexingOption, indexingType,
|
|
|
|
|
newSectionEditField, newSectionEditLinkOption, newSectionEditLinkType,
|
|
|
|
|
displayTitleItem, displayTitle,
|
2014-04-15 14:09:48 +00:00
|
|
|
|
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
|
2015-08-19 18:05:01 +00:00
|
|
|
|
indexingField = this.indexing.getField();
|
|
|
|
|
indexingOption = this.getMetaItem( 'mwIndex' );
|
2017-04-13 21:38:20 +00:00
|
|
|
|
indexingType = indexingOption && indexingOption.getAttribute( 'property' ) || 'default';
|
2015-05-08 15:15:16 +00:00
|
|
|
|
indexingField.selectItemByData( indexingType );
|
2013-11-15 20:36:53 +00:00
|
|
|
|
this.indexingOptionTouched = false;
|
2013-11-15 20:50:15 +00:00
|
|
|
|
|
|
|
|
|
// New section edit link items
|
2015-08-19 18:05:01 +00:00
|
|
|
|
newSectionEditField = this.newEditSectionLink.getField();
|
|
|
|
|
newSectionEditLinkOption = this.getMetaItem( 'mwNewSectionEdit' );
|
2017-04-13 21:38:20 +00:00
|
|
|
|
newSectionEditLinkType = newSectionEditLinkOption && newSectionEditLinkOption.getAttribute( 'property' ) || 'default';
|
2015-05-08 15:15:16 +00:00
|
|
|
|
newSectionEditField.selectItemByData( newSectionEditLinkType );
|
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
|
|
|
|
|
displayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
|
|
|
|
|
displayTitle = displayTitleItem && displayTitleItem.getAttribute( 'content' ) || '';
|
2017-01-25 17:21:09 +00:00
|
|
|
|
if ( !displayTitle ) {
|
2017-09-26 12:15:34 +00:00
|
|
|
|
displayTitle = mw.Title.newFromText( ve.init.target.pageName ).getPrefixedText();
|
2017-01-25 17:21:09 +00:00
|
|
|
|
}
|
2014-04-22 21:07:13 +00:00
|
|
|
|
this.displayTitleInput.setValue( displayTitle );
|
|
|
|
|
this.displayTitleTouched = false;
|
|
|
|
|
|
2014-04-15 14:09:48 +00:00
|
|
|
|
// Simple checkbox items
|
|
|
|
|
$.each( this.metaItemCheckboxes, function () {
|
2014-12-09 21:01:13 +00:00
|
|
|
|
var isSelected = !!advancedSettingsPage.getMetaItem( this.metaName );
|
|
|
|
|
this.fieldLayout.getField().setSelected( isSelected );
|
2014-04-15 14:09:48 +00:00
|
|
|
|
} );
|
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 ) {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
var currentIndexingItem, newIndexingData, newIndexingItem,
|
|
|
|
|
currentNewSectionEditLinkItem, newNewSectionEditLinkData, newNewSectionEditLinkItem,
|
|
|
|
|
currentDisplayTitleItem, newDisplayTitle, newDisplayTitleItem,
|
2015-08-19 18:05:01 +00:00
|
|
|
|
advancedSettingsPage = this;
|
|
|
|
|
|
2013-11-15 20:36:53 +00:00
|
|
|
|
// Data initialization
|
|
|
|
|
data = data || {};
|
2015-07-30 23:21:52 +00:00
|
|
|
|
if ( data.action !== 'apply' ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-11-15 20:36:53 +00:00
|
|
|
|
|
2015-08-19 18:05:01 +00:00
|
|
|
|
// Indexing items
|
|
|
|
|
currentIndexingItem = this.getMetaItem( 'mwIndex' );
|
2018-01-17 13:38:10 +00:00
|
|
|
|
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 {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
newIndexingItem = { type: 'mwIndex', attributes: { property: newIndexingData.data } };
|
|
|
|
|
|
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
|
|
|
|
|
currentNewSectionEditLinkItem = this.getMetaItem( 'mwNewSectionEdit' );
|
2018-01-17 13:38:10 +00:00
|
|
|
|
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 {
|
2017-04-07 00:55:45 +00:00
|
|
|
|
newNewSectionEditLinkItem = { type: 'mwNewSectionEdit', attributes: { property: newNewSectionEditLinkData.data } };
|
|
|
|
|
|
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
|
|
|
|
|
currentDisplayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
|
|
|
|
|
newDisplayTitle = this.displayTitleInput.getValue();
|
2017-09-26 12:15:34 +00:00
|
|
|
|
if ( newDisplayTitle === mw.Title.newFromText( ve.init.target.pageName ).getPrefixedText() ) {
|
2017-01-25 17:21:09 +00:00
|
|
|
|
newDisplayTitle = '';
|
|
|
|
|
}
|
2017-04-07 00:55:45 +00:00
|
|
|
|
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
|
2016-11-08 14:14:47 +00:00
|
|
|
|
// HACK: Putting this at index 0, offset 0 so that it works – bug 61862
|
2017-04-07 00:55:45 +00:00
|
|
|
|
this.metaList.insertMeta( newDisplayTitleItem, 0, 0 );
|
2014-04-22 21:07:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-15 14:09:48 +00:00
|
|
|
|
$.each( this.metaItemCheckboxes, function () {
|
|
|
|
|
var currentItem = advancedSettingsPage.getMetaItem( this.metaName ),
|
2014-12-09 21:01:13 +00:00
|
|
|
|
isSelected = this.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 ) {
|
2014-08-22 20:50:48 +00:00
|
|
|
|
advancedSettingsPage.metaList.insertMeta( { type: this.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
|
|
|
|
};
|