mediawiki-extensions-Visual.../modules/es/tools/es.ButtonTool.js
2011-12-05 21:10:19 +00:00

44 lines
828 B
JavaScript

/**
* Creates an es.ButtonTool object.
*
* @class
* @constructor
* @param {es.ToolbarView} toolbar
* @param {String} name
*/
es.ButtonTool = function( toolbar, name ) {
// Inheritance
es.Tool.call( this, toolbar, name );
if ( !name ) {
return;
}
// Properties
this.$.addClass( 'es-toolbarButtonTool' ).addClass( 'es-toolbarButtonTool-' + name );
// Events
var _this = this;
this.$.bind( {
'mousedown': function( e ) {
if ( e.button === 0 ) {
e.preventDefault();
return false;
}
},
'mouseup': function ( e ) {
if ( e.button === 0 ) {
_this.onClick( e );
}
}
} );
};
/* Methods */
es.ButtonTool.prototype.onClick = function() {
throw 'ButtonTool.onClick not implemented in this subclass:' + this.constructor;
};
/* Inheritance */
es.extendClass( es.ButtonTool, es.Tool );