mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
8f05cdbf70
Not having a description yet is fine, but they should at least be indexed as blocks so that they are searchable and listed in the jsduck generated pages. jsduck defaults to @method + name of prototype property. And it even guesses parameters sometimes. Search: \n\n([a-zA-Z\.]+\.prototype\.[a-zA-Z]+) Where: modules/ve,modules/ve-mw Where-Not: modules/ve/test Replace: \n\n/** */\n$1 Added @return in a few places where it was easy to add. Change-Id: I830c94cc7dbc261bd7a077391f930cbfff165f9d
69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWExternalLinkAnnotation class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* DataModel MediaWiki external link annotation.
|
|
*
|
|
* Example HTML sources:
|
|
* <a rel="mw:ExtLink">
|
|
* <a rel="mw:ExtLink/Numbered">
|
|
*
|
|
* Each example is semantically slightly different, but they don't need special treatment (yet).
|
|
*
|
|
* @class
|
|
* @extends ve.dm.LinkAnnotation
|
|
* @constructor
|
|
* @param {Object} element
|
|
*/
|
|
ve.dm.MWExternalLinkAnnotation = function VeDmMWExternalLinkAnnotation( element ) {
|
|
// Parent constructor
|
|
ve.dm.LinkAnnotation.call( this, element );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.dm.MWExternalLinkAnnotation, ve.dm.LinkAnnotation );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.dm.MWExternalLinkAnnotation.static.name = 'link/mwExternal';
|
|
|
|
ve.dm.MWExternalLinkAnnotation.static.matchRdfaTypes = [
|
|
'mw:ExtLink',
|
|
'mw:ExtLink/Numbered'
|
|
];
|
|
|
|
ve.dm.MWExternalLinkAnnotation.static.toDataElement = function ( domElements ) {
|
|
var parentResult = ve.dm.LinkAnnotation.static.toDataElement.apply( this, arguments );
|
|
parentResult.type = 'link/mwExternal';
|
|
parentResult.attributes.rel = domElements[0].getAttribute( 'rel' );
|
|
return parentResult;
|
|
};
|
|
|
|
ve.dm.MWExternalLinkAnnotation.static.toDomElements = function ( dataElement ) {
|
|
var parentResult = ve.dm.LinkAnnotation.static.toDomElements.apply( this, arguments );
|
|
parentResult[0].setAttribute( 'rel', dataElement.attributes.rel || 'mw:ExtLink' );
|
|
return parentResult;
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @return {Object}
|
|
*/
|
|
ve.dm.MWExternalLinkAnnotation.prototype.getComparableObject = function () {
|
|
return {
|
|
'type': this.getType(),
|
|
'href': this.getAttribute( 'href' ),
|
|
'rel': this.getAttribute( 'rel' ) || 'mw:ExtLink'
|
|
};
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.MWExternalLinkAnnotation );
|