r101567 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101566‎ | r101567 | r101568 >
Date:01:02, 2 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Support for moving cursor end and home
Modified paths:
  • /trunk/parsers/wikidom/lib/hype/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/hype/views/es.SurfaceView.js
@@ -90,17 +90,27 @@
9191 this.keyboard.keys.command = true;
9292 break;
9393 case 36: // Home
 94+ this.moveCursor( 'home' );
9495 break;
9596 case 35: // End
 97+ this.moveCursor( 'end' );
9698 break;
9799 case 37: // Left arrow
98 - this.moveCursor( 'left' );
 100+ if ( this.keyboard.keys.command ) {
 101+ this.moveCursor( 'home' );
 102+ } else {
 103+ this.moveCursor( 'left' );
 104+ }
99105 break;
100106 case 38: // Up arrow
101107 this.moveCursor( 'up' );
102108 break;
103109 case 39: // Right arrow
104 - this.moveCursor( 'right' );
 110+ if ( this.keyboard.keys.command ) {
 111+ this.moveCursor( 'end' );
 112+ } else {
 113+ this.moveCursor( 'right' );
 114+ }
105115 break;
106116 case 40: // Down arrow
107117 this.moveCursor( 'down' );
@@ -119,13 +129,24 @@
120130 //
121131 };
122132
123 -es.SurfaceView.prototype.moveCursor = function( direction ) {
124 - if ( direction === 'left') {
 133+es.SurfaceView.prototype.moveCursor = function( instruction ) {
 134+ if ( instruction === 'left') {
125135 this.showCursor( this.documentView.getModel().getRelativeContentOffset( this.cursor.offset, -1 ) );
126 - } else if ( direction === 'right' ) {
 136+ } else if ( instruction === 'right' ) {
127137 this.showCursor( this.documentView.getModel().getRelativeContentOffset( this.cursor.offset, 1 ) );
128 - } else if ( direction === 'up' || direction === 'down' ) {
 138+ } else if ( instruction === 'up' || instruction === 'down' ) {
129139 // ...
 140+ } else if ( instruction === 'home' ) {
 141+ this.showCursor( this.documentView.getRenderedLineRange( this.cursor.offset ).start );
 142+ } else if ( instruction === 'end' ) {
 143+ var end = this.documentView.getRenderedLineRange( this.cursor.offset ).end
 144+ var data = this.documentView.getModel().data;
 145+ if ( es.DocumentModel.isContentData( data, end ) ) {
 146+ while( data[ end - 1] === ' ' ) {
 147+ end--;
 148+ }
 149+ }
 150+ this.showCursor( end );
130151 }
131152 };
132153

Status & tagging log