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
|
|
|
|
* @cfg {string} [pagename] Pagename to return the names of internal pages
|
2014-11-20 17:05:47 +00:00
|
|
|
* @cfg {string} [imageUrl] Thumbnail image URL with URL encoding
|
|
|
|
* @cfg {string} [description] Page description
|
2014-11-06 01:18:37 +00:00
|
|
|
*/
|
2014-11-22 01:40:00 +00:00
|
|
|
ve.ui.MWInternalLinkMenuOptionWidget = function VeUiMWInternalLinkMenuOptionWidget( config ) {
|
2014-11-21 13:00:50 +00:00
|
|
|
// Config initialization
|
2015-04-28 15:26:42 +00:00
|
|
|
config = ve.extendObject( { icon: 'page-existing' }, config );
|
2014-11-06 01:18:37 +00:00
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.pagename = config.pagename;
|
|
|
|
|
|
|
|
// Parent constructor
|
2014-11-22 01:40:00 +00:00
|
|
|
ve.ui.MWLinkMenuOptionWidget.call( this, $.extend( { label: this.pagename, href: mw.util.getUrl( this.pagename ) }, config ) );
|
2014-11-06 01:18:37 +00:00
|
|
|
|
|
|
|
// Style based on link cache information
|
|
|
|
ve.init.platform.linkCache.styleElement( this.pagename, 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 );
|