mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
34da7d56b8
New changes: 04a5947 Localisation updates from https://translatewiki.net. dd4691b Update OOjs to v1.1.5 2e1a0bb Context refactor Local changes: Add context item support for references, citations, templates and links Change-Id: I5d488ecbf9768dc63de6e545505dbfd5eb84cc61
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
/*!
|
|
* VisualEditor MWInternalLinkContextItem class.
|
|
*
|
|
* @copyright 2011-2015 VisualEditor Team and others; see http://ve.mit-license.org
|
|
*/
|
|
|
|
/**
|
|
* Context item for a MWInternalLink.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.LinkContextItem
|
|
*
|
|
* @constructor
|
|
* @param {ve.ui.Context} context Context item is in
|
|
* @param {ve.dm.Model} model Model item is related to
|
|
* @param {Object} config Configuration options
|
|
*/
|
|
ve.ui.MWInternalLinkContextItem = function VeMWInternalLinkContextItem( context, model, config ) {
|
|
// Parent constructor
|
|
ve.ui.MWInternalLinkContextItem.super.call( this, context, model, config );
|
|
|
|
// Initialization
|
|
this.$element.addClass( 've-ui-mwInternalLinkContextItem' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWInternalLinkContextItem, ve.ui.LinkContextItem );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.MWInternalLinkContextItem.static.name = 'link/internal';
|
|
|
|
ve.ui.MWInternalLinkContextItem.static.modelClasses = [ ve.dm.MWInternalLinkAnnotation ];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWInternalLinkContextItem.prototype.getDescription = function () {
|
|
return this.model.getAttribute( 'normalizedTitle' );
|
|
};
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWInternalLinkContextItem.prototype.renderBody = function () {
|
|
var $link = $( '<a>' )
|
|
.text( this.getDescription() )
|
|
.attr( {
|
|
href: this.model.getHref(),
|
|
target: '_blank'
|
|
} );
|
|
this.$body.empty().append( $link );
|
|
|
|
// Style based on link cache information
|
|
ve.init.platform.linkCache.styleElement( this.model.getAttribute( 'lookupTitle' ), $link );
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.contextItemFactory.register( ve.ui.MWInternalLinkContextItem );
|