2013-03-21 19:18:52 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWLanguageMetaItem class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2013-03-21 19:18:52 +00:00
|
|
|
* @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
|
|
|
|
*/
|
2016-08-22 21:44:59 +00:00
|
|
|
ve.dm.MWLanguageMetaItem = function VeDmMWLanguageMetaItem() {
|
2013-03-21 19:18:52 +00:00
|
|
|
// Parent constructor
|
2016-08-22 21:44:59 +00:00
|
|
|
ve.dm.MWLanguageMetaItem.super.apply( this, arguments );
|
2013-03-21 19:18:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.dm.MWLanguageMetaItem, ve.dm.MetaItem );
|
2013-03-21 19:18:52 +00:00
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
2013-05-28 11:31:41 +00:00
|
|
|
ve.dm.MWLanguageMetaItem.static.name = 'mwLanguage';
|
2013-03-21 19:18:52 +00:00
|
|
|
|
|
|
|
ve.dm.MWLanguageMetaItem.static.matchTagNames = [ 'link' ];
|
|
|
|
|
2013-12-06 21:12:44 +00:00
|
|
|
ve.dm.MWLanguageMetaItem.static.matchRdfaTypes = [ 'mw:PageProp/Language' ];
|
2013-03-21 19:18:52 +00:00
|
|
|
|
|
|
|
ve.dm.MWLanguageMetaItem.static.toDataElement = function ( domElements ) {
|
2015-08-19 17:33:02 +00:00
|
|
|
var href = domElements[ 0 ].getAttribute( 'href' );
|
2013-03-21 19:18:52 +00:00
|
|
|
return {
|
2014-08-22 20:50:48 +00:00
|
|
|
type: this.name,
|
|
|
|
attributes: {
|
|
|
|
href: href
|
2013-03-21 19:18:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-04-02 20:23:16 +00:00
|
|
|
ve.dm.MWLanguageMetaItem.static.toDomElements = function ( dataElement, doc ) {
|
|
|
|
var domElement = doc.createElement( 'link' );
|
2013-12-06 21:12:44 +00:00
|
|
|
domElement.setAttribute( 'rel', 'mw:PageProp/Language' );
|
2013-03-21 19:18:52 +00:00
|
|
|
domElement.setAttribute( 'href', dataElement.attributes.href );
|
|
|
|
return [ domElement ];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWLanguageMetaItem );
|