2013-12-02 20:10:55 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor user interface MWTransclusionContentPage class.
|
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 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
|
|
|
|
* @param {ve.dm.MWTransclusionContentModel} content Transclusion content
|
|
|
|
* @param {string} name Unique symbolic name of page
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
2014-02-28 00:00:10 +00:00
|
|
|
ve.ui.MWTransclusionContentPage = function VeUiMWTransclusionContentPage( content, name, config ) {
|
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
|
|
|
|
OO.ui.PageLayout.call( this, name, config );
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.content = content;
|
|
|
|
this.textInput = new OO.ui.TextInputWidget( {
|
2014-08-22 20:50:48 +00:00
|
|
|
multiline: true,
|
|
|
|
autosize: true,
|
|
|
|
classes: [ 've-ui-mwTransclusionDialog-input' ]
|
2014-06-26 10:41:18 +00:00
|
|
|
} )
|
2013-12-02 20:10:55 +00:00
|
|
|
.setValue( this.content.getValue() )
|
2014-08-22 20:50:48 +00:00
|
|
|
.connect( this, { change: 'onTextInputChange' } );
|
2014-01-17 14:24:12 +00:00
|
|
|
this.removeButton = new OO.ui.ButtonWidget( {
|
2014-08-22 20:50:48 +00:00
|
|
|
framed: false,
|
|
|
|
icon: 'remove',
|
|
|
|
title: ve.msg( 'visualeditor-dialog-transclusion-remove-content' ),
|
|
|
|
flags: [ 'destructive' ],
|
|
|
|
classes: [ 've-ui-mwTransclusionDialog-removeButton' ]
|
2014-06-26 10:41:18 +00:00
|
|
|
} )
|
2014-08-22 20:50:48 +00:00
|
|
|
.connect( this, { click: 'onRemoveButtonClick' } );
|
2013-12-02 20:10:55 +00:00
|
|
|
this.valueFieldset = new OO.ui.FieldsetLayout( {
|
2014-08-22 20:50:48 +00:00
|
|
|
label: ve.msg( 'visualeditor-dialog-transclusion-content' ),
|
|
|
|
icon: 'source',
|
|
|
|
$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' )
|
|
|
|
.append( this.valueFieldset.$element, this.removeButton.$element );
|
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
|
|
|
|
*/
|
|
|
|
ve.ui.MWTransclusionContentPage.prototype.setOutlineItem = function ( outlineItem ) {
|
|
|
|
// Parent method
|
|
|
|
OO.ui.PageLayout.prototype.setOutlineItem.call( this, outlineItem );
|
|
|
|
|
|
|
|
if ( this.outlineItem ) {
|
|
|
|
this.outlineItem
|
|
|
|
.setIcon( 'source' )
|
|
|
|
.setMovable( true )
|
2014-03-01 00:39:02 +00:00
|
|
|
.setRemovable( true )
|
2014-02-15 01:37:32 +00:00
|
|
|
.setLabel( ve.msg( 'visualeditor-dialog-transclusion-content' ) );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-12-02 20:10:55 +00:00
|
|
|
ve.ui.MWTransclusionContentPage.prototype.onTextInputChange = function () {
|
|
|
|
this.content.setValue( this.textInput.getValue() );
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.ui.MWTransclusionContentPage.prototype.onRemoveButtonClick = function () {
|
|
|
|
this.content.remove();
|
|
|
|
};
|