Index: trunk/extensions/VisualEditor/modules/sandbox/sandbox.js |
— | — | @@ -518,24 +518,17 @@ |
519 | 519 | '$': $( '#es-mode-history' ), |
520 | 520 | '$panel': $( '#es-panel-history' ), |
521 | 521 | 'update': function() { |
522 | | - var events = '', |
523 | | - i = surfaceModel.history.length, |
524 | | - end = Math.max( 0, i - 25 ), |
525 | | - action, |
526 | | - ops, |
527 | | - data, |
528 | | - attr; |
529 | | - while ( --i >= end ) { |
530 | | - attr = i === surfaceModel.historyIndex ? |
531 | | - ' class="es-panel-history-active"' : ''; |
532 | | - action = surfaceModel.history[i]; |
533 | | - if ( action instanceof es.Range ) { |
534 | | - events += '<div' + attr + '>sel(' + action.from + ', ' + action.to + |
535 | | - ')</div>'; |
536 | | - } else { |
537 | | - ops = action.getOperations().slice( 0 ); |
538 | | - for ( var j = 0; j < ops.length; j++ ) { |
539 | | - data = ops[j].data || ops[j].length; |
| 522 | + function oneStack( stack, active ) { |
| 523 | + var operations, |
| 524 | + i, |
| 525 | + j, |
| 526 | + events = [], |
| 527 | + data; |
| 528 | + |
| 529 | + for ( i = 0; i < stack.length; i++) { |
| 530 | + operations = stack[i].getOperations().slice(0); |
| 531 | + for ( j = 0; j < operations.length; j++ ) { |
| 532 | + data = operations[j].data || operations[j].length; |
540 | 533 | if ( es.isArray( data ) ) { |
541 | 534 | data = data[0]; |
542 | 535 | if ( es.isArray( data ) ) { |
— | — | @@ -545,12 +538,37 @@ |
546 | 539 | if ( typeof data !== 'string' && typeof data !== 'number' ) { |
547 | 540 | data = '-'; |
548 | 541 | } |
549 | | - ops[j] = ops[j].type.substr( 0, 3 ) + '(' + data + ')'; |
| 542 | + operations[j] = operations[j].type.substr( 0, 3 ) + '(' + data + ')'; |
550 | 543 | } |
551 | | - events += '<div' + attr + '>' + ops.join( ', ' ) + '</div>'; |
| 544 | + events.push( '[' + operations.join( ', ' ) + ']' ); |
552 | 545 | } |
| 546 | + if ( active) { |
| 547 | + return '<div class="es-panel-history-active">' + events.join( ', ' ) + '</div>'; |
| 548 | + } else { |
| 549 | + return '<div>' + events.join( ', ' ) + '</div>'; |
| 550 | + } |
553 | 551 | } |
| 552 | + |
| 553 | + var events = ''; |
| 554 | + i = surfaceModel.bigStack.length, |
| 555 | + j = 0, |
| 556 | + end; |
| 557 | + |
| 558 | + if ( surfaceModel.smallStack.length > 0 ) { |
| 559 | + events += oneStack( surfaceModel.smallStack ); |
| 560 | + end = Math.max( 0, i - 24 ); |
| 561 | + } else { |
| 562 | + end = Math.max( 0, i - 25 ); |
| 563 | + } |
| 564 | + |
| 565 | + |
| 566 | + while ( --i >= end ) { |
| 567 | + j++; |
| 568 | + events += oneStack( surfaceModel.bigStack[i].stack, surfaceModel.undoIndex === j); |
| 569 | + } |
| 570 | + |
554 | 571 | this.$panel.html( events ); |
| 572 | + return; |
555 | 573 | } |
556 | 574 | }, |
557 | 575 | 'help': { |