mediawiki-extensions-Visual.../modules/ve/ce/nodes/ve.ce.DocumentNode.js

71 lines
1.4 KiB
JavaScript
Raw Normal View History

/**
* VisualEditor content editable DocumentNode class.
*
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
2012-02-07 19:13:19 +00:00
/**
* ContentEditable node for a document.
*
2012-02-07 19:13:19 +00:00
* @class
* @constructor
* @extends {ve.ce.BranchNode}
* @param model {ve.dm.DocumentNode} Model to observe
2012-02-07 19:13:19 +00:00
*/
ve.ce.DocumentNode = function ( model, surface ) {
2012-02-07 19:13:19 +00:00
// Inheritance
ve.ce.BranchNode.call( this, 'document', model );
2012-02-07 19:13:19 +00:00
// Properties
this.surface = surface;
2012-02-07 19:13:19 +00:00
// DOM Changes
this.$.addClass( 've-ce-documentNode' );
2012-02-07 19:13:19 +00:00
this.$.attr('contentEditable', 'true');
2012-02-28 23:43:38 +00:00
this.$.attr('spellcheck', 'true');
2012-02-07 19:13:19 +00:00
};
/* Static Members */
/**
* Node rules.
*
* @see ve.ce.NodeFactory
* @static
* @member
2012-02-07 19:13:19 +00:00
*/
ve.ce.DocumentNode.rules = {
'canBeSplit': false
};
2012-02-07 19:13:19 +00:00
/* Methods */
/**
* Gets the outer length, which for a document node is the same as the inner length.
*
2012-02-07 19:13:19 +00:00
* @method
* @returns {Integer} Length of the entire node
2012-02-07 19:13:19 +00:00
*/
ve.ce.DocumentNode.prototype.getOuterLength = function () {
return this.length;
2012-02-07 19:13:19 +00:00
};
/**
* Gets the surface this document is attached to.
*
* @method
* @returns {ve.ve.Surface} Surface this document is attached to
*/
ve.ce.DocumentNode.prototype.getSurface = function () {
return this.surface;
};
/* Registration */
ve.ce.nodeFactory.register( 'document', ve.ce.DocumentNode );
2012-02-07 19:13:19 +00:00
/* Inheritance */
ve.extendClass( ve.ce.DocumentNode, ve.ce.BranchNode );