mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-26 19:56:49 +00:00
Make Bold and Italic toolbar buttons works (when clicked)
This commit is contained in:
parent
af39b6dc47
commit
4d3e38756f
|
@ -2,7 +2,7 @@ es.BoldButtonTool = function( toolbar ) {
|
|||
es.ButtonTool.call( this, toolbar, 'bold' );
|
||||
};
|
||||
|
||||
es.BoldButtonTool.prototype.updateState = function ( selection, annotations ) {
|
||||
es.BoldButtonTool.prototype.updateState = function( selection, annotations ) {
|
||||
for ( var i = 0; i < annotations.length; i++ ) {
|
||||
if ( annotations[i].type === 'textStyle/bold' ) {
|
||||
this.$.addClass( 'es-toolbarTool-down' );
|
||||
|
@ -12,6 +12,16 @@ es.BoldButtonTool.prototype.updateState = function ( selection, annotations ) {
|
|||
this.$.removeClass( 'es-toolbarTool-down' );
|
||||
};
|
||||
|
||||
es.BoldButtonTool.prototype.onClick = function() {
|
||||
var method = this.$.hasClass( 'es-toolbarTool-down' ) ? 'clear' : 'set';
|
||||
var tx = this.toolbar.surfaceView.model.getDocument().prepareContentAnnotation(
|
||||
this.toolbar.surfaceView.currentSelection,
|
||||
method,
|
||||
{ 'type': 'textStyle/bold' }
|
||||
);
|
||||
this.toolbar.surfaceView.model.transact( tx );
|
||||
};
|
||||
|
||||
es.ToolbarView.tools.bold = es.BoldButtonTool;
|
||||
|
||||
es.extendClass( es.BoldButtonTool, es.ButtonTool );
|
|
@ -13,8 +13,6 @@ es.ButtonTool = function( toolbar, name ) {
|
|||
};
|
||||
|
||||
es.ButtonTool.prototype.onClick = function( e ) {
|
||||
console.log( this.$ );
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
es.extendClass( es.ButtonTool, es.Tool );
|
|
@ -2,7 +2,7 @@ es.ItalicButtonTool = function( toolbar ) {
|
|||
es.ButtonTool.call( this, toolbar, 'italic' );
|
||||
};
|
||||
|
||||
es.ItalicButtonTool.prototype.updateState = function ( selection, annotations ) {
|
||||
es.ItalicButtonTool.prototype.updateState = function( selection, annotations ) {
|
||||
for ( var i = 0; i < annotations.length; i++ ) {
|
||||
if ( annotations[i].type === 'textStyle/italic' ) {
|
||||
this.$.addClass( 'es-toolbarTool-down' );
|
||||
|
@ -12,6 +12,16 @@ es.ItalicButtonTool.prototype.updateState = function ( selection, annotations )
|
|||
this.$.removeClass( 'es-toolbarTool-down' );
|
||||
};
|
||||
|
||||
es.ItalicButtonTool.prototype.onClick = function() {
|
||||
var method = this.$.hasClass( 'es-toolbarTool-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 );
|
|
@ -23,5 +23,5 @@ es.Tool = function( toolbar ) {
|
|||
} );
|
||||
};
|
||||
|
||||
es.Tool.prototype.updateState = function () {
|
||||
es.Tool.prototype.updateState = function() {
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue