From 6f37b4608cd0eb9a1cb46749733357a5ff86804d Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 15 Jan 2014 22:26:15 +0000 Subject: [PATCH] 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 --- .../ve-mw/ce/nodes/ve.ce.MWBlockImageNode.js | 29 ++++++++++++++----- .../ve-mw/ce/nodes/ve.ce.MWInlineImageNode.js | 6 ++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWBlockImageNode.js b/modules/ve-mw/ce/nodes/ve.ce.MWBlockImageNode.js index f42a03ffe5..57f01e2eec 100644 --- a/modules/ve-mw/ce/nodes/ve.ce.MWBlockImageNode.js +++ b/modules/ve-mw/ce/nodes/ve.ce.MWBlockImageNode.js @@ -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; } }; diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWInlineImageNode.js b/modules/ve-mw/ce/nodes/ve.ce.MWInlineImageNode.js index b0cb28e4a6..5d39f6fc56 100644 --- a/modules/ve-mw/ce/nodes/ve.ce.MWInlineImageNode.js +++ b/modules/ve-mw/ce/nodes/ve.ce.MWInlineImageNode.js @@ -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' );