2012-05-01 00:36:22 +00:00
|
|
|
/**
|
|
|
|
* ContentEditable node for a table cell.
|
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.TableCellNode} Model to observe
|
|
|
|
*/
|
|
|
|
ve.ce.TableCellNode = function( model ) {
|
|
|
|
// Inheritance
|
2012-06-08 05:02:25 +00:00
|
|
|
ve.ce.BranchNode.call(
|
|
|
|
this, 'tableCell', model, ve.ce.BranchNode.getDomWrapper( model, 'style' )
|
|
|
|
);
|
|
|
|
|
|
|
|
// Events
|
|
|
|
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.TableCellNode.rules = {
|
|
|
|
'canBeSplit': false
|
|
|
|
};
|
|
|
|
|
2012-06-08 05:02:25 +00:00
|
|
|
/**
|
|
|
|
* Mapping of list item style values and DOM wrapper element types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
* @member
|
|
|
|
*/
|
|
|
|
ve.ce.TableCellNode.domWrapperElementTypes = {
|
|
|
|
'data': 'td',
|
2012-06-15 06:54:06 +00:00
|
|
|
'header': 'th'
|
2012-06-08 05:02:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* 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.TableCellNode.prototype.onUpdate = function() {
|
|
|
|
this.updateDomWrapper( 'style' );
|
|
|
|
};
|
|
|
|
|
2012-05-01 00:36:22 +00:00
|
|
|
/* Registration */
|
|
|
|
|
2012-05-31 22:20:58 +00:00
|
|
|
ve.ce.nodeFactory.register( 'tableCell', ve.ce.TableCellNode );
|
2012-05-01 00:36:22 +00:00
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.extendClass( ve.ce.TableCellNode, ve.ce.BranchNode );
|