12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- /**
- * @author mrdoob / http://mrdoob.com/
- */
- Sidebar.History = function ( editor ) {
- var signals = editor.signals;
- var history = editor.history;
- var container = new UI.CollapsiblePanel();
- container.setCollapsed( editor.config.getKey( 'ui/sidebar/history/collapsed' ) );
- container.onCollapsedChange( function ( boolean ) {
- editor.config.setKey( 'ui/sidebar/history/collapsed', boolean );
- } );
- container.addStatic( new UI.Text( 'HISTORY' ) );
- container.add( new UI.Break() );
- var ignoreObjectSelectedSignal = false;
- var outliner = new UI.Outliner( editor );
- outliner.onChange( function () {
- ignoreObjectSelectedSignal = true;
- editor.history.goToState( parseInt( outliner.getValue() ) );
- ignoreObjectSelectedSignal = false;
- } );
- outliner.onDblClick( function () {
- //editor.focusById( parseInt( outliner.getValue() ) );
- } );
- container.add( outliner );
- //
- var refreshUI = function () {
- var options = [];
- var enumerator = 1;
- ( function addObjects( objects, pad ) {
- for ( var i = 0, l = objects.length; i < l; i ++ ) {
- var object = objects[ i ];
- var html = pad + "<span style='color: #0000cc '>" + enumerator++ + ". Undo: " + object.name + "</span>";
- options.push( { value: object.id, html: html } );
- }
- } )( history.undos, ' ' );
- ( function addObjects( objects, pad ) {
- for ( var i = objects.length - 1; i >= 0; i -- ) {
- var object = objects[ i ];
- var html = pad + "<span style='color: #71544e'>" + enumerator++ + ". Redo: " + object.name + "</span>";
- options.push( { value: object.id, html: html } );
- }
- } )( history.redos, ' ' );
- outliner.setOptions( options );
- };
- refreshUI();
- // events
- signals.editorCleared.add( refreshUI );
- signals.historyChanged.add( refreshUI );
- signals.historyChanged.add( function ( cmd ) {
-
- outliner.setValue( cmd !== undefined ? cmd.id : null );
- } );
- return container;
- };
|