http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94929

Revision: 94929
Author:   inez
Date:     2011-08-18 19:28:26 +0000 (Thu, 18 Aug 2011)
Log Message:
-----------
Implement getWordBoundaries and getSectionBoundaries for ListBlock

Modified Paths:
--------------
    trunk/parsers/wikidom/lib/es/es.ListBlock.js

Modified: trunk/parsers/wikidom/lib/es/es.ListBlock.js
===================================================================
--- trunk/parsers/wikidom/lib/es/es.ListBlock.js        2011-08-18 19:26:02 UTC 
(rev 94928)
+++ trunk/parsers/wikidom/lib/es/es.ListBlock.js        2011-08-18 19:28:26 UTC 
(rev 94929)
@@ -184,7 +184,36 @@
        return length === 0 ? 0 : length - 1;
 };
 
+
 /**
+ * Gets the start and end points of the word closest a given offset.
+ * 
+ * @method
+ * @param offset {Integer} Offset to find word nearest to
+ * @returns {Object} Range object of boundaries
+ */
+es.ListBlock.prototype.getWordBoundaries = function( offset ) {
+       var location = this.getLocationFromOffset( offset ),
+               boundaries = location.item.flow.content.getWordBoundaries( 
location.offset );
+       boundaries.start += offset - location.offset; 
+       boundaries.end += offset - location.offset;
+       return boundaries;
+};
+
+/**
+ * Gets the start and end points of the section closest a given offset.
+ * 
+ * @method
+ * @param offset {Integer} Offset to find section nearest to
+ * @returns {Object} Range object of boundaries
+ */
+es.ListBlock.prototype.getSectionBoundaries = function( offset ) {
+       var location = this.getLocationFromOffset( offset ),
+               start = offset - location.offset;
+       return new es.Range( start, start + location.item.content.getLength() );
+};
+
+/**
  * Inserts content into a block at an offset.
  * 
  * @method


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to