r104094 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104093‎ | r104094 | r104095 >
Date:22:00, 23 November 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added combine arguments where needed
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
@@ -70,10 +70,11 @@
7171 // Respond to selection changes
7272 if ( selection.from !== selection.to ) {
7373 _this.hideCursor();
 74+ _this.documentView.drawSelection( selection );
7475 } else {
7576 _this.showCursor();
 77+ _this.documentView.clearSelection( selection );
7678 }
77 - _this.documentView.drawSelection( selection );
7879 } );
7980 this.model.getDocument().on( 'update', function() {
8081 _this.emit( 'update' );
@@ -156,10 +157,6 @@
157158 // Extend current or create new selection
158159 selection.to = offset;
159160 } else {
160 - if ( selection.to !== selection.from ) {
161 - // Clear the selection if there was any
162 - this.documentView.clearSelection();
163 - }
164161 selection.from = selection.to = offset;
165162
166163 var position = es.Position.newFromEventPagePosition( e ),
@@ -371,9 +368,9 @@
372369 case 85:
373370 if ( e.metaKey || e.ctrlKey ) {
374371 if ( this.keyboard.keys.shift ) {
375 - this.model.redo( 1 );
 372+ this.model.redo( 1, true );
376373 } else {
377 - this.model.undo( 1 );
 374+ this.model.undo( 1, true );
378375 }
379376 return false;
380377 }
@@ -383,9 +380,9 @@
384381 case 90:
385382 if ( e.metaKey || e.ctrlKey ) {
386383 if ( this.keyboard.keys.shift ) {
387 - this.model.redo( 1, true );
 384+ this.model.redo( 1 );
388385 } else {
389 - this.model.undo( 1, true );
 386+ this.model.undo( 1 );
390387 }
391388 return false;
392389 }
@@ -444,7 +441,7 @@
445442 }
446443
447444 selection.from = selection.to = targetOffset;
448 - this.model.select( selection );
 445+ this.model.select( selection, true );
449446
450447 if ( sourceNode === targetNode ||
451448 ( typeof sourceSplitableNode !== 'undefined' &&
@@ -452,12 +449,12 @@
453450 tx = this.model.getDocument().prepareRemoval(
454451 new es.Range( targetOffset, sourceOffset )
455452 );
456 - this.model.transact( tx );
 453+ this.model.transact( tx, true );
457454 } else {
458455 tx = this.model.getDocument().prepareInsertion(
459456 targetOffset, sourceNode.model.getContent()
460457 );
461 - this.model.transact( tx );
 458+ this.model.transact( tx, true );
462459
463460 var nodeToDelete = sourceNode;
464461 es.DocumentNode.traverseUpstream( nodeToDelete, function( node ) {
@@ -471,15 +468,14 @@
472469 range.from = this.documentView.getOffsetFromNode( nodeToDelete, false );
473470 range.to = range.from + nodeToDelete.getElementLength();
474471 tx = this.model.getDocument().prepareRemoval( range );
475 - this.model.transact( tx );
 472+ this.model.transact( tx, true );
476473 }
477474 } else {
478475 // selection removal
479476 tx = this.model.getDocument().prepareRemoval( selection );
480 - this.model.transact( tx );
481 - this.documentView.clearSelection();
 477+ this.model.transact( tx, true );
482478 selection.from = selection.to = selection.start;
483 - this.model.select( selection );
 479+ this.model.select( selection, true );
484480 }
485481 };
486482
@@ -500,7 +496,7 @@
501497 nodeOffset + node.getElementLength(),
502498 [ { 'type': 'paragraph' }, { 'type': '/paragraph' } ]
503499 );
504 - this.model.transact( tx );
 500+ this.model.transact( tx, true );
505501 selection.from = selection.to = nodeOffset + node.getElementLength() + 1;
506502 } else {
507503 var stack = [],
@@ -526,11 +522,11 @@
527523 splitable = es.DocumentView.splitRules[ elementType ].self;
528524 } );
529525 tx = this.documentView.model.prepareInsertion( selection.to, stack );
530 - this.model.transact( tx );
 526+ this.model.transact( tx, true );
531527 selection.from = selection.to =
532528 this.model.getDocument().getRelativeContentOffset( selection.to, 1 );
533529 }
534 - this.model.select( selection );
 530+ this.model.select( selection, true );
535531 };
536532
537533 es.SurfaceView.prototype.insertFromInput = function() {
@@ -541,16 +537,15 @@
542538 var tx;
543539 if ( selection.from != selection.to ) {
544540 tx = this.model.getDocument().prepareRemoval( selection );
545 - this.model.transact( tx );
546 - this.documentView.clearSelection();
 541+ this.model.transact( tx, true );
547542 selection.from = selection.to =
548543 Math.min( selection.from, selection.to );
549544 }
550545 tx = this.model.getDocument().prepareInsertion( selection.from, val.split('') );
551 - this.model.transact( tx );
 546+ this.model.transact( tx, true );
552547 selection.from += val.length;
553548 selection.to += val.length;
554 - this.model.select( selection );
 549+ this.model.select( selection, true );
555550 }
556551 };
557552
@@ -671,9 +666,6 @@
672667 if ( this.keyboard.keys.shift && selection.from !== to) {
673668 selection.to = to;
674669 } else {
675 - if ( selection.from !== selection.to ) {
676 - this.documentView.clearSelection();
677 - }
678670 selection.from = selection.to = to;
679671 }
680672 this.model.select( selection );

Status & tagging log