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

Revision: 105511
Author:   inez
Date:     2011-12-08 03:14:10 +0000 (Thu, 08 Dec 2011)
Log Message:
-----------
Revert r105509 and r105507 - taken approach is not gonna work

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js
    trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js
    trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js
    trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js

Modified: trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js  
2011-12-08 02:02:21 UTC (rev 105510)
+++ trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js  
2011-12-08 03:14:10 UTC (rev 105511)
@@ -120,14 +120,6 @@
  *                                     (such as when replacing - delete, then 
insert)
  */
 es.SurfaceModel.prototype.transact = function( transaction, isPartial ) {
-       
-       if(es.isArray(transaction)) {
-               for( var i = 0; i < transaction.length; i++ ) {
-                       this.transact( transaction[i] );
-               }
-               return;
-       }
-       
        // console.log( 'tx:' + $.map( transaction.getOperations(), 
function(tx) { return tx.type; } ).join(",") 
        //                              + ' isPartial:' + isPartial ); 
        this.doc.commit( transaction );

Modified: 
trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js     
2011-12-08 02:02:21 UTC (rev 105510)
+++ trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js     
2011-12-08 03:14:10 UTC (rev 105511)
@@ -68,7 +68,9 @@
                item.type,
                item.attributes
        );
-       this.toolbar.surfaceView.model.transact( txs );
+       for ( var i = 0; i < txs.length; i++ ) {
+               this.toolbar.surfaceView.model.transact( txs[i] );
+       }
 };
 
 es.FormatDropdownTool.prototype.updateState = function( annotations, nodes ) {

Modified: trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js 
2011-12-08 02:02:21 UTC (rev 105510)
+++ trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js 
2011-12-08 03:14:10 UTC (rev 105511)
@@ -29,7 +29,7 @@
                insertAt,
                removeLength,
                data,
-               txs = [],
+               tx,
                i,
                j;
 
@@ -82,12 +82,13 @@
                styles = listItems[i].getElementAttribute( 'styles' );
                if ( styles[styles.length - 1] !== style ) {
                        styles.splice( styles.length - 1, 1, style );
-                       txs.push( 
surface.model.getDocument().prepareElementAttributeChange(
+                       tx = 
surface.model.getDocument().prepareElementAttributeChange(
                                surface.documentView.model.getOffsetFromNode( 
listItems[i], false ),
                                'set',
                                'styles',
                                styles
-                       ) );
+                       );
+                       surface.model.transact( tx );
                }
        }
 
@@ -112,12 +113,16 @@
                }
                data = data.concat( [ { 'type': '/list' } ] );
 
-               txs.push( surface.model.getDocument().prepareInsertion( 
insertAt, data ) );
-               txs.push( surface.model.getDocument().prepareRemoval(
+               tx = surface.model.getDocument().prepareInsertion( insertAt, 
data );
+               surface.model.transact( tx );
+
+               tx = surface.model.getDocument().prepareRemoval(
                        new es.Range( insertAt + data.length, insertAt + 
removeLength + data.length )
-               ) );
+               );
+               surface.model.transact( tx );
+
        }
-       surface.model.transact( txs );
+
        surface.model.select( selection, true );
 };
 

Modified: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js    
2011-12-08 02:02:21 UTC (rev 105510)
+++ trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js    
2011-12-08 03:14:10 UTC (rev 105511)
@@ -613,15 +613,13 @@
        }, 10 );
 };
 
