r104805 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104804‎ | r104805 | r104806 >
Date:00:21, 1 December 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Filter out insertion annotations that aren't textStyle or link
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
@@ -144,6 +144,18 @@
145145 this.insertionAnnotations.push( annotation );
146146 };
147147
 148+es.SurfaceView.prototype.loadInsertionAnnotations = function( annotation ) {
 149+ this.insertionAnnotations =
 150+ this.model.getDocument().getAnnotationsFromOffset( _this.currentSelection.to );
 151+ // Filter out annotations that aren't textStyles or links
 152+ for ( var i = 0; i < this.insertionAnnotations.length; i++ ) {
 153+ if ( !this.insertionAnnotations[i].type.match( /(textStyle\/|link\/)/ ) ) {
 154+ this.insertionAnnotations.splice( i, 1 );
 155+ i--;
 156+ }
 157+ }
 158+};
 159+
148160 es.SurfaceView.prototype.removeInsertionAnnotation = function( annotation ) {
149161 var index = es.DocumentView.getIndexOfAnnotation( this.insertionAnnotations, annotation );
150162 if ( index !== -1 ) {
@@ -163,18 +175,15 @@
164176 var _this = this;
165177 function update() {
166178 if ( _this.currentSelection.from !== _this.currentSelection.to ) {
 179+ _this.clearInsertionAnnotations();
167180 _this.hideCursor();
168181 _this.documentView.drawSelection( _this.currentSelection );
169182 // Update the context icon position
170183 _this.contextView.update();
171 - // Clear insertion annotations
172 - _this.insertionAnnotations = [];
173184 } else {
 185+ _this.loadInsertionAnnotations();
174186 _this.showCursor();
175187 _this.documentView.clearSelection( _this.currentSelection );
176 - // Load new insertion annotations
177 - _this.insertionAnnotations =
178 - _this.model.getDocument().getAnnotationsFromOffset( _this.currentSelection.to );
179188 }
180189 _this.updateSelectionTimeout = undefined;
181190 }

Status & tagging log