Index: trunk/extensions/VisualEditor/modules/es/tools/es.ClearButtonTool.js |
— | — | @@ -1,20 +1,22 @@ |
2 | 2 | es.ClearButtonTool = function( toolbar, name ) {
|
3 | 3 | es.ButtonTool.call( this, toolbar, name );
|
4 | 4 | this.$.addClass( 'es-toolbarButtonTool-disabled' );
|
| 5 | + this.pattern = /(textStyle\/|link\/).*/;
|
5 | 6 | };
|
6 | 7 |
|
7 | 8 | es.ClearButtonTool.prototype.onClick = function() {
|
8 | 9 | var tx = this.toolbar.surfaceView.model.getDocument().prepareContentAnnotation(
|
9 | 10 | this.toolbar.surfaceView.currentSelection,
|
10 | 11 | 'clear',
|
11 | | - /.*/
|
| 12 | + this.pattern
|
12 | 13 | );
|
13 | 14 | this.toolbar.surfaceView.model.transact( tx );
|
14 | 15 | this.toolbar.surfaceView.clearInsertionAnnotations();
|
15 | 16 | };
|
16 | 17 |
|
17 | 18 | es.ClearButtonTool.prototype.updateState = function( annotations ) {
|
18 | | - if ( annotations.length === 0 ) {
|
| 19 | + var matchingAnnotations = es.DocumentModel.getMatchingAnnotations( annotations, this.pattern );
|
| 20 | + if ( matchingAnnotations.length === 0 ) {
|
19 | 21 | this.$.addClass( 'es-toolbarButtonTool-disabled' );
|
20 | 22 | } else {
|
21 | 23 | this.$.removeClass( 'es-toolbarButtonTool-disabled' );
|