r100649 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100648‎ | r100649 | r100650 >
Date:21:40, 24 October 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Tons of syntax fixes (jshint complaints)
Modified paths:
  • /trunk/parsers/wikidom/demos/es/es.js (modified) (history)
  • /trunk/parsers/wikidom/demos/es/index.html (modified) (history)
  • /trunk/parsers/wikidom/demos/renderers/index.html (modified) (history)
  • /trunk/parsers/wikidom/demos/surface/index.html (modified) (history)
  • /trunk/parsers/wikidom/demos/surface/jquery.editSurface.js (modified) (history)
  • /trunk/parsers/wikidom/demos/surface/jquery.flow.js (modified) (history)
  • /trunk/parsers/wikidom/demos/synth/es.js (modified) (history)
  • /trunk/parsers/wikidom/demos/synth/index.html (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.BlockTransaction.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Container.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Content.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.ContentFlow.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Cursor.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Document.Context.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Document.HtmlSerializer.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Document.JsonSerializer.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Document.Serializer.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Document.WikitextSerializer.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.EventEmitter.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.ListBlock.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.ListBlockItem.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Selection.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Surface.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/bases/es.AggregateArray.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/bases/es.EventEmitter.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/bases/es.ModelList.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/bases/es.ViewList.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/es.Html.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/es.JsonSerializer.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/es.Selection.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/es.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.CommentBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.ContentModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.HeadingBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.HorizontalRuleBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.ParagraphBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.TableBlockModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/models/es.TableBlockRowModel.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.BlockView.js (modified) (history)
  • /trunk/parsers/wikidom/lib/synth/views/es.ContentView.js (modified) (history)
  • /trunk/parsers/wikidom/tests/serializers/test.js (modified) (history)
  • /trunk/parsers/wikidom/tests/synth/test.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/tests/synth/test.js
@@ -8,7 +8,7 @@
99
1010 var updates = 0;
1111 container1.on( 'update', function( item ) {
12 - updates++
 12+ updates++;
1313 } );
1414
1515 // Creating
@@ -39,7 +39,7 @@
4040
4141 // Accessing
4242
43 - deepEqual( container1.all(), [item1, item2, item3], 'es.ModelContainer.items returns all items' )
 43+ deepEqual( container1.all(), [item1, item2, item3], 'es.ModelContainer.items returns all items' );
4444
4545 strictEqual( container1.get( 0 ), item1, 'es.ModelContainer.get returns correct item at index' );
4646 strictEqual( container1.get( 1 ), item2, 'es.ModelContainer.get returns correct item at index' );
@@ -74,7 +74,7 @@
7575 return false;
7676 }
7777 } );
78 - equal( count, 2, 'es.ModelContainer.each stops iterating when a callback returns false' )
 78+ equal( count, 2, 'es.ModelContainer.each stops iterating when a callback returns false' );
7979
8080 // Updating
8181
@@ -208,7 +208,8 @@
209209 c = new ContentStub( 'c', 2 ),
210210 d = new ContentStub( 'd', 3 ),
211211 e = new ContentStub( 'e', 4 ),
212 - contentSeries1 = new es.AggregateArray( [a, b, c, d, e] );
 212+ contentSeries1 = new es.AggregateArray( [a, b, c, d, e] ),
 213+ i;
