r103995 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103994‎ | r103995 | r103996 >
Date:00:59, 23 November 2011
Author:tparscal
Status:deferred (Comments)
Tags:
Comment:
Added soft undo/redo
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
@@ -263,6 +263,15 @@
264264 };
265265
266266 es.SurfaceView.prototype.onKeyDown = function( e ) {
 267+ var _this = this;
 268+ function handleInsert() {
 269+ if ( _this.keyboard.keydownTimeout ) {
 270+ clearTimeout( _this.keyboard.keydownTimeout );
 271+ }
 272+ _this.keyboard.keydownTimeout = setTimeout( function () {
 273+ _this.insertFromInput();
 274+ }, 10 );
 275+ }
267276 switch ( e.keyCode ) {
268277 // Shift
269278 case 16:
@@ -358,25 +367,33 @@
359368 this.handleEnter();
360369 e.preventDefault();
361370 break;
 371+ // U (soft undo/soft redo)
 372+ case 85:
 373+ if ( e.metaKey || e.ctrlKey ) {
 374+ if ( this.keyboard.keys.shift ) {
 375+ this.model.redo( 1 );
 376+ } else {
 377+ this.model.undo( 1 );
 378+ }
 379+ return false;
 380+ }
 381+ handleInsert();
 382+ break;
362383 // Z (undo/redo)
363384 case 90:
364385 if ( e.metaKey || e.ctrlKey ) {
365386 if ( this.keyboard.keys.shift ) {
366 - this.model.redo();
 387+ this.model.redo( 1, true );
367388 } else {
368 - this.model.undo();
 389+ this.model.undo( 1, true );
369390 }
370 - break;
 391+ return false;
371392 }
 393+ handleInsert();
 394+ break;
372395 // Insert content (maybe)
373396 default:
374 - if ( this.keyboard.keydownTimeout ) {
375 - clearTimeout( this.keyboard.keydownTimeout );
376 - }
377 - var surface = this;
378 - this.keyboard.keydownTimeout = setTimeout( function () {
379 - surface.insertFromInput();
380 - }, 10 );
 397+ handleInsert();
381398 break;
382399 }
383400 return true;

Comments

#Comment by Hashar (talk | contribs)   12:15, 25 November 2011

It is CTRL+R under vim, not Z :-)

You guys rocks!

#Comment by Yair rand (talk | contribs)   00:03, 29 November 2011

Why the handleInsert();break; at the end of U and Z?

Status & tagging log