mediawiki-extensions-Visual.../modules/ve/ce/nodes/ve.ce.AlienNode.js
Roan Kattouw dfbd870e16 Fix copyDomElement issues
* Fix bug in MWTransclusionNode sometimes passing a NodeList rather
  than an array (caused an error because NodeLists can't be .map()ped)
* Use copyDomElements in ce.AlienNode as well

Change-Id: I11c6483d3c062047be80f75a3fac03f13bff9662
2013-06-18 23:37:09 +00:00

116 lines
2.7 KiB
JavaScript

/*!
* VisualEditor ContentEditable AlienNode, AlienBlockNode and AlienInlineNode classes.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* ContentEditable alien node.
*
* @class
* @abstract
* @extends ve.ce.LeafNode
* @mixins ve.ce.ProtectedNode
* @mixins ve.ce.GeneratedContentNode
*
* @constructor
* @param {ve.dm.AlienNode} model Model to observe
* @param {Object} [config] Config options
*/
ve.ce.AlienNode = function VeCeAlienNode( model, config ) {
// Parent constructor
ve.ce.LeafNode.call( this, model, config );
// Mixin constructors
ve.ce.ProtectedNode.call( this );
ve.ce.GeneratedContentNode.call( this );
// DOM Changes
this.$.addClass( 've-ce-alienNode' );
};
/* Inheritance */
ve.inheritClass( ve.ce.AlienNode, ve.ce.LeafNode );
ve.mixinClass( ve.ce.AlienNode, ve.ce.ProtectedNode );
ve.mixinClass( ve.ce.AlienNode, ve.ce.GeneratedContentNode );
/* Static Properties */
ve.ce.AlienNode.static.name = 'alien';
ve.ce.AlienNode.static.$phantomTemplate = ve.ce.AlienNode.static.$phantomTemplate.clone()
.addClass( 've-ce-alienNode-phantom' )
.attr( 'title', ve.msg( 'visualeditor-aliennode-tooltip' ) );
/* Methods */
/**
* Handle update events.
*
* @method
*/
ve.ce.AlienNode.prototype.onUpdate = function () {
// TODO use GeneratedContentNode the way it was meant to be used
this.$.html( ve.copyDomElements( this.model.getAttribute( 'domElements' ) || [], this.getElementDocument() ) );
};
/* Concrete subclasses */
/**
* ContentEditable alien block node.
*
* @class
* @extends ve.ce.AlienNode
* @constructor
* @param {ve.dm.AlienBlockNode} model Model to observe
*/
ve.ce.AlienBlockNode = function VeCeAlienBlockNode( model ) {
// Parent constructor
ve.ce.AlienNode.call( this, model );
// DOM Changes
this.$.addClass( 've-ce-alienBlockNode' );
};
/* Inheritance */
ve.inheritClass( ve.ce.AlienBlockNode, ve.ce.AlienNode );
/* Static Properties */
ve.ce.AlienBlockNode.static.name = 'alienBlock';
/**
* ContentEditable alien inline node.
*
* @class
* @extends ve.ce.AlienNode
* @constructor
* @param {ve.dm.AlienInlineNode} model Model to observe
*/
ve.ce.AlienInlineNode = function VeCeAlienInlineNode( model ) {
// Parent constructor
ve.ce.AlienNode.call( this, model );
// DOM Changes
this.$.addClass( 've-ce-alienInlineNode' );
};
/* Inheritance */
ve.inheritClass( ve.ce.AlienInlineNode, ve.ce.AlienNode );
/* Static Properties */
ve.ce.AlienInlineNode.static.name = 'alienInline';
/* Registration */
ve.ce.nodeFactory.register( ve.ce.AlienNode );
ve.ce.nodeFactory.register( ve.ce.AlienBlockNode );
ve.ce.nodeFactory.register( ve.ce.AlienInlineNode );