r102028 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102027‎ | r102028 | r102029 >
Date:18:50, 4 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Basic support for cursor up and down (with and without selectiong/shift key down)
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
@@ -251,7 +251,43 @@
252252 this.hideCursor();
253253 }
254254 } else if ( instruction === 'up' || instruction === 'down' ) {
255 - // ...
 255+
 256+ var currentPosition = this.documentView.getRenderedPositionFromOffset( this.selection.to );
 257+
 258+ if ( this.cursor.initialLeft === null ) {
 259+ this.cursor.initialLeft = currentPosition.left;
 260+ }
 261+
 262+ var fakePosition = new es.Position( this.cursor.initialLeft, currentPosition.top ),
 263+ offset, step, edge, i = 0;
 264+
 265+ if ( instruction === 'up' ) {
 266+ step = -5;
 267+ edge = 0;
 268+ } else {
 269+ step = 5;
 270+ edge = this.documentView.getContentLength();
 271+ }
 272+
 273+
 274+ do {
 275+ fakePosition.top += ++i * step;
 276+ offset = this.documentView.getOffsetFromRenderedPosition( fakePosition );
 277+ fakePosition = this.documentView.getRenderedPositionFromOffset( offset );
 278+ fakePosition.left = this.cursor.initialLeft;
 279+ } while ( currentPosition.top === fakePosition.top && offset !== edge );
 280+
 281+
 282+ if ( !this.keyboard.keys.shift ) {
 283+ this.selection.from = this.selection.to = this.documentView.getOffsetFromRenderedPosition( fakePosition );
 284+ this.documentView.clearSelection();
 285+ this.showCursor();
 286+ } else {
 287+ this.selection.to = this.documentView.getOffsetFromRenderedPosition( fakePosition );
 288+ this.documentView.drawSelection( this.selection );
 289+ this.hideCursor();
 290+ }
 291+
256292 } else if ( instruction === 'home' ) {
257293 var offset = this.cursor.initialBias ? this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) : this.selection.to;
258294 offset = this.documentView.getRenderedLineRangeFromOffset( offset ).start;

Status & tagging log