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-02-06 23:50:56 +00:00
|
|
|
*/
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.dm.ListItemNode = function( children, attributes ) {
|
2012-02-06 23:50:56 +00:00
|
|
|
// Inheritance
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.dm.BranchNode.call( this, 'listItem', children, attributes );
|
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'],
|
|
|
|
'toDomElement': function( type, element ) {
|
|
|
|
return document.createElement( 'li' );
|
|
|
|
},
|
|
|
|
'toDataElement': function( tag, element ) {
|
|
|
|
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 );
|