2013-11-15 20:36:53 +00:00
|
|
|
|
/*!
|
|
|
|
|
* VisualEditor user interface MWAdvancedSettingsPage class.
|
|
|
|
|
*
|
2016-01-03 22:56:59 +00:00
|
|
|
|
* @copyright 2011-2016 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
|
|
|
|
|
*/
|
2016-08-22 21:44:59 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage = function VeUiMWAdvancedSettingsPage() {
|
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( {
|
|
|
|
|
data: 'mwIndexForce',
|
|
|
|
|
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( {
|
|
|
|
|
data: 'mwIndexDisable',
|
|
|
|
|
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
|
|
|
|
{
|
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( {
|
|
|
|
|
data: 'mwNewSectionEditForce',
|
|
|
|
|
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( {
|
|
|
|
|
data: 'mwNewSectionEditDisable',
|
|
|
|
|
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
|
|
|
|
{
|
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;
|
2015-04-09 23:47:15 +00:00
|
|
|
|
this.enableDisplayTitleCheckbox = new OO.ui.CheckboxInputWidget();
|
2014-12-09 21:01:13 +00:00
|
|
|
|
this.enableDisplayTitleCheckbox.connect( this, { change: 'onEnableDisplayTitleCheckboxChange' } );
|
2014-04-22 21:07:13 +00:00
|
|
|
|
this.enableDisplayTitleField = new OO.ui.FieldLayout(
|
2014-12-09 21:01:13 +00:00
|
|
|
|
this.enableDisplayTitleCheckbox,
|
2014-04-22 21:07:13 +00:00
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
|
align: 'inline',
|
2014-09-15 01:18:03 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle-enable' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle-help' )
|
2014-04-22 21:07:13 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
this.displayTitleInput = new OO.ui.TextInputWidget( {
|
2014-08-22 20:50:48 +00:00
|
|
|
|
placeholder: ve.msg( 'visualeditor-dialog-meta-settings-displaytitle' )
|
2014-04-22 21:07:13 +00:00
|
|
|
|
} );
|
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,
|
2015-04-09 23:47:15 +00:00
|
|
|
|
{ align: 'inline' }
|
2014-04-22 21:07:13 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.advancedSettingsFieldset.addItems( [ this.indexing, this.newEditSectionLink, this.enableDisplayTitleField, this.displayTitleField ] );
|
|
|
|
|
|
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
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
|
align: 'inline',
|
|
|
|
|
label: this.label
|
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
|
|
|
|
/**
|
|
|
|
|
* Handle redirect state change events.
|
|
|
|
|
*
|
|
|
|
|
* @param {boolean} value Whether a redirect is to be set for this page
|
|
|
|
|
*/
|
2014-12-09 21:01:13 +00:00
|
|
|
|
ve.ui.MWAdvancedSettingsPage.prototype.onEnableDisplayTitleCheckboxChange = function ( value ) {
|
2014-04-22 21:07:13 +00:00
|
|
|
|
this.displayTitleInput.setDisabled( !value );
|
|
|
|
|
if ( !value ) {
|
|
|
|
|
this.displayTitleInput.setValue( '' );
|
2014-12-09 21:01:13 +00:00
|
|
|
|
this.enableDisplayTitleCheckbox.setSelected( false );
|
2014-04-22 21:07:13 +00:00
|
|
|
|
}
|
|
|
|
|
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 () {
|
|
|
|
|
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' );
|
|
|
|
|
indexingType = indexingOption && indexingOption.element.type || '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' );
|
|
|
|
|
newSectionEditLinkType = newSectionEditLinkOption && newSectionEditLinkOption.element.type || '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' ) || '';
|
2014-12-09 21:01:13 +00:00
|
|
|
|
this.enableDisplayTitleCheckbox.setSelected( !!displayTitleItem );
|
2014-04-22 21:07:13 +00:00
|
|
|
|
this.displayTitleInput.setValue( displayTitle );
|
|
|
|
|
this.displayTitleInput.setDisabled( !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 ) {
|
2015-08-19 18:05:01 +00:00
|
|
|
|
var currentIndexingItem, newIndexingData,
|
|
|
|
|
currentNewSectionEditLinkItem, newNewSectionEditLinkOptionData,
|
|
|
|
|
currentDisplayTitleItem, newDisplayTitle, newDisplayTitleItemData,
|
|
|
|
|
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' );
|
|
|
|
|
newIndexingData = this.indexing.getField().getSelectedItem();
|
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 {
|
|
|
|
|
if ( !currentIndexingItem ) {
|
2014-08-22 20:50:48 +00:00
|
|
|
|
this.metaList.insertMeta( { type: newIndexingData.data } );
|
2013-11-15 20:36:53 +00:00
|
|
|
|
} else if ( currentIndexingItem.element.type !== newIndexingData.data ) {
|
|
|
|
|
currentIndexingItem.replaceWith(
|
|
|
|
|
ve.extendObject( true, {},
|
|
|
|
|
currentIndexingItem.getElement(),
|
2014-08-22 20:50:48 +00:00
|
|
|
|
{ type: newIndexingData.data }
|
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' );
|
|
|
|
|
newNewSectionEditLinkOptionData = this.newEditSectionLink.getField().getSelectedItem();
|
|
|
|
|
|
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 ) {
|
|
|
|
|
if ( newNewSectionEditLinkOptionData.data === 'default' ) {
|
|
|
|
|
if ( currentNewSectionEditLinkItem ) {
|
|
|
|
|
currentNewSectionEditLinkItem.remove();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ( !currentNewSectionEditLinkItem ) {
|
2014-08-22 20:50:48 +00:00
|
|
|
|
this.metaList.insertMeta( { type: newNewSectionEditLinkOptionData.data } );
|
2013-11-15 20:50:15 +00:00
|
|
|
|
} else if ( currentNewSectionEditLinkItem.element.type !== newNewSectionEditLinkOptionData.data ) {
|
|
|
|
|
currentNewSectionEditLinkItem.replaceWith(
|
|
|
|
|
ve.extendObject( true, {},
|
|
|
|
|
currentNewSectionEditLinkItem.getElement(),
|
2014-08-22 20:50:48 +00:00
|
|
|
|
{ type: newNewSectionEditLinkOptionData.data }
|
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();
|
|
|
|
|
newDisplayTitleItemData = { type: 'mwDisplayTitle', attributes: { content: newDisplayTitle } };
|
|
|
|
|
|
|
|
|
|
// 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(),
|
|
|
|
|
newDisplayTitleItemData
|
|
|
|
|
) );
|
|
|
|
|
}
|
|
|
|
|
} 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
|
2014-04-22 21:07:13 +00:00
|
|
|
|
this.metaList.insertMeta( newDisplayTitleItemData, 0, 0 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
};
|