Index: trunk/parsers/wikidom/lib/hype/bases/es.DocumentViewBranchNode.js |
— | — | @@ -7,7 +7,8 @@ |
8 | 8 | * @param model {es.ModelNode} Model to observe |
9 | 9 | * @param {jQuery} [$element] Element to use as a container |
10 | 10 | */ |
11 | | -es.DocumentViewBranchNode = function( model, $element ) { |
| 11 | +es.DocumentViewBranchNode = function( model, $element, horizontal ) { |
| 12 | + this.horizontal = horizontal || false; |
12 | 13 | // Extension |
13 | 14 | return es.extendObject( new es.DocumentNode( new es.ViewNode( model, $element ) ), this ); |
14 | 15 | }; |
— | — | @@ -69,13 +70,15 @@ |
70 | 71 | } |
71 | 72 | var node = this[0]; |
72 | 73 | for ( var i = 1; i < this.length; i++ ) { |
73 | | - if ( this[i].$.offset().top > position.top ) { |
| 74 | + if ( this.horizontal && this[i].$.offset().left > position.left ) { |
74 | 75 | break; |
| 76 | + } else if ( this[i].$.offset().top > position.top ) { |
| 77 | + break; |
75 | 78 | } |
76 | 79 | node = this[i]; |
77 | 80 | } |
78 | 81 | return node.getParent().getOffsetFromNode( node, true ) + |
79 | | - node.getOffsetFromRenderedPosition( position ); |
| 82 | + node.getOffsetFromRenderedPosition( position ) + 1; |
80 | 83 | }; |
81 | 84 | |
82 | 85 | /** |
— | — | @@ -88,7 +91,7 @@ |
89 | 92 | es.DocumentViewBranchNode.prototype.getRenderedPositionFromOffset = function( offset ) { |
90 | 93 | var node = this.getNodeFromOffset( offset, true ); |
91 | 94 | if ( node !== null ) { |
92 | | - return node.getRenderedPositionFromOffset( offset - this.getOffsetFromNode( node, true ) ); |
| 95 | + return node.getRenderedPositionFromOffset( offset - this.getOffsetFromNode( node, true ) - 1); |
93 | 96 | } |
94 | 97 | return null; |
95 | 98 | }; |
Index: trunk/parsers/wikidom/lib/hype/views/es.TableRowView.js |
— | — | @@ -7,35 +7,7 @@ |
8 | 8 | */ |
9 | 9 | es.TableRowView = function( model ) { |
10 | 10 | // Extension |
11 | | - var view = es.extendObject( new es.DocumentViewBranchNode( model, $( '<tr>' ) ), this ); |
| 11 | + var view = es.extendObject( new es.DocumentViewBranchNode( model, $( '<tr>' ), true ), this ); |
12 | 12 | view.$.attr( 'style', model.getElementAttribute( 'html/style' ) ); |
13 | 13 | return view; |
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 | | - |
| 14 | +}; |
\ No newline at end of file |