https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113296

Revision: 113296
Author:   christian
Date:     2012-03-07 21:06:07 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
replacing cursor after annotating works

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js

Modified: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js        
2012-03-07 21:06:01 UTC (rev 113295)
+++ trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js        
2012-03-07 21:06:07 UTC (rev 113296)
@@ -84,7 +84,9 @@
 /* Methods */
 
 ve.ce.Surface.prototype.annotate = function( method, annotation ) {
-       var range = this.getSelection();
+       var range = this.getSelection(),
+               _this = this;
+
        if ( method === 'toggle' ) {
                var annotations = this.getAnnotations();
                if ( ve.dm.DocumentNode.getIndexOfAnnotation( annotations.full, 
annotation ) !== -1 ) {
@@ -97,12 +99,16 @@
                var tx = this.model.getDocument().prepareContentAnnotation(
                        range, method, annotation
                );
-               
+
+               // transact with autoRender
                this.autoRender = true;
                this.model.transact( tx );
                this.autoRender = false;
-               //TODO: Redraw selection
-                               
+
+               this.clearPollData();
+
+               // show cursor
+               _this.showCursorAt(range.to);
        } else {
                if ( method === 'set' ) {
                        this.addInsertionAnnotation( annotation );
@@ -175,11 +181,7 @@
                        // re-render
                        _this.getLeafNode( node ).data( 'view' 
).renderContent();
                        
-                       // clear the prev information from poll object 
(probably a better way to do this)
-                       _this.poll.prevText =
-                               _this.poll.prevHash =
-                               _this.poll.prevOffset =
-                               _this.poll.node = null;
+                       _this.clearPollData();
 
                        // place cursor
                        _this.showCursorAt( selection.start );
@@ -196,7 +198,7 @@
                .html('')
                .show()
                .css( 'top', $(window).scrollTop() )
-               .css(' left', $(window).scrollLeft() )
+               .css( 'left', $(window).scrollLeft() )
                .focus();
 
        setTimeout( function() {
@@ -211,11 +213,7 @@
                        _this.model.transact( tx );
                        _this.autoRender = false;
 
-                       // clear the prev information from poll object 
(probably a better way to do this)
-                       _this.poll.prevText =
-                               _this.poll.prevHash =
-                               _this.poll.prevOffset =
-                               _this.poll.node = null;
+                       _this.clearPollData();
 
                        // place cursor
                        _this.showCursorAt( insertionPoint + 
_this.clipboard[key].length );
@@ -272,6 +270,15 @@
        }
 };
 
+ve.ce.Surface.prototype.clearPollData = function() {
+       this.stopPolling();
+       this.poll.prevText =
+               this.poll.prevHash =
+               this.poll.prevOffset =
+               this.poll.node = null;
+       this.startPolling();
+};
+
 ve.ce.Surface.prototype.pollContent = function() {
        var localOffset, text, hash;
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to