mediawiki-extensions-Visual.../modules/ve/ui/ve.ui.Tool.js
Trevor Parscal b4de3ead08 Throw ve.Error instead of string literals
Throwing strings is bad because it doesn't include a lot of important
information that an error object does, such as a stack trace or where
the error was actually thrown from.

ve.Error inherits directly from Error. In the future we may create
more specific subclasses and/or do custom stuff.

Some interesting reading on the subject:
* http://www.devthought.com/2011/12/22/a-string-is-not-an-error/

Change-Id: Ib7c568a1dcb98abac44c6c146e84dde5315b2826
2012-08-08 06:19:00 +02:00

36 lines
809 B
JavaScript

/**
* VisualEditor user interface Tool class.
*
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Creates an ve.ui.Tool object.
*
* @class
* @constructor
* @param {ve.ui.Toolbar} toolbar
* @param {String} name
*/
ve.ui.Tool = function ( toolbar, name, title ) {
this.toolbar = toolbar;
this.name = name;
this.title = title;
this.$ = $( '<div class="es-tool"></div>' ).attr( 'title', this.title );
};
/* Static Members */
ve.ui.Tool.tools = {};
/* Methods */
ve.ui.Tool.prototype.updateState = function () {
throw new ve.Error( 'Tool.updateState not implemented in this subclass:' + this.constructor );
};
ve.ui.Tool.prototype.clearState = function () {
this.$.removeClass( 'es-toolbarButtonTool-down' );
};