2012-10-01 21:11:41 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor data model MWExternalLinkAnnotation class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2012-10-15 18:45:50 +00:00
|
|
|
* MediaWiki external link annotation.
|
|
|
|
*
|
|
|
|
* Example HTML sources:
|
|
|
|
* <a rel="mw:ExtLink">
|
|
|
|
* <a rel="mw:ExtLink/Numbered">
|
|
|
|
* <a rel="mw:ExtLink/URL">
|
|
|
|
*
|
|
|
|
* Each example is semantically slightly different, but don't need special treatment (yet).
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @extends {ve.dm.LinkAnnotation}
|
|
|
|
* @param {HTMLElement} element
|
2012-10-01 21:11:41 +00:00
|
|
|
*/
|
|
|
|
ve.dm.MWExternalLinkAnnotation = function VeDmMWExternalLinkAnnotation( element ) {
|
2012-10-15 18:45:50 +00:00
|
|
|
// Parent constructor
|
2012-10-01 21:11:41 +00:00
|
|
|
ve.dm.LinkAnnotation.call( this, element );
|
|
|
|
};
|
|
|
|
|
2012-10-15 18:45:50 +00:00
|
|
|
/* Inheritance */
|
|
|
|
|
2012-10-01 21:11:41 +00:00
|
|
|
ve.inheritClass( ve.dm.MWExternalLinkAnnotation, ve.dm.LinkAnnotation );
|
|
|
|
|
2012-10-15 18:45:50 +00:00
|
|
|
/* Static Members */
|
|
|
|
|
2012-10-01 21:11:41 +00:00
|
|
|
ve.dm.MWExternalLinkAnnotation.static.name = 'link/MWexternal';
|
|
|
|
|
2012-10-15 18:45:50 +00:00
|
|
|
ve.dm.MWExternalLinkAnnotation.static.matchRdfaTypes = [
|
|
|
|
'mw:ExtLink', 'mw:ExtLink/Numbered', 'mw:ExtLink/URL'
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert to an object with HTML element information.
|
|
|
|
*
|
|
|
|
* @method
|
|
|
|
* @returns {Object} HTML element information, including tag and attributes properties
|
|
|
|
*/
|
2012-10-01 21:11:41 +00:00
|
|
|
ve.dm.MWExternalLinkAnnotation.prototype.toHTML = function () {
|
|
|
|
var parentResult = ve.dm.LinkAnnotation.prototype.toHTML.call( this );
|
|
|
|
parentResult.attributes.rel = parentResult.attributes.rel || 'mw:ExtLink';
|
|
|
|
return parentResult;
|
|
|
|
};
|
|
|
|
|
2012-10-15 18:45:50 +00:00
|
|
|
/* Registration */
|
|
|
|
|
2012-10-01 21:11:41 +00:00
|
|
|
ve.dm.annotationFactory.register( 'link/MWexternal', ve.dm.MWExternalLinkAnnotation );
|