Index: trunk/parsers/wikidom/lib/es/es.ListBlock.js |
— | — | @@ -28,23 +28,30 @@ |
29 | 29 | };
|
30 | 30 |
|
31 | 31 | es.ListBlockList.prototype.getLocation = function( offset ) {
|
| 32 | +
|
32 | 33 | var itemOffset = 0,
|
33 | 34 | itemLength;
|
| 35 | +
|
34 | 36 | for ( var i = 0; i < this.items.length; i++ ) {
|
| 37 | +
|
35 | 38 | itemLength = this.items[i].getLength();
|
| 39 | +
|
36 | 40 | if ( offset >= itemOffset && offset < itemOffset + itemLength ) {
|
| 41 | +
|
37 | 42 | if ( offset - itemOffset < this.items[i].content.getLength() ) {
|
38 | 43 | return {
|
39 | 44 | 'item': this.items[i],
|
40 | | - 'offset': itemOffset
|
| 45 | + 'offset': offset - itemOffset
|
41 | 46 | };
|
42 | 47 | }
|
| 48 | +
|
43 | 49 | var location = this.items[i].getLocation( offset - itemOffset );
|
44 | 50 | return {
|
45 | 51 | 'item': location.item,
|
46 | | - 'offset': itemOffset + location.offset
|
| 52 | + 'offset': /*itemOffset +*/ location.offset
|
47 | 53 | }
|
48 | 54 | }
|
| 55 | +
|
49 | 56 | itemOffset += itemLength;
|
50 | 57 | }
|
51 | 58 | };
|
— | — | @@ -100,17 +107,23 @@ |
101 | 108 |
|
102 | 109 |
|
103 | 110 |
|
104 | | -es.ListBlockList.prototype.getLocation = function( offset ) {
|
105 | | - if ( offset < this.content.length ) {
|
| 111 | +es.ListBlockItem.prototype.getLocation = function( offset ) {
|
| 112 | +
|
| 113 | + if ( offset < this.content.getLength() ) {
|
106 | 114 | return {
|
107 | 115 | 'item': this,
|
108 | 116 | 'offset': offset
|
109 | 117 | };
|
110 | 118 | }
|
| 119 | +
|
| 120 | + offset -= this.content.getLength();
|
| 121 | +
|
111 | 122 | var listOffset = 0,
|
112 | 123 | listLength;
|
| 124 | +
|
113 | 125 | for ( var i = 0; i < this.lists.length; i++ ) {
|
114 | | - listLength = this.lists[i].length;
|
| 126 | + listLength = this.lists[i].getLength();
|
| 127 | +
|
115 | 128 | if ( offset >= listOffset && offset < listOffset + listLength ) {
|
116 | 129 | return this.lists[i].getLocation( offset - listOffset );
|
117 | 130 | }
|