r92891 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92890‎ | r92891 | r92892 >
Date:21:12, 22 July 2011
Author:inez
Status:deferred
Tags:
Comment:
Make getLocation methods works for ListBlockList and ListBlockItem
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.ListBlock.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ListBlock.js
@@ -28,23 +28,30 @@
2929 };
3030
3131 es.ListBlockList.prototype.getLocation = function( offset ) {
 32+
3233 var itemOffset = 0,
3334 itemLength;
 35+
3436 for ( var i = 0; i < this.items.length; i++ ) {
 37+
3538 itemLength = this.items[i].getLength();
 39+
3640 if ( offset >= itemOffset && offset < itemOffset + itemLength ) {
 41+
3742 if ( offset - itemOffset < this.items[i].content.getLength() ) {
3843 return {
3944 'item': this.items[i],
40 - 'offset': itemOffset
 45+ 'offset': offset - itemOffset
4146 };
4247 }
 48+
4349 var location = this.items[i].getLocation( offset - itemOffset );
4450 return {
4551 'item': location.item,
46 - 'offset': itemOffset + location.offset
 52+ 'offset': /*itemOffset +*/ location.offset
4753 }
4854 }
 55+
4956 itemOffset += itemLength;
5057 }
5158 };
@@ -100,17 +107,23 @@
101108
102109
103110
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() ) {
106114 return {
107115 'item': this,
108116 'offset': offset
109117 };
110118 }
 119+
 120+ offset -= this.content.getLength();
 121+
111122 var listOffset = 0,
112123 listLength;
 124+
113125 for ( var i = 0; i < this.lists.length; i++ ) {
114 - listLength = this.lists[i].length;
 126+ listLength = this.lists[i].getLength();
 127+
115128 if ( offset >= listOffset && offset < listOffset + listLength ) {
116129 return this.lists[i].getLocation( offset - listOffset );
117130 }

Status & tagging log