-es.SurfaceView.prototype.handleDelete = function( backspace, notExecute ) {
+es.SurfaceView.prototype.handleDelete = function( backspace, isPartial ) {
        var selection = this.currentSelection.clone(),
                sourceOffset,
                targetOffset,
                sourceSplitableNode,
                targetSplitableNode,
-               tx,
-               txs = [];
-
+               tx;
        if ( selection.from === selection.to ) {
                if ( backspace ) {
                        sourceOffset = selection.to;
@@ -651,13 +649,15 @@
                if ( sourceNode === targetNode ||
                        ( typeof sourceSplitableNode !== 'undefined' &&
                        sourceSplitableNode.getParent()  === 
targetSplitableNode.getParent() ) ) {
-                       txs.push( this.model.getDocument().prepareRemoval(
+                       tx = this.model.getDocument().prepareRemoval(
                                new es.Range( targetOffset, sourceOffset )
-                       ) );
+                       );
+                       this.model.transact( tx, isPartial );
                } else {
-                       txs.push( this.model.getDocument().prepareInsertion(
+                       tx = this.model.getDocument().prepareInsertion(
                                targetOffset, sourceNode.model.getContentData()
-                       ) );
+                       );
+                       this.model.transact( tx, isPartial );
                        
                        var nodeToDelete = sourceNode;
                        es.DocumentNode.traverseUpstream( nodeToDelete, 
function( node ) {
@@ -671,31 +671,23 @@
                        var range = new es.Range();
                        range.from = this.documentView.getOffsetFromNode( 
nodeToDelete, false );
                        range.to = range.from + nodeToDelete.getElementLength();
-                       txs.push( this.model.getDocument().prepareRemoval( 
range ) );
+                       tx = this.model.getDocument().prepareRemoval( range );
+                       this.model.transact( tx, isPartial );
                }
-               if ( notExecute ) {
-                       return txs;
-               } else {
-                       this.model.transact( txs );
-               }
        } else {
                // selection removal
                tx = this.model.getDocument().prepareRemoval( selection );
+               this.model.transact( tx, isPartial );
                selection.from = selection.to = selection.start;
                this.model.select( selection );
-               if ( notExecute ) {
-                       return [tx];
-               } else {
-                       this.model.transact( tx );
-               }
        }
 };
 
 es.SurfaceView.prototype.handleEnter = function() {
        var selection = this.currentSelection.clone(),
-               txs = [];
+               tx;
        if ( selection.from !== selection.to ) {
-               txs.concat( this.handleDelete( false, true ) );
+               this.handleDelete( false, true );
        }
        var     node = this.documentView.getNodeFromOffset( selection.to, false 
),
                nodeOffset = this.documentView.getOffsetFromNode( node, false );
@@ -704,11 +696,11 @@
                nodeOffset + node.getContentLength() + 1 === selection.to &&
                node ===  es.DocumentViewNode.getSplitableNode( node )
        ) {
-               txs.push( this.documentView.model.prepareInsertion(
+               tx = this.documentView.model.prepareInsertion(
                        nodeOffset + node.getElementLength(),
                        [ { 'type': 'paragraph' }, { 'type': '/paragraph' } ]
-               ) );
-               this.model.transact( txs );
+               );
+               this.model.transact( tx );
                selection.from = selection.to = nodeOffset + 
node.getElementLength() + 1;       
        } else {
                var     stack = [],
@@ -734,8 +726,8 @@
                        splitable = es.DocumentView.splitRules[ elementType 
].self;
                        return true;
                } );
-               txs.push( this.documentView.model.prepareInsertion( 
selection.to, stack ) );
-               this.model.transact( txs );
+               tx = this.documentView.model.prepareInsertion( selection.to, 
stack );
+               this.model.transact( tx );
                selection.from = selection.to =
                        this.model.getDocument().getRelativeContentOffset( 
selection.to, 1 );
        }
@@ -764,15 +756,17 @@
                this.$input.val( '' );
 
                // Prepare and process a transaction
-               var txs = [];
+               var tx;
                if ( selection.from != selection.to ) {
-                       txs.push( this.model.getDocument().prepareRemoval( 
selection ) );
-                       selection.from = selection.to = Math.min( 
selection.from, selection.to );
+                       tx = this.model.getDocument().prepareRemoval( selection 
);
+                       this.model.transact( tx, true );
+                       selection.from = selection.to =
+                               Math.min( selection.from, selection.to );
                }
                var data = val.split('');
                es.DocumentModel.addAnnotationsToData( data, 
this.getInsertionAnnotations() );
-               txs.push( this.model.getDocument().prepareInsertion( 
selection.from, data ) );
-               this.model.transact( txs );
+               tx = this.model.getDocument().prepareInsertion( selection.from, 
data );
+               this.model.transact( tx );
 
                // Move the selection
                selection.from += val.length;


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to