2011-12-05 21:10:19 +00:00
|
|
|
/**
|
|
|
|
* Creates an es.ButtonTool object.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @param {es.ToolbarView} toolbar
|
|
|
|
* @param {String} name
|
|
|
|
*/
|
2011-12-09 21:16:42 +00:00
|
|
|
es.ButtonTool = function( toolbar, name, title ) {
|
2011-12-05 21:10:19 +00:00
|
|
|
// Inheritance
|
2011-12-09 21:16:42 +00:00
|
|
|
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 ) {
|
2011-12-06 00:10:30 +00:00
|
|
|
if ( e.which === 1 ) {
|
2011-12-04 02:59:53 +00:00
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'mouseup': function ( e ) {
|
2011-12-06 00:10:30 +00:00
|
|
|
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 );
|