mediawiki-extensions-Visual.../modules/ve/dm/annotations/ve.dm.MWExternalLinkAnnotation.js
Catrope 0b55bb8cdc Move common Node/Annotation/MetaItem code into ve.dm.Model
ve.dm.Model is now the common base class for these three. ve.dm.Node
inherited from ve.Node before, so it now uses it as a mixin instead.
This required changing ve.Node's usage of ve.EventEmitter from
inhertiance to a mixin as well, because inherited methods apparently
don't get mixed in correctly.

* Change annotation terminology from linmodAnnotation to element for
  consistency with Node, MetaItem and Model
* Reimplement getClonedElement() in Node for .internal treatment

Change-Id: Ifd3922af23557c0b0f8984d36b31c8a1e2ec497e
2013-04-09 12:05:05 -07:00

56 lines
1.6 KiB
JavaScript

/*!
* VisualEditor DataModel MWExternalLinkAnnotation class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* DataModel MediaWiki external link annotation.
*
* Example HTML sources:
* <a rel="mw:ExtLink">
* <a rel="mw:ExtLink/Numbered">
* <a rel="mw:ExtLink/URL">
*
* Each example is semantically slightly different, but they don't need special treatment (yet).
*
* @class
* @extends ve.dm.LinkAnnotation
* @constructor
* @param {Object} element
*/
ve.dm.MWExternalLinkAnnotation = function VeDmMWExternalLinkAnnotation( element ) {
// Parent constructor
ve.dm.LinkAnnotation.call( this, element );
};
/* Inheritance */
ve.inheritClass( ve.dm.MWExternalLinkAnnotation, ve.dm.LinkAnnotation );
/* Static Properties */
ve.dm.MWExternalLinkAnnotation.static.name = 'link/MWexternal';
ve.dm.MWExternalLinkAnnotation.static.matchRdfaTypes = [
'mw:ExtLink', 'mw:ExtLink/Numbered', 'mw:ExtLink/URL'
];
ve.dm.MWExternalLinkAnnotation.static.toDataElement = function ( domElements ) {
var parentResult = ve.dm.LinkAnnotation.static.toDataElement.apply( this, arguments );
parentResult.type = 'link/MWexternal';
parentResult.attributes.rel = domElements[0].getAttribute( 'rel' );
return parentResult;
};
ve.dm.MWExternalLinkAnnotation.static.toDomElements = function ( dataElement ) {
var parentResult = ve.dm.LinkAnnotation.static.toDomElements( dataElement );
parentResult[0].setAttribute( 'rel', dataElement.attributes.rel || 'mw:ExtLink' );
return parentResult;
};
/* Registration */
ve.dm.modelRegistry.register( ve.dm.MWExternalLinkAnnotation );