mediawiki-extensions-Visual.../modules/ve/ui/tools/ve.ui.ClearAnnotationTool.js
Trevor Parscal 6774cd74f3 Detangle triggers from OOUI
Changes:

* Pass toolGroup into tools instead of toolbar
* Split tool labels into title and accel
* Make toolbars provide accelerator labels
* Remove getLabelText method since it's not being used and is likely not useful
* Make tools update their own labels
* Only show accelerator information for triggers that are active in the surface
* Make surface toolbars listen to commands being added and update tools accordingly
* Introduce command object to encapsulate command info

Change-Id: Ieac4bfa63b63ac0a9dee154af3007a33b4d447ff
2013-10-29 05:50:30 +00:00

65 lines
1.6 KiB
JavaScript

/*!
* VisualEditor UserInterface ClearAnnotationTool class.
*
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* UserInterface clear tool.
*
* @class
* @extends OO.ui.Tool
* @constructor
* @param {OO.ui.ToolGroup} toolGroup
* @param {Object} [config] Configuration options
*/
ve.ui.ClearAnnotationTool = function VeUiClearAnnotationTool( toolGroup, config ) {
// Parent constructor
OO.ui.Tool.call( this, toolGroup, config );
// Initialization
this.setDisabled( true );
};
/* Inheritance */
OO.inheritClass( ve.ui.ClearAnnotationTool, OO.ui.Tool );
/* Static Properties */
ve.ui.ClearAnnotationTool.static.name = 'clear';
ve.ui.ClearAnnotationTool.static.group = 'utility';
ve.ui.ClearAnnotationTool.static.icon = 'clear';
ve.ui.ClearAnnotationTool.static.titleMessage = 'visualeditor-clearbutton-tooltip';
/* Methods */
/**
* Handle the tool being selected.
*
* @method
*/
ve.ui.ClearAnnotationTool.prototype.onSelect = function () {
this.toolbar.getSurface().execute( 'annotation', 'clearAll' );
};
/**
* Handle the toolbar state being updated.
*
* @method
* @param {ve.dm.Node[]} nodes List of nodes covered by the current selection
* @param {ve.dm.AnnotationSet} full Annotations that cover all of the current selection
* @param {ve.dm.AnnotationSet} partial Annotations that cover some or all of the current selection
*/
ve.ui.ClearAnnotationTool.prototype.onUpdateState = function ( nodes, full, partial ) {
this.setDisabled( partial.isEmpty() );
};
/* Registration */
ve.ui.toolFactory.register( ve.ui.ClearAnnotationTool );