2012-05-01 00:36:22 +00:00
|
|
|
/**
|
|
|
|
* ContentEditable node for a list.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-01 00:36:22 +00:00
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @extends {ve.ce.BranchNode}
|
|
|
|
* @param model {ve.dm.ListNode} Model to observe
|
|
|
|
*/
|
|
|
|
ve.ce.ListNode = function( model ) {
|
|
|
|
// Inheritance
|
2012-05-05 00:50:54 +00:00
|
|
|
ve.ce.BranchNode.call( this, 'list', model, ve.ce.BranchNode.getDomWrapper( model, 'style' ) );
|
2012-05-02 18:29:44 +00:00
|
|
|
|
|
|
|
// Events
|
2012-05-02 20:58:50 +00:00
|
|
|
this.model.addListenerMethod( this, 'update', 'onUpdate' );
|
2012-05-01 00:36:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Static Members */
|
|
|
|
|
|
|
|
/**
|
2012-05-02 18:29:44 +00:00
|
|
|
* Node rules.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-01 00:36:22 +00:00
|
|
|
* @see ve.ce.NodeFactory
|
2012-05-02 18:29:44 +00:00
|
|
|
* @static
|
|
|
|
* @member
|
2012-05-01 00:36:22 +00:00
|
|
|
*/
|
|
|
|
ve.ce.ListNode.rules = {
|
|
|
|
'canBeSplit': false
|
|
|
|
};
|
|
|
|
|
2012-05-02 18:29:44 +00:00
|
|
|
/**
|
|
|
|
* Mapping of list style values and DOM wrapper element types.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-02 18:29:44 +00:00
|
|
|
* @static
|
|
|
|
* @member
|
|
|
|
*/
|
|
|
|
ve.ce.ListNode.domWrapperElementTypes = {
|
2012-05-01 02:38:42 +00:00
|
|
|
'bullet': 'ul',
|
2012-05-04 18:56:32 +00:00
|
|
|
'number': 'ol'
|
2012-05-01 02:38:42 +00:00
|
|
|
};
|
|
|
|
|
2012-05-02 18:29:44 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Responds to model update events.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-02 18:29:44 +00:00
|
|
|
* If the style changed since last update the DOM wrapper will be replaced with an appropriate one.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-05-02 18:29:44 +00:00
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
ve.ce.ListNode.prototype.onUpdate = function() {
|
2012-05-04 20:31:14 +00:00
|
|
|
this.updateDomWrapper( 'style' );
|
2012-05-02 18:29:44 +00:00
|
|
|
};
|
|
|
|
|
2012-05-01 00:36:22 +00:00
|
|
|
/* Registration */
|
|
|
|
|
2012-05-31 22:20:58 +00:00
|
|
|
ve.ce.nodeFactory.register( 'list', ve.ce.ListNode );
|
2012-05-01 00:36:22 +00:00
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.extendClass( ve.ce.ListNode, ve.ce.BranchNode );
|