mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
ed0637a016
As per changes in core: * Use new #this.setAnnotationFromValues method. * Inline 'initialize' in constructor. * Bring over 'Change language' button. * Rename 'Change language' button to 'Find language' and move to top of form so that it's obvious it's not just a submit button for the form. * Properties -> local vairables. Depends on If121603b5637 in core. Change-Id: I059acea7258fc5097b747595e09fae394ab066ec
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface LanguageInputWidget class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.MWLanguageInputWidget object.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.LanguageInputWidget
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ui.MWLanguageInputWidget = function VeUiMWLanguageInputWidget( config ) {
|
|
// Parent constructor
|
|
ve.ui.LanguageInputWidget.call( this, config );
|
|
|
|
var changeButton = new OO.ui.ButtonWidget( {
|
|
'label': ve.msg( 'visualeditor-languageinspector-widget-changelang' ),
|
|
// Add 'href' so the button returns true on click and triggers ULS
|
|
'href': '#',
|
|
'flags': ['primary']
|
|
} );
|
|
|
|
// Events
|
|
changeButton.$element.uls( {
|
|
'onSelect': ve.bind( function ( language ) {
|
|
this.setAnnotationFromValues( language, $.uls.data.getDir( language ) );
|
|
}, this ),
|
|
'compact': true,
|
|
// Temporary Quicklist for the Prototype:
|
|
// (This will likely change once we find a better list)
|
|
'quickList': [ 'en', 'hi', 'he', 'ml', 'ta', 'fr' ]
|
|
} );
|
|
|
|
// TODO: Rethink the layout, maybe integrate the change button into the language field
|
|
// TODO: Consider using getAutonym to display a nicer language name label somewhere
|
|
|
|
// Initialization
|
|
this.$element.prepend( $( '<div>' ).addClass( 've-ui-mwLangugageInputWidget-uls' ).append( changeButton.$element ) );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWLanguageInputWidget, ve.ui.LanguageInputWidget );
|