Use less repetitive code when calling .showHandles()

This is just shorter and avoids duplication, but does the same
as before.

Change-Id: Ib33603bcba15c08e93406c71677b4733bf16a149
This commit is contained in:
Thiemo Kreuz 2021-09-03 09:15:13 +02:00
parent 760d8a3a86
commit fccb9bb4bb
2 changed files with 7 additions and 19 deletions

View file

@ -136,20 +136,12 @@ ve.ce.MWBlockImageNode.prototype.updateClasses = function ( oldAlign ) {
// Border
this.$element.toggleClass( 'mw-image-border', !!this.model.getAttribute( 'borderImage' ) );
switch ( alignClass ) {
case 'mw-halign-right':
this.showHandles( [ 'sw' ] );
break;
case 'mw-halign-left':
this.showHandles( [ 'se' ] );
break;
case 'mw-halign-center':
this.showHandles( [ 'sw', 'se' ] );
break;
default:
this.showHandles();
break;
}
this.showHandles( {
'mw-halign-right': [ 'sw' ],
'mw-halign-left': [ 'se' ],
'mw-halign-center': [ 'sw', 'se' ]
// Defaults to undefined
}[ alignClass ] );
};
/**

View file

@ -46,11 +46,7 @@ ve.ce.MWInlineImageNode = function VeCeMWInlineImageNode( model, config ) {
.attr( 'width', this.model.getAttribute( 'width' ) )
.attr( 'height', this.model.getAttribute( 'height' ) );
if ( this.$element.css( 'direction' ) === 'rtl' ) {
this.showHandles( [ 'sw' ] );
} else {
this.showHandles( [ 'se' ] );
}
this.showHandles( [ this.$element.css( 'direction' ) === 'rtl' ? 'sw' : 'se' ] );
this.updateClasses();