mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-14 18:15:19 +00:00
ada58df361
Change-Id: I3c618c196e504a80ca297a4132a17f1977a24fb7
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWLanguageMetaItem class.
|
|
*
|
|
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel language meta item.
|
|
*
|
|
* @class
|
|
* @extends ve.dm.MetaItem
|
|
* @constructor
|
|
* @param {Object} element Reference to element in meta-linmod
|
|
*/
|
|
ve.dm.MWLanguageMetaItem = function VeDmMWLanguageMetaItem( element ) {
|
|
// Parent constructor
|
|
ve.dm.MetaItem.call( this, element );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.dm.MWLanguageMetaItem, ve.dm.MetaItem );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.dm.MWLanguageMetaItem.static.name = 'mwLanguage';
|
|
|
|
ve.dm.MWLanguageMetaItem.static.matchTagNames = [ 'link' ];
|
|
|
|
ve.dm.MWLanguageMetaItem.static.matchRdfaTypes = [ 'mw:PageProp/Language' ];
|
|
|
|
ve.dm.MWLanguageMetaItem.static.toDataElement = function ( domElements ) {
|
|
var href = domElements[ 0 ].getAttribute( 'href' );
|
|
return {
|
|
type: this.name,
|
|
attributes: {
|
|
href: href
|
|
}
|
|
};
|
|
};
|
|
|
|
ve.dm.MWLanguageMetaItem.static.toDomElements = function ( dataElement, doc ) {
|
|
var domElement = doc.createElement( 'link' );
|
|
domElement.setAttribute( 'rel', 'mw:PageProp/Language' );
|
|
domElement.setAttribute( 'href', dataElement.attributes.href );
|
|
return [ domElement ];
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWLanguageMetaItem );
|