r91739 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91738‎ | r91739 | r91740 >
Date:17:50, 8 July 2011
Author:inez
Status:deferred
Tags:
Comment:
Remember horizontal cursor position as long as cursor is moved up or down
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Surface.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.Surface.js
@@ -25,6 +25,7 @@
2626 this.location = null;
2727 this.selection = null;
2828 this.keydownInterval = null;
 29+ this.initialHorizontalCursorPosition = null;
2930 this.render();
3031
3132 this.state = {
@@ -71,24 +72,28 @@
7273
7374 switch ( e.keyCode ) {
7475 case 37: // Left arrow
 76+ this.initialHorizontalCursorPosition = null;
7577 this.moveCursorLeft();
7678 break;
7779 case 38: // Up arrow
7880 this.moveCursorUp();
7981 break;
8082 case 39: // Right arrow
 83+ this.initialHorizontalCursorPosition = null;
8184 this.moveCursorRight();
8285 break;
8386 case 40: // Down arrow
8487 this.moveCursorDown();
8588 break;
8689 case 8: // Backspace
 90+ this.initialHorizontalCursorPosition = null;
8791 this.handleBackspace();
8892 break;
8993 case 46: // Delete
9094 this.handleDelete();
9195 break;
9296 default:
 97+ this.initialHorizontalCursorPosition = null;
9398 this.cursor.hide();
9499 if ( this.keydownInterval ) {
95100 clearTimeout( this.keydownInterval );
@@ -131,6 +136,8 @@
132137 }
133138
134139 Surface.prototype.onMouseDown = function( e ) {
 140+ this.initialHorizontalCursorPosition = null;
 141+
135142 var $target = $( e.target );
136143 $block = $target.is( '.editSurface-block' )
137144 ? $target : $target.closest( '.editSurface-block' );
@@ -226,6 +233,13 @@
227234 Surface.prototype.moveCursorUp = function() {
228235 var location = this.getLocation(),
229236 position = location.block.getPosition( location.offset );
 237+
 238+ if ( this.initialHorizontalCursorPosition ) {
 239+ position.left = this.initialHorizontalCursorPosition;
 240+ } else {
 241+ this.initialHorizontalCursorPosition = position.left;
 242+ }
 243+
230244 position.top = position.top - 1;
231245 if ( position.top < 0 ) {
232246 var previousBlock = location.block.previousBlock();
@@ -245,6 +259,13 @@
246260 Surface.prototype.moveCursorDown = function() {
247261 var location = this.getLocation()
248262 position = location.block.getPosition( location.offset );
 263+
 264+ if ( this.initialHorizontalCursorPosition ) {
 265+ position.left = this.initialHorizontalCursorPosition;
 266+ } else {
 267+ this.initialHorizontalCursorPosition = position.left;
 268+ }
 269+
249270 position.top = position.bottom + 1;
250271 if ( position.top > location.block.$.height() ) {
251272 var nextBlock = location.block.nextBlock();

Status & tagging log