2014-11-06 01:18:37 +00:00
|
|
|
/*!
|
2014-11-20 17:05:47 +00:00
|
|
|
* VisualEditor UserInterface MWInternalLinkMenuOptionWidget class.
|
2014-11-06 01:18:37 +00:00
|
|
|
*
|
2014-11-20 17:05:47 +00:00
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
2014-11-06 01:18:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-11-20 01:02:44 +00:00
|
|
|
* Creates a ve.ui.MWInternalLinkMenuOptionWidget object.
|
2014-11-06 01:18:37 +00:00
|
|
|
*
|
|
|
|
* @class
|
2014-11-20 01:02:44 +00:00
|
|
|
* @extends ve.ui.MWLinkMenuOptionWidget
|
2014-11-06 01:18:37 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [config] Configuration options
|
2015-05-03 21:21:00 +00:00
|
|
|
* @cfg {string} [data] Page title
|
2014-11-20 17:05:47 +00:00
|
|
|
* @cfg {string} [imageUrl] Thumbnail image URL with URL encoding
|
|
|
|
* @cfg {string} [description] Page description
|
2015-05-03 21:21:00 +00:00
|
|
|
* @cfg {string} [query] Matching query string
|
2014-11-06 01:18:37 +00:00
|
|
|
*/
|
2014-11-22 01:40:00 +00:00
|
|
|
ve.ui.MWInternalLinkMenuOptionWidget = function VeUiMWInternalLinkMenuOptionWidget( config ) {
|
2015-05-03 21:21:00 +00:00
|
|
|
var title = config.data;
|
2014-11-06 01:18:37 +00:00
|
|
|
|
2015-05-03 21:21:00 +00:00
|
|
|
// Config initialization
|
|
|
|
config = ve.extendObject( {
|
|
|
|
icon: 'page-existing',
|
|
|
|
label: title,
|
|
|
|
href: mw.util.getUrl( title ),
|
|
|
|
autoFitLabel: false
|
|
|
|
}, config );
|
2014-11-06 01:18:37 +00:00
|
|
|
|
|
|
|
// Parent constructor
|
2015-05-03 21:21:00 +00:00
|
|
|
ve.ui.MWInternalLinkMenuOptionWidget.super.call( this, config );
|
|
|
|
|
|
|
|
// Highlight matching parts of link suggestion
|
|
|
|
this.$label.autoEllipsis( { hasSpan: false, tooltip: true, matchText: config.query } );
|
2014-11-06 01:18:37 +00:00
|
|
|
|
|
|
|
// Style based on link cache information
|
2015-05-03 21:21:00 +00:00
|
|
|
ve.init.platform.linkCache.styleElement( title, this.$link );
|
2014-11-20 17:05:47 +00:00
|
|
|
|
|
|
|
// Intialization
|
|
|
|
this.$element.addClass( 've-ui-mwInternalLinkMenuOptionWidget' );
|
|
|
|
|
|
|
|
if ( config.imageUrl ) {
|
|
|
|
this.$icon
|
|
|
|
.addClass( 've-ui-mwInternalLinkMenuOptionWidget-hasImage' )
|
|
|
|
.css( 'background-image', 'url(' + config.imageUrl + ')' );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( config.description ) {
|
|
|
|
this.$element.append(
|
|
|
|
$( '<span>' )
|
|
|
|
.addClass( 've-ui-mwInternalLinkMenuOptionWidget-description' )
|
|
|
|
.text( config.description )
|
|
|
|
);
|
|
|
|
}
|
2014-11-06 01:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2014-11-20 01:02:44 +00:00
|
|
|
OO.inheritClass( ve.ui.MWInternalLinkMenuOptionWidget, ve.ui.MWLinkMenuOptionWidget );
|