Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 1x 1x 1x | /*!
* VisualEditor UserInterface LanguageResultWidget class.
*
* @copyright See AUTHORS.txt
*/
/**
* Creates an ve.ui.LanguageResultWidget object.
*
* @class
* @extends OO.ui.OptionWidget
*
* @constructor
* @param {Object} [config] Configuration options
*/
ve.ui.LanguageResultWidget = function VeUiLanguageResultWidget( config = {} ) {
// Parent constructor
ve.ui.LanguageResultWidget.super.call( this, config );
// Initialization
this.$element.addClass( 've-ui-languageResultWidget' );
this.name = new OO.ui.LabelWidget( { classes: [ 've-ui-languageResultWidget-name' ] } );
this.otherMatch = new OO.ui.LabelWidget( { classes: [ 've-ui-languageResultWidget-otherMatch' ] } );
this.setLabel( this.otherMatch.$element.add( this.name.$element ) );
};
/* Inheritance */
OO.inheritClass( ve.ui.LanguageResultWidget, OO.ui.OptionWidget );
/* Methods */
/**
* Update labels based on query
*
* @param {string} query Query text which matched this result
* @param {string} matchedProperty Data property which matched the query text
* @param {Function} [compare] String comparator
* @return {ve.ui.LanguageResultWidget}
* @chainable
*/
ve.ui.LanguageResultWidget.prototype.updateLabel = function ( query, matchedProperty, compare ) {
const data = this.getData();
if ( matchedProperty === 'name' ) {
this.name.setHighlightedQuery( data.name, query, compare );
} else {
this.name.setLabel( data.name );
}
if ( matchedProperty === 'code' || matchedProperty === 'autonym' ) {
this.otherMatch.setHighlightedQuery( data[ matchedProperty ], query, compare );
} else {
this.otherMatch.setLabel( data.code );
}
return this;
};
|