r94850 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94849‎ | r94850 | r94851 >
Date:00:36, 18 August 2011
Author:inez
Status:deferred (Comments)
Tags:
Comment:
Implement method renumber in ListBlock (should be called after every modification to list that may (add/delete/change type of item)
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.ListBlock.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ListBlock.js
@@ -21,6 +21,8 @@
2222 this.list.on( 'update', function() {
2323 listBlock.emit( 'update' );
2424 } );
 25+
 26+ this.renumber();
2527 };
2628
2729 /* Static Methods */
@@ -46,6 +48,23 @@
4749
4850 /* Public Methods */
4951
 52+es.ListBlock.prototype.renumber = function( position ) {
 53+ var itemLevel,
 54+ levels = [];
 55+
 56+ for ( var i = 0; i < this.list.items.length; i++ ) {
 57+ itemLevel = this.list.items[i].level;
 58+ levels = levels.slice(0, itemLevel + 1);
 59+
 60+ if ( this.list.items[i].style === 'number' ) {
 61+ if ( !levels[itemLevel] ) {
 62+ levels[itemLevel] = 0;
 63+ }
 64+ this.list.items[i].setNumber( ++levels[itemLevel] );
 65+ }
 66+ }
 67+};
 68+
5069 /**
5170 * Gets the offset of a position.
5271 *

Comments

#Comment by Ucucha (talk | contribs)   00:53, 18 August 2011

Why does es.ListBlock.prototype.renumber take position as an argument, when it is not used in the function itself and no argument is given when the method is called?

#Comment by Ucucha (talk | contribs)   12:28, 18 August 2011

This was fixed in r94853

Status & tagging log