2013-10-17 20:15:36 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWNumberedExternalLinkNode class.
|
|
|
|
*
|
2016-01-03 22:56:59 +00:00
|
|
|
* @copyright 2011-2016 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' ];
|
|
|
|
|
2016-03-17 15:30:59 +00:00
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.matchFunction = function ( domElement ) {
|
2013-10-17 20:15:36 +00:00
|
|
|
// Must be empty
|
2016-03-17 15:30:59 +00:00
|
|
|
return domElement.childNodes.length === 0;
|
2013-10-17 20:15:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.toDataElement = function ( domElements ) {
|
|
|
|
return {
|
2014-08-22 20:50:48 +00:00
|
|
|
type: this.name,
|
|
|
|
attributes: {
|
2015-08-19 17:33:02 +00:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
|
2015-08-13 00:58:23 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience wrapper for .getHref() on the current element.
|
|
|
|
*
|
|
|
|
* @return {string} Link href
|
|
|
|
*/
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.prototype.getHref = function () {
|
|
|
|
return this.element.attributes.href;
|
|
|
|
};
|
|
|
|
|
2013-10-17 20:15:36 +00:00
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWNumberedExternalLinkNode );
|