r104792 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104791‎ | r104792 | r104793 >
Date:23:50, 30 November 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Limited select event emitting to when selection changes
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js
@@ -70,13 +70,11 @@
7171 }
7272 // Filter out calls to select if they do not change the selection values
7373 this.selection = selection;
74 - if (
75 - !combine ||
76 - !this.previousSelection || (
77 - this.previousSelection.from !== this.selection.from ||
78 - this.previousSelection.to !== this.selection.to
79 - )
80 - ) {
 74+ var selectionChanged = !this.previousSelection || (
 75+ this.previousSelection.from !== this.selection.from ||
 76+ this.previousSelection.to !== this.selection.to
 77+ );
 78+ if ( !combine || selectionChanged ) {
8179 var lastAction = this.states[this.states.length - 1];
8280 if ( lastAction instanceof es.Range ) {
8381 this.currentStateDistance += Math.abs(
@@ -84,7 +82,9 @@
8583 );
8684 }
8785 this.currentState.push( selection );
88 - this.emit( 'select', this.selection.clone() );
 86+ if ( selectionChanged ) {
 87+ this.emit( 'select', this.selection.clone() );
 88+ }
8989 }
9090 this.previousSelection = this.selection.clone();
9191 };

Status & tagging log