r102040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102039‎ | r102040 | r102041 >
Date:20:26, 4 November 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Line-break and variable redeclaration cleanup
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
@@ -230,28 +230,38 @@
231231
232232 es.SurfaceView.prototype.moveCursor = function( instruction ) {
233233 this.selection.normalize();
 234+ var offset;
234235 if ( instruction === 'left') {
235236 if ( !this.keyboard.keys.shift ) {
236 - this.selection.from = this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.getLength() ? this.selection.start : this.selection.to, -1 );
 237+ this.selection.from = this.selection.to =
 238+ this.documentView.getModel().getRelativeContentOffset(
 239+ this.selection.getLength() ? this.selection.start : this.selection.to, -1
 240+ );
237241 this.documentView.clearSelection();
238242 this.showCursor();
239243 } else {
240 - this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 );
 244+ this.selection.to = this.documentView.getModel().getRelativeContentOffset(
 245+ this.selection.to, -1
 246+ );
241247 this.documentView.drawSelection( this.selection );
242248 this.hideCursor();
243249 }
244250 } else if ( instruction === 'right' ) {
245251 if ( !this.keyboard.keys.shift ) {
246 - this.selection.from = this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.getLength() ? this.selection.end : this.selection.to, 1 );
 252+ this.selection.from = this.selection.to =
 253+ this.documentView.getModel().getRelativeContentOffset(
 254+ this.selection.getLength() ? this.selection.end : this.selection.to, 1
 255+ );
247256 this.documentView.clearSelection();
248257 this.showCursor();
249258 } else {
250 - this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.to, 1 );
 259+ this.selection.to = this.documentView.getModel().getRelativeContentOffset(
 260+ this.selection.to, 1
 261+ );
251262 this.documentView.drawSelection( this.selection );
252263 this.hideCursor();
253264 }
254265 } else if ( instruction === 'up' || instruction === 'down' ) {
255 -
256266 var currentPosition = this.documentView.getRenderedPositionFromOffset( this.selection.to );
257267
258268 if ( this.cursor.initialLeft === null ) {
@@ -259,8 +269,10 @@
260270 }
261271
262272 var fakePosition = new es.Position( this.cursor.initialLeft, currentPosition.top ),
263 - offset, step, edge, i = 0;
264 -
 273+ step,
 274+ edge,
 275+ i = 0;
 276+
265277 if ( instruction === 'up' ) {
266278 step = -5;
267279 edge = 0;
@@ -269,7 +281,6 @@
270282 edge = this.documentView.getContentLength();
271283 }
272284
273 -
274285 do {
275286 fakePosition.top += ++i * step;
276287 offset = this.documentView.getOffsetFromRenderedPosition( fakePosition );
@@ -277,9 +288,9 @@
278289 fakePosition.left = this.cursor.initialLeft;
279290 } while ( currentPosition.top === fakePosition.top && offset !== edge );
280291
281 -
282292 if ( !this.keyboard.keys.shift ) {
283 - this.selection.from = this.selection.to = this.documentView.getOffsetFromRenderedPosition( fakePosition );
 293+ this.selection.from = this.selection.to =
 294+ this.documentView.getOffsetFromRenderedPosition( fakePosition );
284295 this.documentView.clearSelection();
285296 this.showCursor();
286297 } else {
@@ -287,10 +298,12 @@
288299 this.documentView.drawSelection( this.selection );
289300 this.hideCursor();
290301 }
291 -
292302 } else if ( instruction === 'home' ) {
293 - var offset = this.cursor.initialBias ? this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) : this.selection.to;
294 - offset = this.documentView.getRenderedLineRangeFromOffset( offset ).start;
 303+ offset = this.documentView.getRenderedLineRangeFromOffset(
 304+ this.cursor.initialBias ?
 305+ this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) :
 306+ this.selection.to
 307+ ).start;
295308 if ( !this.keyboard.keys.shift ) {
296309 this.selection.from = this.selection.to = offset;
297310 this.documentView.clearSelection();
@@ -301,8 +314,11 @@
302315 this.hideCursor();
303316 }
304317 } else if ( instruction === 'end' ) {
305 - var offset = this.cursor.initialBias ? this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) : this.selection.to;
306 - offset = this.documentView.getRenderedLineRangeFromOffset( offset ).end;
 318+ offset = this.documentView.getRenderedLineRangeFromOffset(
 319+ this.cursor.initialBias ?
 320+ this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) :
 321+ this.selection.to
 322+ ).end;
307323 if ( !this.keyboard.keys.shift ) {
308324 this.selection.from = this.selection.to = offset;
309325 this.documentView.clearSelection();

Status & tagging log