r102727 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102726‎ | r102727 | r102728 >
Date:00:26, 11 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Added support for word selection when shift + ( ctrl || alt ) pressed
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
@@ -340,31 +340,25 @@
341341 case 'left' :
342342 case 'right' :
343343 var offset;
344 - if ( this.keyboard.keys.shift ) {
 344+ if ( this.keyboard.keys.shift || this.selection.from === this.selection.to ) {
345345 offset = this.selection.to;
346346 } else {
347 - offset = this.selection.from === this.selection.to ?
348 - this.selection.to :
349 - instruction === 'left' ? this.selection.start : this.selection.end;
 347+ offset = instruction === 'left' ? this.selection.start : this.selection.end;
350348 }
351349 newTo = this.documentView.getModel().getRelativeContentOffset(
352350 offset,
353 - instruction === 'left' ? -1 : 1
 351+ instruction === 'left' ? -1 : 1
354352 );
355 - if ( this.keyboard.keys.control || this.keyboard.keys.alt ) {
356 - var wordBoundaries = this.documentView.model.getWordBoundaries( newTo );
357 - if ( instruction === 'left' ) {
358 - newTo = wordBoundaries.from;
359 -
360 - newTo = this.documentView.getModel().getRelativeContentOffset(
361 - newTo,
362 - -1
363 - );
364 -
365 - } else {
366 - newTo = wordBoundaries.to;
 353+
 354+ if ( this.keyboard.keys.shift && ( this.keyboard.keys.control || this.keyboard.keys.alt ) ) {
 355+ var wordRange = this.documentView.model.getWordBoundaries(
 356+ instruction === 'left' ? newTo : offset
 357+ );
 358+ if ( wordRange ) {
 359+ newTo = instruction === 'left' ? wordRange.from : wordRange.to;
367360 }
368361 }
 362+
369363 break;
370364 case 'home' :
371365 case 'end' :

Status & tagging log