/** * A widget that represents a template parameter, with a checkbox to add/remove the parameter. * Modelled after {@see OO.ui.OutlineOptionWidget}. Also see {@see OO.ui.CheckboxMultioptionWidget} * for inspiration. * * @class * @extends OO.ui.OptionWidget * * @constructor * @param {Object} config * @param {string} config.data Parameter name * @param {string} config.label * @param {boolean} [config.required=false] Required parameters can't be unchecked * @param {boolean} [config.selected=false] If the parameter is currently used (checked) * @param {boolean} [config.hasValue=false] If the parameter has a value that's not empty */ ve.ui.MWTransclusionOutlineParameterWidget = function VeUiMWTransclusionOutlineParameterWidget( config ) { this.checkbox = new OO.ui.CheckboxInputWidget( { title: config.required ? ve.msg( 'visualeditor-dialog-transclusion-required-parameter' ) : null, disabled: config.required, selected: config.selected || config.required, // Keyboard navigation is handled by the outer OO.ui.SelectWidget tabIndex: -1 } ) .connect( this, { // The array syntax is a way to call `this.emit( 'change' )`. change: [ 'emit', 'change' ] } ); this.checkbox.$input.on( { mousedown: this.onMouseDown.bind( this ) } ); // Parent constructor ve.ui.MWTransclusionOutlineParameterWidget.super.call( this, ve.extendObject( config, { classes: [ 've-ui-mwTransclusionOutlineParameterWidget' ], $label: $( '