2011-11-03 21:48:40 +00:00
|
|
|
/**
|
|
|
|
* Creates an es.DocumentModelLeafNode object.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @abstract
|
|
|
|
* @constructor
|
2011-11-10 19:26:02 +00:00
|
|
|
* @extends {es.DocumentLeafNode}
|
2011-11-03 21:48:40 +00:00
|
|
|
* @extends {es.DocumentModelNode}
|
|
|
|
* @param {String} type Symbolic name of node type
|
2011-11-04 17:07:44 +00:00
|
|
|
* @param {Object} element Element object in document data
|
|
|
|
* @param {Integer} [length] Length of content data in document
|
2011-11-03 21:48:40 +00:00
|
|
|
*/
|
|
|
|
es.DocumentModelLeafNode = function( type, element, length ) {
|
|
|
|
// Inheritance
|
2011-11-10 19:26:02 +00:00
|
|
|
es.DocumentLeafNode.call( this );
|
2011-11-03 21:48:40 +00:00
|
|
|
es.DocumentModelNode.call( this, type, element, length );
|
|
|
|
|
|
|
|
// Properties
|
2011-11-04 17:07:44 +00:00
|
|
|
this.contentLength = length || 0;
|
2011-11-03 21:48:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a plain object representation of the document's data.
|
|
|
|
*
|
|
|
|
* @method
|
2011-11-04 17:07:44 +00:00
|
|
|
* @see {es.DocumentModelNode.getPlainObject}
|
|
|
|
* @see {es.DocumentModel.newFromPlainObject}
|
|
|
|
* @returns {Object} Plain object representation,
|
2011-11-03 21:48:40 +00:00
|
|
|
*/
|
|
|
|
es.DocumentModelLeafNode.prototype.getPlainObject = function() {
|
|
|
|
var obj = { 'type': this.type };
|
|
|
|
if ( this.element && this.element.attributes ) {
|
|
|
|
obj.attributes = es.copyObject( this.element.attributes );
|
|
|
|
}
|
2011-12-05 19:41:04 +00:00
|
|
|
obj.content = es.DocumentModel.getExpandedContentData( this.getContentData() );
|
2011-11-03 21:48:40 +00:00
|
|
|
return obj;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2011-11-10 19:26:02 +00:00
|
|
|
es.extendClass( es.DocumentModelLeafNode, es.DocumentLeafNode );
|
2011-11-03 21:48:40 +00:00
|
|
|
es.extendClass( es.DocumentModelLeafNode, es.DocumentModelNode );
|