2013-03-21 19:18:52 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWLanguageMetaItem class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2013 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 */
|
|
|
|
|
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-08-28 23:30:20 +00:00
|
|
|
ve.dm.MWLanguageMetaItem.static.matchRdfaTypes = [
|
|
|
|
'mw:WikiLink/Language', // old type, pre-bug 53432
|
|
|
|
'mw:PageProp/Language' // new type
|
|
|
|
];
|
2013-03-21 19:18:52 +00:00
|
|
|
|
|
|
|
ve.dm.MWLanguageMetaItem.static.toDataElement = function ( domElements ) {
|
|
|
|
var firstDomElement = domElements[0],
|
|
|
|
href = firstDomElement.getAttribute( 'href' );
|
|
|
|
return {
|
2013-05-28 11:31:41 +00:00
|
|
|
'type': 'mwLanguage',
|
2013-03-21 19:18:52 +00:00
|
|
|
'attributes': {
|
2013-10-17 13:48:37 +00:00
|
|
|
'href': href,
|
|
|
|
'origRel': firstDomElement.getAttribute( 'rel' )
|
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-10-17 13:48:37 +00:00
|
|
|
domElement.setAttribute( 'rel', dataElement.attributes.origRel || '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 );
|