mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 10:59:56 +00:00
36 lines
930 B
JavaScript
36 lines
930 B
JavaScript
/**
|
|
* Creates an es.DocumentView object.
|
|
*
|
|
* @class
|
|
* @constructor
|
|
* @extends {es.DocumentViewBranchNode}
|
|
* @param {es.DocumentModel} documentModel Document model to view
|
|
* @param {es.SurfaceView} surfaceView Surface view this view is a child of
|
|
*/
|
|
es.DocumentView = function( model, surfaceView ) {
|
|
// Inheritance
|
|
es.DocumentViewBranchNode.call( this, model );
|
|
|
|
// Properties
|
|
this.surfaceView = surfaceView;
|
|
|
|
// DOM Changes
|
|
this.$.addClass( 'es-documentView' );
|
|
};
|
|
|
|
/**
|
|
* Get the document offset of a position created from passed DOM event
|
|
*
|
|
* @method
|
|
* @param e {Event} Event to create es.Position from
|
|
* @returns {Integer} Document offset
|
|
*/
|
|
es.DocumentView.prototype.getOffsetFromEvent = function( e ) {
|
|
var position = es.Position.newFromEventPagePosition( e );
|
|
return this.getOffsetFromRenderedPosition( position );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
es.extendClass( es.DocumentView, es.DocumentViewBranchNode );
|