mediawiki-extensions-Visual.../modules/ve/ce/ve.ce.LeafNode.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2012-02-10 16:57:02 +00:00
/**
* Creates an ve.ce.LeafNode object.
2012-02-10 16:57:02 +00:00
*
* @class
* @abstract
* @constructor
* @extends {ve.LeafNode}
* @extends {ve.ce.Node}
2012-02-10 16:57:02 +00:00
* @param model {ve.ModelNode} Model to observe
* @param {jQuery} [$element] Element to use as a container
*/
ve.ce.LeafNode = function( model, $element ) {
2012-02-10 16:57:02 +00:00
// Inheritance
ve.LeafNode.call( this );
ve.ce.Node.call( this, model, $element );
2012-02-10 16:57:02 +00:00
this.$.data( 'view', this );
this.$.addClass( 've-ce-leafNode' );
2012-02-10 16:57:02 +00:00
// Properties
this.contentView = new ve.ce.Content( model, this.$, this );
2012-02-10 16:57:02 +00:00
// Events
this.contentView.on( 'update', this.emitUpdate );
};
/* Methods */
ve.ce.LeafNode.prototype.convertDomElement = function( type ) {
ve.ce.Node.prototype.call( this, type );
// Transplant content view
this.contentView.setContainer( this.$ );
};
2012-02-10 16:57:02 +00:00
/**
* Render content.
*
* @method
*/
ve.ce.LeafNode.prototype.renderContent = function() {
2012-02-10 16:57:02 +00:00
this.contentView.render();
};
ve.ce.LeafNode.prototype.getDOMText = function() {
2012-02-10 22:19:12 +00:00
return ve.ce.getDOMText( this.$[0] );
};
2012-02-10 16:57:02 +00:00
/* Inheritance */
ve.extendClass( ve.ce.LeafNode, ve.LeafNode );
ve.extendClass( ve.ce.LeafNode, ve.ce.Node );