mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-04 18:58:37 +00:00
57a06a6e75
We're getting rid of meta item grouping, so we need to prepare. Merged: * ve.dm.MWIndexMetaItem from ve.dm.MWIndexDisableMetaItem and ve.dm.MWIndexForceMetaItem * ve.dm.MWNewSectionEditMetaItem from ve.dm.MWNewSectionEditDisableMetaItem and ve.dm.MWNewSectionEditForceMetaItem * ve.dm.MWTOCMetaItem from ve.dm.MWTOCDisableMetaItem and ve.dm.MWTOCForceMetaItem These three now inherit from ve.dm.MWFlaggedMetaItem to avoid code duplication. Change-Id: Ic8a9cdb1226dccac2c27e7f4b965c1590a7387c0
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWFlaggedMetaItem class.
|
|
*
|
|
* @copyright 2011-2017 VisualEditor Team and others; see AUTHORS.txt
|
|
* @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 ) {
|
|
var type = domElements[ 0 ].getAttribute( 'property' );
|
|
|
|
if ( !type || this.matchRdfaTypes.indexOf( type ) === -1 ) {
|
|
// Fallback to first match if somehow unset
|
|
type = this.matchRdfaTypes[ 0 ];
|
|
}
|
|
|
|
return { type: this.name, attributes: { type: type } };
|
|
};
|
|
|
|
ve.dm.MWFlaggedMetaItem.static.toDomElements = function ( dataElement, doc ) {
|
|
var meta = doc.createElement( 'meta' ),
|
|
type = OO.getProp( dataElement, 'attributes', 'property' );
|
|
|
|
if ( !type || this.matchRdfaTypes.indexOf( type ) === -1 ) {
|
|
// Fallback to first item if somehow unset
|
|
type = this.matchRdfaTypes[ 0 ];
|
|
}
|
|
|
|
meta.setAttribute( 'property', type );
|
|
|
|
return [ meta ];
|
|
};
|
|
|
|
/* No registration, as this is not a valid meta item, just an abstract class. */
|