2013-12-19 16:38:02 +00:00
|
|
|
|
/*!
|
|
|
|
|
* VisualEditor user interface MWSettingsPage class.
|
|
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
2013-12-19 16:38:02 +00:00
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* MediaWiki meta dialog settings page.
|
|
|
|
|
*
|
|
|
|
|
* @class
|
|
|
|
|
* @extends OO.ui.PageLayout
|
|
|
|
|
*
|
|
|
|
|
* @constructor
|
|
|
|
|
* @param {string} name Unique symbolic name of page
|
|
|
|
|
* @param {Object} [config] Configuration options
|
2014-11-01 04:48:07 +00:00
|
|
|
|
* @param {jQuery} [$overlay] Overlay to render dropdowns in
|
2013-12-19 16:38:02 +00:00
|
|
|
|
*/
|
2014-04-04 17:42:13 +00:00
|
|
|
|
ve.ui.MWSettingsPage = function VeUiMWSettingsPage( name, config ) {
|
2014-04-15 14:09:48 +00:00
|
|
|
|
var settingsPage = this;
|
|
|
|
|
|
2013-12-19 16:38:02 +00:00
|
|
|
|
// Parent constructor
|
|
|
|
|
OO.ui.PageLayout.call( this, name, config );
|
|
|
|
|
|
|
|
|
|
// Properties
|
2014-04-04 17:42:13 +00:00
|
|
|
|
this.metaList = null;
|
2013-12-19 16:38:02 +00:00
|
|
|
|
this.tocOptionTouched = false;
|
2013-11-13 20:15:44 +00:00
|
|
|
|
this.redirectOptionsTouched = false;
|
2014-01-22 20:13:59 +00:00
|
|
|
|
this.tableOfContentsTouched = false;
|
|
|
|
|
this.label = ve.msg( 'visualeditor-dialog-meta-settings-section' );
|
|
|
|
|
|
2013-12-19 16:38:02 +00:00
|
|
|
|
this.settingsFieldset = new OO.ui.FieldsetLayout( {
|
2014-08-22 20:50:48 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-label' ),
|
|
|
|
|
icon: 'settings'
|
2013-12-19 16:38:02 +00:00
|
|
|
|
} );
|
2013-11-15 20:02:34 +00:00
|
|
|
|
|
|
|
|
|
// Initialization
|
|
|
|
|
|
|
|
|
|
// Table of Contents items
|
2014-01-22 20:13:59 +00:00
|
|
|
|
this.tableOfContents = new OO.ui.FieldLayout(
|
2015-02-05 09:35:18 +00:00
|
|
|
|
new OO.ui.ButtonSelectWidget( {
|
|
|
|
|
classes: [ 've-test-page-settings-table-of-contents' ]
|
|
|
|
|
} )
|
2014-01-22 20:13:59 +00:00
|
|
|
|
.addItems( [
|
2014-11-22 01:40:00 +00:00
|
|
|
|
new OO.ui.ButtonOptionWidget( {
|
|
|
|
|
data: 'mwTOCForce',
|
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-toc-force' )
|
|
|
|
|
} ),
|
|
|
|
|
new OO.ui.ButtonOptionWidget( {
|
|
|
|
|
data: 'default',
|
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-toc-default' )
|
|
|
|
|
} ),
|
|
|
|
|
new OO.ui.ButtonOptionWidget( {
|
|
|
|
|
data: 'mwTOCDisable',
|
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-toc-disable' )
|
|
|
|
|
} )
|
2014-01-22 20:13:59 +00:00
|
|
|
|
] )
|
2014-08-22 20:50:48 +00:00
|
|
|
|
.connect( this, { select: 'onTableOfContentsFieldChange' } ),
|
2014-01-22 20:13:59 +00:00
|
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
|
align: 'top',
|
2014-07-19 17:39:34 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-toc-label' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-toc-help' )
|
2014-01-22 20:13:59 +00:00
|
|
|
|
}
|
2013-12-19 16:38:02 +00:00
|
|
|
|
);
|
2013-11-15 20:02:34 +00:00
|
|
|
|
|
2013-11-13 20:15:44 +00:00
|
|
|
|
// Redirect items
|
2015-04-09 23:47:15 +00:00
|
|
|
|
this.enableRedirectInput = new OO.ui.CheckboxInputWidget();
|
2014-01-22 20:13:59 +00:00
|
|
|
|
this.enableRedirectField = new OO.ui.FieldLayout(
|
|
|
|
|
this.enableRedirectInput,
|
|
|
|
|
{
|
2015-02-05 09:35:18 +00:00
|
|
|
|
classes: [ 've-test-page-settings-enable-redirect' ],
|
2014-08-22 20:50:48 +00:00
|
|
|
|
align: 'inline',
|
2014-07-19 17:39:34 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-redirect-label' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-redirect-help' )
|
2014-01-22 20:13:59 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
2014-02-19 20:06:46 +00:00
|
|
|
|
this.redirectTargetInput = new ve.ui.MWTitleInputWidget( {
|
2014-11-01 04:48:07 +00:00
|
|
|
|
placeholder: ve.msg( 'visualeditor-dialog-meta-settings-redirect-placeholder' ),
|
|
|
|
|
$overlay: config.$overlay
|
2013-11-13 20:15:44 +00:00
|
|
|
|
} );
|
2014-01-22 20:13:59 +00:00
|
|
|
|
this.redirectTargetField = new OO.ui.FieldLayout(
|
|
|
|
|
this.redirectTargetInput,
|
2015-04-09 23:47:15 +00:00
|
|
|
|
{ align: 'top' }
|
2014-01-22 20:13:59 +00:00
|
|
|
|
);
|
2015-04-09 23:47:15 +00:00
|
|
|
|
this.enableStaticRedirectInput = new OO.ui.CheckboxInputWidget();
|
2014-01-22 20:13:59 +00:00
|
|
|
|
this.enableStaticRedirectField = new OO.ui.FieldLayout(
|
|
|
|
|
this.enableStaticRedirectInput,
|
|
|
|
|
{
|
2015-02-05 09:35:18 +00:00
|
|
|
|
classes: [ 've-test-page-settings-prevent-redirect' ],
|
2014-08-22 20:50:48 +00:00
|
|
|
|
align: 'inline',
|
2014-07-19 17:39:34 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-redirect-staticlabel' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-redirect-statichelp' )
|
2014-01-22 20:13:59 +00:00
|
|
|
|
}
|
2013-11-13 20:15:44 +00:00
|
|
|
|
);
|
2014-08-22 20:50:48 +00:00
|
|
|
|
this.enableRedirectInput.connect( this, { change: 'onEnableRedirectChange' } );
|
|
|
|
|
this.redirectTargetInput.connect( this, { change: 'onRedirectTargetChange' } );
|
|
|
|
|
this.enableStaticRedirectInput.connect( this, { change: 'onEnableStaticRedirectChange' } );
|
2013-11-13 20:15:44 +00:00
|
|
|
|
|
2014-04-15 14:09:48 +00:00
|
|
|
|
this.metaItemCheckboxes = [
|
2014-01-22 20:13:59 +00:00
|
|
|
|
{
|
2014-04-15 14:09:48 +00:00
|
|
|
|
metaName: 'mwNoEditSection',
|
2014-07-19 17:39:34 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-noeditsection-label' ),
|
2015-02-25 02:37:15 +00:00
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-noeditsection-help' ),
|
|
|
|
|
classes: [ 've-test-page-settings-noeditsection' ]
|
2014-01-22 20:13:59 +00:00
|
|
|
|
}
|
2014-04-29 12:43:14 +00:00
|
|
|
|
].concat( ve.ui.MWSettingsPage.static.extraMetaCheckboxes );
|
2014-07-19 17:41:06 +00:00
|
|
|
|
|
2014-04-15 14:09:48 +00:00
|
|
|
|
if ( mw.config.get( 'wgNamespaceNumber' ) === mw.config.get( 'wgNamespaceIds' ).category ) {
|
|
|
|
|
this.metaItemCheckboxes.push(
|
|
|
|
|
{
|
|
|
|
|
metaName: 'mwHiddenCategory',
|
2014-07-19 17:39:34 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-hiddencat-label' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-hiddencat-help' )
|
2014-04-15 14:09:48 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
metaName: 'mwNoGallery',
|
2014-07-19 17:39:34 +00:00
|
|
|
|
label: ve.msg( 'visualeditor-dialog-meta-settings-nogallery-label' ),
|
|
|
|
|
help: ve.msg( 'visualeditor-dialog-meta-settings-nogallery-help' )
|
2014-04-15 14:09:48 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
2013-11-15 20:02:34 +00:00
|
|
|
|
|
2014-01-22 20:13:59 +00:00
|
|
|
|
this.settingsFieldset.addItems( [
|
|
|
|
|
this.enableRedirectField,
|
|
|
|
|
this.redirectTargetField,
|
|
|
|
|
this.enableStaticRedirectField,
|
2014-04-15 14:09:48 +00:00
|
|
|
|
this.tableOfContents
|
2014-01-22 20:13:59 +00:00
|
|
|
|
] );
|
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
|
|
|
|
{
|
2015-02-25 02:37:15 +00:00
|
|
|
|
classes: this.classes,
|
2014-08-22 20:50:48 +00:00
|
|
|
|
align: 'inline',
|
2014-07-19 17:39:34 +00:00
|
|
|
|
label: this.label,
|
|
|
|
|
help: this.help || ''
|
2014-04-15 14:09:48 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
settingsPage.settingsFieldset.addItems( [ this.fieldLayout ] );
|
|
|
|
|
} );
|
|
|
|
|
|
2013-12-19 16:38:02 +00:00
|
|
|
|
this.$element.append( this.settingsFieldset.$element );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWSettingsPage, OO.ui.PageLayout );
|
|
|
|
|
|
2014-04-29 12:43:14 +00:00
|
|
|
|
/* Allow extra meta item checkboxes to be added by extensions etc. */
|
|
|
|
|
ve.ui.MWSettingsPage.static.extraMetaCheckboxes = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a checkbox to the list of changeable page settings
|
|
|
|
|
* @param {string} metaName The name of the DM meta item
|
|
|
|
|
* @param {string} label The label to show next to the checkbox
|
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWSettingsPage.static.addMetaCheckbox = function ( metaName, label ) {
|
2014-08-22 20:50:48 +00:00
|
|
|
|
this.extraMetaCheckboxes.push( { metaName: metaName, label: label } );
|
2014-04-29 12:43:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
2013-12-19 16:38:02 +00:00
|
|
|
|
/* Methods */
|
|
|
|
|
|
2013-11-13 20:15:44 +00:00
|
|
|
|
/* Table of Contents methods */
|
|
|
|
|
|
2014-02-15 01:37:32 +00:00
|
|
|
|
/**
|
|
|
|
|
* @inheritdoc
|
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWSettingsPage.prototype.setOutlineItem = function ( outlineItem ) {
|
|
|
|
|
// Parent method
|
|
|
|
|
OO.ui.PageLayout.prototype.setOutlineItem.call( this, outlineItem );
|
|
|
|
|
|
|
|
|
|
if ( this.outlineItem ) {
|
|
|
|
|
this.outlineItem
|
|
|
|
|
.setIcon( 'settings' )
|
|
|
|
|
.setLabel( ve.msg( 'visualeditor-dialog-meta-settings-section' ) );
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2013-12-19 16:38:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Handle Table Of Contents display change events.
|
|
|
|
|
*
|
|
|
|
|
* @method
|
|
|
|
|
*/
|
2014-01-22 20:13:59 +00:00
|
|
|
|
ve.ui.MWSettingsPage.prototype.onTableOfContentsFieldChange = function () {
|
|
|
|
|
this.tableOfContentsTouched = true;
|
2013-12-19 16:38:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2013-11-13 20:15:44 +00:00
|
|
|
|
/* Redirect methods */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle redirect state change events.
|
|
|
|
|
*
|
|
|
|
|
* @param {boolean} value Whether a redirect is to be set for this page
|
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWSettingsPage.prototype.onEnableRedirectChange = function ( value ) {
|
|
|
|
|
this.redirectTargetInput.setDisabled( !value );
|
|
|
|
|
this.enableStaticRedirectInput.setDisabled( !value );
|
|
|
|
|
if ( !value ) {
|
|
|
|
|
this.redirectTargetInput.setValue( '' );
|
2015-01-19 23:31:04 +00:00
|
|
|
|
this.enableStaticRedirectInput.setSelected( false );
|
2013-11-13 20:15:44 +00:00
|
|
|
|
}
|
|
|
|
|
this.redirectOptionsTouched = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle redirect target change events.
|
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWSettingsPage.prototype.onRedirectTargetChange = function () {
|
|
|
|
|
this.redirectOptionsTouched = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle static redirect state change events.
|
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWSettingsPage.prototype.onEnableStaticRedirectChange = function () {
|
|
|
|
|
this.redirectOptionsTouched = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2014-04-15 14:09:48 +00:00
|
|
|
|
* Get the first meta item of a given name
|
2013-11-15 20:02:34 +00:00
|
|
|
|
*
|
2014-04-15 14:09:48 +00:00
|
|
|
|
* @param {string} name Name of the meta item
|
|
|
|
|
* @returns {Object|null} Meta item, if any
|
2013-11-15 20:02:34 +00:00
|
|
|
|
*/
|
2014-04-15 14:09:48 +00:00
|
|
|
|
ve.ui.MWSettingsPage.prototype.getMetaItem = function ( name ) {
|
|
|
|
|
return this.metaList.getItemsInGroup( name )[0] || null;
|
2013-11-15 20:02:34 +00:00
|
|
|
|
};
|
|
|
|
|
|
2013-12-19 16:38:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Setup settings page.
|
|
|
|
|
*
|
2014-04-04 17:42:13 +00:00
|
|
|
|
* @param {ve.dm.MetaList} metaList Meta list
|
2013-12-19 16:38:02 +00:00
|
|
|
|
* @param {Object} [data] Dialog setup data
|
|
|
|
|
*/
|
2014-04-04 17:42:13 +00:00
|
|
|
|
ve.ui.MWSettingsPage.prototype.setup = function ( metaList ) {
|
|
|
|
|
this.metaList = metaList;
|
|
|
|
|
|
2013-11-13 20:15:44 +00:00
|
|
|
|
var // Table of Contents items
|
2014-04-15 14:09:48 +00:00
|
|
|
|
tableOfContentsMetaItem = this.getMetaItem( 'mwTOC' ),
|
2014-01-22 20:13:59 +00:00
|
|
|
|
tableOfContentsField = this.tableOfContents.getField(),
|
|
|
|
|
tableOfContentsMode = tableOfContentsMetaItem &&
|
|
|
|
|
tableOfContentsMetaItem.getType() || 'default',
|
2013-11-13 20:15:44 +00:00
|
|
|
|
|
|
|
|
|
// Redirect items
|
2014-04-15 14:09:48 +00:00
|
|
|
|
redirectTargetItem = this.getMetaItem( 'mwRedirect' ),
|
2014-02-20 01:33:37 +00:00
|
|
|
|
redirectTarget = redirectTargetItem && redirectTargetItem.getAttribute( 'title' ) || '',
|
2014-04-15 14:09:48 +00:00
|
|
|
|
redirectStatic = this.getMetaItem( 'mwStaticRedirect' ),
|
|
|
|
|
|
|
|
|
|
settingsPage = this;
|
2013-12-19 16:38:02 +00:00
|
|
|
|
|
2013-11-15 20:02:34 +00:00
|
|
|
|
// Table of Contents items
|
2014-01-22 20:13:59 +00:00
|
|
|
|
tableOfContentsField.selectItem( tableOfContentsField.getItemFromData( tableOfContentsMode ) );
|
|
|
|
|
this.tableOfContentsTouched = false;
|
2013-11-15 20:02:34 +00:00
|
|
|
|
|
2013-11-13 20:15:44 +00:00
|
|
|
|
// Redirect items (disabled states set by change event)
|
2015-02-25 02:31:41 +00:00
|
|
|
|
this.enableRedirectInput.setSelected( !!redirectTargetItem );
|
2013-11-13 20:15:44 +00:00
|
|
|
|
this.redirectTargetInput.setValue( redirectTarget );
|
2014-02-24 20:07:56 +00:00
|
|
|
|
this.redirectTargetInput.setDisabled( !redirectTargetItem );
|
2015-01-19 23:31:04 +00:00
|
|
|
|
this.enableStaticRedirectInput.setSelected( !!redirectStatic );
|
2013-11-13 20:15:44 +00:00
|
|
|
|
this.enableStaticRedirectInput.setDisabled( !redirectTargetItem );
|
|
|
|
|
this.redirectOptionsTouched = 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 = !!settingsPage.getMetaItem( this.metaName );
|
|
|
|
|
this.fieldLayout.getField().setSelected( isSelected );
|
2014-04-15 14:09:48 +00:00
|
|
|
|
} );
|
2013-12-19 16:38:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tear down settings page.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} [data] Dialog tear down data
|
|
|
|
|
*/
|
|
|
|
|
ve.ui.MWSettingsPage.prototype.teardown = function ( data ) {
|
|
|
|
|
// Data initialisation
|
|
|
|
|
data = data || {};
|
|
|
|
|
|
2013-11-15 20:02:34 +00:00
|
|
|
|
var // Table of Contents items
|
2014-04-15 14:09:48 +00:00
|
|
|
|
tableOfContentsMetaItem = this.getMetaItem( 'mwTOC' ),
|
2014-01-22 20:13:59 +00:00
|
|
|
|
tableOfContentsSelectedItem = this.tableOfContents.getField().getSelectedItem(),
|
|
|
|
|
tableOfContentsValue = tableOfContentsSelectedItem && tableOfContentsSelectedItem.getData(),
|
2013-11-15 20:02:34 +00:00
|
|
|
|
|
2013-11-13 20:15:44 +00:00
|
|
|
|
// Redirect items
|
2014-04-15 14:09:48 +00:00
|
|
|
|
currentRedirectTargetItem = this.getMetaItem( 'mwRedirect' ),
|
2013-11-13 20:15:44 +00:00
|
|
|
|
newRedirectData = this.redirectTargetInput.getValue(),
|
2014-08-22 20:50:48 +00:00
|
|
|
|
newRedirectItemData = { type: 'mwRedirect', attributes: { title: newRedirectData } },
|
2013-11-13 20:15:44 +00:00
|
|
|
|
|
2014-04-15 14:09:48 +00:00
|
|
|
|
currentStaticRedirectItem = this.getMetaItem( 'mwStaticRedirect' ),
|
2015-01-19 23:31:04 +00:00
|
|
|
|
newStaticRedirectState = this.enableStaticRedirectInput.isSelected(),
|
2013-11-13 20:15:44 +00:00
|
|
|
|
|
2014-04-15 14:09:48 +00:00
|
|
|
|
settingsPage = this;
|
2013-12-19 16:38:02 +00:00
|
|
|
|
|
|
|
|
|
// Alter the TOC option flag iff it's been touched & is actually different
|
2014-01-22 20:13:59 +00:00
|
|
|
|
if ( this.tableOfContentsTouched ) {
|
|
|
|
|
if ( tableOfContentsValue === 'default' ) {
|
|
|
|
|
if ( tableOfContentsMetaItem ) {
|
|
|
|
|
tableOfContentsMetaItem.remove();
|
2013-12-19 16:38:02 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2014-01-22 20:13:59 +00:00
|
|
|
|
if ( !tableOfContentsMetaItem ) {
|
2014-08-22 20:50:48 +00:00
|
|
|
|
this.metaList.insertMeta( { type: tableOfContentsValue } );
|
2014-01-22 20:13:59 +00:00
|
|
|
|
} else if ( tableOfContentsMetaItem.getType() !== tableOfContentsValue ) {
|
|
|
|
|
tableOfContentsMetaItem.replaceWith(
|
2013-12-19 16:38:02 +00:00
|
|
|
|
ve.extendObject( true, {},
|
2014-01-22 20:13:59 +00:00
|
|
|
|
tableOfContentsMetaItem.getElement(),
|
2014-08-22 20:50:48 +00:00
|
|
|
|
{ type: tableOfContentsValue }
|
2013-12-19 16:38:02 +00:00
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-15 20:02:34 +00:00
|
|
|
|
|
2013-11-13 20:15:44 +00:00
|
|
|
|
// Alter the redirect options iff they've been touched & are different
|
|
|
|
|
if ( this.redirectOptionsTouched ) {
|
|
|
|
|
if ( currentRedirectTargetItem ) {
|
|
|
|
|
if ( newRedirectData ) {
|
2014-02-20 01:33:37 +00:00
|
|
|
|
if ( currentRedirectTargetItem.getAttribute( 'title' ) !== newRedirectData ) {
|
2013-11-13 20:15:44 +00:00
|
|
|
|
// There was a redirect and is a new one, but they differ, so replace
|
|
|
|
|
currentRedirectTargetItem.replaceWith(
|
|
|
|
|
ve.extendObject( true, {},
|
|
|
|
|
currentRedirectTargetItem.getElement(),
|
|
|
|
|
newRedirectItemData
|
|
|
|
|
) );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// There was a redirect and is no new one, so remove
|
|
|
|
|
currentRedirectTargetItem.remove();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ( newRedirectData ) {
|
|
|
|
|
// There's no existing redirect but there is a new one, so create
|
2014-02-24 21:08:10 +00:00
|
|
|
|
// HACK: Putting this at index 0, offset 0 so that it works – bug 61862
|
|
|
|
|
this.metaList.insertMeta( newRedirectItemData, 0, 0 );
|
2013-11-13 20:15:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( currentStaticRedirectItem && ( !newStaticRedirectState || !newRedirectData ) ) {
|
|
|
|
|
currentStaticRedirectItem.remove();
|
|
|
|
|
}
|
2014-02-24 20:11:23 +00:00
|
|
|
|
if ( !currentStaticRedirectItem && newStaticRedirectState && newRedirectData ) {
|
2014-08-22 20:50:48 +00:00
|
|
|
|
this.metaList.insertMeta( { type: 'mwStaticRedirect' } );
|
2013-11-13 20:15:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-15 14:09:48 +00:00
|
|
|
|
$.each( this.metaItemCheckboxes, function () {
|
|
|
|
|
var currentItem = settingsPage.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
|
|
|
|
settingsPage.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-12-19 16:38:02 +00:00
|
|
|
|
};
|