2013-03-21 19:18:52 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWLanguageMetaItem class.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; 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
|
|
|
|
*/
|
|
|
|
ve.dm.MWLanguageMetaItem = function VeDmMWLanguageMetaItem( element ) {
|
|
|
|
// Parent constructor
|
|
|
|
ve.dm.MetaItem.call( this, element );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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 ) {
|
2013-12-06 21:12:44 +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 );
|