2023-08-21 08:08:23 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-02-03 21:03:41 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWReferenceResultWidget class.
|
|
|
|
*
|
2018-01-03 01:05:45 +00:00
|
|
|
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
|
2017-12-29 12:12:35 +00:00
|
|
|
* @license MIT
|
2016-02-03 21:03:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an ve.ui.MWReferenceResultWidget object.
|
|
|
|
*
|
|
|
|
* @constructor
|
2024-02-28 08:57:24 +00:00
|
|
|
* @extends OO.ui.OptionWidget
|
2024-10-04 09:07:58 +00:00
|
|
|
* @param {Object} config
|
|
|
|
* @param {Object} config.item An item from the search index in ve.ui.MWReferenceSearchWidget
|
|
|
|
* @param {ve.dm.MWReferenceModel} config.item.reference
|
|
|
|
* @param {string} config.item.name
|
|
|
|
* @param {string} config.item.footnoteLabel e.g. "note 1"
|
|
|
|
* @param {OO.ui.Element} [config.reuseMenu]
|
2016-02-03 21:03:41 +00:00
|
|
|
*/
|
2024-09-27 22:01:15 +00:00
|
|
|
ve.ui.MWReferenceResultWidget = function VeUiMWReferenceResultWidget( config ) {
|
2024-09-23 09:49:21 +00:00
|
|
|
config = ve.extendObject( {
|
|
|
|
title: ve.msg( 'cite-ve-dialog-reference-useexisting-long-tool' )
|
|
|
|
}, config );
|
|
|
|
|
2016-02-03 21:03:41 +00:00
|
|
|
// Parent constructor
|
|
|
|
ve.ui.MWReferenceResultWidget.super.apply( this, arguments );
|
|
|
|
|
|
|
|
// Initialization
|
2024-09-27 22:01:15 +00:00
|
|
|
const item = config.item;
|
|
|
|
|
2016-02-03 21:03:41 +00:00
|
|
|
this.$element
|
2024-06-14 12:46:53 +00:00
|
|
|
.addClass( 've-ui-mwReferenceResultWidget' );
|
2024-10-02 05:41:13 +00:00
|
|
|
if ( item.reference.extendsRef ) {
|
2024-09-27 22:01:15 +00:00
|
|
|
this.$element.addClass( 've-ui-mwReferenceResultWidget-sub' );
|
|
|
|
}
|
|
|
|
|
|
|
|
const $footnoteLabel = $( '<div>' )
|
|
|
|
.addClass( 've-ui-mwReferenceResultWidget-footnote' )
|
|
|
|
.text( '[' + item.footnoteLabel + ']' );
|
|
|
|
|
|
|
|
const $name = $( '<div>' )
|
|
|
|
.addClass( 've-ui-mwReferenceResultWidget-name' )
|
|
|
|
.toggleClass( 've-ui-mwReferenceResultWidget-name-autogenerated', /^:\d+$/.test( item.name ) )
|
|
|
|
.text( item.name );
|
|
|
|
|
|
|
|
this.setLabel( $footnoteLabel.add( $name ).add( item.$refContent ) );
|
|
|
|
this.setData( item.reference );
|
2024-09-23 09:49:21 +00:00
|
|
|
|
|
|
|
if ( mw.config.get( 'wgCiteBookReferencing' ) && config.reuseMenu ) {
|
|
|
|
this.$element.append( config.reuseMenu.$element );
|
|
|
|
}
|
2016-02-03 21:03:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWReferenceResultWidget, OO.ui.OptionWidget );
|