2014-02-27 23:58:37 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor user interface MWParameterPlaceholderPage class.
|
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
2014-02-27 23:58:37 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki transclusion dialog parameter placeholder page.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends OO.ui.PageLayout
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {ve.dm.MWTemplateModel} parameter Template
|
|
|
|
* @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
|
2014-02-27 23:58:37 +00:00
|
|
|
*/
|
|
|
|
ve.ui.MWParameterPlaceholderPage = function VeUiMWParameterPlaceholderPage( parameter, 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 );
|
|
|
|
|
2014-02-27 23:58:37 +00:00
|
|
|
// Parent constructor
|
2016-08-22 21:44:59 +00:00
|
|
|
ve.ui.MWParameterPlaceholderPage.super.call( this, name, config );
|
2014-02-27 23:58:37 +00:00
|
|
|
|
|
|
|
// Properties
|
2015-04-13 21:30:41 +00:00
|
|
|
this.name = name;
|
2014-02-27 23:58:37 +00:00
|
|
|
this.parameter = parameter;
|
|
|
|
this.template = this.parameter.getTemplate();
|
2015-04-13 21:30:41 +00:00
|
|
|
this.addParameterSearch = new ve.ui.MWParameterSearchWidget( this.template, {
|
|
|
|
showAll: !!config.expandedParamList
|
|
|
|
} )
|
|
|
|
.connect( this, {
|
2015-07-24 18:05:22 +00:00
|
|
|
choose: 'onParameterChoose',
|
2015-04-13 21:30:41 +00:00
|
|
|
showAll: 'onParameterShowAll'
|
|
|
|
} );
|
2014-06-26 10:41:18 +00:00
|
|
|
|
2014-02-27 23:58:37 +00:00
|
|
|
this.removeButton = new OO.ui.ButtonWidget( {
|
2014-08-22 20:50:48 +00:00
|
|
|
framed: false,
|
2017-05-31 23:30:17 +00:00
|
|
|
icon: 'trash',
|
2014-08-22 20:50:48 +00:00
|
|
|
title: ve.msg( 'visualeditor-dialog-transclusion-remove-param' ),
|
2014-12-09 22:28:40 +00:00
|
|
|
flags: [ 'destructive' ],
|
2014-08-22 20:50:48 +00:00
|
|
|
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' } );
|
2014-06-26 10:41:18 +00:00
|
|
|
|
2014-02-27 23:58:37 +00:00
|
|
|
this.addParameterFieldset = new OO.ui.FieldsetLayout( {
|
2014-08-22 20:50:48 +00:00
|
|
|
label: ve.msg( 'visualeditor-dialog-transclusion-add-param' ),
|
|
|
|
icon: 'parameter',
|
|
|
|
classes: [ 've-ui-mwTransclusionDialog-addParameterFieldset' ],
|
|
|
|
$content: this.addParameterSearch.$element
|
2014-02-27 23:58:37 +00:00
|
|
|
} );
|
|
|
|
|
2020-04-03 04:02:55 +00:00
|
|
|
this.addParameterFieldset.$element.attr( 'aria-label', ve.msg( 'visualeditor-dialog-transclusion-add-param' ) );
|
|
|
|
|
2014-02-27 23:58:37 +00:00
|
|
|
// Initialization
|
2014-02-28 01:18:49 +00:00
|
|
|
this.$element
|
|
|
|
.addClass( 've-ui-mwParameterPlaceholderPage' )
|
|
|
|
.append( this.addParameterFieldset.$element, this.removeButton.$element );
|
2014-02-27 23:58:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWParameterPlaceholderPage, OO.ui.PageLayout );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
2015-04-13 21:30:41 +00:00
|
|
|
/**
|
|
|
|
* Respond to the parameter search widget showAll event
|
2015-08-19 18:21:01 +00:00
|
|
|
*
|
2015-04-13 21:30:41 +00:00
|
|
|
* @fires showAll
|
|
|
|
*/
|
|
|
|
ve.ui.MWParameterPlaceholderPage.prototype.onParameterShowAll = function () {
|
|
|
|
this.emit( 'showAll', this.name );
|
|
|
|
};
|
|
|
|
|
2014-02-27 23:58:37 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2016-08-22 21:44:59 +00:00
|
|
|
ve.ui.MWParameterPlaceholderPage.prototype.setOutlineItem = function () {
|
2014-02-27 23:58:37 +00:00
|
|
|
// Parent method
|
2016-08-22 21:44:59 +00:00
|
|
|
ve.ui.MWParameterPlaceholderPage.super.prototype.setOutlineItem.apply( this, arguments );
|
2014-02-27 23:58:37 +00:00
|
|
|
|
|
|
|
if ( this.outlineItem ) {
|
|
|
|
this.outlineItem
|
|
|
|
.setIcon( 'parameter' )
|
|
|
|
.setMovable( false )
|
|
|
|
.setRemovable( true )
|
|
|
|
.setLevel( 1 )
|
|
|
|
.setFlags( [ 'placeholder' ] )
|
|
|
|
.setLabel( ve.msg( 'visualeditor-dialog-transclusion-add-param' ) );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-24 18:05:22 +00:00
|
|
|
ve.ui.MWParameterPlaceholderPage.prototype.onParameterChoose = function ( name ) {
|
2014-02-27 23:58:37 +00:00
|
|
|
var param;
|
|
|
|
|
|
|
|
if ( name ) {
|
|
|
|
param = new ve.dm.MWParameterModel( this.template, name );
|
|
|
|
this.addParameterSearch.query.setValue( '' );
|
|
|
|
this.template.addParameter( param );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.ui.MWParameterPlaceholderPage.prototype.onRemoveButtonClick = function () {
|
|
|
|
this.parameter.remove();
|
|
|
|
};
|