213214
214215 var lengthOfItemsTests = [
215216 { 'input': [], 'output': 0 },
@@ -219,7 +220,7 @@
220221 { 'input': [a, b, c, d, e], 'output': 14 }
221222 ];
222223
223 - for ( var i = 0; i < lengthOfItemsTests.length; i++ ) {
 224+ for ( i = 0; i < lengthOfItemsTests.length; i++ ) {
224225 strictEqual(
225226 ( new es.AggregateArray( lengthOfItemsTests[i].input ) ).getLengthOfItems(),
226227 lengthOfItemsTests[i].output,
@@ -247,7 +248,7 @@
248249 { 'input': 15, 'output': null }
249250 ];
250251
251 - for ( var i = 0; i < lookupTests.length; i++ ) {
 252+ for ( i = 0; i < lookupTests.length; i++ ) {
252253 strictEqual(
253254 contentSeries1.lookup( lookupTests[i].input ),
254255 lookupTests[i].output,
@@ -264,7 +265,7 @@
265266 { 'input': null, 'output': null }
266267 ];
267268
268 - for ( var i = 0; i < rangeOfTests.length; i++ ) {
 269+ for ( i = 0; i < rangeOfTests.length; i++ ) {
269270 deepEqual(
270271 contentSeries1.rangeOf( rangeOfTests[i].input ),
271272 rangeOfTests[i].output,
@@ -279,15 +280,15 @@
280281 var selectTests = [
281282 {
282283 'input': [0, 5],
283 - 'output': [{ 'item': f, 'from': 0, 'to': 5 }],
 284+ 'output': [{ 'item': f, 'from': 0, 'to': 5 }]
284285 },
285286 {
286287 'input': [11, 16],
287 - 'output': [{ 'item': g, 'from': 0, 'to': 5 }],
 288+ 'output': [{ 'item': g, 'from': 0, 'to': 5 }]
288289 },
289290 {
290291 'input': [22, 27],
291 - 'output': [{ 'item': h, 'from': 0, 'to': 5 }],
 292+ 'output': [{ 'item': h, 'from': 0, 'to': 5 }]
292293 },
293294 {
294295 'input': [0, 33],
@@ -307,7 +308,7 @@
308309 },
309310 {
310311 'input': [5, 9],
311 - 'output': [{ 'item': f, 'from': 5, 'to': 9 }],
 312+ 'output': [{ 'item': f, 'from': 5, 'to': 9 }]
312313 },
313314 {
314315 'input': [5, 10],
@@ -343,7 +344,7 @@
344345 }
345346 ];
346347
347 - for ( var i = 0; i < selectTests.length; i++ ) {
 348+ for ( i = 0; i < selectTests.length; i++ ) {
348349 deepEqual(
349350 contentSeries2.select.apply( contentSeries2, selectTests[i].input ),
350351 selectTests[i].output,
Index: trunk/parsers/wikidom/tests/serializers/test.js
@@ -5,7 +5,8 @@
66 wikitextSerializer = new es.Document.WikitextSerializer( context );
77
88 function assertSerializations( tests, domToDom ) {
9 - for ( var i = 0; i < tests.length; i++ ) {
 9+ var i;
 10+ for ( i = 0; i < tests.length; i++ ) {
1011 if ( typeof tests[i].html !== 'undefined' ) {
1112 equals(
1213 htmlSerializer.serializeDocument( tests[i].dom ),
@@ -14,7 +15,7 @@
1516 );
1617 }
1718 }
18 - for ( var i = 0; i < tests.length; i++ ) {
 19+ for ( i = 0; i < tests.length; i++ ) {
1920 if ( typeof tests[i].wikitext !== 'undefined' ) {
2021 equals(
2122 wikitextSerializer.serializeDocument( tests[i].dom ),
@@ -25,7 +26,7 @@
2627 }
2728 if ( typeof domToDom !== 'undefined' && domToDom === true ) {
2829 var doc;
29 - for ( var i = 0; i < tests.length; i++ ) {
 30+ for ( i = 0; i < tests.length; i++ ) {
3031 deepEqual(
3132 doc = es.Document.newFromWikiDomDocument( tests[i].dom ).getWikiDomDocument(),
3233 tests[i].dom,
@@ -142,13 +143,13 @@
143144 } ] },
144145 'html': '<h1>Heading with a <a href="https://www.mediawiki.org/wiki/Main_Page">link</a></h1>',
145146 'wikitext': '=Heading with a [[Main_Page|link]]='
146 - },
 147+ }
147148 ] );
148149 } );
149150
150151 test( 'Paragraphs', function() {
151152 assertSerializations( [
152 - {
 153+ {
153154 'subject': 'paragraph with a single line of plain text',
154155 'dom': { 'blocks': [ {
155156 'type': 'paragraph',
@@ -186,13 +187,13 @@
187188 'html': '<p>Line with <strong>bold</strong> and <em>italic</em> text</p>',
188189 'wikitext': 'Line with \'\'\'bold\'\'\' and \'\'italic\'\' text'
189190 }
190 - ], true );
 191+ ], true );
191192 } );
192193
193194 // Lists
194195 test( 'Lists', function() {
195196 assertSerializations( [
196 - {
 197+ {
197198 'subject': 'numbered list',
198199 'dom': { 'blocks': [ {
199200 'type': 'list',
@@ -206,7 +207,7 @@
207208 'html': '<ol>\n<li>1</li>\n<li>2</li>\n<li>3</li>\n</ol>',
208209 'wikitext': '# 1\n# 2\n# 3'
209210 },
210 - {
 211+ {
211212 'subject': 'bulleted list',
212213 'dom': { 'blocks': [ {
213214 'type': 'list',
@@ -220,7 +221,7 @@
221222 'html': '<ul>\n<li>1</li>\n<li>2</li>\n<li>3</li>\n</ul>',
222223 'wikitext': '* 1\n* 2\n* 3'
223224 },
224 - {
 225+ {
225226 'subject': 'mixed-style nested lists (1)',
226227 'dom': { 'blocks': [ {
227228 'type': 'list',
@@ -242,11 +243,11 @@
243244 { 'line': { 'text': '2' } }
244245 ]
245246 } ] },
246 - 'html': '<ul>\n<li>1\n<ol>\n<li>1.1</li>\n<li>1.2</li>\n<li>1.3</li>\n</ol>'
247 - + '\n</li>\n<li>2</li>\n</ul>',
 247+ 'html': '<ul>\n<li>1\n<ol>\n<li>1.1</li>\n<li>1.2</li>\n<li>1.3</li>\n</ol>' +
 248+ '\n</li>\n<li>2</li>\n</ul>',
248249 'wikitext': '* 1\n*# 1.1\n*# 1.2\n*# 1.3\n* 2'
249250 },
250 - {
 251+ {
251252 'subject': 'mixed-style nested lists (2)',
252253 'dom': { 'blocks': [ {
253254 'type': 'list',
@@ -285,7 +286,7 @@
286287 ]
287288 } ] }
288289 },
289 - {
 290+ {
290291 'subject': 'mixed-style nested lists (3)',
291292 'dom': { 'blocks': [ {
292293 'type': 'list',
@@ -362,8 +363,8 @@
363364 ]
364365 ]
365366 }] },
366 - 'html': '<table>\n<tr>\n<th>A</th>\n<th>B</th>\n</tr>\n<tr>\n'
367 - + '<td>1</td>\n<td>2</td>\n</tr>\n</table>',
 367+ 'html': '<table>\n<tr>\n<th>A</th>\n<th>B</th>\n</tr>\n<tr>\n' +
 368+ '<td>1</td>\n<td>2</td>\n</tr>\n</table>',
368369 'wikitext': '{|\n!A\n!B\n|-\n|1\n|2\n|}'
369370 },
370371 {
Index: trunk/parsers/wikidom/lib/synth/es.js
@@ -62,9 +62,9 @@
6363 bValue = b[k];
6464 aType = typeof aValue;
6565 bType = typeof bValue;
66 - if ( aType !== bType
67 - || ( ( aType === 'string' || aType === 'number' ) && aValue !== bValue )
68 - || ( $.isPlainObject( aValue ) && !es.compareObjects( aValue, bValue ) ) ) {
 66+ if ( aType !== bType ||
 67+ ( ( aType === 'string' || aType === 'number' ) && aValue !== bValue ) ||
 68+ ( $.isPlainObject( aValue ) && !es.compareObjects( aValue, bValue ) ) ) {
6969 return false;
7070 }
7171 }
Index: trunk/parsers/wikidom/lib/synth/models/es.CommentBlockModel.js
@@ -64,7 +64,7 @@
6565 };
6666
6767 // Register constructor
68 -es.BlockModel.constructors['comment'] = es.CommentBlockModel;
 68+es.BlockModel.constructors.comment = es.CommentBlockModel;
6969
7070 /* Inheritance */
7171
Index: trunk/parsers/wikidom/lib/synth/models/es.ParagraphBlockModel.js
@@ -103,7 +103,7 @@
104104 };
105105
106106 // Register constructor
107 -es.BlockModel.constructors['paragraph'] = es.ParagraphBlockModel.newFromPlainObject;
 107+es.BlockModel.constructors.paragraph = es.ParagraphBlockModel.newFromPlainObject;
108108
109109 /* Inheritance */
110110
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockModel.js
@@ -34,7 +34,7 @@
3535 return new es.TableBlockModel(
3636 // Cells - if given, convert plain row objects to es.TableBlockRowModel objects
3737 !$.isArray( obj.children ) ? [] : $.map( obj.children, function( row ) {
38 - return !$.isPlainObject( row ) ? null : es.TableBlockRowModel.newFromPlainObject( row )
 38+ return !$.isPlainObject( row ) ? null : es.TableBlockRowModel.newFromPlainObject( row );
3939 } ),
4040 // Attributes - if given, make a deep copy of attributes
4141 !$.isPlainObject( obj.attributes ) ? {} : $.extend( true, {}, obj.attributes )
@@ -114,7 +114,7 @@
115115 };
116116
117117 // Register constructor
118 -es.BlockModel.constructors['table'] = es.TableBlockModel.newFromPlainObject;
 118+es.BlockModel.constructors.table = es.TableBlockModel.newFromPlainObject;
119119
120120 /* Inheritance */
121121
Index: trunk/parsers/wikidom/lib/synth/models/es.ListBlockModel.js
@@ -143,7 +143,7 @@
144144 };
145145
146146 // Register constructor
147 -es.BlockModel.constructors['list'] = es.ListBlockModel.newFromPlainObject
 147+es.BlockModel.constructors.list = es.ListBlockModel.newFromPlainObject;
148148
149149 /* Inheritance */
150150
Index: trunk/parsers/wikidom/lib/synth/models/es.ContentModel.js
@@ -88,9 +88,11 @@
8989 // TODO: This is invalid data! Throw error?
9090 src.range.end = data.length;
9191 }
92 - for ( var i = src.range.start; i < src.range.end; i++ ) {
 92+ for ( var j = src.range.start; j < src.range.end; j++ ) {
9393 // Auto-convert to array
94 - typeof data[i] === 'string' && ( data[i] = [data[i]] );
 94+ if ( typeof data[j] === 'string' ) {
 95+ data[j] = [data[j]];
 96+ }
9597 // Append
9698 data[i].push( dst );
9799 }
@@ -273,8 +275,8 @@
274276 for ( var i = stack.length - 1; i >= 0; i-- ) {
275277 if ( !stack[i].range.end ) {
276278 if ( annotation ) {
277 - if ( stack[i].type === annotation.type
278 - && es.compareObjects( stack[i].data, annotation.data ) ) {
 279+ if ( stack[i].type === annotation.type &&
 280+ es.compareObjects( stack[i].data, annotation.data ) ) {
279281 stack[i].range.end = offset;
280282 break;
281283 }
@@ -508,6 +510,7 @@
509511 } else {
510512 range.normalize();
511513 }
 514+ var i;
512515 /*
513516 * Content isolation
514517 *
@@ -520,7 +523,7 @@
521524 * expensive to do on all content on every copy, so we only do it when we are going to modify
522525 * the annotation information, and on as few annotated characters as possible.
523526 */
524 - for ( var i = range.start; i < range.end; i++ ) {
 527+ for ( i = range.start; i < range.end; i++ ) {
525528 if ( typeof this.data[i] !== 'string' ) {
526529 this.data[i] = this.data[i].slice( 0 );
527530 }
@@ -541,7 +544,7 @@
542545 }
543546 if ( method === 'add' ) {
544547 var duplicate;
545 - for ( var i = range.start; i < range.end; i++ ) {
 548+ for ( i = range.start; i < range.end; i++ ) {
546549 duplicate = -1;
547550 if ( typeof this.data[i] === 'string' ) {
548551 // Never annotate new lines
@@ -563,7 +566,7 @@
564567 }
565568 }
566569 } else if ( method === 'remove' ) {
567 - for ( var i = range.start; i < range.end; i++ ) {
 570+ for ( i = range.start; i < range.end; i++ ) {
568571 if ( typeof this.data[i] !== 'string' ) {
569572 if ( annotation.type === 'all' ) {
570573 // Remove all annotations by converting the annotated character to a plain
Index: trunk/parsers/wikidom/lib/synth/models/es.HeadingBlockModel.js
@@ -93,7 +93,7 @@
9494 };
9595
9696 // Register constructor
97 -es.BlockModel.constructors['heading'] = es.HeadingBlockModel.newFromPlainObject;
 97+es.BlockModel.constructors.heading = es.HeadingBlockModel.newFromPlainObject;
9898
9999 /* Inheritance */
100100
Index: trunk/parsers/wikidom/lib/synth/models/es.TableBlockRowModel.js
@@ -32,8 +32,8 @@
3333 return new es.TableBlockRowModel(
3434 // Cells - if given, convert plain cell objects to es.TableBlockCellModel objects
3535 !$.isArray( obj.children ) ? [] : $.map( obj.children, function( cell ) {
36 - return !$.isPlainObject( cell ) ? null
37 - : es.TableBlockCellModel.newFromPlainObject( cell )
 36+ return !$.isPlainObject( cell ) ? null :
 37+ es.TableBlockCellModel.newFromPlainObject( cell );
3838 } ),
3939 // Attributes - if given, make a deep copy of attributes
4040 !$.isPlainObject( obj.attributes ) ? {} : $.extend( true, {}, obj.attributes )
Index: trunk/parsers/wikidom/lib/synth/models/es.HorizontalRuleBlockModel.js
@@ -47,11 +47,11 @@
4848 * @returns obj {Object}
4949 */
5050 es.HorizontalRuleBlockModel.prototype.getPlainObject = function() {
51 - return { 'type': 'horizontal-rule' };
 51+ return { 'type': 'horizontalRule' };
5252 };
5353
5454 // Register constructor
55 -es.BlockModel.constructors['horizontal-rule'] = es.HorizontalRuleBlockModel;
 55+es.BlockModel.constructors.horizontalRule = es.HorizontalRuleBlockModel;
5656
5757 /* Inheritance */
5858
Index: trunk/parsers/wikidom/lib/synth/es.JsonSerializer.js
@@ -22,11 +22,11 @@
2323 return 'null';
2424 }
2525 switch ( value.constructor ) {
26 - case ( new Array ).constructor:
 26+ case [].constructor:
2727 return 'array';
28 - case ( new Date ).constructor:
 28+ case ( new Date() ).constructor:
2929 return 'date';
30 - case ( new RegExp ).constructor:
 30+ case ( new RegExp() ).constructor:
3131 return 'regex';
3232 default:
3333 return 'object';
@@ -39,7 +39,8 @@
4040 if ( indention === undefined ) {
4141 indention = '';
4242 }
43 - var type = es.JsonSerializer.typeOf( data );
 43+ var type = es.JsonSerializer.typeOf( data ),
 44+ key;
4445
4546 // Open object/array
4647 var json = '';
@@ -51,8 +52,8 @@
5253 json += '[';
5354 } else {
5455 var empty = true;
55 - for ( var i in data ) {
56 - if ( data.hasOwnProperty( i ) ) {
 56+ for ( key in data ) {
 57+ if ( data.hasOwnProperty( key ) ) {
5758 empty = false;
5859 break;
5960 }
@@ -65,27 +66,26 @@
6667
6768 // Iterate over items
6869 var comma = false;
69 - for ( var i in data ) {
70 - if ( data.hasOwnProperty( i ) ) {
71 - json += ( comma ? ',' : '' ) + '\n' + indention + this.options.indentWith
72 - + ( type === 'array' ? '' : '"' + i + '"' + ': ' );
73 - switch ( es.JsonSerializer.typeOf( data[i] ) ) {
 70+ for ( key in data ) {
 71+ if ( data.hasOwnProperty( key ) ) {
 72+ json += ( comma ? ',' : '' ) + '\n' + indention + this.options.indentWith +
 73+ ( type === 'array' ? '' : '"' + key + '"' + ': ' );
 74+ switch ( es.JsonSerializer.typeOf( data[key] ) ) {
7475 case 'array':
7576 case 'object':
76 - json += this.encode( data[i], indention + this.options.indentWith );
 77+ json += this.encode( data[key], indention + this.options.indentWith );
7778 break;
7879 case 'boolean':
7980 case 'number':
80 - json += data[i].toString();
 81+ json += data[key].toString();
8182 break;
8283 case 'null':
8384 json += 'null';
8485 break;
8586 case 'string':
86 - json += '"' + data[i]
 87+ json += '"' + data[key]
8788 .replace(/[\n]/g, '\\n')
88 - .replace(/[\t]/g, '\\t')
89 - + '"';
 89+ .replace(/[\t]/g, '\\t') + '"';
9090 break;
9191 // Skip other types
9292 }
Index: trunk/parsers/wikidom/lib/synth/es.Html.js
@@ -33,8 +33,8 @@
3434 if ( escape ) {
3535 value = wiki.util.xml.esc( value );
3636 }
37 - return '<' + name + es.Html.makeAttributeList( attributes, true ) + '>'
38 - + value + '</' + name + '>';
 37+ return '<' + name + es.Html.makeAttributeList( attributes, true ) + '>' +
 38+ value + '</' + name + '>';
3939 }
4040 }
4141 };
Index: trunk/parsers/wikidom/lib/synth/es.Selection.js
@@ -15,7 +15,7 @@
1616 this.to = to;
1717 this.start = from;
1818 this.end = to;
19 -}
 19+};
2020
2121 /* Methods */
2222
Index: trunk/parsers/wikidom/lib/synth/bases/es.AggregateArray.js
@@ -68,8 +68,8 @@
6969 var result = { 'on': [], 'off': [] },
7070 left = 0,
7171 right,
72 - items = [],
73 - off = off || false;
 72+ items = [];
 73+ off = off || false;
7474
7575 if ( typeof start.from === 'number' && typeof start.to === 'number') {
7676 start.normalize();
Index: trunk/parsers/wikidom/lib/synth/bases/es.ViewList.js
@@ -40,7 +40,7 @@
4141 itemView = itemModel.createView();
4242 }
4343 return itemView;
44 - }
 44+ };
4545
4646 this.model.on( 'prepend', function( itemModel ) {
4747 var itemView = list.recycleItemView( itemModel, true );
Index: trunk/parsers/wikidom/lib/synth/bases/es.EventEmitter.js
@@ -7,7 +7,7 @@
88 */
99 es.EventEmitter = function() {
1010 this.events = {};
11 -}
 11+};
1212
1313 /* Methods */
1414
@@ -104,7 +104,7 @@
105105 return this;
106106 }
107107 handlers.splice( i, 1 );
108 - if ( handlers.length == 0 ) {
 108+ if ( handlers.length === 0 ) {
109109 delete this.events[type];
110110 }
111111 }
Index: trunk/parsers/wikidom/lib/synth/bases/es.ModelList.js
@@ -46,7 +46,7 @@
4747 * @returns {Integer} Number of items in container
4848 */
4949 es.ModelList.prototype.getLength = function() {
50 - return this.items.length
 50+ return this.items.length;
5151 };
5252
5353 /**
@@ -76,8 +76,7 @@
7777 * @returns {Object} Last item
7878 */
7979 es.ModelList.prototype.last = function() {
80 - return this.items.length
81 - ? this.items[this.items.length - 1] : null;
 80+ return this.items.length ? this.items[this.items.length - 1] : null;
8281 };
8382
8483 /**
Index: trunk/parsers/wikidom/lib/synth/views/es.BlockView.js
@@ -71,7 +71,7 @@
7272 */
7373 es.BlockView.prototype.getHtml = function( options ) {
7474 throw 'BlockView.getHtml not implemented in this subclass.';
75 -}
 75+};
7676
7777 /* Inheritance */
7878
Index: trunk/parsers/wikidom/lib/synth/views/es.ContentView.js
@@ -154,38 +154,36 @@
155155 // Add annotation to the top of the stack
156156 stack.push( annotation );
157157 // Open annotation
158 - out += typeof renderers[type]['open'] === 'function'
159 - ? renderers[type]['open']( annotation.data )
160 - : renderers[type]['open'];
 158+ out += typeof renderers[type].open === 'function' ?
 159+ renderers[type].open( annotation.data ) : renderers[type].open;
161160 } else {
162161 if ( stack[stack.length - 1] === annotation ) {
163162 // Remove annotation from top of the stack
164163 stack.pop();
165164 // Close annotation
166 - out += typeof renderers[type]['close'] === 'function'
167 - ? renderers[type]['close']( annotation.data )
168 - : renderers[type]['close'];
 165+ out += typeof renderers[type].close === 'function' ?
 166+ renderers[type].close( annotation.data ) : renderers[type].close;
169167 } else {
170168 // Find the annotation in the stack
171 - var depth = stack.indexOf( annotation );
 169+ var depth = stack.indexOf( annotation ),
 170+ i;
172171 if ( depth === -1 ) {
173172 throw 'Invalid stack error. An element is missing from the stack.';
174173 }
175174 // Close each already opened annotation
176 - for ( var i = stack.length - 1; i >= depth + 1; i-- ) {
177 - out += typeof renderers[stack[i].type]['close'] === 'function'
178 - ? renderers[stack[i].type]['close']( stack[i].data )
179 - : renderers[stack[i].type]['close'];
 175+ for ( i = stack.length - 1; i >= depth + 1; i-- ) {
 176+ out += typeof renderers[stack[i].type].close === 'function' ?
 177+ renderers[stack[i].type].close( stack[i].data ) :
 178+ renderers[stack[i].type].close;
180179 }
181180 // Close the buried annotation
182 - out += typeof renderers[type]['close'] === 'function'
183 - ? renderers[type]['close']( annotation.data )
184 - : renderers[type]['close'];
 181+ out += typeof renderers[type].close === 'function' ?
 182+ renderers[type].close( annotation.data ) : renderers[type].close;
185183 // Re-open each previously opened annotation
186 - for ( var i = depth + 1; i < stack.length; i++ ) {
187 - out += typeof renderers[stack[i].type]['open'] === 'function'
188 - ? renderers[stack[i].type]['open']( stack[i].data )
189 - : renderers[stack[i].type]['open'];
 184+ for ( i = depth + 1; i < stack.length; i++ ) {
 185+ out += typeof renderers[stack[i].type].open === 'function' ?
 186+ renderers[stack[i].type].open( stack[i].data ) :
 187+ renderers[stack[i].type].open;
190188 }
191189 // Remove the annotation from the middle of the stack
192190 stack.splice( depth, 1 );
@@ -445,7 +443,7 @@
446444 // Iterate over each word+boundary sequence, capturing offsets and encoding text as we go
447445 var match,
448446 end;
449 - while ( match = this.boundaryTest.exec( text ) ) {
 447+ while ( ( match = this.boundaryTest.exec( text ) ) ) {
450448 // Include the boundary character in the range
451449 end = match.index + 1;
452450 // Store the boundary offset
@@ -797,29 +795,31 @@
798796 right,
799797 leftPlain,
800798 rightPlain,
801 - stack = [];
802 - for ( var i = 0; i < data.length; i++ ) {
 799+ stack = [],
 800+ i,
 801+ j;
 802+ for ( i = 0; i < data.length; i++ ) {
803803 right = data[i];
804804 leftPlain = typeof left === 'string';
805805 rightPlain = typeof right === 'string';
806806 if ( !leftPlain && rightPlain ) {
807807 // [formatted][plain] pair, close any annotations for left
808 - for ( var j = 1; j < left.length; j++ ) {
 808+ for ( j = 1; j < left.length; j++ ) {
809809 out += render( 'close', left[j], stack );
810810 }
811811 } else if ( leftPlain && !rightPlain ) {
812812 // [plain][formatted] pair, open any annotations for right
813 - for ( var j = 1; j < right.length; j++ ) {
 813+ for ( j = 1; j < right.length; j++ ) {
814814 out += render( 'open', right[j], stack );
815815 }
816816 } else if ( !leftPlain && !rightPlain ) {
817817 // [formatted][formatted] pair, open/close any differences
818 - for ( var j = 1; j < left.length; j++ ) {
 818+ for ( j = 1; j < left.length; j++ ) {
819819 if ( right.indexOf( left[j] ) === -1 ) {
820820 out += render( 'close', left[j], stack );
821821 }
822822 }
823 - for ( var j = 1; j < right.length; j++ ) {
 823+ for ( j = 1; j < right.length; j++ ) {
824824 if ( left.indexOf( right[j] ) === -1 ) {
825825 out += render( 'open', right[j], stack );
826826 }
@@ -830,7 +830,7 @@
831831 }
832832 // Close all remaining tags at the end of the content
833833 if ( !rightPlain && right ) {
834 - for ( var j = 1; j < right.length; j++ ) {
 834+ for ( j = 1; j < right.length; j++ ) {
835835 out += render( 'close', right[j], stack );
836836 }
837837 }
Index: trunk/parsers/wikidom/lib/es/es.BlockTransaction.js
@@ -38,10 +38,11 @@
3939 */
4040 es.BlockTransaction.operations = ( function() {
4141 function annotate( con, add, rem ) {
42 - for ( var i = 0; i < add.length; i++ ) {
 42+ var i;
 43+ for ( i = 0; i < add.length; i++ ) {
4344 con.annotate( 'add', add[i] );
4445 }
45 - for ( var i = 0; i < rem.length; i++ ) {
 46+ for ( i = 0; i < rem.length; i++ ) {
4647 con.annotate( 'remove', rem[i] );
4748 }
4849 }
Index: trunk/parsers/wikidom/lib/es/es.js
@@ -62,9 +62,9 @@
6363 bValue = b[k];
6464 aType = typeof aValue;
6565 bType = typeof bValue;
66 - if ( aType !== bType
67 - || ( ( aType === 'string' || aType === 'number' ) && aValue !== bValue )
68 - || ( $.isPlainObject( aValue ) && !es.compareObjects( aValue, bValue ) ) ) {
 66+ if ( aType !== bType ||
 67+ ( ( aType === 'string' || aType === 'number' ) && aValue !== bValue ) ||
 68+ ( $.isPlainObject( aValue ) && !es.compareObjects( aValue, bValue ) ) ) {
6969 return false;
7070 }
7171 }
Index: trunk/parsers/wikidom/lib/es/es.Document.Context.js
@@ -31,8 +31,8 @@
3232 * @returns {Boolean} True if page exists
3333 */
3434 es.Document.Context.prototype.isPage = function( namespace, title ) {
35 - return typeof this.options.isPage === 'function'
36 - ? this.options.isPage( namespace, title ) : false;
 35+ return typeof this.options.isPage === 'function' ?
 36+ this.options.isPage( namespace, title ) : false;
3737 };
3838
3939 /**
@@ -46,8 +46,8 @@
4747 * @returns {Object} Page DOM (document object)
4848 */
4949 es.Document.Context.prototype.getWikiDom = function( namespace, title ) {
50 - return typeof this.options.getWikiDom === 'function'
51 - ? this.options.getWikiDom( namespace, title ) : null;
 50+ return typeof this.options.getWikiDom === 'function' ?
 51+ this.options.getWikiDom( namespace, title ) : null;
5252 };
5353
5454 /**
Index: trunk/parsers/wikidom/lib/es/es.ContentFlow.js
@@ -44,7 +44,7 @@
4545
4646 // Initialization
4747 this.scanBoundaries();
48 -}
 48+};
4949
5050 es.ContentFlow.prototype.getLineIndex = function( offset ) {
5151 for ( var i = 0; i < this.lines.length; i++ ) {
@@ -230,7 +230,7 @@
231231 // Iterate over each word+boundary sequence, capturing offsets and encoding text as we go
232232 var match,
233233 end;
234 - while ( match = this.boundaryTest.exec( text ) ) {
 234+ while ( ( match = this.boundaryTest.exec( text ) ) ) {
235235 // Include the boundary character in the range
236236 end = match.index + 1;
237237 // Store the boundary offset
Index: trunk/parsers/wikidom/lib/es/es.ListBlockItem.js
@@ -26,7 +26,7 @@
2727 this.flow.on( 'render', function() {
2828 listBlockItem.emit( 'update' );
2929 } );
30 -}
 30+};
3131
3232 /* Public Methods */
3333
Index: trunk/parsers/wikidom/lib/es/es.Content.js
@@ -185,7 +185,9 @@
186186 }
187187 for ( k = src.range.start; k < src.range.end; k++ ) {
188188 // Auto-convert to array
189 - typeof data[k] === 'string' && ( data[k] = [data[k]] );
 189+ if ( typeof data[k] === 'string' ) {
 190+ data[k] = [data[k]];
 191+ }
190192 // Append
191193 data[k].push( dst );
192194 }
@@ -209,23 +211,22 @@
210212 es.Content.renderAnnotation = function( bias, annotation, stack ) {
211213 var renderers = es.Content.annotationRenderers,
212214 type = annotation.type,
213 - out = '';
 215+ out = '',
 216+ i;
214217 if ( type in renderers ) {
215218 if ( bias === 'open' ) {
216219 // Add annotation to the top of the stack
217220 stack.push( annotation );
218221 // Open annotation
219 - out += typeof renderers[type]['open'] === 'function'
220 - ? renderers[type]['open']( annotation.data )
221 - : renderers[type]['open'];
 222+ out += typeof renderers[type].open === 'function' ?
 223+ renderers[type].open( annotation.data ) : renderers[type].open;
222224 } else {
223225 if ( stack[stack.length - 1] === annotation ) {
224226 // Remove annotation from top of the stack
225227 stack.pop();
226228 // Close annotation
227 - out += typeof renderers[type]['close'] === 'function'
228 - ? renderers[type]['close']( annotation.data )
229 - : renderers[type]['close'];
 229+ out += typeof renderers[type].close === 'function' ?
 230+ renderers[type].close( annotation.data ) : renderers[type].close;
230231 } else {
231232 // Find the annotation in the stack
232233 var depth = stack.indexOf( annotation );
@@ -233,20 +234,20 @@
234235 throw 'Invalid stack error. An element is missing from the stack.';
235236 }
236237 // Close each already opened annotation
237 - for ( var i = stack.length - 1; i >= depth + 1; i-- ) {
238 - out += typeof renderers[stack[i].type]['close'] === 'function'
239 - ? renderers[stack[i].type]['close']( stack[i].data )
240 - : renderers[stack[i].type]['close'];
 238+ for ( i = stack.length - 1; i >= depth + 1; i-- ) {
 239+ out += typeof renderers[stack[i].type].close === 'function' ?
 240+ renderers[stack[i].type].close( stack[i].data ) :
 241+ renderers[stack[i].type].close;
241242 }
242243 // Close the buried annotation
243 - out += typeof renderers[type]['close'] === 'function'
244 - ? renderers[type]['close']( annotation.data )
245 - : renderers[type]['close'];
 244+ out += typeof renderers[type].close === 'function' ?
 245+ renderers[type].close( annotation.data ) :
 246+ renderers[type].close;
246247 // Re-open each previously opened annotation
247 - for ( var i = depth + 1; i < stack.length; i++ ) {
248 - out += typeof renderers[stack[i].type]['open'] === 'function'
249 - ? renderers[stack[i].type]['open']( stack[i].data )
250 - : renderers[stack[i].type]['open'];
 248+ for ( i = depth + 1; i < stack.length; i++ ) {
 249+ out += typeof renderers[stack[i].type].open === 'function' ?
 250+ renderers[stack[i].type].open( stack[i].data ) :
 251+ renderers[stack[i].type].open;
251252 }
252253 // Remove the annotation from the middle of the stack
253254 stack.splice( depth, 1 );
@@ -532,6 +533,7 @@
533534 } else {
534535 range.normalize();
535536 }
 537+ var i;
536538 /*
537539 * Because content data is an array of either strings containing a single character each or
538540 * references to arrays containing a single character string followed by a series of references
@@ -542,7 +544,7 @@
543545 * expensive to do on all content on every copy, so we only do it when we are going to modify
544546 * the annotation information, and on as few annotated characters as possible.
545547 */
546 - for ( var i = range.start; i < range.end; i++ ) {
 548+ for ( i = range.start; i < range.end; i++ ) {
547549 if ( typeof this.data[i] !== 'string' ) {
548550 this.data[i] = this.data[i].slice( 0 );
549551 }
@@ -563,7 +565,7 @@
564566 }
565567 if ( method === 'add' ) {
566568 var duplicate;
567 - for ( var i = range.start; i < range.end; i++ ) {
 569+ for ( i = range.start; i < range.end; i++ ) {
568570 duplicate = -1;
569571 if ( typeof this.data[i] === 'string' ) {
570572 // Never annotate new lines
@@ -585,7 +587,7 @@
586588 }
587589 }
588590 } else if ( method === 'remove' ) {
589 - for ( var i = range.start; i < range.end; i++ ) {
 591+ for ( i = range.start; i < range.end; i++ ) {
590592 if ( typeof this.data[i] !== 'string' ) {
591593 if ( annotation.type === 'all' ) {
592594 // Remove all annotations by converting the annotated character to a plain
@@ -659,8 +661,8 @@
660662 }
661663 }
662664
663 - out += right[0] in es.Content.htmlCharacters
664 - ? es.Content.htmlCharacters[right[0]] : right[0];
 665+ out += right[0] in es.Content.htmlCharacters ?
 666+ es.Content.htmlCharacters[right[0]] : right[0];
665667 left = right;
666668 }
667669 // close all remaining tags at the end of the content
@@ -756,7 +758,7 @@
757759
758760 for ( i = 0; i < this.data.length; i++ ) {
759761
760 - if ( line == null ) {
 762+ if ( line === null ) {
761763 line = { text : '' };
762764 }
763765
@@ -799,7 +801,7 @@
800802 left = right;
801803 }
802804
803 - if ( line != null ) {
 805+ if ( line !== null ) {
804806 this.handleAnnotation( 'close', line, i - offset );
805807 lines.push( line );
806808 }
Index: trunk/parsers/wikidom/lib/es/es.Document.HtmlSerializer.js
@@ -109,7 +109,7 @@
110110 es.Document.HtmlSerializer.prototype.serializeTransclusion = function( transclusion ) {
111111 var title = [];
112112 if ( transclusion.namespace !== 'Main' ) {
113 - title.push( transclusion.namespace )
 113+ title.push( transclusion.namespace );
114114 }
115115 title.push( transclusion.title );
116116 title = title.join( ':' );
@@ -129,7 +129,7 @@
130130 for ( var l = 0, lMax = item.lists.length; l < lMax; l++ ) {
131131 out.push( this.serializeList( item.lists[l] ) );
132132 }
133 - out.push( es.Document.Serializer.buildXmlClosingTag( 'li' ) )
 133+ out.push( es.Document.Serializer.buildXmlClosingTag( 'li' ) );
134134 return out.join( '\n' );
135135 } else {
136136 return es.Document.Serializer.buildXmlTag( 'li', {}, this.serializeLine( item.line ) );
@@ -137,15 +137,15 @@
138138 };
139139
140140 es.Document.HtmlSerializer.prototype.serializeLine = function( line ) {
 141+ var as = new es.AnnotationSerializer();
 142+ function addXml( range, tag, attributes ) {
 143+ as.add(
 144+ range,
 145+ es.Document.Serializer.buildXmlOpeningTag( tag, attributes ),
 146+ es.Document.Serializer.buildXmlClosingTag( tag )
 147+ );
 148+ }
141149 if ( 'annotations' in line && line.annotations.length ) {
142 - var as = new es.AnnotationSerializer();
143 - function addXml( range, tag, attributes ) {
144 - as.add(
145 - range,
146 - es.Document.Serializer.buildXmlOpeningTag( tag, attributes ),
147 - es.Document.Serializer.buildXmlClosingTag( tag )
148 - );
149 - };
150150 for ( var a = 0, aMax = line.annotations.length; a < aMax; a++ ) {
151151 var an = line.annotations[a];
152152 switch ( an.type ) {
@@ -195,7 +195,7 @@
196196 /* Registration */
197197
198198 es.Document.serializers.html = function( doc, context, options ) {
199 - var serializer = new es.Document.HtmlSerializer( context, options )
 199+ var serializer = new es.Document.HtmlSerializer( context, options );
200200 return serializer.serializeDocument( doc );
201201 };
202202
Index: trunk/parsers/wikidom/lib/es/es.EventEmitter.js
@@ -7,7 +7,7 @@
88 */
99 es.EventEmitter = function() {
1010 this.events = {};
11 -}
 11+};
1212
1313 /* Methods */
1414
@@ -104,7 +104,7 @@
105105 return this;
106106 }
107107 handlers.splice( i, 1 );
108 - if ( handlers.length == 0 ) {
 108+ if ( handlers.length === 0 ) {
109109 delete this.events[type];
110110 }
111111 }
Index: trunk/parsers/wikidom/lib/es/es.Cursor.js
@@ -38,9 +38,12 @@
3939 clearInterval( this.blinkInterval );
4040 }
4141 this.blinkInterval = setInterval( function( cursor ) {
42 - cursor.$.css( 'display' ) == 'block'
43 - ? cursor.$.hide() : cursor.$.show();
44 - }, 500, this );
 42+ if ( cursor.$.css( 'display' ) === 'block' ) {
 43+ cursor.$.hide();
 44+ } else {
 45+ cursor.$.show();
 46+ }
 47+ }, 500 );
4548 };
4649
4750 /**
Index: trunk/parsers/wikidom/lib/es/es.Document.WikitextSerializer.js
@@ -98,8 +98,8 @@
9999 }
100100 for ( var c = 0, cMax = row.length; c < cMax; c++ ) {
101101 var type = types[row[c].type || 'data'],
102 - attr = row[c].attributes
103 - ? es.Document.Serializer.buildXmlAttributes( row[c].attributes ) + '|' : ''
 102+ attr = row[c].attributes ?
 103+ es.Document.Serializer.buildXmlAttributes( row[c].attributes ) + '|' : '';
104104 out.push( type + attr + this.serializeDocument( row[c].document, true ) );
105105 }
106106 }
@@ -112,7 +112,7 @@
113113 if ( transclusion.namespace === 'Main' ) {
114114 title.push( '' );
115115 } else if ( transclusion.namespace !== 'Template' ) {
116 - title.push( transclusion.namespace )
 116+ title.push( transclusion.namespace );
117117 }
118118 title.push( transclusion.title );
119119 return '{{' + title.join( ':' ) + '}}';
@@ -166,7 +166,7 @@
167167 /* Registration */
168168
169169 es.Document.serializers.wikitext = function( doc, context, options ) {
170 - var serializer = new es.Document.WikitextSerializer( context, options )
 170+ var serializer = new es.Document.WikitextSerializer( context, options );
171171 return serializer.serializeDocument( doc );
172172 };
173173
Index: trunk/parsers/wikidom/lib/es/es.Document.JsonSerializer.js
@@ -23,11 +23,11 @@
2424 return 'null';
2525 }
2626 switch ( value.constructor ) {
27 - case ( new Array ).constructor:
 27+ case [].constructor:
2828 return 'array';
29 - case ( new Date ).constructor:
 29+ case ( new Date() ).constructor:
3030 return 'date';
31 - case ( new RegExp ).constructor:
 31+ case ( new RegExp() ).constructor:
3232 return 'regex';
3333 default:
3434 return 'object';
@@ -43,7 +43,8 @@
4444 var type = es.Document.JsonSerializer.typeOf( data );
4545
4646 // Open object/array
47 - var json = '';
 47+ var json = '',
 48+ key;
4849 if ( type === 'array' ) {
4950 if (data.length === 0) {
5051 // Empty array
@@ -52,7 +53,7 @@
5354 json += '[';
5455 } else {
5556 var empty = true;
56 - for ( var i in data ) {
 57+ for ( key in data ) {
5758 if ( data.hasOwnProperty( i ) ) {
5859 empty = false;
5960 break;
@@ -66,29 +67,28 @@
6768
6869 // Iterate over items
6970 var comma = false;
70 - for ( var i in data ) {
71 - if ( data.hasOwnProperty( i ) ) {
72 - json += ( comma ? ',' : '' ) + '\n' + indention + this.options.indentWith
73 - + ( type === 'array' ? '' : '"' + i + '"' + ': ' );
74 - switch ( es.Document.JsonSerializer.typeOf( data[i] ) ) {
 71+ for ( key in data ) {
 72+ if ( data.hasOwnProperty( key ) ) {
 73+ json += ( comma ? ',' : '' ) + '\n' + indention + this.options.indentWith +
 74+ ( type === 'array' ? '' : '"' + key + '"' + ': ' );
 75+ switch ( es.Document.JsonSerializer.typeOf( data[key] ) ) {
7576 case 'array':
7677 case 'object':
7778 json += this.encode(
78 - data[i], indention + this.options.indentWith
 79+ data[key], indention + this.options.indentWith
7980 );
8081 break;
8182 case 'boolean':
8283 case 'number':
83 - json += data[i].toString();
 84+ json += data[key].toString();
8485 break;
8586 case 'null':
8687 json += 'null';
8788 break;
8889 case 'string':
89 - json += '"' + data[i]
 90+ json += '"' + data[key]
9091 .replace(/[\n]/g, '\\n')
91 - .replace(/[\t]/g, '\\t')
92 - + '"';
 92+ .replace(/[\t]/g, '\\t') + '"';
9393 break;
9494 // Skip other types
9595 }
@@ -111,7 +111,7 @@
112112 /* Registration */
113113
114114 es.Document.serializers.json = function( doc, context, options ) {
115 - var serializer = new es.Document.JsonSerializer( context, options )
 115+ var serializer = new es.Document.JsonSerializer( context, options );
116116 return serializer.serializeDocument( doc );
117117 };
118118
Index: trunk/parsers/wikidom/lib/es/es.Container.js
@@ -60,8 +60,7 @@
6161 * @returns {Object} Last child object
6262 */
6363 es.Container.prototype.last = function() {
64 - return this._list.length
65 - ? this._list[this._list.length - 1] : null;
 64+ return this._list.length ? this._list[this._list.length - 1] : null;
6665 };
6766
6867 /**
Index: trunk/parsers/wikidom/lib/es/es.Selection.js
@@ -15,7 +15,7 @@
1616 this.to = to;
1717 this.start = from;
1818 this.end = to;
19 -}
 19+};
2020
2121 /* Methods */
2222
Index: trunk/parsers/wikidom/lib/es/es.ListBlock.js
@@ -173,7 +173,7 @@
174174 return {
175175 'item' : this.list.items[i],
176176 'offset' : offset - globalOffset
177 - }
 177+ };
178178 }
179179 globalOffset += itemLength + 1;
180180 }
@@ -366,11 +366,13 @@
367367 };
368368
369369 es.ListBlock.prototype.getWikiDom = function() {
370 - var items = this.list.items;
371 - var stack = [];
372 - var lastStyle = null;
 370+ var items = this.list.items,
 371+ stack = [],
 372+ lastStyle = null,
 373+ i,
 374+ j;
373375
374 - for ( var i = 0; i < items.length; i++ ) {
 376+ for ( i = 0; i < items.length; i++ ) {
375377 var item = items[i];
376378 var itemLevel = item.getLevel();
377379
@@ -385,7 +387,7 @@
386388
387389 // if the current element level is higher than the previous one
388390 if ( itemLevel + 1 > stack.length ) {
389 - for ( var j = stack.length; j < itemLevel + 1; j++ ) {
 391+ for ( j = stack.length; j < itemLevel + 1; j++ ) {
390392 stack.push( {
391393 'style' : item.getStyle(j),
392394 'items' : []
@@ -395,7 +397,7 @@
396398
397399 // if the current element level is lower then the previous one
398400 if ( itemLevel + 1 < stack.length ) {
399 - for ( var j = stack.length; j > itemLevel + 1; j-- ) {
 401+ for ( j = stack.length; j > itemLevel + 1; j-- ) {
400402 stack = es.ListBlock.wikiDomPushPop( stack );
401403 }
402404 }
@@ -407,7 +409,7 @@
408410 }
409411 }
410412
411 - for ( var i = stack.length; i > 1; i-- ) {
 413+ for ( i = stack.length; i > 1; i-- ) {
412414 stack = es.ListBlock.wikiDomPushPop( stack );
413415 }
414416
Index: trunk/parsers/wikidom/lib/es/es.Document.Serializer.js
@@ -63,7 +63,7 @@
6464 if ( escape ) {
6565 value = wiki.util.xml.esc( value );
6666 }
67 - return '<' + tag + es.Document.Serializer.buildXmlAttributes( attributes, true ) + '>'
68 - + value + '</' + tag + '>';
 67+ return '<' + tag + es.Document.Serializer.buildXmlAttributes( attributes, true ) + '>' +
 68+ value + '</' + tag + '>';
6969 }
7070 };
Index: trunk/parsers/wikidom/lib/es/es.Surface.js
@@ -118,12 +118,12 @@
119119 // First render
120120 this.$.append( this.doc.$ );
121121 this.doc.renderBlocks();
122 -}
 122+};
123123
124124 es.Surface.prototype.getLocationFromEvent = function( e ) {
125125 var $target = $( e.target ),
126 - $block = $target.is( '.editSurface-block' )
127 - ? $target : $target.closest( '.editSurface-block' );
 126+ $block = $target.is( '.editSurface-block' ) ?
 127+ $target : $target.closest( '.editSurface-block' );
128128 // Not a block or child of a block? Find the nearest block...
129129 if( !$block.length ) {
130130 var $blocks = this.$.find( '> .editSurface-document .editSurface-block' );
@@ -143,10 +143,11 @@
144144 };
145145
146146 es.Surface.prototype.onKeyDown = function( e ) {
 147+ var range;
147148 switch ( e.keyCode ) {
148149 case 36: // Home
149150 this.initialHorizontalCursorPosition = null;
150 - var range = this.location.block.getLineBoundaries( this.location.offset );
 151+ range = this.location.block.getLineBoundaries( this.location.offset );
151152 this.location = new es.Location( this.location.block, range.start );
152153 this.cursor.show(
153154 this.location.block.getPosition( this.location.offset ),
@@ -161,7 +162,7 @@
162163 break;
163164 case 35: // End
164165 this.initialHorizontalCursorPosition = null;
165 - var range = this.location.block.getLineBoundaries( this.location.offset );
 166+ range = this.location.block.getLineBoundaries( this.location.offset );
166167 this.location = new es.Location( this.location.block, range.end );
167168 this.cursor.show(
168169 this.location.block.getPosition( this.location.offset ),
@@ -317,14 +318,15 @@
318319 };
319320
320321 es.Surface.prototype.handleBackspace = function() {
 322+ var deleteSelection;
321323 if ( this.selection.from && this.selection.to ) {
322 - var deleteSelection = this.selection;
 324+ deleteSelection = this.selection;
323325 deleteSelection.normalize();
324326 this.location = this.selection.start;
325327 this.selection = new es.Selection();
326328 this.deleteContent( deleteSelection );
327329 } else if ( this.location.offset > 0 ) {
328 - var deleteSelection = new es.Selection(
 330+ deleteSelection = new es.Selection(
329331 new es.Location( this.location.block, this.location.offset - 1 ), this.location
330332 );
331333 deleteSelection.normalize();
@@ -335,14 +337,15 @@
336338 };
337339
338340 es.Surface.prototype.handleDelete = function() {
 341+ var deleteSelection;
339342 if ( this.selection.from && this.selection.to ) {
340 - var deleteSelection = this.selection;
 343+ deleteSelection = this.selection;
341344 deleteSelection.normalize();
342345 this.location = this.selection.start;
343346 this.selection = new es.Selection();
344347 this.deleteContent( deleteSelection );
345348 } else if ( this.location.offset < this.location.block.getLength() ) {
346 - var deleteSelection = new es.Selection(
 349+ deleteSelection = new es.Selection(
347350 new es.Location( this.location.block, this.location.offset + 1 ), this.location
348351 );
349352 deleteSelection.normalize();
@@ -371,6 +374,7 @@
372375 this.mouse.clickPosition = clickPosition;
373376 }
374377 this.location = this.getLocationFromEvent( e );
 378+ var boundaries;
375379 switch ( this.mouse.clicks ) {
376380 case 1:
377381 if ( this.keyboard.keys.shift ) {
@@ -388,7 +392,7 @@
389393 break;
390394 case 2:
391395 // Select word offset is within
392 - var boundaries = this.location.block.getWordBoundaries( this.location.offset );
 396+ boundaries = this.location.block.getWordBoundaries( this.location.offset );
393397 this.selection = new es.Selection(
394398 new es.Location( this.location.block, boundaries.start ),
395399 new es.Location( this.location.block, boundaries.end )
@@ -397,7 +401,7 @@
398402 break;
399403 case 3:
400404 // Select section within block offset is within
401 - var boundaries = this.location.block.getSectionBoundaries( this.location.offset );
 405+ boundaries = this.location.block.getSectionBoundaries( this.location.offset );
402406 this.selection = new es.Selection(
403407 new es.Location( this.location.block, boundaries.start ),
404408 new es.Location( this.location.block, boundaries.end )
@@ -542,8 +546,8 @@
543547 'top': fromBlockOffset.top + from.position.bottom,
544548 'left': blockLeft,
545549 'width': blockWidth,
546 - 'height': ( toBlockOffset.top + to.position.top )
547 - - ( fromBlockOffset.top + from.position.bottom )
 550+ 'height': ( toBlockOffset.top + to.position.top ) -
 551+ ( fromBlockOffset.top + from.position.bottom )
548552 } )
549553 .show();
550554 // TODO: Get text from multiple-block selection
Index: trunk/parsers/wikidom/demos/synth/es.js
@@ -118,7 +118,7 @@
119119 'type': 'xlink',
120120 'data': { 'href': '#' },
121121 'range': { 'start': 22, 'end': 29 }
122 - },
 122+ }
123123 ]
124124 }
125125 },
Index: trunk/parsers/wikidom/demos/synth/index.html
@@ -1,4 +1,4 @@
2 -<!doctype html>
 2+<!DOCTYPE html>
33
44 <html>
55 <head>
Index: trunk/parsers/wikidom/demos/es/es.js
@@ -16,10 +16,10 @@
1717 'type': 'xlink',
1818 'data': { 'href': '#' },
1919 'range': { 'start': 22, 'end': 29 }
20 - },
 20+ }
2121 ]
2222 },
23 - { 'text': "Word wrap is the additional feature of most text editors, word processors, and web browsers, of breaking lines between and not within words, except when a single word is longer than a line." },
 23+ { 'text': "Word wrap is the additional feature of most text editors, word processors, and web browsers, of breaking lines between and not within words, except when a single word is longer than a line." }
2424 ]
2525 },
2626 {
@@ -38,7 +38,7 @@
3939 }
4040 ]
4141 },
42 - { '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." },
 42+ { '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." }
4343 ]
4444 },
4545 {
Index: trunk/parsers/wikidom/demos/es/index.html
@@ -1,4 +1,4 @@
2 -<!doctype html>
 2+<!DOCTYPE html>
33
44 <html>
55 <head>
Index: trunk/parsers/wikidom/demos/surface/jquery.flow.js
@@ -39,18 +39,18 @@
4040 if ( typeof to === 'undefined' ) {
4141 to = {};
4242 }
43 - if ( from == null || typeof from != 'object' ) {
 43+ if ( from === null || typeof from != 'object' ) {
4444 return from;
4545 }
4646 if ( from.constructor != Object && from.constructor != Array ) {
4747 return from;
4848 }
49 - if ( from.constructor == Date
50 - || from.constructor == RegExp
51 - || from.constructor == Function
52 - || from.constructor == String
53 - || from.constructor == Number
54 - || from.constructor == Boolean ) {
 49+ if ( from.constructor == Date ||
 50+ from.constructor == RegExp ||
 51+ from.constructor == Function ||
 52+ from.constructor == String ||
 53+ from.constructor == Number ||
 54+ from.constructor == Boolean ) {
5555 return new from.constructor( from );
5656 }
5757 to = to || new from.constructor();
Index: trunk/parsers/wikidom/demos/surface/jquery.editSurface.js
@@ -14,9 +14,9 @@
1515 .addClass( 'editSurface-container' )
1616 .append( '<div class="editSurface-document"></div>' )
1717 .after( '<div class="editSurface-cursor"></div>' )
18 - .before( '<div class="editSurface-range"></div>'
19 - + '<div class="editSurface-range"></div>'
20 - + '<div class="editSurface-range"></div>');
 18+ .before( '<div class="editSurface-range"></div>' +
 19+ '<div class="editSurface-range"></div>' +
 20+ '<div class="editSurface-range"></div>');
2121
2222 // Shortcuts
2323 var $document = $this.find( '.editSurface-document' );
@@ -63,8 +63,8 @@
6464 },
6565 'mouseup': function( e ) {
6666 if ( sel.active ) {
67 - if ( !sel.from || !sel.to
68 - || ( sel.from.line === sel.to.line && sel.from.char === sel.to.char ) ) {
 67+ if ( !sel.from || !sel.to ||
 68+ ( sel.from.line === sel.to.line && sel.from.char === sel.to.char ) ) {
6969 sel.from = null;
7070 sel.to = null;
7171 sel.start = null;
@@ -84,9 +84,9 @@
8585 $target = getNearestLine( sel.start.$target.parent().children(), e.pageY );
8686 }
8787 sel.end = getCursorPosition( e.pageX, e.pageY, $target );
88 - if ( sel.start.line < sel.end.line
89 - || ( sel.start.line === sel.end.line
90 - && sel.start.char < sel.end.char ) ) {
 88+ if ( sel.start.line < sel.end.line ||
 89+ ( sel.start.line === sel.end.line &&
 90+ sel.start.char < sel.end.char ) ) {
9191 sel.from = sel.start;
9292 sel.to = sel.end;
9393 } else {
@@ -131,7 +131,7 @@
132132 text = sel.from.$target.data( 'flow' ).text.substr( sel.from.char );
133133 var $sibling = sel.from.$target.next();
134134 for ( var i = sel.from.line + 1; i < sel.to.line; i++ ) {
135 - text += $sibling.data( 'flow' ).text
 135+ text += $sibling.data( 'flow' ).text;
136136 $sibling = $sibling.next();
137137 }
138138 text += sel.to.$target.data( 'flow' ).text.substr( 0, sel.to.char );
@@ -203,8 +203,8 @@
204204 ranges.$first.show().css( {
205205 'left': sel.from.x,
206206 'top': sel.from.top,
207 - 'width': ( $container.innerWidth() - sel.from.x )
208 - + $container.offset().left,
 207+ 'width': ( $container.innerWidth() - sel.from.x ) +
 208+ $container.offset().left,
209209 'height': sel.from.height
210210 } );
211211 if ( sel.from.line < sel.to.line - 1 ) {
@@ -235,10 +235,8 @@
236236 function renderDocument( doc ) {
237237 $document.empty();
238238 for ( var i = 0; i < doc.blocks.length; i++ ) {
239 - switch ( doc.blocks[i].type ) {
240 - case 'paragraph':
241 - renderParagraph( doc.blocks[i], $document )
242 - break;
 239+ if ( doc.blocks[i].type === 'paragraph' ) {
 240+ renderParagraph( doc.blocks[i], $document );
243241 }
244242 }
245243 }
@@ -269,10 +267,14 @@
270268 // Flip
271269 cursor.visible = !cursor.visible;
272270 // Hide/show
273 - cursor.visible ? cursor.$.hide() : cursor.$.show();
 271+ if ( cursor.visible ) {
 272+ cursor.$.hide();
 273+ } else {
 274+ cursor.$.show();
 275+ }
274276 // Repeat
275 - cursor.timeout = setTimeout( cursor.blink, cursor.speed )
276 - }
 277+ cursor.timeout = setTimeout( cursor.blink, cursor.speed );
 278+ };
277279 cursor.show = function() {
278280 // Start visible (will flip when run)
279281 cursor.visible = true;
Index: trunk/parsers/wikidom/demos/surface/index.html
@@ -1,4 +1,4 @@
2 -<!doctype html>
 2+<!DOCTYPE html>
33
44 <html>
55 <head>
Index: trunk/parsers/wikidom/demos/renderers/index.html
@@ -1,4 +1,4 @@
2 -<!doctype html>
 2+<!DOCTYPE html>
33
44 <html>
55 <head>

Follow-up revisions

RevisionCommit summaryAuthorDate
r101338Followup r100649, fix some fatal errors caused by the cleanupjohnduhart05:13, 31 October 2011

Status & tagging log