2011-11-30 07:10:15 +00:00
|
|
|
es.ItalicButtonTool = function( toolbar ) {
|
|
|
|
es.ButtonTool.call( this, toolbar, 'italic' );
|
|
|
|
};
|
|
|
|
|
2011-11-30 07:42:10 +00:00
|
|
|
es.ItalicButtonTool.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/italic' ) {
|
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.ItalicButtonTool.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/italic' }
|
|
|
|
);
|
|
|
|
this.toolbar.surfaceView.model.transact( tx );
|
|
|
|
};
|
|
|
|
|
2011-11-30 07:10:15 +00:00
|
|
|
es.ToolbarView.tools.italic = es.ItalicButtonTool;
|
|
|
|
|
|
|
|
es.extendClass( es.ItalicButtonTool, es.ButtonTool );
|