mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 16:44:51 +00:00
33 lines
645 B
JavaScript
33 lines
645 B
JavaScript
es.ButtonTool = function( toolbar, name ) {
|
|
es.Tool.call( this, toolbar, name );
|
|
|
|
// for es.extendClass
|
|
if ( !name ) {
|
|
return;
|
|
}
|
|
|
|
this.$.addClass( 'es-toolbarButtonTool' ).addClass( 'es-toolbarButtonTool-' + name );
|
|
|
|
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 );
|
|
}
|
|
}
|
|
} );
|
|
|
|
};
|
|
|
|
es.ButtonTool.prototype.onClick = function() {
|
|
throw 'ButtonTool.onClick not implemented in this subclass:' + this.constructor;
|
|
};
|
|
|
|
es.extendClass( es.ButtonTool, es.Tool ); |