Only show non-anchored resize handles for MWBlock/InlineImages

For block images, show the bottom left/right anchor if the image
is right/left aligned, and both if it is centred.

For inline images, show the bottom right anchor unless the page is
RTL.

Change-Id: Icb5b74b954493257c517a5fbac5f0a0a457c544c
This commit is contained in:
Ed Sanders 2014-01-15 22:26:15 +00:00 committed by Catrope
parent e31b28527e
commit 6f37b4608c
2 changed files with 28 additions and 7 deletions

View file

@ -149,7 +149,8 @@ ve.ce.MWBlockImageNode.prototype.updateCaption = function () {
* @param {string} [oldAlign] The old alignment, for removing classes
*/
ve.ce.MWBlockImageNode.prototype.updateClasses = function ( oldAlign ) {
var align = this.model.getAttribute( 'align' ),
var alignClass,
align = this.model.getAttribute( 'align' ),
type = this.model.getAttribute( 'type' );
if ( oldAlign && oldAlign !== align ) {
@ -160,15 +161,29 @@ ve.ce.MWBlockImageNode.prototype.updateClasses = function ( oldAlign ) {
}
if ( type !== 'none' && type !== 'frameless' ) {
alignClass = this.getCssClass( 'default', align );
this.$image.addClass( 've-ce-mwBlockImageNode-thumbimage' );
this.$figure
.addClass( this.getCssClass( 'default', align ) )
.addClass( 've-ce-mwBlockImageNode-borderwrap' );
this.$figure.addClass( 've-ce-mwBlockImageNode-borderwrap' );
} else {
alignClass = this.getCssClass( 'none', align );
this.$image.removeClass( 've-ce-mwBlockImageNode-thumbimage' );
this.$figure
.addClass( this.getCssClass( 'none', align ) )
.removeClass( 've-ce-mwBlockImageNode-borderwrap' );
this.$figure.removeClass( 've-ce-mwBlockImageNode-borderwrap' );
}
this.$figure.addClass( alignClass );
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;
}
};

View file

@ -50,6 +50,12 @@ ve.ce.MWInlineImageNode = function VeCeMWInlineImageNode( model, config ) {
this.$image.css( 'vertical-align', valign );
}
if ( this.$element.css( 'direction' ) === 'rtl' ) {
this.showHandles( ['sw'] );
} else {
this.showHandles( ['se'] );
}
// DOM changes
this.$element.addClass( 've-ce-mwInlineImageNode' );