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

33 lines
645 B
JavaScript
Raw Normal View History

2011-12-04 02:59:53 +00:00
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;
};
2011-11-30 23:05:06 +00:00
es.extendClass( es.ButtonTool, es.Tool );