2013-11-12 21:17:09 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface LanguageInputWidget class.
|
|
|
|
*
|
2014-03-25 01:36:51 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-11-12 21:17:09 +00:00
|
|
|
* @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 );
|
|
|
|
|
2014-02-20 20:36:52 +00:00
|
|
|
var changeButton = new OO.ui.ButtonWidget( {
|
2013-11-12 21:17:09 +00:00
|
|
|
'label': ve.msg( 'visualeditor-languageinspector-widget-changelang' ),
|
|
|
|
// Add 'href' so the button returns true on click and triggers ULS
|
|
|
|
'href': '#',
|
|
|
|
'flags': ['primary']
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Events
|
2014-02-20 20:36:52 +00:00
|
|
|
changeButton.$element.uls( {
|
2013-11-12 21:17:09 +00:00
|
|
|
'onSelect': ve.bind( function ( language ) {
|
2014-02-20 20:36:52 +00:00
|
|
|
this.setAnnotationFromValues( language, $.uls.data.getDir( language ) );
|
2013-11-12 21:17:09 +00:00
|
|
|
}, 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
|
2014-02-20 20:36:52 +00:00
|
|
|
this.$element.prepend( $( '<div>' ).addClass( 've-ui-mwLangugageInputWidget-uls' ).append( changeButton.$element ) );
|
2013-11-12 21:17:09 +00:00
|
|
|
};
|
2014-02-20 20:36:52 +00:00
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWLanguageInputWidget, ve.ui.LanguageInputWidget );
|