mediawiki-extensions-Visual.../modules/ve2/dm/annotations/ve.dm.LinkAnnotation.js
Trevor Parscal cc0c490502 Fix typo in LinkAnnotation
Change-Id: Idfb969a73c59aef1acf54edd61d555cdc295534c
2012-06-07 21:16:55 -07:00

46 lines
1 KiB
JavaScript

/**
* DataModel annotation for a link.
*
* @class
* @constructor
* @extends {ve.dm.Annotation}
*/
ve.dm.LinkAnnotation = function() {
// Inheritance
ve.dm.Annotation.call( this );
};
/* Static Members */
/**
* Converters.
*
* @see {ve.dm.Converter}
* @static
* @member
*/
ve.dm.LinkAnnotation.converters = {
'domElementTypes': ['a'],
'toDomElement': function( subType, annotation ) {
if ( annotation.type ) {
var link = document.createElement( 'a' );
link.setAttribute( 'data-type', 'link/' + subType );
return link;
}
},
'toDataAnnotation': function( tag, element ) {
// FIXME: the parser currently doesn't output this data this way
// Internal links get 'linkType': 'internal' in the data-mw-rt attrib, while external
// links currently get nothing
return { 'type': 'link/' + ( element.getAttribute( 'data-type' ) || 'unknown' ) };
}
};
/* Registration */
ve.dm.annotationFactory.register( 'link', ve.dm.LinkAnnotation );
/* Inheritance */
ve.extendClass( ve.dm.LinkAnnotation, ve.dm.Annotation );