2013-08-27 23:28:29 +00:00
|
|
|
/*!
|
|
|
|
* 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
|
2013-10-09 20:09:59 +00:00
|
|
|
* @extends OO.ui.Tool
|
2013-08-27 23:28:29 +00:00
|
|
|
* @constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
* @param {OO.ui.ToolGroup} toolGroup
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-08-27 23:28:29 +00:00
|
|
|
*/
|
2013-10-23 23:27:12 +00:00
|
|
|
ve.ui.ClearAnnotationTool = function VeUiClearAnnotationTool( toolGroup, config ) {
|
2013-08-27 23:28:29 +00:00
|
|
|
// Parent constructor
|
2013-10-23 23:27:12 +00:00
|
|
|
OO.ui.Tool.call( this, toolGroup, config );
|
2013-08-27 23:28:29 +00:00
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.setDisabled( true );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.inheritClass( ve.ui.ClearAnnotationTool, OO.ui.Tool );
|
2013-08-27 23:28:29 +00:00
|
|
|
|
|
|
|
/* 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 );
|