Index: trunk/parsers/wikidom/lib/hype/views/es.TableRowView.js |
— | — | @@ -11,3 +11,31 @@ |
12 | 12 | view.$.attr( 'style', model.getElementAttribute( 'html/style' ) ); |
13 | 13 | return view; |
14 | 14 | }; |
| 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 | + |