Index: trunk/parsers/wikidom/lib/es/es.ListBlock.js |
— | — | @@ -21,6 +21,8 @@ |
22 | 22 | this.list.on( 'update', function() { |
23 | 23 | listBlock.emit( 'update' ); |
24 | 24 | } ); |
| 25 | + |
| 26 | + this.renumber(); |
25 | 27 | }; |
26 | 28 | |
27 | 29 | /* Static Methods */ |
— | — | @@ -46,6 +48,23 @@ |
47 | 49 | |
48 | 50 | /* Public Methods */ |
49 | 51 | |
| 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 | + |
50 | 69 | /** |
51 | 70 | * Gets the offset of a position. |
52 | 71 | * |