2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor data model ListItemNode class.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2012-02-06 23:50:56 +00:00
|
|
|
/**
|
2012-06-20 01:20:28 +00:00
|
|
|
* DataModel node for a list item.
|
|
|
|
*
|
2012-02-06 23:50:56 +00:00
|
|
|
* @class
|
|
|
|
* @constructor
|
2012-06-20 01:20:28 +00:00
|
|
|
* @extends {ve.dm.BranchNode}
|
|
|
|
* @param {ve.dm.BranchNode[]} [children] Child nodes to attach
|
|
|
|
* @param {Object} [attributes] Reference to map of attribute key/value pairs
|
2012-08-16 17:53:33 +00:00
|
|
|
* @param {Object} [internal] Reference to internal data object
|
2012-02-06 23:50:56 +00:00
|
|
|
*/
|
2012-08-16 17:53:33 +00:00
|
|
|
ve.dm.ListItemNode = function ( children, attributes, internal ) {
|
2012-02-06 23:50:56 +00:00
|
|
|
// Inheritance
|
2012-08-16 17:53:33 +00:00
|
|
|
ve.dm.BranchNode.call( this, 'listItem', children, attributes, internal );
|
2012-02-06 23:50:56 +00:00
|
|
|
};
|
|
|
|
|
2012-06-20 01:20:28 +00:00
|
|
|
/* Static Members */
|
2012-02-06 23:50:56 +00:00
|
|
|
|
|
|
|
/**
|
2012-06-20 01:20:28 +00:00
|
|
|
* Node rules.
|
|
|
|
*
|
|
|
|
* @see ve.dm.NodeFactory
|
|
|
|
* @static
|
|
|
|
* @member
|
2012-02-06 23:50:56 +00:00
|
|
|
*/
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.dm.ListItemNode.rules = {
|
|
|
|
'isWrapped': true,
|
|
|
|
'isContent': false,
|
|
|
|
'canContainContent': false,
|
|
|
|
'childNodeTypes': null,
|
|
|
|
'parentNodeTypes': ['list']
|
2012-02-06 23:50:56 +00:00
|
|
|
};
|
|
|
|
|
2012-06-20 01:20:28 +00:00
|
|
|
/**
|
|
|
|
* Node converters.
|
|
|
|
*
|
|
|
|
* @see {ve.dm.Converter}
|
|
|
|
* @static
|
|
|
|
* @member
|
|
|
|
*/
|
|
|
|
ve.dm.ListItemNode.converters = {
|
|
|
|
'domElementTypes': ['li'],
|
2012-08-07 01:50:44 +00:00
|
|
|
'toDomElement': function ( type, element ) {
|
2012-06-20 01:20:28 +00:00
|
|
|
return document.createElement( 'li' );
|
|
|
|
},
|
2012-08-07 01:50:44 +00:00
|
|
|
'toDataElement': function ( tag, element ) {
|
2012-06-20 01:20:28 +00:00
|
|
|
return { 'type': 'listItem' };
|
|
|
|
}
|
|
|
|
};
|
2012-02-06 23:50:56 +00:00
|
|
|
|
2012-06-20 01:20:28 +00:00
|
|
|
/* Registration */
|
2012-02-06 23:50:56 +00:00
|
|
|
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.dm.nodeFactory.register( 'listItem', ve.dm.ListItemNode );
|
2012-02-06 23:50:56 +00:00
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.extendClass( ve.dm.ListItemNode, ve.dm.BranchNode );
|