mediawiki-extensions-Visual.../modules/ve2/dm/annotations/ve.dm.ObjectAnnotation.js
Trevor Parscal 042ffb4e3b Added foundation for new converter
* Added converters to all relevant node implementations
* Added new annotation objects with their own factory

Change-Id: I9870d6d5eac45083929d74d2e58917d0939ca917
2012-05-31 16:50:16 -07:00

44 lines
840 B
JavaScript

/**
* DataModel annotation for a object.
*
* @class
* @constructor
* @extends {ve.dm.Annotation}
*/
ve.dm.ObjectAnnotation = function() {
// Inheritance
ve.dm.Annotation.call( this );
};
/* Static Members */
/**
* Converters.
*
* @see {ve.dm.Converter}
* @static
* @member
*/
ve.dm.ObjectAnnotation.converters = {
'tags': ['template', 'hook'],
'html': {
'convert': function( subType, annotation ) {
return annotation.type &&
ve.dm.createHtmlElement( 'div', { 'data-type': subType } );
}
},
'data': {
'convert': function( tag, element ) {
return { 'type': 'object/' + ( element.getAttribute( 'data-type' ) || 'unknown' ) };
}
}
};
/* Registration */
ve.dm.annotationFactory.register( 'object', ve.dm.ObjectAnnotation );
/* Inheritance */
ve.extendClass( ve.dm.ObjectAnnotation, ve.dm.Annotation );