2015-05-03 21:21:00 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWInternalLinkAnnotationWidget class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an ve.ui.MWInternalLinkAnnotationWidget object.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.LinkAnnotationWidget
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
ve.ui.MWInternalLinkAnnotationWidget = function VeUiMWInternalLinkAnnotationWidget() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ui.MWInternalLinkAnnotationWidget.super.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWInternalLinkAnnotationWidget, ve.ui.LinkAnnotationWidget );
|
|
|
|
|
2015-05-29 12:08:05 +00:00
|
|
|
/* Static Methods */
|
2015-05-03 21:21:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2015-05-29 12:08:05 +00:00
|
|
|
ve.ui.MWInternalLinkAnnotationWidget.static.getAnnotationFromText = function ( value ) {
|
2015-08-25 15:39:32 +00:00
|
|
|
var title = mw.Title.newFromText( value.trim() );
|
2015-05-03 21:21:00 +00:00
|
|
|
|
2015-08-25 15:39:32 +00:00
|
|
|
if ( !title ) {
|
2015-05-03 21:21:00 +00:00
|
|
|
return null;
|
|
|
|
}
|
2015-08-25 15:39:32 +00:00
|
|
|
return ve.dm.MWInternalLinkAnnotation.static.newFromTitle( title );
|
2015-05-03 21:21:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2015-05-29 12:08:05 +00:00
|
|
|
ve.ui.MWInternalLinkAnnotationWidget.static.getTextFromAnnotation = function ( annotation ) {
|
2015-05-03 21:21:00 +00:00
|
|
|
return annotation ? annotation.getAttribute( 'title' ) : '';
|
|
|
|
};
|
2015-05-29 12:08:05 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a text input widget to be used by the annotation widget
|
|
|
|
*
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
* @return {OO.ui.TextInputWidget} Text input widget
|
|
|
|
*/
|
|
|
|
ve.ui.MWInternalLinkAnnotationWidget.prototype.createInputWidget = function ( config ) {
|
2015-09-25 20:29:10 +00:00
|
|
|
return new mw.widgets.TitleSearchWidget( ve.extendObject( {
|
2015-05-29 12:08:05 +00:00
|
|
|
icon: 'search',
|
2015-10-14 16:24:10 +00:00
|
|
|
showRedlink: true,
|
2015-06-15 10:25:44 +00:00
|
|
|
showImages: mw.config.get( 'wgVisualEditor' ).usePageImages,
|
|
|
|
showDescriptions: mw.config.get( 'wgVisualEditor' ).usePageDescriptions,
|
|
|
|
cache: ve.init.platform.linkCache
|
2015-09-25 20:29:10 +00:00
|
|
|
}, config ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWInternalLinkAnnotationWidget.prototype.getTextInputWidget = function () {
|
|
|
|
return this.input.query;
|
2015-05-29 12:08:05 +00:00
|
|
|
};
|
2015-06-23 21:06:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ui.MWInternalLinkAnnotationWidget.prototype.getHref = function () {
|
|
|
|
var title = ve.ui.MWInternalLinkAnnotationWidget.super.prototype.getHref.call( this );
|
|
|
|
return mw.util.getUrl( title );
|
|
|
|
};
|