Index: trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js |
— | — | @@ -33,6 +33,14 @@ |
34 | 34 | this.undoIndex = 0; |
35 | 35 | }; |
36 | 36 | |
| 37 | +es.SurfaceModel.prototype.getHistory = function() { |
| 38 | + if ( this.smallStack.length > 0 ) { |
| 39 | + return this.bigStack.slice(0).concat([{stack:this.smallStack.slice(0)}]); |
| 40 | + } else { |
| 41 | + return this.bigStack.slice(0); |
| 42 | + } |
| 43 | +}; |
| 44 | + |
37 | 45 | /** |
38 | 46 | * Gets the document model of the surface. |
39 | 47 | * |
Index: trunk/extensions/VisualEditor/modules/sandbox/sandbox.js |
— | — | @@ -635,17 +635,23 @@ |
636 | 636 | '$': $( '#es-mode-history' ), |
637 | 637 | '$panel': $( '#es-panel-history' ), |
638 | 638 | 'update': function() { |
639 | | - function oneStack( stack, active ) { |
640 | | - var operations, |
641 | | - i, |
642 | | - j, |
643 | | - events = [], |
644 | | - data; |
| 639 | + var history = surfaceModel.getHistory(), |
| 640 | + i = history.length, |
| 641 | + end = Math.max( 0, i - 25 ), |
| 642 | + j, |
| 643 | + k, |
| 644 | + ops, |
| 645 | + events = '', |
| 646 | + z = 0, |
| 647 | + operations; |
645 | 648 | |
646 | | - for ( i = 0; i < stack.length; i++) { |
647 | | - operations = stack[i].getOperations().slice(0); |
648 | | - for ( j = 0; j < operations.length; j++ ) { |
649 | | - data = operations[j].data || operations[j].length; |
| 649 | + while ( --i >= end ) { |
| 650 | + z++; |
| 651 | + operations = []; |
| 652 | + for ( j = 0; j < history[i].stack.length; j++) { |
| 653 | + ops = history[i].stack[j].getOperations().slice(0); |
| 654 | + for ( k = 0; k < ops.length; k++ ) { |
| 655 | + data = ops[k].data || ops[k].length; |
650 | 656 | if ( es.isArray( data ) ) { |
651 | 657 | data = data[0]; |
652 | 658 | if ( es.isArray( data ) ) { |
— | — | @@ -655,37 +661,14 @@ |
656 | 662 | if ( typeof data !== 'string' && typeof data !== 'number' ) { |
657 | 663 | data = '-'; |
658 | 664 | } |
659 | | - operations[j] = operations[j].type.substr( 0, 3 ) + '(' + data + ')'; |
| 665 | + ops[k] = ops[k].type.substr( 0, 3 ) + '(' + data + ')'; |
660 | 666 | } |
661 | | - events.push( '[' + operations.join( ', ' ) + ']' ); |
| 667 | + operations.push('[' + ops.join( ', ' ) + ']'); |
662 | 668 | } |
663 | | - if ( active) { |
664 | | - return '<div class="es-panel-history-active">' + events.join( ', ' ) + '</div>'; |
665 | | - } else { |
666 | | - return '<div>' + events.join( ', ' ) + '</div>'; |
667 | | - } |
| 669 | + events += '<div' + (z === surfaceModel.undoIndex ? ' class="es-panel-history-active"' : '') + '>' + operations.join(', ') + '</div>'; |
668 | 670 | } |
669 | | - |
670 | | - var events = '', |
671 | | - i = surfaceModel.bigStack.length, |
672 | | - j = 0, |
673 | | - end; |
674 | | - |
675 | | - if ( surfaceModel.smallStack.length > 0 ) { |
676 | | - events += oneStack( surfaceModel.smallStack ); |
677 | | - end = Math.max( 0, i - 24 ); |
678 | | - } else { |
679 | | - end = Math.max( 0, i - 25 ); |
680 | | - } |
681 | 671 | |
682 | | - |
683 | | - while ( --i >= end ) { |
684 | | - j++; |
685 | | - events += oneStack( surfaceModel.bigStack[i].stack, surfaceModel.undoIndex === j); |
686 | | - } |
687 | | - |
688 | 672 | this.$panel.html( events ); |
689 | | - return; |
690 | 673 | } |
691 | 674 | }, |
692 | 675 | 'help': { |