2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
/**
|
2012-06-20 01:20:28 +00:00
|
|
|
* ContentEditable node for a document.
|
|
|
|
*
|
2012-02-07 19:13:19 +00:00
|
|
|
* @class
|
|
|
|
* @constructor
|
2012-03-06 22:39:43 +00:00
|
|
|
* @extends {ve.ce.BranchNode}
|
2012-06-20 01:20:28 +00:00
|
|
|
* @param model {ve.dm.DocumentNode} Model to observe
|
2012-02-07 19:13:19 +00:00
|
|
|
*/
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.ce.DocumentNode = function( model, surface ) {
|
2012-02-07 19:13:19 +00:00
|
|
|
// Inheritance
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.ce.BranchNode.call( this, 'document', model );
|
2012-02-07 19:13:19 +00:00
|
|
|
|
|
|
|
// Properties
|
2012-06-20 01:20:28 +00:00
|
|
|
this.surface = surface;
|
2012-02-07 19:13:19 +00:00
|
|
|
|
|
|
|
// DOM Changes
|
2012-04-04 18:53:23 +00:00
|
|
|
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 */
|
|
|
|
|
|
|
|
/**
|
2012-06-20 01:20:28 +00:00
|
|
|
* Node rules.
|
|
|
|
*
|
|
|
|
* @see ve.ce.NodeFactory
|
|
|
|
* @static
|
|
|
|
* @member
|
2012-02-07 19:13:19 +00:00
|
|
|
*/
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.ce.DocumentNode.rules = {
|
|
|
|
'canBeSplit': false
|
|
|
|
};
|
2012-02-07 19:13:19 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
2012-06-20 01:20:28 +00:00
|
|
|
* 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
|
2012-06-20 01:20:28 +00:00
|
|
|
* @returns {Integer} Length of the entire node
|
2012-02-07 19:13:19 +00:00
|
|
|
*/
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.ce.DocumentNode.prototype.getOuterLength = function() {
|
|
|
|
return this.length;
|
2012-02-07 19:13:19 +00:00
|
|
|
};
|
|
|
|
|
2012-06-21 06:20:42 +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;
|
|
|
|
};
|
|
|
|
|
2012-06-20 01:20:28 +00:00
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.ce.nodeFactory.register( 'document', ve.ce.DocumentNode );
|
2012-02-07 19:13:19 +00:00
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2012-03-06 22:39:43 +00:00
|
|
|
ve.extendClass( ve.ce.DocumentNode, ve.ce.BranchNode );
|