2013-10-17 20:15:36 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor ContentEditable MWNumberedExternalLinkNode class.
|
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 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
|
2014-09-17 00:33:39 +00:00
|
|
|
* @mixins ve.ce.FocusableNode
|
2013-10-17 20:15:36 +00:00
|
|
|
* @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.FocusableNode.call( this );
|
|
|
|
|
|
|
|
// DOM changes
|
2015-08-31 16:26:49 +00:00
|
|
|
this.$element.addClass( 've-ce-mwNumberedExternalLinkNode' );
|
2013-10-17 20:15:36 +00:00
|
|
|
|
|
|
|
// Add link
|
2015-04-09 23:47:15 +00:00
|
|
|
this.$link = $( '<a>' )
|
2013-11-22 17:01:32 +00:00
|
|
|
// CSS for numbering needs rel=mw:ExtLink
|
|
|
|
.attr( 'rel', 'mw:ExtLink' )
|
2014-06-02 21:01:01 +00:00
|
|
|
.addClass( 'external' )
|
2013-11-22 17:01:32 +00:00
|
|
|
.appendTo( this.$element );
|
2013-10-17 20:15:36 +00:00
|
|
|
|
|
|
|
// Events
|
2014-08-22 20:50:48 +00:00
|
|
|
this.model.connect( this, { update: 'onUpdate' } );
|
2013-10-17 20:15:36 +00:00
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.onUpdate();
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ce.MWNumberedExternalLinkNode, ve.ce.LeafNode );
|
|
|
|
|
|
|
|
OO.mixinClass( ve.ce.MWNumberedExternalLinkNode, ve.ce.FocusableNode );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.ce.MWNumberedExternalLinkNode.static.name = 'link/mwNumberedExternal';
|
|
|
|
|
|
|
|
ve.ce.MWNumberedExternalLinkNode.static.tagName = 'span';
|
|
|
|
|
2014-10-22 02:44:27 +00:00
|
|
|
ve.ce.MWNumberedExternalLinkNode.static.primaryCommandName = 'link';
|
2013-12-20 23:25:24 +00:00
|
|
|
|
2014-06-10 01:18:23 +00:00
|
|
|
/* Static Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.ce.MWNumberedExternalLinkNode.static.getDescription = function ( model ) {
|
|
|
|
return model.getAttribute( 'href' );
|
|
|
|
};
|
|
|
|
|
2013-10-17 20:15:36 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle model update events.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ce.MWNumberedExternalLinkNode.prototype.onUpdate = function () {
|
|
|
|
this.$link.attr( 'href', this.model.getAttribute( 'href' ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ce.nodeFactory.register( ve.ce.MWNumberedExternalLinkNode );
|