All files / src/dm/annotations ve.dm.TextStyleAnnotation.js

100% Statements 23/23
100% Branches 8/8
100% Functions 6/6
100% Lines 23/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75                              1x   1456x         1x       1x   1x   1x 359x 359x               1x 356x   356x     1x             1x 603x     1x 3x 2x   1x     1x 2x 1x   1x         1x  
/*!
 * VisualEditor DataModel TextStyleAnnotation class.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * DataModel text style annotation.
 *
 * @class
 * @abstract
 * @extends ve.dm.Annotation
 * @constructor
 * @param {Object} element
 */
ve.dm.TextStyleAnnotation = function VeDmTextStyleAnnotation() {
	// Parent constructor
	ve.dm.TextStyleAnnotation.super.apply( this, arguments );
};
 
/* Inheritance */
 
OO.inheritClass( ve.dm.TextStyleAnnotation, ve.dm.Annotation );
 
/* Static Properties */
 
ve.dm.TextStyleAnnotation.static.name = 'textStyle';
 
ve.dm.TextStyleAnnotation.static.matchTagNames = [];
 
ve.dm.TextStyleAnnotation.static.toDataElement = function ( domElements, converter ) {
	var nodeName = converter.isFromClipboard() ? this.matchTagNames[ 0 ] : domElements[ 0 ].nodeName.toLowerCase();
	return {
		type: this.name,
		attributes: {
			nodeName: nodeName
		}
	};
};
 
ve.dm.TextStyleAnnotation.static.toDomElements = function ( dataElement, doc ) {
	var nodeName = ve.getProp( dataElement, 'attributes', 'nodeName' );
 
	return [ doc.createElement( nodeName || this.matchTagNames[ 0 ] ) ];
};
 
ve.dm.TextStyleAnnotation.static.description = null;
 
/* Methods */
 
/**
 * @return {Object}
 */
ve.dm.TextStyleAnnotation.prototype.getComparableObject = function () {
	return { type: this.getType() };
};
 
ve.dm.TextStyleAnnotation.prototype.describeAdded = function () {
	if ( this.constructor.static.description ) {
		return [ ve.msg( 'visualeditor-changedesc-textstyle-added', OO.ui.resolveMsg( this.constructor.static.description ) ) ];
	}
	return [];
};
 
ve.dm.TextStyleAnnotation.prototype.describeRemoved = function () {
	if ( this.constructor.static.description ) {
		return [ ve.msg( 'visualeditor-changedesc-textstyle-removed', OO.ui.resolveMsg( this.constructor.static.description ) ) ];
	}
	return [];
};
 
/* Registration */
 
ve.dm.modelRegistry.register( ve.dm.TextStyleAnnotation );