mediawiki-extensions-Visual.../modules/es/tools/es.ButtonTool.js

44 lines
840 B
JavaScript
Raw Normal View History

2011-12-05 21:10:19 +00:00
/**
* Creates an es.ButtonTool object.
*
* @class
* @constructor
* @param {es.ToolbarView} toolbar
* @param {String} name
*/
es.ButtonTool = function( toolbar, name, title ) {
2011-12-05 21:10:19 +00:00
// Inheritance
es.Tool.call( this, toolbar, name, title );
2011-12-04 02:59:53 +00:00
if ( !name ) {
return;
}
2011-12-05 21:10:19 +00:00
// Properties
2011-12-04 02:59:53 +00:00
this.$.addClass( 'es-toolbarButtonTool' ).addClass( 'es-toolbarButtonTool-' + name );
2011-12-05 21:10:19 +00:00
// Events
2011-12-04 02:59:53 +00:00
var _this = this;
this.$.bind( {
'mousedown': function( e ) {
if ( e.which === 1 ) {
2011-12-04 02:59:53 +00:00
e.preventDefault();
return false;
}
},
'mouseup': function ( e ) {
if ( e.which === 1 ) {
2011-12-04 02:59:53 +00:00
_this.onClick( e );
}
}
} );
};
2011-12-05 21:10:19 +00:00
/* Methods */
2011-12-04 02:59:53 +00:00
es.ButtonTool.prototype.onClick = function() {
throw 'ButtonTool.onClick not implemented in this subclass:' + this.constructor;
};
2011-12-05 21:10:19 +00:00
/* Inheritance */
2011-11-30 23:05:06 +00:00
es.extendClass( es.ButtonTool, es.Tool );