2011-11-02 21:00:55 +00:00
|
|
|
/**
|
|
|
|
* Creates an es.HeadingView object.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @extends {es.DocumentViewLeafNode}
|
|
|
|
* @param {es.HeadingModel} model Heading model to view
|
|
|
|
*/
|
|
|
|
es.HeadingView = function( model ) {
|
|
|
|
// Inheritance
|
2011-11-02 23:01:35 +00:00
|
|
|
es.DocumentViewLeafNode.call( this, model );
|
2011-11-02 21:00:55 +00:00
|
|
|
|
|
|
|
// DOM Changes
|
|
|
|
this.$.addClass( 'es-headingView' );
|
|
|
|
|
|
|
|
// Events
|
|
|
|
this.on( 'update', this.setClasses );
|
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.setClasses();
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
es.HeadingView.prototype.setClasses = function() {
|
|
|
|
var classes = this.$.attr( 'class' ),
|
|
|
|
level = this.model.getElementAttribute( 'level' );
|
|
|
|
this.$
|
|
|
|
// Remove any existing level classes
|
2011-11-02 22:47:16 +00:00
|
|
|
.attr( 'class', classes.replace( /es-headingView-level[0-9]+/, '' ) )
|
2011-11-02 21:00:55 +00:00
|
|
|
// Add a new level class
|
|
|
|
.addClass( 'es-headingView-level' + level );
|
|
|
|
};
|
|
|
|
|
2011-11-14 23:59:36 +00:00
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
es.DocumentModel.nodeRules.heading = {
|
|
|
|
'self': true,
|
|
|
|
'children': null
|
|
|
|
};
|
|
|
|
|
2011-11-02 21:00:55 +00:00
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
es.extendClass( es.HeadingView, es.DocumentViewLeafNode );
|