mediawiki-extensions-Visual.../modules/es/bases/es.DocumentModelLeafNode.js
Trevor Parscal 07af0cab63 * Moved getContent and getText from leaf nodes to document model nodes
* Renamed getContent to getContentData
* Renamed getText to getContentText
* Added getElementData
2011-12-05 19:41:04 +00:00

45 lines
1.2 KiB
JavaScript

/**
* Creates an es.DocumentModelLeafNode object.
*
* @class
* @abstract
* @constructor
* @extends {es.DocumentLeafNode}
* @extends {es.DocumentModelNode}
* @param {String} type Symbolic name of node type
* @param {Object} element Element object in document data
* @param {Integer} [length] Length of content data in document
*/
es.DocumentModelLeafNode = function( type, element, length ) {
// Inheritance
es.DocumentLeafNode.call( this );
es.DocumentModelNode.call( this, type, element, length );
// Properties
this.contentLength = length || 0;
};
/* Methods */
/**
* Gets a plain object representation of the document's data.
*
* @method
* @see {es.DocumentModelNode.getPlainObject}
* @see {es.DocumentModel.newFromPlainObject}
* @returns {Object} Plain object representation,
*/
es.DocumentModelLeafNode.prototype.getPlainObject = function() {
var obj = { 'type': this.type };
if ( this.element && this.element.attributes ) {
obj.attributes = es.copyObject( this.element.attributes );
}
obj.content = es.DocumentModel.getExpandedContentData( this.getContentData() );
return obj;
};
/* Inheritance */
es.extendClass( es.DocumentModelLeafNode, es.DocumentLeafNode );
es.extendClass( es.DocumentModelLeafNode, es.DocumentModelNode );