2013-10-17 20:15:36 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DataModel MediaWiki numbered external link node.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.dm.LeafNode
|
2014-09-17 00:33:39 +00:00
|
|
|
* @mixins ve.dm.FocusableNode
|
2014-06-07 03:17:26 +00:00
|
|
|
*
|
2013-10-17 20:15:36 +00:00
|
|
|
* @constructor
|
|
|
|
* @param {Object} [element] Reference to element in linear model
|
|
|
|
*/
|
2014-06-07 03:17:26 +00:00
|
|
|
ve.dm.MWNumberedExternalLinkNode = function VeDmMWNumberedExternalLinkNode() {
|
2013-10-17 20:15:36 +00:00
|
|
|
// Parent constructor
|
2014-06-07 03:17:26 +00:00
|
|
|
ve.dm.LeafNode.apply( this, arguments );
|
2014-09-17 00:33:39 +00:00
|
|
|
|
|
|
|
// Mixin constructors
|
|
|
|
ve.dm.FocusableNode.call( this );
|
2013-10-17 20:15:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.dm.MWNumberedExternalLinkNode, ve.dm.LeafNode );
|
|
|
|
|
2014-09-17 00:33:39 +00:00
|
|
|
OO.mixinClass( ve.dm.MWNumberedExternalLinkNode, ve.dm.FocusableNode );
|
|
|
|
|
2013-10-17 20:15:36 +00:00
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.name = 'link/mwNumberedExternal';
|
|
|
|
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.isContent = true;
|
|
|
|
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.matchTagNames = [ 'a' ];
|
|
|
|
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.matchRdfaTypes = [ 'mw:ExtLink' ];
|
|
|
|
|
2014-08-02 10:34:30 +00:00
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.blacklistedAnnotationTypes = [ 'link' ];
|
|
|
|
|
2013-10-17 20:15:36 +00:00
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.matchFunction = function ( element ) {
|
|
|
|
// Must be empty
|
|
|
|
return element.childNodes.length === 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.toDataElement = function ( domElements ) {
|
|
|
|
return {
|
2014-08-22 20:50:48 +00:00
|
|
|
type: this.name,
|
|
|
|
attributes: {
|
|
|
|
href: domElements[0].getAttribute( 'href' )
|
2013-10-17 20:15:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.toDomElements = function ( dataElement, doc ) {
|
|
|
|
var domElement = doc.createElement( 'a' );
|
|
|
|
domElement.setAttribute( 'href', dataElement.attributes.href );
|
|
|
|
domElement.setAttribute( 'rel', 'mw:ExtLink' );
|
|
|
|
return [ domElement ];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWNumberedExternalLinkNode );
|