mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
172ebb839e
This inspector isn't designed for insertion mode yet; attempting to use it in insertion mode causes nasty JS errors. Bonus: * Make its tool title "Simple link" rather than "Link", for when we do reintroduce it. * Make double-clicking / pressing enter while selecting a link node open the link node inspector rather than the link annotation inspector. * Make link nodes render with MW's external link arrow icon * Move the link node inspector's messages to the right RL module Bug: 66047 Change-Id: Ib94da7ed3a2a88297dbdd1529f20cd8dab7c8421
78 lines
2.1 KiB
JavaScript
78 lines
2.1 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable MWNumberedExternalLinkNode class.
|
|
*
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* ContentEditable MediaWiki numbered external link node.
|
|
*
|
|
* @class
|
|
* @extends ve.ce.LeafNode
|
|
* @constructor
|
|
* @param {ve.dm.MWNumberedExternalLinkNode} model Model to observe
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ce.MWNumberedExternalLinkNode = function VeCeMWNumberedExternalLinkNode( model, config ) {
|
|
// Parent constructor
|
|
ve.ce.LeafNode.call( this, model, config );
|
|
|
|
// Mixin constructors
|
|
ve.ce.ProtectedNode.call( this );
|
|
ve.ce.FocusableNode.call( this );
|
|
ve.ce.ClickableNode.call( this );
|
|
|
|
// DOM changes
|
|
this.$element
|
|
.addClass( 've-ce-mwNumberedExternalLinkNode' )
|
|
// Need CE=false to prevent selection issues
|
|
.prop( 'contentEditable', 'false' );
|
|
|
|
// Add link
|
|
this.$link = this.$( '<a>' )
|
|
// CSS for numbering needs rel=mw:ExtLink
|
|
.attr( 'rel', 'mw:ExtLink' )
|
|
.addClass( 'external' )
|
|
.appendTo( this.$element );
|
|
|
|
// Events
|
|
this.model.connect( this, { 'update': 'onUpdate' } );
|
|
|
|
// Initialization
|
|
this.onUpdate();
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ce.MWNumberedExternalLinkNode, ve.ce.LeafNode );
|
|
|
|
OO.mixinClass( ve.ce.MWNumberedExternalLinkNode, ve.ce.ProtectedNode );
|
|
OO.mixinClass( ve.ce.MWNumberedExternalLinkNode, ve.ce.FocusableNode );
|
|
OO.mixinClass( ve.ce.MWNumberedExternalLinkNode, ve.ce.ClickableNode );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ce.MWNumberedExternalLinkNode.static.name = 'link/mwNumberedExternal';
|
|
|
|
ve.ce.MWNumberedExternalLinkNode.static.tagName = 'span';
|
|
|
|
ve.ce.MWNumberedExternalLinkNode.static.primaryCommandName = 'linkNode';
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handle model update events.
|
|
*
|
|
* If the source changed since last update the image's src attribute will be updated accordingly.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ce.MWNumberedExternalLinkNode.prototype.onUpdate = function () {
|
|
this.$link.attr( 'href', this.model.getAttribute( 'href' ) );
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWNumberedExternalLinkNode );
|