Page MenuHomeWickedGov Phorge

ve.dm.DatetimeAnnotation.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

ve.dm.DatetimeAnnotation.js

/*!
* VisualEditor DataModel DatetimeAnnotation class.
*
* @copyright See AUTHORS.txt
*/
/**
* DataModel datetime annotation.
*
* Represents `<time>` tags.
*
* @class
* @extends ve.dm.TextStyleAnnotation
* @constructor
* @param {Object} element
*/
ve.dm.DatetimeAnnotation = function VeDmDatetimeAnnotation() {
// Parent constructor
ve.dm.DatetimeAnnotation.super.apply( this, arguments );
};
/* Inheritance */
OO.inheritClass( ve.dm.DatetimeAnnotation, ve.dm.TextStyleAnnotation );
/* Static Properties */
ve.dm.DatetimeAnnotation.static.name = 'textStyle/datetime';
ve.dm.DatetimeAnnotation.static.matchTagNames = [ 'time' ];
ve.dm.DatetimeAnnotation.static.toDataElement = function ( domElements ) {
// Parent method
const dataElement = ve.dm.DatetimeAnnotation.super.static.toDataElement.apply( this, arguments );
dataElement.attributes.datetime = domElements[ 0 ].getAttribute( 'datetime' );
return dataElement;
};
ve.dm.DatetimeAnnotation.static.toDomElements = function ( dataElement, doc ) {
const domElement = doc.createElement( 'time' );
if ( dataElement.attributes.datetime ) {
// If it's null, don't bother creating a blank attribute; <time> alone is valid
domElement.setAttribute( 'datetime', dataElement.attributes.datetime );
}
return [ domElement ];
};
/* Methods */
/**
* @inheritdoc
*/
ve.dm.DatetimeAnnotation.prototype.getComparableObject = function () {
return {
type: this.getType(),
datetime: this.getAttribute( 'datetime' )
};
};
/* Registration */
ve.dm.modelRegistry.register( ve.dm.DatetimeAnnotation );

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 22, 19:53 (1 d, 20 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b3/a8/ce81beb37732156c66b2d785c093
Default Alt Text
ve.dm.DatetimeAnnotation.js (1 KB)

Event Timeline