2013-01-25 04:09:53 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel AlienNode, AlienBlockNode and AlienInlineNode classes.
|
|
|
|
*
|
2013-02-19 23:37:34 +00:00
|
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
2013-01-25 04:09:53 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DataModel alien node.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @abstract
|
2013-05-29 01:35:42 +00:00
|
|
|
* @extends ve.dm.LeafNode
|
|
|
|
* @mixins ve.dm.GeneratedContentNode
|
|
|
|
*
|
2013-01-25 04:09:53 +00:00
|
|
|
* @constructor
|
|
|
|
* @param {number} [length] Length of content data in document; ignored and overridden to 0
|
|
|
|
* @param {Object} [element] Reference to element in linear model
|
|
|
|
*/
|
2013-03-06 22:44:18 +00:00
|
|
|
ve.dm.AlienNode = function VeDmAlienNode( length, element ) {
|
2013-01-25 04:09:53 +00:00
|
|
|
// Parent constructor
|
2013-05-29 01:35:42 +00:00
|
|
|
ve.dm.LeafNode.call( this, 0, element );
|
|
|
|
|
|
|
|
// Mixin constructors
|
|
|
|
ve.dm.GeneratedContentNode.call( this );
|
2013-01-25 04:09:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-05-29 01:35:42 +00:00
|
|
|
ve.inheritClass( ve.dm.AlienNode, ve.dm.LeafNode );
|
|
|
|
|
|
|
|
ve.mixinClass( ve.dm.AlienNode, ve.dm.GeneratedContentNode );
|
2013-01-25 04:09:53 +00:00
|
|
|
|
|
|
|
/* Static members */
|
|
|
|
|
|
|
|
ve.dm.AlienNode.static.name = 'alien';
|
|
|
|
|
2013-02-16 01:42:25 +00:00
|
|
|
ve.dm.AlienNode.static.storeHtmlAttributes = false;
|
|
|
|
|
2013-06-24 16:27:35 +00:00
|
|
|
ve.dm.AlienNode.static.enableAboutGrouping = true;
|
2013-04-03 22:59:46 +00:00
|
|
|
|
2013-04-10 21:54:29 +00:00
|
|
|
ve.dm.AlienNode.static.toDataElement = function ( domElements, converter ) {
|
2013-04-13 21:22:26 +00:00
|
|
|
var isInline = this.isHybridInline( domElements, converter ),
|
2013-04-27 11:59:04 +00:00
|
|
|
type = isInline ? 'alienInline' : 'alienBlock';
|
2013-02-16 02:37:50 +00:00
|
|
|
|
2013-01-25 04:09:53 +00:00
|
|
|
return {
|
|
|
|
'type': type,
|
|
|
|
'attributes': {
|
2013-07-28 20:51:32 +00:00
|
|
|
'domElements': ve.copy( domElements )
|
2013-01-25 04:09:53 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-06-18 18:51:39 +00:00
|
|
|
ve.dm.AlienNode.static.toDomElements = function ( dataElement, doc ) {
|
|
|
|
return ve.copyDomElements( dataElement.attributes.domElements, doc );
|
2013-01-25 04:09:53 +00:00
|
|
|
};
|
|
|
|
|
2013-08-27 20:44:28 +00:00
|
|
|
ve.dm.AlienNode.static.getHashObject = function ( dataElement ) {
|
|
|
|
var parentResult = ve.dm.LeafNode.static.getHashObject( dataElement );
|
|
|
|
if ( parentResult.attributes && parentResult.attributes.domElements ) {
|
|
|
|
// If present, replace domElements with a DOM summary
|
|
|
|
parentResult.attributes = ve.copy( parentResult.attributes );
|
|
|
|
parentResult.attributes.domElements = ve.copy(
|
|
|
|
parentResult.attributes.domElements, ve.convertDomElements
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return parentResult;
|
|
|
|
};
|
|
|
|
|
2013-01-25 04:09:53 +00:00
|
|
|
/* Concrete subclasses */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DataModel alienBlock node.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.dm.AlienNode
|
|
|
|
* @constructor
|
|
|
|
* @param {number} [length] Length of content data in document; ignored and overridden to 0
|
|
|
|
* @param {Object} [element] Reference to element in linear model
|
|
|
|
*/
|
|
|
|
ve.dm.AlienBlockNode = function VeDmAlienBlockNode( length, element ) {
|
|
|
|
// Parent constructor
|
2013-03-06 22:44:18 +00:00
|
|
|
ve.dm.AlienNode.call( this, length, element );
|
2013-01-25 04:09:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ve.inheritClass( ve.dm.AlienBlockNode, ve.dm.AlienNode );
|
|
|
|
|
|
|
|
ve.dm.AlienBlockNode.static.name = 'alienBlock';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DataModel alienInline node.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.dm.AlienNode
|
|
|
|
* @constructor
|
|
|
|
* @param {number} [length] Length of content data in document; ignored and overridden to 0
|
|
|
|
* @param {Object} [element] Reference to element in linear model
|
|
|
|
*/
|
|
|
|
ve.dm.AlienInlineNode = function VeDmAlienInlineNode( length, element ) {
|
|
|
|
// Parent constructor
|
2013-03-06 22:44:18 +00:00
|
|
|
ve.dm.AlienNode.call( this, length, element );
|
2013-01-25 04:09:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ve.inheritClass( ve.dm.AlienInlineNode, ve.dm.AlienNode );
|
|
|
|
|
|
|
|
ve.dm.AlienInlineNode.static.name = 'alienInline';
|
|
|
|
|
|
|
|
ve.dm.AlienInlineNode.static.isContent = true;
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.AlienNode );
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.AlienBlockNode );
|
|
|
|
ve.dm.modelRegistry.register( ve.dm.AlienInlineNode );
|