mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
d2dfb9ac4f
* Move and rename generic parts of ve.ui to OO.ui * We now have a UI test suite because ve.Element (outside ve.ui) is now part of oojs-ui, so it needs a test suite. * Added to the MW test run (just like we do for unicodejs). * Updated csslint config (also added ve-mw and syntaxhighlight which were missing). oojs-ui still depends on the TriggerRegistry in VE, this is addressed in a follow-up commit. Change-Id: Iec147155c1ddf20b73a4d15d87b8742207032312
65 lines
1.6 KiB
JavaScript
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 {ve.ui.SurfaceToolbar} toolbar
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ui.ClearAnnotationTool = function VeUiClearAnnotationTool( toolbar, config ) {
|
|
// Parent constructor
|
|
OO.ui.Tool.call( this, toolbar, 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 );
|