2017-04-07 00:55:45 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWFlaggedMetaItem class.
|
|
|
|
*
|
2018-01-03 00:54:47 +00:00
|
|
|
* @copyright 2011-2018 VisualEditor Team and others; see AUTHORS.txt
|
2017-04-07 00:55:45 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DataModel flagged meta item abstract (for pairs of meta items).
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @abstract
|
|
|
|
* @extends ve.dm.MetaItem
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} [element] Reference to element in meta-linmod
|
|
|
|
*/
|
|
|
|
ve.dm.MWFlaggedMetaItem = function VeDmMWFlaggedMetaItem() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.dm.MWFlaggedMetaItem.super.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.dm.MWFlaggedMetaItem, ve.dm.MetaItem );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
/* No name/group/matchRdfaTypes, as this is not a valid meta item, just an abstract class. */
|
|
|
|
|
|
|
|
ve.dm.MWFlaggedMetaItem.static.matchTagNames = [ 'meta' ];
|
|
|
|
|
|
|
|
ve.dm.MWFlaggedMetaItem.static.toDataElement = function ( domElements ) {
|
2017-05-02 21:41:38 +00:00
|
|
|
var property = domElements[ 0 ].getAttribute( 'property' );
|
2017-04-07 00:55:45 +00:00
|
|
|
|
2017-05-02 21:41:38 +00:00
|
|
|
if ( !property || this.matchRdfaTypes.indexOf( property ) === -1 ) {
|
2017-04-07 00:55:45 +00:00
|
|
|
// Fallback to first match if somehow unset
|
2017-05-02 21:41:38 +00:00
|
|
|
property = this.matchRdfaTypes[ 0 ];
|
2017-04-07 00:55:45 +00:00
|
|
|
}
|
|
|
|
|
2017-05-02 21:41:38 +00:00
|
|
|
return { type: this.name, attributes: { property: property } };
|
2017-04-07 00:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ve.dm.MWFlaggedMetaItem.static.toDomElements = function ( dataElement, doc ) {
|
|
|
|
var meta = doc.createElement( 'meta' ),
|
2017-05-02 21:41:38 +00:00
|
|
|
property = OO.getProp( dataElement, 'attributes', 'property' );
|
2017-04-07 00:55:45 +00:00
|
|
|
|
2017-05-02 21:41:38 +00:00
|
|
|
if ( !property || this.matchRdfaTypes.indexOf( property ) === -1 ) {
|
2017-04-07 00:55:45 +00:00
|
|
|
// Fallback to first item if somehow unset
|
2017-05-02 21:41:38 +00:00
|
|
|
property = this.matchRdfaTypes[ 0 ];
|
2017-04-07 00:55:45 +00:00
|
|
|
}
|
|
|
|
|
2017-05-02 21:41:38 +00:00
|
|
|
meta.setAttribute( 'property', property );
|
2017-04-07 00:55:45 +00:00
|
|
|
|
|
|
|
return [ meta ];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* No registration, as this is not a valid meta item, just an abstract class. */
|