mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
cf1a889ac8
New changes: a047e72 [BREAKING CHANGE] Create ve.dm.Focusable and store focusable flag there Local changes: * Add new ve.dm.FocusableNode mixin where required Change-Id: Ie9ee2de05acfe3c4c62c4864e65bd20397d6a069
68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWNumberedExternalLinkNode class.
|
|
*
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel MediaWiki numbered external link node.
|
|
*
|
|
* @class
|
|
* @extends ve.dm.LeafNode
|
|
* @mixins ve.dm.FocusableNode
|
|
*
|
|
* @constructor
|
|
* @param {Object} [element] Reference to element in linear model
|
|
*/
|
|
ve.dm.MWNumberedExternalLinkNode = function VeDmMWNumberedExternalLinkNode() {
|
|
// Parent constructor
|
|
ve.dm.LeafNode.apply( this, arguments );
|
|
|
|
// Mixin constructors
|
|
ve.dm.FocusableNode.call( this );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.dm.MWNumberedExternalLinkNode, ve.dm.LeafNode );
|
|
|
|
OO.mixinClass( ve.dm.MWNumberedExternalLinkNode, ve.dm.FocusableNode );
|
|
|
|
/* 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' ];
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.blacklistedAnnotationTypes = [ 'link' ];
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.matchFunction = function ( element ) {
|
|
// Must be empty
|
|
return element.childNodes.length === 0;
|
|
};
|
|
|
|
ve.dm.MWNumberedExternalLinkNode.static.toDataElement = function ( domElements ) {
|
|
return {
|
|
type: this.name,
|
|
attributes: {
|
|
href: domElements[0].getAttribute( 'href' )
|
|
}
|
|
};
|
|
};
|
|
|
|
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 );
|