mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-16 02:51:50 +00:00
27 lines
895 B
JavaScript
27 lines
895 B
JavaScript
es.ItalicButtonTool = function( toolbar ) {
|
|
es.ButtonTool.call( this, toolbar, 'italic' );
|
|
};
|
|
|
|
es.ItalicButtonTool.prototype.updateState = function( selection, annotations ) {
|
|
for ( var i = 0; i < annotations.length; i++ ) {
|
|
if ( annotations[i].type === 'textStyle/italic' ) {
|
|
this.$.addClass( 'es-toolbarButtonTool-down' );
|
|
return;
|
|
}
|
|
}
|
|
this.$.removeClass( 'es-toolbarButtonTool-down' );
|
|
};
|
|
|
|
es.ItalicButtonTool.prototype.onClick = function() {
|
|
var method = this.$.hasClass( 'es-toolbarButtonTool-down' ) ? 'clear' : 'set';
|
|
var tx = this.toolbar.surfaceView.model.getDocument().prepareContentAnnotation(
|
|
this.toolbar.surfaceView.currentSelection,
|
|
method,
|
|
{ 'type': 'textStyle/italic' }
|
|
);
|
|
this.toolbar.surfaceView.model.transact( tx );
|
|
};
|
|
|
|
es.ToolbarView.tools.italic = es.ItalicButtonTool;
|
|
|
|
es.extendClass( es.ItalicButtonTool, es.ButtonTool ); |