r104915 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104914‎ | r104915 | r104916 >
Date:23:10, 1 December 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Fixed clear button to only clear testStyle and link annotations, and also only be enabled when these kinds of annotations are in the current selection
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/tools/es.ClearButtonTool.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/tools/es.ClearButtonTool.js
@@ -1,20 +1,22 @@
22 es.ClearButtonTool = function( toolbar, name ) {
33 es.ButtonTool.call( this, toolbar, name );
44 this.$.addClass( 'es-toolbarButtonTool-disabled' );
 5+ this.pattern = /(textStyle\/|link\/).*/;
56 };
67
78 es.ClearButtonTool.prototype.onClick = function() {
89 var tx = this.toolbar.surfaceView.model.getDocument().prepareContentAnnotation(
910 this.toolbar.surfaceView.currentSelection,
1011 'clear',
11 - /.*/
 12+ this.pattern
1213 );
1314 this.toolbar.surfaceView.model.transact( tx );
1415 this.toolbar.surfaceView.clearInsertionAnnotations();
1516 };
1617
1718 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 ) {
1921 this.$.addClass( 'es-toolbarButtonTool-disabled' );
2022 } else {
2123 this.$.removeClass( 'es-toolbarButtonTool-disabled' );

Status & tagging log