r102077 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102076‎ | r102077 | r102078 >
Date:00:49, 5 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Very basic support for content (typing on keyboard) insertion
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
@@ -56,7 +56,7 @@
5757 } );
5858
5959 // Hidden input
60 - this.$input = $( '<input class="es-surfaceView-input" />' )
 60+ this.$input = $( '<textarea class="es-surfaceView-textarea" />' )
6161 .prependTo( this.$ )
6262 .on( {
6363 'focus' : function() {
@@ -199,11 +199,29 @@
200200 case 46: // Delete
201201 break;
202202 default: // Insert content (maybe)
 203+ if ( this.keyboard.keydownTimeout ) {
 204+ clearTimeout( this.keyboard.keydownTimeout );
 205+ }
 206+ var surface = this;
 207+ this.keyboard.keydownTimeout = setTimeout( function () {
 208+ surface.insertFromInput();
 209+ }, 10 );
203210 break;
204211 }
205 - return false;
 212+ return true;
206213 };
207214
 215+es.SurfaceView.prototype.insertFromInput = function() {
 216+ var val = this.$input.val();
 217+ this.$input.val( '' );
 218+ if ( val.length > 0 ) {
 219+ var transaction = this.documentView.model.prepareInsertion( this.selection.to, val.split('') );
 220+ this.documentView.model.commit ( transaction );
 221+ this.selection.to += val.length;
 222+ this.showCursor();
 223+ }
 224+};
 225+
208226 es.SurfaceView.prototype.onKeyUp = function( e ) {
209227 switch ( e.keyCode ) {
210228 case 16: // Shift

Status & tagging log