2011-11-30 07:35:59 +00:00
|
|
|
es.BoldButtonTool = function( toolbar ) {
|
2011-11-30 07:10:15 +00:00
|
|
|
es.ButtonTool.call( this, toolbar, 'bold' );
|
|
|
|
};
|
|
|
|
|
2011-11-30 07:42:10 +00:00
|
|
|
es.BoldButtonTool.prototype.updateState = function( selection, annotations ) {
|
2011-11-30 07:35:59 +00:00
|
|
|
for ( var i = 0; i < annotations.length; i++ ) {
|
|
|
|
if ( annotations[i].type === 'textStyle/bold' ) {
|
2011-11-30 08:07:22 +00:00
|
|
|
this.$.addClass( 'es-toolbarButtonTool-down' );
|
2011-11-30 07:35:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-11-30 08:07:22 +00:00
|
|
|
this.$.removeClass( 'es-toolbarButtonTool-down' );
|
2011-11-30 07:35:59 +00:00
|
|
|
};
|
|
|
|
|
2011-11-30 07:42:10 +00:00
|
|
|
es.BoldButtonTool.prototype.onClick = function() {
|
2011-11-30 08:07:22 +00:00
|
|
|
var method = this.$.hasClass( 'es-toolbarButtonTool-down' ) ? 'clear' : 'set';
|
2011-11-30 07:42:10 +00:00
|
|
|
var tx = this.toolbar.surfaceView.model.getDocument().prepareContentAnnotation(
|
|
|
|
this.toolbar.surfaceView.currentSelection,
|
|
|
|
method,
|
|
|
|
{ 'type': 'textStyle/bold' }
|
|
|
|
);
|
|
|
|
this.toolbar.surfaceView.model.transact( tx );
|
|
|
|
};
|
|
|
|
|
2011-11-30 07:10:15 +00:00
|
|
|
es.ToolbarView.tools.bold = es.BoldButtonTool;
|
|
|
|
|
|
|
|
es.extendClass( es.BoldButtonTool, es.ButtonTool );
|