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-09-27 22:01:15 +00:00
|
|
|
* @param {Object} config Configuration options
|
|
|
|
* @param {Object} config.item Result item
|
2016-02-03 21:03:41 +00:00
|
|
|
*/
|
2024-09-27 22:01:15 +00:00
|
|
|
ve.ui.MWReferenceResultWidget = function VeUiMWReferenceResultWidget( 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-09-27 22:01:15 +00:00
|
|
|
if ( item.reference.extendsRef !== undefined ) {
|
|
|
|
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 );
|
2016-02-03 21:03:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWReferenceResultWidget, OO.ui.OptionWidget );
|