mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
4be0218bbb
New changes: a53f101 Update OOjs UI to v0.1.0 1fa518b Update OOjs UI to v0.1.0-pre (15f4156bac) 257af53 Use ContextWidget instead of toolbar inside context menu 5f10e73 Follow-up Ia2076a42: Mark getDescription() as @inheritable for Annotation, Node Local changes to adjust for the ContextWidget changes. Change-Id: I47f68f5cf1b9583dab9bd0109fa6504481bdfc67
71 lines
2 KiB
JavaScript
71 lines
2 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable MWInternalLinkAnnotation class.
|
|
*
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/*global mw */
|
|
|
|
/**
|
|
* ContentEditable MediaWiki internal link annotation.
|
|
*
|
|
* @class
|
|
* @extends ve.ce.LinkAnnotation
|
|
* @constructor
|
|
* @param {ve.dm.MWInternalLinkAnnotation} model Model to observe
|
|
* @param {ve.ce.ContentBranchNode} [parentNode] Node rendering this annotation
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ce.MWInternalLinkAnnotation = function VeCeMWInternalLinkAnnotation( model, parentNode, config ) {
|
|
var annotation = this;
|
|
// Parent constructor
|
|
ve.ce.LinkAnnotation.call( this, model, parentNode, config );
|
|
|
|
// DOM changes
|
|
this.$element.addClass( 've-ce-mwInternalLinkAnnotation' );
|
|
this.$element.attr( 'title', model.getAttribute( 'title' ) );
|
|
|
|
// Style based on link cache information
|
|
ve.init.platform.linkCache.get( model.getAttribute( 'lookupTitle' ) )
|
|
.done( function ( data ) {
|
|
if ( data.missing ) {
|
|
annotation.$element.addClass( 'new' );
|
|
}
|
|
} );
|
|
|
|
// HACK: Override href in case hrefPrefix isn't set
|
|
// This is a workaround for bug 58314 until such time as Parsoid gets rid of
|
|
// ../-prefixed hrefs.
|
|
if ( this.model.getAttribute( 'hrefPrefix' ) === undefined ) {
|
|
this.$element.attr( 'href', ve.resolveUrl(
|
|
// Repeat '../' wgPageName.split( '/' ).length - 1 times
|
|
// (= the number of slashes in wgPageName)
|
|
new Array( mw.config.get( 'wgPageName' ).split( '/' ).length ).join( '../' ) +
|
|
this.model.getHref(),
|
|
this.getModelHtmlDocument()
|
|
) );
|
|
}
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ce.MWInternalLinkAnnotation, ve.ce.LinkAnnotation );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ce.MWInternalLinkAnnotation.static.name = 'link/mwInternal';
|
|
|
|
/* Static Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ce.MWInternalLinkAnnotation.static.getDescription = function ( model ) {
|
|
return model.getAttribute( 'title' );
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.annotationFactory.register( ve.ce.MWInternalLinkAnnotation );
|