r93337 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93336‎ | r93337 | r93338 >
Date:23:40, 27 July 2011
Author:inez
Status:deferred
Tags:
Comment:
Support annotating multiple items at once in ListBlock.annotateContent
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.ListBlock.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ListBlock.js
@@ -74,11 +74,35 @@
7575 */
7676 es.ListBlock.prototype.annotateContent = function( method, annotation, range ) {
7777 range.normalize();
78 - // TODO: Support annotating multiple items at once
79 - var location = this.list.getLocationFromOffset( range.start );
80 - location.item.content.annotate(
81 - method, annotation, new es.Range( location.offset, location.offset + range.getLength() )
82 - );
 78+
 79+ var locationStart = this.list.getLocationFromOffset( range.start ),
 80+ locationEnd = this.list.getLocationFromOffset( range.end );
 81+
 82+ if ( locationStart.item == locationEnd.item ) {
 83+
 84+ locationStart.item.content.annotate( method, annotation, locationStart.offset, locationStart.offset + range.end - range.start );
 85+
 86+ } else {
 87+ var itemsToAnnotate;
 88+ this.traverseItems( function( item, index ) {
 89+ if ( item == locationEnd.item ) {
 90+ return false;
 91+ }
 92+ if ( $.isArray( itemsToAnnotate ) ) {
 93+ itemsToAnnotate.push( item );
 94+ }
 95+ if ( item == locationStart.item ) {
 96+ itemsToAnnotate = [];
 97+ }
 98+ } );
 99+
 100+ locationStart.item.content.annotate( method, annotation, locationStart.offset, locationStart.item.content.getLength() );
 101+ locationEnd.item.content.annotate( method, annotation, 0, locationEnd.offset);
 102+
 103+ for ( var i = 0; i < itemsToAnnotate.length; i++ ) {
 104+ itemsToAnnotate[i].content.annotate( method, annotation, 0, itemsToAnnotate[i].content.getLength());
 105+ }
 106+ }
83107 };
84108
85109 /**

Status & tagging log