2013-12-02 20:10:55 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor user interface MWTransclusionContentPage class.
|
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
2013-12-02 20:10:55 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki transclusion dialog content page.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.PageLayout
|
|
|
|
*
|
|
|
|
* @constructor
|
2021-06-04 10:16:58 +00:00
|
|
|
* @param {ve.dm.MWTransclusionContentModel} content
|
2013-12-02 20:10:55 +00:00
|
|
|
* @param {string} name Unique symbolic name of page
|
|
|
|
* @param {Object} [config] Configuration options
|
2018-04-04 20:37:32 +00:00
|
|
|
* @cfg {jQuery} [$overlay] Overlay to render dropdowns in
|
2019-02-24 12:38:03 +00:00
|
|
|
* @cfg {boolean} [isReadOnly] Page is read-only
|
2013-12-02 20:10:55 +00:00
|
|
|
*/
|
2014-02-28 00:00:10 +00:00
|
|
|
ve.ui.MWTransclusionContentPage = function VeUiMWTransclusionContentPage( content, name, config ) {
|
2021-07-15 08:49:06 +00:00
|
|
|
var veConfig = mw.config.get( 'wgVisualEditorConfig' );
|
|
|
|
|
2014-04-25 23:50:21 +00:00
|
|
|
// Configuration initialization
|
|
|
|
config = ve.extendObject( {
|
2014-08-22 20:50:48 +00:00
|
|
|
scrollable: false
|
2014-04-25 23:50:21 +00:00
|
|
|
}, config );
|
|
|
|
|
2013-12-02 20:10:55 +00:00
|
|
|
// Parent constructor
|
2016-08-22 21:44:59 +00:00
|
|
|
ve.ui.MWTransclusionContentPage.super.call( this, name, config );
|
2013-12-02 20:10:55 +00:00
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.content = content;
|
2018-08-07 11:39:14 +00:00
|
|
|
this.textInput = new ve.ui.MWLazyMultilineTextInputWidget( {
|
2014-08-22 20:50:48 +00:00
|
|
|
autosize: true,
|
|
|
|
classes: [ 've-ui-mwTransclusionDialog-input' ]
|
2014-06-26 10:41:18 +00:00
|
|
|
} )
|
2021-06-17 16:17:54 +00:00
|
|
|
.setValue( this.content.serialize() )
|
2019-02-24 12:38:03 +00:00
|
|
|
.setReadOnly( config.isReadOnly )
|
2014-08-22 20:50:48 +00:00
|
|
|
.connect( this, { change: 'onTextInputChange' } );
|
2013-12-02 20:10:55 +00:00
|
|
|
this.valueFieldset = new OO.ui.FieldsetLayout( {
|
2021-08-17 11:06:49 +00:00
|
|
|
label: ve.msg( veConfig.transclusionDialogNewSidebar ?
|
|
|
|
'visualeditor-dialog-transclusion-wikitext' :
|
|
|
|
'visualeditor-dialog-transclusion-content'
|
|
|
|
),
|
2015-11-04 14:15:29 +00:00
|
|
|
icon: 'wikiText',
|
2014-08-22 20:50:48 +00:00
|
|
|
$content: this.textInput.$element
|
2013-12-02 20:10:55 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
// Initialization
|
2014-02-28 01:18:49 +00:00
|
|
|
this.$element
|
|
|
|
.addClass( 've-ui-mwTransclusionContentPage' )
|
2019-02-24 12:38:03 +00:00
|
|
|
.append( this.valueFieldset.$element );
|
|
|
|
|
2021-07-15 08:49:06 +00:00
|
|
|
if ( !config.isReadOnly && !veConfig.transclusionDialogNewSidebar ) {
|
2021-06-04 10:45:25 +00:00
|
|
|
var removeButton = new OO.ui.ButtonWidget( {
|
|
|
|
framed: false,
|
|
|
|
icon: 'trash',
|
|
|
|
title: ve.msg( 'visualeditor-dialog-transclusion-remove-content' ),
|
|
|
|
flags: [ 'destructive' ],
|
|
|
|
classes: [ 've-ui-mwTransclusionDialog-removeButton' ]
|
|
|
|
} )
|
|
|
|
.connect( this, { click: 'onRemoveButtonClick' } );
|
|
|
|
|
|
|
|
removeButton.$element.appendTo( this.$element );
|
2019-02-24 12:38:03 +00:00
|
|
|
}
|
2013-12-02 20:10:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWTransclusionContentPage, OO.ui.PageLayout );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
2014-02-15 01:37:32 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2021-09-15 10:10:56 +00:00
|
|
|
ve.ui.MWTransclusionContentPage.prototype.setupOutlineItem = function () {
|
|
|
|
this.outlineItem
|
|
|
|
.setIcon( 'wikiText' )
|
|
|
|
.setMovable( true )
|
|
|
|
.setRemovable( true )
|
|
|
|
.setLabel( ve.msg( 'visualeditor-dialog-transclusion-content' ) );
|
2014-02-15 01:37:32 +00:00
|
|
|
};
|
|
|
|
|
2021-09-17 09:29:50 +00:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
2013-12-02 20:10:55 +00:00
|
|
|
ve.ui.MWTransclusionContentPage.prototype.onTextInputChange = function () {
|
2021-06-04 10:16:58 +00:00
|
|
|
this.content.setWikitext( this.textInput.getValue() );
|
2013-12-02 20:10:55 +00:00
|
|
|
};
|
|
|
|
|
2021-09-17 09:29:50 +00:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
2013-12-02 20:10:55 +00:00
|
|
|
ve.ui.MWTransclusionContentPage.prototype.onRemoveButtonClick = function () {
|
|
|
|
this.content.remove();
|
|
|
|
};
|