r93479 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93478‎ | r93479 | r93480 >
Date:19:17, 29 July 2011
Author:inez
Status:deferred
Tags:
Comment:
Support for Home and End key actions in ParagraphBlock
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.Surface.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js
@@ -165,6 +165,19 @@
166166 return new es.Range( 0, this.content.getLength() );
167167 };
168168
 169+es.ParagraphBlock.prototype.getLineFromOffset = function( offset ) {
 170+ var line;
 171+
 172+ for ( var i = 0; i < this.flow.lines.length; i++ ) {
 173+ line = this.flow.lines[i];
 174+ if ( offset >= line.range.start && offset < line.range.end ) {
 175+ break;
 176+ }
 177+ }
 178+
 179+ return line;
 180+};
 181+
169182 /* Registration */
170183
171184 /**
Index: trunk/parsers/wikidom/lib/es/es.Surface.js
@@ -144,6 +144,24 @@
145145
146146 es.Surface.prototype.onKeyDown = function( e ) {
147147 switch ( e.keyCode ) {
 148+ case 36: // Home
 149+ this.initialHorizontalCursorPosition = null;
 150+ var line = this.location.block.getLineFromOffset( this.location.offset );
 151+ this.location = new es.Location( this.location.block, line.range.start );
 152+ this.cursor.show(
 153+ this.location.block.getPosition( this.location.offset ),
 154+ this.location.block.$.offset()
 155+ );
 156+ break;
 157+ case 35: // End
 158+ this.initialHorizontalCursorPosition = null;
 159+ var line = this.location.block.getLineFromOffset( this.location.offset );
 160+ this.location = new es.Location( this.location.block, line.range.end-1 );
 161+ this.cursor.show(
 162+ this.location.block.getPosition( this.location.offset ),
 163+ this.location.block.$.offset()
 164+ );
 165+ break;
148166 case 16: // Shift
149167 this.keyboard.keys.shift = true;
150168 if ( !this.keyboard.selecting ) {

Status & tagging log