2012-05-01 00:36:22 +00:00
|
|
|
/**
|
|
|
|
* ContentEditable node for a heading.
|
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.HeadingNode} Model to observe
|
|
|
|
*/
|
|
|
|
ve.ce.HeadingNode = function( model ) {
|
|
|
|
// Inheritance
|
2012-05-05 00:50:54 +00:00
|
|
|
ve.ce.BranchNode.call(
|
|
|
|
this, 'heading', model, ve.ce.BranchNode.getDomWrapper( model, 'level' )
|
|
|
|
);
|
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.HeadingNode.rules = {
|
|
|
|
'canBeSplit': true
|
|
|
|
};
|
|
|
|
|
2012-05-02 18:29:44 +00:00
|
|
|
/**
|
|
|
|
* Mapping of heading level 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.HeadingNode.domWrapperElementTypes = {
|
2012-05-01 02:38:42 +00:00
|
|
|
'1': 'h1',
|
|
|
|
'2': 'h2',
|
|
|
|
'3': 'h3',
|
|
|
|
'4': 'h4',
|
|
|
|
'5': 'h5',
|
|
|
|
'6': 'h6'
|
|
|
|
};
|
|
|
|
|
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 level 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.HeadingNode.prototype.onUpdate = function() {
|
2012-05-04 20:31:14 +00:00
|
|
|
this.updateDomWrapper( 'level' );
|
2012-05-02 18:29:44 +00:00
|
|
|
};
|
|
|
|
|
2012-05-01 00:36:22 +00:00
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ce.factory.register( 'heading', ve.ce.HeadingNode );
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.extendClass( ve.ce.HeadingNode, ve.ce.BranchNode );
|