r101162 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101161‎ | r101162 | r101163 >
Date:18:19, 28 October 2011
Author:inez
Status:deferred
Tags:
Comment:
Support for placing cursor inside table cells
Modified paths:
  • /trunk/parsers/wikidom/lib/hype/views/es.TableRowView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/hype/views/es.TableRowView.js
@@ -11,3 +11,31 @@
1212 view.$.attr( 'style', model.getElementAttribute( 'html/style' ) );
1313 return view;
1414 };
 15+
 16+/**
 17+ * Gets the nearest offset of a rendered position.
 18+ *
 19+ * The only difference between this method and one in DocumentViewBranchNode is that it checks
 20+ * 'left' property of position instead of 'top'. If such case will become more frequent lets
 21+ * consider having private property in DocumentViewBranchNode which defines if horizontal
 22+ * or vertical scanning should be executed.
 23+ *
 24+ * @method
 25+ * @param {es.Position} position Position to get offset for
 26+ * @returns {Integer} Offset of position
 27+ */
 28+es.TableRowView.prototype.getOffsetFromRenderedPosition = function( position ) {
 29+ if ( this.length === 0 ) {
 30+ return 0;
 31+ }
 32+ var node = this[0];
 33+ for ( var i = 1; i < this.length; i++ ) {
 34+ if ( this[i].$.offset().left > position.left ) {
 35+ break;
 36+ }
 37+ node = this[i];
 38+ }
 39+ return node.getParent().getOffsetFromNode( node, true ) +
 40+ node.getOffsetFromRenderedPosition( position );
 41+};
 42+

Status & tagging log