mediawiki-extensions-Visual.../modules/ve/ce/nodes/ve.ce.DocumentNode.js
Timo Tijhof ab7d6bf082 Documentation & clean up
* Commands for Sublime:

  Find*: "(\* @[a-z]+) ([^{].*) \{(.*)\}"
  Replace: "$1 {$3} $2"

  Save all && Close all

  Find: " function("
  Replace: " function ("

  Save all && Close all

  Find: "Intialization"
  Replace: "Initialization"

  Save all && Close all

* Consistent use of types (documented in CODING.rm):
  - Merged {Integer} into {Number}.
  - Merged {DOM Node} into {DOMElement}.

* Remove work-around /*jshint newcap: false */ from ve.js
  Calling Object() as a function to to use the internal
  toObject no longer throws a newcap warning in JSHint.
  It only does that normal functions now .

  (e.g. var a = Cap(); or var a = new uncap();)

* Add missing annotations (@static, @method, ..).

* Remove unused variables

* Remove null-assignments to variables that should just be
  undefined. There's a few variables explicitly set to null
  whereas they are set a few lines under and not used otherwise
  (e.g. 'tx' in ve.ce.Surface.prototype.onPaste)

Change-Id: I0721a08f8ecd93c25595aedaa1aadb0e08b83799
2012-09-17 16:02:52 +02:00

71 lines
1.4 KiB
JavaScript

/**
* VisualEditor content editable DocumentNode class.
*
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* ContentEditable node for a document.
*
* @class
* @constructor
* @extends {ve.ce.BranchNode}
* @param {ve.dm.DocumentNode} model Model to observe
*/
ve.ce.DocumentNode = function VeCeDocumentNode( model, surface ) {
// Parent constructor
ve.ce.BranchNode.call( this, 'document', model );
// Properties
this.surface = surface;
// DOM Changes
this.$.addClass( 've-ce-documentNode' );
this.$.attr('contentEditable', 'true');
this.$.attr('spellcheck', 'true');
};
/* Inheritance */
ve.inheritClass( ve.ce.DocumentNode, ve.ce.BranchNode );
/* Static Members */
/**
* Node rules.
*
* @see ve.ce.NodeFactory
* @static
* @member
*/
ve.ce.DocumentNode.rules = {
'canBeSplit': false
};
/* Methods */
/**
* Gets the outer length, which for a document node is the same as the inner length.
*
* @method
* @returns {Number} Length of the entire node
*/
ve.ce.DocumentNode.prototype.getOuterLength = function () {
return this.length;
};
/**
* 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 );