2013-10-17 20:15:36 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor ContentEditable MWNumberedExternalLinkNode class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-10-17 20:15:36 +00:00
|
|
|
* @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 );
|
|
|
|
|
|
|
|
// DOM changes
|
2013-11-22 17:01:32 +00:00
|
|
|
this.$element
|
|
|
|
.addClass( 've-ce-mwNumberedExternalLinkNode' )
|
|
|
|
// Need CE=false to prevent selection issues
|
|
|
|
.prop( 'contentEditable', 'false' );
|
2013-10-17 20:15:36 +00:00
|
|
|
|
|
|
|
// Add link
|
2013-11-22 17:01:32 +00:00
|
|
|
this.$link = this.$( '<a>' )
|
|
|
|
// CSS for numbering needs rel=mw:ExtLink
|
|
|
|
.attr( 'rel', 'mw:ExtLink' )
|
|
|
|
.appendTo( this.$element );
|
2013-10-17 20:15:36 +00:00
|
|
|
|
|
|
|
// 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 );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.ce.MWNumberedExternalLinkNode.static.name = 'link/mwNumberedExternal';
|
|
|
|
|
|
|
|
ve.ce.MWNumberedExternalLinkNode.static.tagName = 'span';
|
|
|
|
|
|
|
|
/* 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 );
|