r92658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92657‎ | r92658 | r92659 >
Date:18:44, 20 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Moved all EditSurface objects and functions into the es.* namespace.
Modified paths:
  • /trunk/parsers/wikidom/demos/es/index.html (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Block.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Content.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Cursor.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Document.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.EventEmitter.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Surface.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.TextFlow.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.js (modified) (history)
  • /trunk/parsers/wikidom/tests/annotations/test.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/tests/annotations/test.js
@@ -51,7 +51,7 @@
5252 }
5353 ];
5454
55 -var content = Content.newFromLines( lines );
 55+var content = es.Content.newFromLines( lines );
5656
5757 /* Tests */
5858
@@ -148,7 +148,7 @@
149149 ];
150150
151151 deepEqual(
152 - Content.newFromLines( lines1 ).getLines(),
 152+ es.Content.newFromLines( lines1 ).getLines(),
153153 lines1,
154154 'Content.getLines returns correct array of all lines for annotations overlapping between lines'
155155 );
Index: trunk/parsers/wikidom/lib/es/es.Document.js
@@ -1,11 +1,11 @@
22 /**
33 *
4 - * @extends {EventEmitter}
 4+ * @extends {es.EventEmitter}
55 * @param blocks {Array} List of blocks
6 - * @returns {Document}
 6+ * @returns {es.Document}
77 */
8 -function Document( blocks ) {
9 - EventEmitter.call( this );
 8+es.Document = function( blocks ) {
 9+ es.EventEmitter.call( this );
1010 this.blocks = [];
1111 var i;
1212 for( i = 0; i < blocks.length; i++ ) {
@@ -19,27 +19,27 @@
2020 /**
2121 * Gets the first block in the document.
2222 *
23 - * @returns {Block}
 23+ * @returns {es.Block}
2424 */
25 -Document.prototype.firstBlock = function() {
 25+es.Document.prototype.firstBlock = function() {
2626 return this.blocks.length ? this.blocks[0] : null;
2727 };
2828
2929 /**
3030 * Gets the last block in the document.
3131 *
32 - * @returns {Block}
 32+ * @returns {es.Block}
3333 */
34 -Document.prototype.lastBlock = function() {
 34+es.Document.prototype.lastBlock = function() {
3535 return this.blocks.length ? this.blocks[this.blocks.length - 1] : null;
3636 };
3737
3838 /**
3939 * Adds a block to the end of the document.
4040 *
41 - * @param {Block} Block to append
 41+ * @param {es.Block} Block to append
4242 */
43 -Document.prototype.appendBlock = function( block ) {
 43+es.Document.prototype.appendBlock = function( block ) {
4444 block.document = this;
4545 block.on( 'update', function() {
4646 block.document.emit( 'update' );
@@ -50,9 +50,9 @@
5151 /**
5252 * Adds a block to the beginning of the document.
5353 *
54 - * @param {Block} Block to prepend
 54+ * @param {es.Block} Block to prepend
5555 */
56 -Document.prototype.prependBlock = function( block ) {
 56+es.Document.prototype.prependBlock = function( block ) {
5757 block.document = this;
5858 block.on( 'update', function() {
5959 block.document.emit( 'update' );
@@ -63,10 +63,10 @@
6464 /**
6565 * Adds a block to the document after an existing block.
6666 *
67 - * @param block {Block} Block to insert
68 - * @param before {Block} Block to insert before, if null then block will be inserted at the end
 67+ * @param block {es.Block} Block to insert
 68+ * @param before {es.Block} Block to insert before, if null then block will be inserted at the end
6969 */
70 -Document.prototype.insertBlockBefore = function( block, before ) {
 70+es.Document.prototype.insertBlockBefore = function( block, before ) {
7171 block.document = this;
7272 block.on( 'update', function() {
7373 block.document.emit( 'update' );
@@ -79,10 +79,10 @@
8080 };
8181 /**
8282 * Adds a block to the document after an existing block.
83 - * @param block {Block} Block to insert
84 - * @param after {Block} Block to insert after, if null then block will be inserted at the end
 83+ * @param block {es.Block} Block to insert
 84+ * @param after {es.Block} Block to insert after, if null then block will be inserted at the end
8585 */
86 -Document.prototype.insertBlockAfter = function( block, after ) {
 86+es.Document.prototype.insertBlockAfter = function( block, after ) {
8787 block.document = this;
8888 block.on( 'update', function() {
8989 block.document.emit( 'update' );
@@ -97,15 +97,15 @@
9898 /**
9999 * Removes a block from the document.
100100 *
101 - * @param {Block} Block to remove
 101+ * @param {es.Block} Block to remove
102102 */
103 -Document.prototype.removeBlock = function( block ) {
 103+es.Document.prototype.removeBlock = function( block ) {
104104 block.removeAllListeners( 'update' );
105105 this.blocks.splice( block.getIndex(), 1 );
106106 block.document = null;
107107 };
108108
109 -Document.prototype.renderBlocks = function( offset ) {
 109+es.Document.prototype.renderBlocks = function( offset ) {
110110 // Remember width, to avoid updates when without width changes
111111 this.width = this.$.innerWidth();
112112 // Render blocks
@@ -116,7 +116,7 @@
117117 }
118118 };
119119
120 -Document.prototype.updateBlocks = function( offset ) {
 120+es.Document.prototype.updateBlocks = function( offset ) {
121121 // Bypass rendering when width has not changed
122122 var width = this.$.innerWidth();
123123 if ( this.width === width ) {
@@ -130,4 +130,4 @@
131131 } );
132132 };
133133
134 -extend( Document, EventEmitter );
 134+es.extend( es.Document, es.EventEmitter );
Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js
@@ -1,22 +1,22 @@
22 /**
33 *
4 - * @extends {Block}
 4+ * @extends {es.Block}
55 * @param lines {Array} List of line objects
6 - * @returns {ParagraphBlock}
 6+ * @returns {es.ParagraphBlock}
77 */
8 -function ParagraphBlock( lines ) {
9 - Block.call( this );
10 - this.content = Content.newFromLines( lines || [] );
 8+es.ParagraphBlock = function( lines ) {
 9+ es.Block.call( this );
 10+ this.content = es.Content.newFromLines( lines || [] );
1111 this.$ = $( '<div class="editSurface-block editSurface-paragraph"></div>' )
1212 .data( 'block', this );
13 - this.flow = new TextFlow( this.$, this.content );
 13+ this.flow = new es.TextFlow( this.$, this.content );
1414 var block = this;
1515 this.flow.on( 'render', function() {
1616 block.emit( 'update' );
1717 } );
1818 }
1919
20 -ParagraphBlock.prototype.getLength = function() {
 20+es.ParagraphBlock.prototype.getLength = function() {
2121 return this.content.getLength();
2222 };
2323
@@ -26,7 +26,7 @@
2727 * @param offset {Integer} Position to insert content at
2828 * @param content {Object} Content to insert
2929 */
30 -ParagraphBlock.prototype.insertContent = function( offset, content ) {
 30+es.ParagraphBlock.prototype.insertContent = function( offset, content ) {
3131 this.content.insert( offset, content );
3232 };
3333
@@ -36,7 +36,7 @@
3737 * @param offset {Integer} Offset to start removing content from
3838 * @param length {Integer} Offset to start removing content to
3939 */
40 -ParagraphBlock.prototype.deleteContent = function( start, end ) {
 40+es.ParagraphBlock.prototype.deleteContent = function( start, end ) {
4141 // Normalize start/end
4242 if ( end < start ) {
4343 var tmp = end;
@@ -51,7 +51,7 @@
5252 *
5353 * @param $container {jQuery Selection} Container to render into
5454 */
55 -ParagraphBlock.prototype.renderContent = function( offset ) {
 55+es.ParagraphBlock.prototype.renderContent = function( offset ) {
5656 this.flow.render( offset );
5757 };
5858
@@ -60,7 +60,7 @@
6161 *
6262 * @param position {Integer} Offset to translate
6363 */
64 -ParagraphBlock.prototype.getOffset = function( position ) {
 64+es.ParagraphBlock.prototype.getOffset = function( position ) {
6565 return this.flow.getOffset( position );
6666 };
6767
@@ -69,7 +69,7 @@
7070 *
7171 * @param offset {Integer} Offset to translate
7272 */
73 -ParagraphBlock.prototype.getPosition = function( offset ) {
 73+es.ParagraphBlock.prototype.getPosition = function( offset ) {
7474 return this.flow.getPosition( offset );
7575 };
7676
@@ -83,7 +83,7 @@
8484 * @param start {Integer} Offset to begin annotating from
8585 * @param end {Integer} Offset to stop annotating to
8686 */
87 -ParagraphBlock.prototype.annotateContent = function( method, annotation, start, end ) {
 87+es.ParagraphBlock.prototype.annotateContent = function( method, annotation, start, end ) {
8888 this.content.annotate( method, annotation, start, end );
8989 };
9090
@@ -93,7 +93,7 @@
9494 * @param offset {Integer} Offset to find word nearest to
9595 * @return {Object} Range object of boundaries
9696 */
97 -Block.prototype.getWordBoundaries = function( offset ) {
 97+es.Block.prototype.getWordBoundaries = function( offset ) {
9898 return this.content.getWordBoundaries( offset );
9999 };
100100
@@ -105,8 +105,8 @@
106106 * @param offset {Integer} Offset to find section nearest to
107107 * @return {Object} Range object of boundaries
108108 */
109 -Block.prototype.getSectionBoundaries = function( offset ) {
110 - return new Range( 0, this.content.getLength() );
 109+es.Block.prototype.getSectionBoundaries = function( offset ) {
 110+ return new es.Range( 0, this.content.getLength() );
111111 };
112112
113 -extend( ParagraphBlock, Block );
 113+es.extend( es.ParagraphBlock, es.Block );
Index: trunk/parsers/wikidom/lib/es/es.js
@@ -1,4 +1,11 @@
22 /**
 3+ * EditSurafce namespace.
 4+ *
 5+ * All classes and functions will be attached to this object to keep the global namespace clean.
 6+ */
 7+var es = {};
 8+
 9+/**
310 * Extends a constructor with prototype of another.
411 *
512 * When using this, it's required to include a call to the constructor of the parent class as the
@@ -19,7 +26,7 @@
2027 * @param dst {Function} Class to copy prototype members to
2128 * @param src {Function} Class to copy prototype members from
2229 */
23 -function extend( dst, src ) {
 30+es.extend = function( dst, src ) {
2431 var base = new src();
2532 var i; // iterator
2633
@@ -35,9 +42,9 @@
3643 *
3744 * @param start {Integer} Starting point
3845 * @param end {Integer} Ending point
39 - * @returns {Range}
 46+ * @returns {es.Range}
4047 */
41 -function Range( start, end ) {
 48+es.Range = function( start, end ) {
4249 this.start = start || null;
4350 this.end = end || null;
4451 }
@@ -50,9 +57,9 @@
5158 * @param left {Integer} Horizontal position
5259 * @param top {Integer} Vertical position (of top, if bottom is used)
5360 * @param bottom {Integer} Vertical position of bottom (optional)
54 - * @returns {Position}
 61+ * @returns {es.Position}
5562 */
56 -function Position( left, top, bottom ) {
 63+es.Position = function( left, top, bottom ) {
5764 this.left = left || 0;
5865 this.top = top || 0;
5966 this.bottom = bottom || 0;
@@ -61,11 +68,11 @@
6269 /**
6370 * Content location, an offset within a block.
6471 *
65 - * @param block {Block} Location target
 72+ * @param block {es.Block} Location target
6673 * @param offset {Integer} Location offset
67 - * @returns {Location}
 74+ * @returns {es.Location}
6875 */
69 -function Location( block, offset ) {
 76+es.Location = function( block, offset ) {
7077 this.block = block;
7178 this.offset = offset || 0;
7279 }
@@ -73,11 +80,11 @@
7481 /**
7582 * Content selection, a pair of locations.
7683 *
77 - * @param from {Location} Starting location
78 - * @param to {Location} Ending location
79 - * @returns {Selection}
 84+ * @param from {es.Location} Starting location
 85+ * @param to {es.Location} Ending location
 86+ * @returns {es.Selection}
8087 */
81 -function Selection( from, to ) {
 88+es.Selection = function( from, to ) {
8289 this.from = from;
8390 this.to = to;
8491 this.start = from;
@@ -87,7 +94,7 @@
8895 /**
8996 * Ensures that "from" is before "to".
9097 */
91 -Selection.prototype.normalize = function() {
 98+es.Selection.prototype.normalize = function() {
9299 if ( this.from.block.getIndex() < this.to.block.getIndex()
93100 || ( this.from.block === this.to.block && this.from.offset < this.to.offset ) ) {
94101 this.start = this.from;
@@ -105,7 +112,7 @@
106113 *
107114 * @returns {Array} List of blocks
108115 */
109 -Selection.prototype.through = function() {
 116+es.Selection.prototype.through = function() {
110117 var through = [];
111118 if ( this.from !== this.to && this.from.nextBlock() !== this.to ) {
112119 var next = this.from.nextBlock();
@@ -117,11 +124,11 @@
118125 return through;
119126 };
120127
121 -function Content( data ) {
 128+es.Content = function( data ) {
122129 this.setData( data );
123130 }
124131
125 -Content.prototype.setData = function( data ) {
 132+es.Content.prototype.setData = function( data ) {
126133 // Data type detection
127134 if ( typeof data === 'string' ) {
128135 this.type = 'string';
Index: trunk/parsers/wikidom/lib/es/es.Surface.js
@@ -4,13 +4,13 @@
55 * @param doc
66 * @returns {Surface}
77 */
8 -function Surface( $container, doc ) {
 8+es.Surface = function( $container, doc ) {
99 var surface = this;
1010
1111 this.$ = $container.addClass( 'editSurface' );
1212 this.doc = doc;
1313 this.location = null;
14 - this.selection = new Selection();
 14+ this.selection = new es.Selection();
1515 this.initialHorizontalCursorPosition = null;
1616 this.mouse = {
1717 'selecting': false,
@@ -39,14 +39,14 @@
4040 this.$rangeEnd = $( '<div class="editSurface-range"></div>' ).appendTo( this.$ranges );
4141
4242 // Cursor
43 - this.cursor = new Cursor();
 43+ this.cursor = new es.Cursor();
4444 this.$.append( this.cursor.$ );
4545
4646 // Hidden input
4747 var $document = $(document);
4848 this.$input = $( '<input class="editSurface-input" />' )
4949 .prependTo( this.$ )
50 - .bind({
 50+ .bind( {
5151 'focus' : function() {
5252 $(document).bind({
5353 'mousemove.editSurface' : function(e) {
@@ -67,7 +67,7 @@
6868 $document.unbind('.editSurface');
6969 surface.cursor.hide();
7070 }
71 - });
 71+ } );
7272
7373 $(window).resize( function() {
7474 surface.cursor.hide();
@@ -88,7 +88,7 @@
8989 this.doc.renderBlocks();
9090 }
9191
92 -Surface.prototype.getLocationFromEvent = function( e ) {
 92+es.Surface.prototype.getLocationFromEvent = function( e ) {
9393 var $target = $( e.target );
9494 $block = $target.is( '.editSurface-block' )
9595 ? $target : $target.closest( '.editSurface-block' );
@@ -106,18 +106,18 @@
107107 }
108108 var block = $block.data( 'block' ),
109109 blockPosition = $block.offset(),
110 - mousePosition = new Position( e.pageX - blockPosition.left, e.pageY - blockPosition.top );
111 - return new Location( block, block.getOffset( mousePosition ) );
 110+ mousePosition = new es.Position( e.pageX - blockPosition.left, e.pageY - blockPosition.top );
 111+ return new es.Location( block, block.getOffset( mousePosition ) );
112112 };
113113
114 -Surface.prototype.onKeyDown = function( e ) {
 114+es.Surface.prototype.onKeyDown = function( e ) {
115115 switch ( e.keyCode ) {
116116 case 16: // Shift
117117 this.shiftDown = true;
118118 if ( !this.keyboard.selecting ) {
119119 this.keyboard.selecting = true;
120120 if ( !this.selection.to ) {
121 - this.selection = new Selection( this.location );
 121+ this.selection = new es.Selection( this.location );
122122 }
123123 this.drawSelection();
124124 }
@@ -131,7 +131,7 @@
132132 if ( this.shiftDown && this.keyboard.selecting ) {
133133 this.selection.to = this.location;
134134 } else {
135 - this.selection = new Selection();
 135+ this.selection = new es.Selection();
136136 }
137137 this.drawSelection();
138138 break;
@@ -140,7 +140,7 @@
141141 if ( this.shiftDown && this.keyboard.selecting ) {
142142 this.selection.to = this.location;
143143 } else {
144 - this.selection = new Selection();
 144+ this.selection = new es.Selection();
145145 }
146146 this.drawSelection();
147147 break;
@@ -150,7 +150,7 @@
151151 if ( this.shiftDown && this.keyboard.selecting ) {
152152 this.selection.to = this.location;
153153 } else {
154 - this.selection = new Selection();
 154+ this.selection = new es.Selection();
155155 }
156156 this.drawSelection();
157157 break;
@@ -159,7 +159,7 @@
160160 if ( this.shiftDown && this.keyboard.selecting ) {
161161 this.selection.to = this.location;
162162 } else {
163 - this.selection = new Selection();
 163+ this.selection = new es.Selection();
164164 }
165165 this.drawSelection();
166166 break;
@@ -188,8 +188,8 @@
189189 surface.deleteContent( deleteSelection );
190190 }
191191 var insertLocation = surface.location;
192 - surface.selection = new Selection();
193 - surface.location = new Location(
 192+ surface.selection = new es.Selection();
 193+ surface.location = new es.Location(
194194 surface.location.block, surface.location.offset + val.length
195195 );
196196 surface.insertContent( insertLocation, val.split('') );
@@ -200,7 +200,7 @@
201201 return true;
202202 };
203203
204 -Surface.prototype.onKeyUp = function( e ) {
 204+es.Surface.prototype.onKeyUp = function( e ) {
205205 switch ( e.keyCode ) {
206206 case 16: // Shift
207207 this.shiftDown = false;
@@ -221,41 +221,41 @@
222222 return true;
223223 };
224224
225 -Surface.prototype.handleBackspace = function() {
 225+es.Surface.prototype.handleBackspace = function() {
226226 if ( this.selection.from && this.selection.to ) {
227227 var deleteSelection = this.selection;
228228 deleteSelection.normalize();
229229 this.location = this.selection.start;
230 - this.selection = new Selection();
 230+ this.selection = new es.Selection();
231231 this.deleteContent( deleteSelection );
232232 } else if ( this.location.offset > 0 ) {
233 - var deleteSelection = new Selection(
234 - new Location( this.location.block, this.location.offset - 1 ), this.location
 233+ var deleteSelection = new es.Selection(
 234+ new es.Location( this.location.block, this.location.offset - 1 ), this.location
235235 );
236 - this.selection = new Selection();
 236+ this.selection = new es.Selection();
237237 this.location = deleteSelection.from;
238238 this.deleteContent( deleteSelection );
239239 }
240240 };
241241
242 -Surface.prototype.handleDelete = function() {
 242+es.Surface.prototype.handleDelete = function() {
243243 if ( this.selection.from && this.selection.to ) {
244244 var deleteSelection = this.selection;
245245 deleteSelection.normalize();
246246 this.location = this.selection.end;
247 - this.selection = new Selection();
 247+ this.selection = new es.Selection();
248248 this.deleteContent( deleteSelection );
249249 } else if ( this.location.offset < block.getLength() - 1 ) {
250 - var deleteSelection = new Selection(
251 - new Location( this.location.block, this.location.offset + 1 ), this.location
 250+ var deleteSelection = new es.Selection(
 251+ new es.Location( this.location.block, this.location.offset + 1 ), this.location
252252 );
253 - this.selection = new Selection();
 253+ this.selection = new es.Selection();
254254 this.location = deleteSelection.from;
255255 this.deleteContent( deleteSelection );
256256 }
257257 };
258258
259 -Surface.prototype.onMouseDown = function( e ) {
 259+es.Surface.prototype.onMouseDown = function( e ) {
260260 if ( e.button === 0 ) {
261261 clearTimeout( this.mouse.clickTimeout );
262262 if ( this.mouse.clickX === e.pageX && this.mouse.clickY === e.pageY ) {
@@ -275,7 +275,7 @@
276276 switch ( this.mouse.clicks ) {
277277 case 1:
278278 // Clear selection and move cursor to nearest offset
279 - this.selection = new Selection( this.location );
 279+ this.selection = new es.Selection( this.location );
280280 var cursorPosition = this.location.block.getPosition( this.location.offset );
281281 this.cursor.show( cursorPosition, this.location.block.$.offset() );
282282 this.$input.css( 'top', cursorPosition.top );
@@ -286,7 +286,7 @@
287287 case 2:
288288 // Select word offset is within
289289 var boundaries = this.location.block.getWordBoundaries( this.location.offset );
290 - this.selection = new Selection(
 290+ this.selection = new es.Selection(
291291 new Location( this.location.block, boundaries.start ),
292292 new Location( this.location.block, boundaries.end )
293293 );
@@ -295,7 +295,7 @@
296296 case 3:
297297 // Select section within block offset is within
298298 var boundaries = this.location.block.getSectionBoundaries( this.location.offset );
299 - this.selection = new Selection(
 299+ this.selection = new es.Selection(
300300 new Location( this.location.block, boundaries.start ),
301301 new Location( this.location.block, boundaries.end )
302302 );
@@ -310,7 +310,7 @@
311311 return false;
312312 };
313313
314 -Surface.prototype.onMouseMove = function( e ) {
 314+es.Surface.prototype.onMouseMove = function( e ) {
315315 if ( e.button === 0 && this.mouse.selecting ) {
316316 this.cursor.hide();
317317 this.selection.to = this.getLocationFromEvent( e );
@@ -318,7 +318,7 @@
319319 }
320320 };
321321
322 -Surface.prototype.onMouseUp = function( e ) {
 322+es.Surface.prototype.onMouseUp = function( e ) {
323323 if ( e.button === 0 && this.selection.to ) {
324324 this.location = this.selection.to;
325325 this.drawSelection();
@@ -332,7 +332,7 @@
333333 *
334334 * @return {Boolean} If selection is visibly painted
335335 */
336 -Surface.prototype.drawSelection = function() {
 336+es.Surface.prototype.drawSelection = function() {
337337 var blockWidth;
338338
339339 if ( this.selection.from && this.selection.to ) {
@@ -442,34 +442,34 @@
443443 /**
444444 * Sets the selection to a new range.
445445 *
446 - * @param from {Selection} Selection to apply
 446+ * @param from {es.Selection} Selection to apply
447447 */
448 -Surface.prototype.setSelection = function( selection ) {
 448+es.Surface.prototype.setSelection = function( selection ) {
449449 this.selection = selection;
450450 };
451451
452452 /**
453453 * Gets the current document selection.
454454 *
455 - * @returns {Selection}
 455+ * @returns {es.Selection}
456456 */
457 -Surface.prototype.getSelection = function() {
 457+es.Surface.prototype.getSelection = function() {
458458 return this.selection;
459459 };
460460
461461 /**
462462 * Gets the current cursor location.
463463 *
464 - * @returns {Location}
 464+ * @returns {es.Location}
465465 */
466 -Surface.prototype.getLocation = function() {
 466+es.Surface.prototype.getLocation = function() {
467467 return this.location;
468468 };
469469
470470 /**
471471 * Moves the cursor to the nearest location directly above the current flowed line.
472472 */
473 -Surface.prototype.moveCursorUp = function() {
 473+es.Surface.prototype.moveCursorUp = function() {
474474 var block = this.location.block,
475475 offset = this.location.offset,
476476 position = block.getPosition( offset );
@@ -492,13 +492,13 @@
493493 position = block.getPosition( offset );
494494 this.cursor.show( position, block.$.offset() );
495495
496 - this.location = new Location( block, offset );
 496+ this.location = new es.Location( block, offset );
497497 };
498498
499499 /**
500500 * Moves the cursor to the nearest location directly below the current flowed line.
501501 */
502 -Surface.prototype.moveCursorDown = function() {
 502+es.Surface.prototype.moveCursorDown = function() {
503503 var block = this.location.block,
504504 offset = this.location.offset,
505505 position = block.getPosition( offset );
@@ -521,13 +521,13 @@
522522 position = block.getPosition( offset );
523523 this.cursor.show( position, block.$.offset() );
524524
525 - this.location = new Location( block, offset );
 525+ this.location = new es.Location( block, offset );
526526 };
527527
528528 /**
529529 * Moves the cursor backward of the current position.
530530 */
531 -Surface.prototype.moveCursorRight = function() {
 531+es.Surface.prototype.moveCursorRight = function() {
532532 var block = this.location.block,
533533 offset = this.location.offset;
534534
@@ -545,13 +545,13 @@
546546 block.$.offset()
547547 );
548548
549 - this.location = new Location( block, offset );
 549+ this.location = new es.Location( block, offset );
550550 };
551551
552552 /**
553553 * Moves the cursor forward of the current position.
554554 */
555 -Surface.prototype.moveCursorLeft = function() {
 555+es.Surface.prototype.moveCursorLeft = function() {
556556 var block = this.location.block,
557557 offset = this.location.offset;
558558
@@ -569,10 +569,10 @@
570570 block.$.offset()
571571 );
572572
573 - this.location = new Location( block, offset );
 573+ this.location = new es.Location( block, offset );
574574 };
575575
576 -Surface.prototype.insertContent = function( location, content ) {
 576+es.Surface.prototype.insertContent = function( location, content ) {
577577 if ( typeof location === 'undefined' ) {
578578 location = this.location;
579579 }
@@ -582,7 +582,7 @@
583583 this.location.block.insertContent( location.offset, content );
584584 };
585585
586 -Surface.prototype.deleteContent = function( selection ) {
 586+es.Surface.prototype.deleteContent = function( selection ) {
587587 if ( typeof selection === 'undefined' ) {
588588 selection = this.selection;
589589 }
@@ -623,9 +623,9 @@
624624 *
625625 * @param method {String} Way to apply annotation ("toggle", "add" or "remove")
626626 * @param annotation {Object} Annotation to apply
627 - * @param selection {Selection} Range to apply annotation to
 627+ * @param selection {es.Selection} Range to apply annotation to
628628 */
629 -Surface.prototype.annotateContent = function( method, annotation, selection ) {
 629+es.Surface.prototype.annotateContent = function( method, annotation, selection ) {
630630 if ( typeof selection === 'undefined' ) {
631631 selection = this.selection;
632632 }
Index: trunk/parsers/wikidom/lib/es/es.Block.js
@@ -1,13 +1,13 @@
22 /**
3 - * @extends {EventEmitter}
4 - * @returns {Block}
 3+ * @extends {es.EventEmitter}
 4+ * @returns {es.Block}
55 */
6 -function Block() {
7 - EventEmitter.call( this );
 6+es.Block = function() {
 7+ es.EventEmitter.call( this );
88 this.document = null;
99 }
1010
11 -Block.prototype.getLength = function() {
 11+es.Block.prototype.getLength = function() {
1212 throw 'Block.getLength not implemented in this subclass.';
1313 };
1414
@@ -16,7 +16,7 @@
1717 *
1818 * @returns {Integer} Index of block
1919 */
20 -Block.prototype.getIndex = function() {
 20+es.Block.prototype.getIndex = function() {
2121 if ( !this.document ) {
2222 throw 'Missing document error. Block is not attached to a document.';
2323 }
@@ -26,9 +26,9 @@
2727 /**
2828 * Gets the next block in the document.
2929 *
30 - * @returns {Block|Null} Block directly proceeding this one, or null if none exists
 30+ * @returns {es.Block|Null} Block directly proceeding this one, or null if none exists
3131 */
32 -Block.prototype.nextBlock = function() {
 32+es.Block.prototype.nextBlock = function() {
3333 if ( !this.document ) {
3434 throw 'Missing document error. Block is not attached to a document.';
3535 }
@@ -39,9 +39,9 @@
4040 /**
4141 * Gets the previous block in the document.
4242 *
43 - * @returns {Block|Null} Block directly preceding this one, or null if none exists
 43+ * @returns {es.Block|Null} Block directly preceding this one, or null if none exists
4444 */
45 -Block.prototype.previousBlock = function() {
 45+es.Block.prototype.previousBlock = function() {
4646 if ( !this.document ) {
4747 throw 'Missing document error. Block is not attached to a document.';
4848 }
@@ -55,7 +55,7 @@
5656 * @param offset {Integer} Position to insert content at
5757 * @param content {Object} Content to insert
5858 */
59 -Block.prototype.insertContent = function( offset, content ) {
 59+es.Block.prototype.insertContent = function( offset, content ) {
6060 throw 'Block.insertContent not implemented in this subclass.';
6161 };
6262
@@ -65,14 +65,14 @@
6666 * @param offset {Integer} Position to start removing content from
6767 * @param length {Integer} Length of content to remove
6868 */
69 -Block.prototype.deleteContent = function( offset, length ) {
 69+es.Block.prototype.deleteContent = function( offset, length ) {
7070 throw 'Block.deleteContent not implemented in this subclass.';
7171 };
7272
7373 /**
7474 * Renders content into a container.
7575 */
76 -Block.prototype.renderContent = function() {
 76+es.Block.prototype.renderContent = function() {
7777 throw 'Block.renderContent not implemented in this subclass.';
7878 };
7979
@@ -81,7 +81,7 @@
8282 *
8383 * @param position {Integer} Offset to translate
8484 */
85 -Block.prototype.getOffset = function( position ) {
 85+es.Block.prototype.getOffset = function( position ) {
8686 throw 'Block.getOffset not implemented in this subclass.';
8787 };
8888
@@ -90,7 +90,7 @@
9191 *
9292 * @param offset {Integer} Offset to translate
9393 */
94 -Block.prototype.getPosition = function( offset ) {
 94+es.Block.prototype.getPosition = function( offset ) {
9595 throw 'Block.getPosition not implemented in this subclass.';
9696 };
9797
@@ -104,7 +104,7 @@
105105 * @param start {Integer} Offset to begin annotating from
106106 * @param end {Integer} Offset to stop annotating to
107107 */
108 -Block.prototype.annotateContent = function( method, annotation, start, end ) {
 108+es.Block.prototype.annotateContent = function( method, annotation, start, end ) {
109109 throw 'Block.annotateContent not implemented in this subclass.';
110110 };
111111
@@ -114,7 +114,7 @@
115115 * @param offset {Integer} Offset to find word nearest to
116116 * @return {Object} Range object of boundaries
117117 */
118 -Block.prototype.getWordBoundaries = function( offset ) {
 118+es.Block.prototype.getWordBoundaries = function( offset ) {
119119 throw 'Block.getWordBoundaries not implemented in this subclass.';
120120 };
121121
@@ -124,8 +124,8 @@
125125 * @param offset {Integer} Offset to find section nearest to
126126 * @return {Object} Range object of boundaries
127127 */
128 -Block.prototype.getSectionBoundaries = function( offset ) {
 128+es.Block.prototype.getSectionBoundaries = function( offset ) {
129129 throw 'Block.getSectionBoundaries not implemented in this subclass.';
130130 };
131131
132 -extend( Block, EventEmitter );
 132+es.extend( es.Block, es.EventEmitter );
Index: trunk/parsers/wikidom/lib/es/es.Content.js
@@ -6,12 +6,12 @@
77 * paired with offset annotation), especially when performing substring operations. Content can be
88 * derived from or converted to one or more WikiDom line objects.
99 *
10 - * @extends {EventEmitter}
 10+ * @extends {es.EventEmitter}
1111 * @param content {Array} List of plain or annotated characters
12 - * @returns {Content}
 12+ * @returns {es.Content}
1313 */
14 -function Content( content ) {
15 - EventEmitter.call( this );
 14+es.Content = function( content ) {
 15+ es.EventEmitter.call( this );
1616 this.data = content || [];
1717 };
1818
@@ -23,7 +23,7 @@
2424 * Each supported annotation renderer must have an open and close property, each either a string or
2525 * a function which accepts a data argument.
2626 */
27 -Content.annotationRenderers = {
 27+es.Content.annotationRenderers = {
2828 'template': {
2929 'open': function( data ) {
3030 return '<span class="editSurface-format-object">' + data.html;
@@ -58,7 +58,7 @@
5959 }
6060 };
6161
62 -Content.htmlCharacters = {
 62+es.Content.htmlCharacters = {
6363 '&': '&amp;',
6464 '<': '&lt;',
6565 '>': '&gt;',
@@ -83,7 +83,7 @@
8484 * @param asymmetrical {Boolean} Whether to check only that b contains values from a
8585 * @return {Boolean} If the objects contain the same values as each other
8686 */
87 -Content.compareObjects = function( a, b, asymmetrical ) {
 87+es.Content.compareObjects = function( a, b, asymmetrical ) {
8888 var aValue, bValue, aType, bType;
8989 var k;
9090 for ( k in a ) {
@@ -93,12 +93,12 @@
9494 bType = typeof bValue;
9595 if ( aType !== bType
9696 || ( ( aType === 'string' || aType === 'number' ) && aValue !== bValue )
97 - || ( $.isPlainObject( aValue ) && !Content.compareObjects( aValue, bValue ) ) ) {
 97+ || ( $.isPlainObject( aValue ) && !es.Content.compareObjects( aValue, bValue ) ) ) {
9898 return false;
9999 }
100100 }
101101 // If the check is not asymmetrical, recursing with the arguments swapped will verify our result
102 - return asymmetrical ? true : Content.compareObjects( b, a, true );
 102+ return asymmetrical ? true : es.Content.compareObjects( b, a, true );
103103 };
104104
105105 /**
@@ -107,7 +107,7 @@
108108 * @param source {Object} Object to copy
109109 * @return {Object} Copy of source object
110110 */
111 -Content.copyObject = function( source ) {
 111+es.Content.copyObject = function( source ) {
112112 var destination = {};
113113 var key;
114114 for ( key in source ) {
@@ -116,7 +116,7 @@
117117 if ( sourceType === 'string' || sourceType === 'number' ) {
118118 destination[key] = sourceValue;
119119 } else if ( $.isPlainObject( sourceValue ) ) {
120 - destination[key] = Content.copyObject( sourceValue );
 120+ destination[key] = es.Content.copyObject( sourceValue );
121121 }
122122 }
123123 return destination;
@@ -130,7 +130,7 @@
131131 * properties, the latter of which being an array of annotation objects including range information
132132 * @return {Array} List of plain or annotated characters
133133 */
134 -Content.convertLine = function( line ) {
 134+es.Content.convertLine = function( line ) {
135135 // Convert string to array of characters
136136 var data = line.text.split('');
137137 var i;
@@ -139,7 +139,7 @@
140140 // Build simplified annotation object
141141 var dst = { 'type': src.type };
142142 if ( 'data' in src ) {
143 - dst.data = Content.copyObject( src.data );
 143+ dst.data = es.Content.copyObject( src.data );
144144 }
145145 // Apply annotation to range
146146 var k;
@@ -157,10 +157,10 @@
158158 * Creates a new Content object from a WikiDom line object.
159159 *
160160 * @param line {Object} WikiDom compatible line object - @see Content.convertLine
161 - * @return {Content} New content object containing data derived from the WikiDom line
 161+ * @return {es.Content} New content object containing data derived from the WikiDom line
162162 */
163 -Content.newFromLine = function( line ) {
164 - return new Content( Content.convertLine( line ) );
 163+es.Content.newFromLine = function( line ) {
 164+ return new es.Content( es.Content.convertLine( line ) );
165165 };
166166
167167 /**
@@ -172,18 +172,18 @@
173173 * into multiple line objects, thus making a clean round trip possible.
174174 *
175175 * @param line {Array} List of WikiDom compatible line objects - @see Content.convertLine
176 - * @return {Content} New content object containing data derived from the WikiDom line
 176+ * @return {es.Content} New content object containing data derived from the WikiDom line
177177 */
178 -Content.newFromLines = function( lines ) {
 178+es.Content.newFromLines = function( lines ) {
179179 var data = [];
180180 var i;
181181 for ( i = 0; i < lines.length; i++ ) {
182 - data = data.concat( Content.convertLine( lines[i] ) );
 182+ data = data.concat( es.Content.convertLine( lines[i] ) );
183183 if ( i < lines.length - 1 ) {
184184 data.push( '\n' );
185185 }
186186 }
187 - return new Content( data );
 187+ return new es.Content( data );
188188 };
189189
190190 /**
@@ -197,8 +197,8 @@
198198 * @param stack {Array} List of currently open annotations
199199 * @return {String} Rendered annotation
200200 */
201 -Content.renderAnnotation = function( bias, annotation, stack ) {
202 - var renderers = Content.annotationRenderers,
 201+es.Content.renderAnnotation = function( bias, annotation, stack ) {
 202+ var renderers = es.Content.annotationRenderers,
203203 type = annotation.type,
204204 out = '';
205205 if ( type in renderers ) {
@@ -258,7 +258,7 @@
259259 * @param end {Integer} Optional end of range, if omitted range will end a this.data.length
260260 * @return {String} Plain text within given range
261261 */
262 -Content.prototype.substring = function( start, end ) {
 262+es.Content.prototype.substring = function( start, end ) {
263263 // Wrap values
264264 start = Math.max( 0, start || 0 );
265265 if ( end === undefined ) {
@@ -285,10 +285,10 @@
286286 *
287287 * @param start {Integer} Optional beginning of range, if omitted range will begin at 0
288288 * @param end {Integer} Optional end of range, if omitted range will end a this.data.length
289 - * @return {Content} New content object
 289+ * @return {es.Content} New content object
290290 */
291 -Content.prototype.slice = function( start, end ) {
292 - return new Content( this.data.slice( start, end ) );
 291+es.Content.prototype.slice = function( start, end ) {
 292+ return new es.Content( this.data.slice( start, end ) );
293293 };
294294
295295 /**
@@ -299,7 +299,7 @@
300300 * @param offset {Integer} Position to insert content at
301301 * @param content {Array} Content data to insert
302302 */
303 -Content.prototype.insert = function( offset, content ) {
 303+es.Content.prototype.insert = function( offset, content ) {
304304 // TODO: Prefer to not take annotations from a neighbor that's a space character
305305 var neighbor = this.data[Math.max( offset - 1, 0 )];
306306 if ( $.isArray( neighbor ) ) {
@@ -326,7 +326,7 @@
327327 * @param start {Integer} Beginning of range
328328 * @param end {Integer} End of range
329329 */
330 -Content.prototype.remove = function( start, end ) {
 330+es.Content.prototype.remove = function( start, end ) {
331331 this.data.splice( start, end - start );
332332 this.emit( 'remove', {
333333 'start': start,
@@ -340,7 +340,7 @@
341341 *
342342 * @return {Integer} Length of content data
343343 */
344 -Content.prototype.getLength = function() {
 344+es.Content.prototype.getLength = function() {
345345 return this.data.length;
346346 };
347347
@@ -356,14 +356,14 @@
357357 * @param strict {Boolean} Optionally compare annotation data as well as type
358358 * @return {Array} List of indexes of covered characters within content data
359359 */
360 -Content.prototype.coverageOfAnnotation = function( start, end, annotation, strict ) {
 360+es.Content.prototype.coverageOfAnnotation = function( start, end, annotation, strict ) {
361361 var coverage = [];
362362 var i, index;
363363 for ( i = start; i < end; i++ ) {
364364 index = this.indexOfAnnotation( i, annotation );
365365 if ( typeof this.data[i] !== 'string' && index !== -1 ) {
366366 if ( strict ) {
367 - if ( Content.compareObjects( this.data[i][index].data, annotation.data ) ) {
 367+ if ( es.Content.compareObjects( this.data[i][index].data, annotation.data ) ) {
368368 coverage.push( i );
369369 }
370370 } else {
@@ -385,14 +385,14 @@
386386 * @param annotation {Object} Annotation to compare with
387387 * @param strict {Boolean} Optionally compare annotation data as well as type
388388 */
389 -Content.prototype.indexOfAnnotation = function( offset, annotation, strict ) {
390 - var annotatedCharacter = this.data[offset];
 389+es.Content.prototype.indexOfAnnotation = function( offset, annotation, strict ) {
 390+ var annotatedChar = this.data[offset];
391391 var i;
392 - if ( typeof annotatedCharacter !== 'string' ) {
 392+ if ( typeof annotatedChar !== 'string' ) {
393393 for ( i = 1; i < this.data[offset].length; i++ ) {
394 - if ( annotatedCharacter[i].type === annotation.type ) {
 394+ if ( annotatedChar[i].type === annotation.type ) {
395395 if ( strict ) {
396 - if ( Content.compareObjects( annotatedCharacter[i].data, annotation.data ) ) {
 396+ if ( es.Content.compareObjects( annotatedChar[i].data, annotation.data ) ) {
397397 return i;
398398 }
399399 } else {
@@ -418,7 +418,7 @@
419419 * @param start {Integer} Offset to begin annotating from
420420 * @param end {Integer} Offset to stop annotating to
421421 */
422 -Content.prototype.annotate = function( method, annotation, start, end ) {
 422+es.Content.prototype.annotate = function( method, annotation, start, end ) {
423423 var i;
424424
425425 start = Math.max( start, 0 );
@@ -487,7 +487,7 @@
488488 * @param end {Integer} End of range
489489 * @param {String} Rendered HTML of content data
490490 */
491 -Content.prototype.render = function( start, end ) {
 491+es.Content.prototype.render = function( start, end ) {
492492 if ( start || end ) {
493493 return this.slice( start, end ).render();
494494 }
@@ -505,27 +505,28 @@
506506 if ( !leftPlain && rightPlain ) {
507507 // [formatted][plain] pair, close any annotations for left
508508 for ( j = 1; j < left.length; j++ ) {
509 - out += Content.renderAnnotation( 'close', left[j], stack );
 509+ out += es.Content.renderAnnotation( 'close', left[j], stack );
510510 }
511511 } else if ( leftPlain && !rightPlain ) {
512512 // [plain][formatted] pair, open any annotations for right
513513 for ( j = 1; j < right.length; j++ ) {
514 - out += Content.renderAnnotation( 'open', right[j], stack );
 514+ out += es.Content.renderAnnotation( 'open', right[j], stack );
515515 }
516516 } else if ( !leftPlain && !rightPlain ) {
517517 // [formatted][formatted] pair, open/close any differences
518518 for ( j = 1; j < left.length; j++ ) {
519519 if ( right.indexOf( left[j] ) === -1 ) {
520 - out += Content.renderAnnotation( 'close', left[j], stack );
 520+ out += es.Content.renderAnnotation( 'close', left[j], stack );
521521 }
522522 }
523523 for ( j = 1; j < right.length; j++ ) {
524524 if ( left.indexOf( right[j] ) === -1 ) {
525 - out += Content.renderAnnotation( 'open', right[j], stack );
 525+ out += es.Content.renderAnnotation( 'open', right[j], stack );
526526 }
527527 }
528528 }
529 - out += right[0] in Content.htmlCharacters ? Content.htmlCharacters[right[0]] : right[0];
 529+ out += right[0] in es.Content.htmlCharacters
 530+ ? es.Content.htmlCharacters[right[0]] : right[0];
530531 left = right;
531532 }
532533 return out;
@@ -537,7 +538,7 @@
538539 * @param offset {Integer} Offset to find word nearest to
539540 * @return {Object} Range object of boundaries
540541 */
541 -Content.prototype.getWordBoundaries = function( offset ) {
 542+es.Content.prototype.getWordBoundaries = function( offset ) {
542543 if ( offset < 0 || offset > this.data.length ) {
543544 throw 'Out of bounds error. Offset expected to be >= 0 and <= to ' + this.data.length;
544545 }
@@ -559,10 +560,10 @@
560561 }
561562 end++;
562563 }
563 - return new Range( start, end );
 564+ return new es.Range( start, end );
564565 };
565566
566 -Content.prototype.getLines = function() {
 567+es.Content.prototype.getLines = function() {
567568 var lines = [],
568569 right = '',
569570 rightPlain,
@@ -597,7 +598,7 @@
598599 for ( j = 1; j < left.length; j++ ) {
599600 for ( k = line.annotations.length - 1; k >= 0; k-- ) {
600601 if ( left[j].type === line.annotations[k].type ) {
601 - if ( Content.compareObjects( left[j].data, line.annotations[k].data ) ) {
 602+ if ( es.Content.compareObjects( left[j].data, line.annotations[k].data ) ) {
602603 line.annotations[k].range.end = i - offset;
603604 break;
604605 }
@@ -609,7 +610,7 @@
610611 if ( !rightPlain ) {
611612 for ( j = 1; j < right.length; j++ ) {
612613 if ( leftPlain || this.indexOfAnnotation( i - 1, right[j], true ) === -1 ) {
613 - var annotation = Content.copyObject( right[j] );
 614+ var annotation = es.Content.copyObject( right[j] );
614615 annotation.range = {
615616 start : i - offset,
616617 end : i + 1 - offset
@@ -631,4 +632,4 @@
632633 return lines;
633634 };
634635
635 -extend( Content, EventEmitter );
 636+es.extend( es.Content, es.EventEmitter );
Index: trunk/parsers/wikidom/lib/es/es.EventEmitter.js
@@ -1,8 +1,8 @@
2 -function EventEmitter() {
 2+es.EventEmitter = function() {
33 this.events = {};
44 }
55
6 -EventEmitter.prototype.emit = function( type ) {
 6+es.EventEmitter.prototype.emit = function( type ) {
77 if ( type === 'error' && !( 'error' in this.events ) ) {
88 throw 'Missing error handler error.';
99 }
@@ -17,7 +17,7 @@
1818 return true;
1919 };
2020
21 -EventEmitter.prototype.addListener = function( type, listener ) {
 21+es.EventEmitter.prototype.addListener = function( type, listener ) {
2222 if ( typeof listener !== 'function' ) {
2323 throw 'Invalid listener error. Function expected.';
2424 }
@@ -30,11 +30,11 @@
3131 return this;
3232 };
3333
34 -EventEmitter.prototype.on = function( type, listener ) {
 34+es.EventEmitter.prototype.on = function( type, listener ) {
3535 this.addListener( type, listener );
3636 };
3737
38 -EventEmitter.prototype.once = function( type, listener ) {
 38+es.EventEmitter.prototype.once = function( type, listener ) {
3939 var that = this;
4040 this.addListener( type, function g() {
4141 that.removeListener( type, g );
@@ -42,7 +42,7 @@
4343 } );
4444 };
4545
46 -EventEmitter.prototype.removeListener = function( type, listener ) {
 46+es.EventEmitter.prototype.removeListener = function( type, listener ) {
4747 if ( typeof listener !== 'function' ) {
4848 throw 'Invalid listener error. Function expected.';
4949 }
@@ -65,13 +65,13 @@
6666 return this;
6767 };
6868
69 -EventEmitter.prototype.removeAllListeners = function( type ) {
 69+es.EventEmitter.prototype.removeAllListeners = function( type ) {
7070 if ( type in this.events ) {
7171 delete this.events[type];
7272 }
7373 return this;
7474 };
7575
76 -EventEmitter.prototype.listeners = function( type ) {
 76+es.EventEmitter.prototype.listeners = function( type ) {
7777 return type in this.events ? this.events[type] : [];
7878 };
Index: trunk/parsers/wikidom/lib/es/es.TextFlow.js
@@ -1,18 +1,18 @@
22 /**
33 * Renders and provides access to flowed text.
44 *
5 - * @extends {EventEmitter}
 5+ * @extends {es.EventEmitter}
66 * @param $container {jQuery Selection} Element to render into
7 - * @param content {Content} Initial content to render
8 - * @returns {TextFlow}
 7+ * @param content {es.Content} Initial content to render
 8+ * @returns {es.TextFlow}
99 */
10 -function TextFlow( $container, content ) {
 10+es.TextFlow = function( $container, content ) {
1111 // Inheritance
12 - EventEmitter.call( this );
 12+ es.EventEmitter.call( this );
1313
1414 // Members
1515 this.$ = $container;
16 - this.content = content || new Content();
 16+ this.content = content || new es.Content();
1717 this.boundaries = [];
1818 this.lines = [];
1919 this.width = null;
@@ -49,7 +49,7 @@
5050 * @param position.top {Integer} Vertical position in pixels
5151 * @return {Integer} Offset within content nearest the given coordinates
5252 */
53 -TextFlow.prototype.getOffset = function( position ) {
 53+es.TextFlow.prototype.getOffset = function( position ) {
5454 /*
5555 * Line finding
5656 *
@@ -116,7 +116,7 @@
117117 * @param offset {Integer} Offset within content
118118 * @return {Object} Object containing left, top and bottom properties, each positions in pixels
119119 */
120 -TextFlow.prototype.getPosition = function( offset ) {
 120+es.TextFlow.prototype.getPosition = function( offset ) {
121121 /*
122122 * Range validation
123123 *
@@ -188,7 +188,7 @@
189189 /**
190190 * Updates the word boundary cache, which is used for word fitting.
191191 */
192 -TextFlow.prototype.scanBoundaries = function() {
 192+es.TextFlow.prototype.scanBoundaries = function() {
193193 /*
194194 * Word boundary scan
195195 *
@@ -229,7 +229,7 @@
230230 * causing them to be fragmented. Word fragments are rendered on their own lines, except for their
231231 * remainder, which is combined with whatever proceeding words can fit on the same line.
232232 */
233 -TextFlow.prototype.renderIteration = function( limit ) {
 233+es.TextFlow.prototype.renderIteration = function( limit ) {
234234 var rs = this.renderState,
235235 iteration = 0,
236236 fractional = false,
@@ -307,7 +307,7 @@
308308 *
309309 * @param offset {Integer} Offset to re-render from, if possible (not yet implemented)
310310 */
311 -TextFlow.prototype.render = function( offset ) {
 311+es.TextFlow.prototype.render = function( offset ) {
312312 var rs = this.renderState;
313313
314314 // Check if rendering is currently underway
@@ -370,7 +370,7 @@
371371 * @param wordOffset {Integer} Index within this.words which the line begins with
372372 * @param fractional {Boolean} If the line begins in the middle of a word
373373 */
374 -TextFlow.prototype.appendLine = function( start, end, wordOffset, fractional ) {
 374+es.TextFlow.prototype.appendLine = function( start, end, wordOffset, fractional ) {
375375 var rs = this.renderState,
376376 lineCount = rs.lines.length;
377377 $line = this.$.find( '.editSurface-line[line-index=' + lineCount + ']' );
@@ -421,7 +421,7 @@
422422 * @param width {Integer} Maximum width to allow the line to extend to
423423 * @return {Integer} Last index within "words" that contains a word that fits
424424 */
425 -TextFlow.prototype.fitWords = function( start, end, ruler, width ) {
 425+es.TextFlow.prototype.fitWords = function( start, end, ruler, width ) {
426426 var offset = start,
427427 charOffset = this.boundaries[offset],
428428 middle,
@@ -476,7 +476,7 @@
477477 * @param width {Integer} Maximum width to allow the line to extend to
478478 * @return {Integer} Last index within "text" that contains a character that fits
479479 */
480 -TextFlow.prototype.fitCharacters = function( start, end, ruler, width ) {
 480+es.TextFlow.prototype.fitCharacters = function( start, end, ruler, width ) {
481481 var offset = start,
482482 middle,
483483 lineWidth,
@@ -524,4 +524,4 @@
525525 return { 'end': start, 'width': lineWidth };
526526 };
527527
528 -extend( TextFlow, EventEmitter );
 528+es.extend( es.TextFlow, es.EventEmitter );
Index: trunk/parsers/wikidom/lib/es/es.Cursor.js
@@ -1,8 +1,8 @@
22 /**
33 *
4 - * @returns {Cursor}
 4+ * @returns {es.Cursor}
55 */
6 -function Cursor() {
 6+es.Cursor = function() {
77 this.cursorInterval = null;
88 this.$ = $( '<div class="editSurface-cursor"></div>' );
99 }
@@ -13,7 +13,7 @@
1414 * @param position {Position} Position to show the cursor at
1515 * @param offset {Position} Offset to be added to position
1616 */
17 -Cursor.prototype.show = function( position, offset ) {
 17+es.Cursor.prototype.show = function( position, offset ) {
1818 if ( position ) {
1919 if ( $.isPlainObject( offset ) ) {
2020 position.left += offset.left;
@@ -41,7 +41,7 @@
4242 /**
4343 * Hides the cursor.
4444 */
45 -Cursor.prototype.hide = function() {
 45+es.Cursor.prototype.hide = function() {
4646 if( this.cursorInterval ) {
4747 clearInterval( this.cursorInterval );
4848 }
Index: trunk/parsers/wikidom/demos/es/index.html
@@ -64,8 +64,8 @@
6565 <!-- Demo -->
6666 <script>
6767 $(document).ready( function() {
68 - var doc = new Document([
69 - new ParagraphBlock([
 68+ var doc = new es.Document([
 69+ new es.ParagraphBlock([
7070 {
7171 'text': "In text display, line wrap is the feature of continuing on a new line when a line is full, such that each line fits in the viewable window, allowing text to be read from top to bottom without any horizontal scrolling.",
7272 'annotations': [
@@ -97,7 +97,7 @@
9898 },
9999 { 'text': "A soft return is the break resulting from line wrap or word wrap, whereas a hard return is an intentional break, creating a new paragraph." },
100100 ]),
101 - new ParagraphBlock([
 101+ new es.ParagraphBlock([
102102 { 'text': "The soft returns are usually placed after the ends of complete words, or after the punctuation that follows complete words. However, word wrap may also occur following a hyphen." },
103103 { 'text': "Word wrap following hyphens is sometimes not desired, and can be avoided by using a so-called non-breaking hyphen instead of a regular hyphen. On the other hand, when using word processors, invisible hyphens, called soft hyphens, can also be inserted inside words so that word wrap can occur following the soft hyphens." },
104104 { 'text': "Sometimes, word wrap is not desirable between words. In such cases, word wrap can usually be avoided by using a hard space or non-breaking space between the words, instead of regular spaces." },
@@ -105,7 +105,7 @@
106106 { 'text': "Text might have\ttabs\tin it too. Not all text will end in a line breaking character" }
107107 ])
108108 ]);
109 - var surface = new Surface( $('#es-editor'), doc );
 109+ var surface = new es.Surface( $('#es-editor'), doc );
110110
111111 $( '#es-toolbar .es-toolbarTool' ).mousedown( function( e ) {
112112 e.preventDefault();

Status & tagging log