r113296 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113295‎ | r113296 | r113297 >
Date:21:06, 7 March 2012
Author:christian
Status:deferred
Tags:
Comment:
replacing cursor after annotating works
Modified paths:
  • /trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js
@@ -84,7 +84,9 @@
8585 /* Methods */
8686
8787 ve.ce.Surface.prototype.annotate = function( method, annotation ) {
88 - var range = this.getSelection();
 88+ var range = this.getSelection(),
 89+ _this = this;
 90+
8991 if ( method === 'toggle' ) {
9092 var annotations = this.getAnnotations();
9193 if ( ve.dm.DocumentNode.getIndexOfAnnotation( annotations.full, annotation ) !== -1 ) {
@@ -97,12 +99,16 @@
98100 var tx = this.model.getDocument().prepareContentAnnotation(
99101 range, method, annotation
100102 );
101 -
 103+
 104+ // transact with autoRender
102105 this.autoRender = true;
103106 this.model.transact( tx );
104107 this.autoRender = false;
105 - //TODO: Redraw selection
106 -
 108+
 109+ this.clearPollData();
 110+
 111+ // show cursor
 112+ _this.showCursorAt(range.to);
107113 } else {
108114 if ( method === 'set' ) {
109115 this.addInsertionAnnotation( annotation );
@@ -175,11 +181,7 @@
176182 // re-render
177183 _this.getLeafNode( node ).data( 'view' ).renderContent();
178184
179 - // clear the prev information from poll object (probably a better way to do this)
180 - _this.poll.prevText =
181 - _this.poll.prevHash =
182 - _this.poll.prevOffset =
183 - _this.poll.node = null;
 185+ _this.clearPollData();
184186
185187 // place cursor
186188 _this.showCursorAt( selection.start );
@@ -196,7 +198,7 @@
197199 .html('')
198200 .show()
199201 .css( 'top', $(window).scrollTop() )
200 - .css(' left', $(window).scrollLeft() )
 202+ .css( 'left', $(window).scrollLeft() )
201203 .focus();
202204
203205 setTimeout( function() {
@@ -211,11 +213,7 @@
212214 _this.model.transact( tx );
213215 _this.autoRender = false;
214216
215 - // clear the prev information from poll object (probably a better way to do this)
216 - _this.poll.prevText =
217 - _this.poll.prevHash =
218 - _this.poll.prevOffset =
219 - _this.poll.node = null;
 217+ _this.clearPollData();
220218
221219 // place cursor
222220 _this.showCursorAt( insertionPoint + _this.clipboard[key].length );
@@ -272,6 +270,15 @@
273271 }
274272 };
275273
 274+ve.ce.Surface.prototype.clearPollData = function() {
 275+ this.stopPolling();
 276+ this.poll.prevText =
 277+ this.poll.prevHash =
 278+ this.poll.prevOffset =
 279+ this.poll.node = null;
 280+ this.startPolling();
 281+};
 282+
276283 ve.ce.Surface.prototype.pollContent = function() {
277284 var localOffset, text, hash;
278285

Status & tagging log