Index: trunk/extensions/VisualEditor/modules/es/tools/es.ButtonTool.js |
— | — | @@ -39,6 +39,15 @@ |
40 | 40 | throw 'ButtonTool.onClick not implemented in this subclass:' + this.constructor; |
41 | 41 | }; |
42 | 42 | |
| 43 | +es.ButtonTool.prototype.updateEnabled = function() { |
| 44 | + if ( this.enabled ) { |
| 45 | + this.$.removeClass( 'es-toolbarButtonTool-disabled' ); |
| 46 | + } else { |
| 47 | + this.$.addClass( 'es-toolbarButtonTool-disabled' ); |
| 48 | + } |
| 49 | +}; |
| 50 | + |
| 51 | + |
43 | 52 | /* Inheritance */ |
44 | 53 | |
45 | | -es.extendClass( es.ButtonTool, es.Tool ); |
\ No newline at end of file |
| 54 | +es.extendClass( es.ButtonTool, es.Tool ); |
Index: trunk/extensions/VisualEditor/modules/es/tools/es.HistoryButtonTool.js |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | |
15 | 15 | // Properties |
16 | 16 | this.data = data; |
| 17 | + this.enabled = false; |
17 | 18 | }; |
18 | 19 | |
19 | 20 | /* Methods */ |
— | — | @@ -29,9 +30,20 @@ |
30 | 31 | }; |
31 | 32 | |
32 | 33 | es.HistoryButtonTool.prototype.updateState = function( annotations ) { |
33 | | - // |
34 | | -}; |
| 34 | + var surfaceModel = this.toolbar.surfaceView.model; |
| 35 | + switch( this.name ) { |
| 36 | + case 'undo': |
| 37 | + this.enabled = surfaceModel.bigStack.length - surfaceModel.undoIndex > 0; |
| 38 | + break; |
| 39 | + case 'redo': |
| 40 | + this.enabled = surfaceModel.undoIndex > 0; |
| 41 | + break; |
| 42 | + } |
35 | 43 | |
| 44 | + this.updateEnabled(); |
| 45 | +} |
| 46 | + |
| 47 | + |
36 | 48 | /* Registration */ |
37 | 49 | |
38 | 50 | es.Tool.tools.undo = { |
Index: trunk/extensions/VisualEditor/modules/es/styles/es.ToolbarView.css |
— | — | @@ -87,6 +87,11 @@ |
88 | 88 | .es-toolbarButtonTool-outdent:before { |
89 | 89 | background-image: url(../images/outdent.png); |
90 | 90 | } |
| 91 | +.es-toolbarButtonTool-disabled { |
| 92 | + -moz-opacity: 0.25; |
| 93 | + filter:alpha(opacity=25); |
| 94 | + opacity: 0.25; |
| 95 | +} |
91 | 96 | .es-toolbarButtonTool-disabled.es-toolbarButtonTool-clear:before, |
92 | 97 | .es-toolbarButtonTool-disabled.es-toolbarButtonTool-indent:before, |
93 | 98 | .es-toolbarButtonTool-disabled.es-toolbarButtonTool-outdent:before { |