2013-06-18 21:24:16 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWTitleInputWidget class.
|
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
2013-06-18 21:24:16 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2015-05-25 13:51:13 +00:00
|
|
|
* Thin wrapper around mw.widgets.TitleInputWidget
|
2013-06-18 21:24:16 +00:00
|
|
|
*
|
|
|
|
* @class
|
2015-05-25 13:51:13 +00:00
|
|
|
* @extends mw.widgets.TitleInputWidget
|
2013-06-18 21:24:16 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-06-18 21:24:16 +00:00
|
|
|
*/
|
|
|
|
ve.ui.MWTitleInputWidget = function VeUiMWTitleInputWidget( config ) {
|
|
|
|
// Parent constructor
|
2015-05-25 13:51:13 +00:00
|
|
|
ve.ui.MWTitleInputWidget.super.call( this, config );
|
2015-06-06 11:17:32 +00:00
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.$element.addClass( 've-ui-mwTitleInputWidget' );
|
|
|
|
this.lookupMenu.$element.addClass( 've-ui-mwTitleInputWidget-menu' );
|
2013-06-18 21:24:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2015-05-25 13:51:13 +00:00
|
|
|
OO.inheritClass( ve.ui.MWTitleInputWidget, mw.widgets.TitleInputWidget );
|
2013-06-18 21:24:16 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
2015-05-25 13:51:13 +00:00
|
|
|
* Get a list of menu option widgets from the (possibly cached) data returned by
|
|
|
|
* #getLookupCacheDataFromResponse.
|
|
|
|
*
|
|
|
|
* See the parent documentation at <https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.widgets.TitleInputWidget>
|
|
|
|
*
|
|
|
|
* @param {Mixed} data Cached result data, usually an array
|
|
|
|
* @return {OO.ui.MenuOptionWidget[]} Menu items
|
2013-06-18 21:24:16 +00:00
|
|
|
*/
|
2015-01-15 22:07:34 +00:00
|
|
|
ve.ui.MWTitleInputWidget.prototype.getLookupMenuOptionsFromData = function ( data ) {
|
2015-05-25 13:51:13 +00:00
|
|
|
var i, len,
|
2014-09-09 22:08:14 +00:00
|
|
|
linkCacheUpdate = {};
|
2015-05-25 13:51:13 +00:00
|
|
|
if ( data && data.length ) {
|
|
|
|
for ( i = 0, len = data.length; i < len; i++ ) {
|
|
|
|
linkCacheUpdate[data[i]] = { missing: false };
|
2013-06-18 21:24:16 +00:00
|
|
|
}
|
2014-09-09 22:08:14 +00:00
|
|
|
ve.init.platform.linkCache.set( linkCacheUpdate );
|
2013-06-18 21:24:16 +00:00
|
|
|
}
|
|
|
|
|
2015-05-25 13:51:13 +00:00
|
|
|
return ve.ui.MWTitleInputWidget.super.prototype.getLookupMenuOptionsFromData.apply( this, arguments );
|
2014-10-28 23:38:28 +00:00
|
|
|
};
|