mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
dc27d8acb4
* Moved implementation of getting and updating a DOM wrapper to ve.ce.BranchNode * Updated ve.ce.BranchNode tests * Renamed ve.NodeFactory.createNode to ve.NodeFactory.create * Added ve.NodeFactory.lookup which gets the constructor of a type * Added attribute pass-through to ve.dm.BranchNodeStub Change-Id: I8f5b7d3d3ae616cc5f39828b24b655163d782ae5
63 lines
1.3 KiB
JavaScript
63 lines
1.3 KiB
JavaScript
/**
|
|
* ContentEditable node for a definition list item.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends {ve.ce.BranchNode}
|
|
* @param model {ve.dm.DefinitionListItemNode} Model to observe
|
|
*/
|
|
ve.ce.DefinitionListItemNode = function( model ) {
|
|
// Inheritance
|
|
ve.ce.BranchNode.call( this, model, ve.ce.BranchNode.getDomWrapper( model, 'style' ) );
|
|
|
|
// Events
|
|
this.model.addListenerMethod( this, 'update', 'onUpdate' );
|
|
};
|
|
|
|
/* Static Members */
|
|
|
|
/**
|
|
* Node rules.
|
|
*
|
|
* @see ve.ce.NodeFactory
|
|
* @static
|
|
* @member
|
|
*/
|
|
ve.ce.DefinitionListItemNode.rules = {
|
|
'canHaveChildren': true,
|
|
'canHaveGrandchildren': true,
|
|
'canBeSplit': false
|
|
};
|
|
|
|
/**
|
|
* Mapping of list item style values and DOM wrapper element types.
|
|
*
|
|
* @static
|
|
* @member
|
|
*/
|
|
ve.ce.DefinitionListItemNode.domWrapperElementTypes = {
|
|
'definition': 'dd',
|
|
'term': 'dt'
|
|
};
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Responds to model update events.
|
|
*
|
|
* If the style changed since last update the DOM wrapper will be replaced with an appropriate one.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ce.DefinitionListItemNode.prototype.onUpdate = function() {
|
|
this.updateDomWrapper( 'style' );
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ce.factory.register( 'definitionListItem', ve.ce.DefinitionListItemNode );
|
|
|
|
/* Inheritance */
|
|
|
|
ve.extendClass( ve.ce.DefinitionListItemNode, ve.ce.BranchNode );
|