r103625 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103624‎ | r103625 | r103626 >
Date:23:21, 18 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Improve logic for moving cursor up and down - especially in case of initialBias - code has to be refactored.
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
@@ -592,10 +592,29 @@
593593 } else if (fakePosition.top > top + this.dimensions.height + this.dimensions.scrollTop ) {
594594 break;
595595 }
596 - fakePosition = this.documentView.getRenderedPositionFromOffset(
597 - this.documentView.getOffsetFromRenderedPosition( fakePosition ),
598 - this.cursor.initialBias
 596+ offset = this.documentView.getOffsetFromRenderedPosition( fakePosition );
 597+ fakePosition1 = this.documentView.getRenderedPositionFromOffset(
 598+ offset,
 599+ false
599600 );
 601+ fakePosition2 = this.documentView.getRenderedPositionFromOffset(
 602+ offset,
 603+ true
 604+ );
 605+
 606+ if(this.cursor.initialBias) {
 607+ if(fakePosition1.top != fakePosition2.top) {
 608+ fakePosition = fakePosition2;
 609+ newBias = true;
 610+ } else {
 611+ fakePosition = fakePosition1;
 612+ //newBias = true;
 613+ }
 614+ } else {
 615+ fakePosition = fakePosition1;
 616+ newBias = false;
 617+ }
 618+
600619 fakePosition.left = this.cursor.initialLeft;
601620 } while ( position.top === fakePosition.top );
602621 to = this.documentView.getOffsetFromRenderedPosition( fakePosition );
@@ -604,12 +623,13 @@
605624 break;
606625 }
607626
608 - this.cursor.initialBias = (
609 - ( direction === 'right' && unit === 'line' ) ||
610 - ( this.cursor.initialBias && direction === 'down' && unit === 'char' ) ||
611 - ( this.cursor.initialBias && direction === 'up' && unit === 'char' ) ) ?
612 - true :
613 - false;
 627+ if(typeof newBias !== 'undefined') {
 628+ this.cursor.initialBias = newBias;
 629+ }
 630+
 631+ if( direction != 'up' && direction != 'down' ) {
 632+ this.cursor.initialBias = direction === 'right' && unit === 'line' ? true : false;
 633+ }
614634
615635 if ( this.keyboard.keys.shift && this.selection.from !== to) {
616636 this.selection.to = to;

Status & tagging log