SuchetaG has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/213812

Change subject: Fixing the behaviour of resizable images so that redlinked 
images, inline and block, can be represented properly
......................................................................

Fixing the behaviour of resizable images so that redlinked images, inline and 
block, can be represented properly

Change-Id: I2ff34db8178c901110fd395658000623a675e202
---
M src/ce/ve.ce.ResizableNode.js
1 file changed, 36 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/12/213812/1

diff --git a/src/ce/ve.ce.ResizableNode.js b/src/ce/ve.ce.ResizableNode.js
index b6f68e7..1302716 100644
--- a/src/ce/ve.ce.ResizableNode.js
+++ b/src/ce/ve.ce.ResizableNode.js
@@ -24,6 +24,7 @@
        // Properties
        this.$resizable = $resizable || this.$element;
        this.resizing = false;
+       this.enabled = !!this.$resizable.length;
        this.$resizeHandles = $( '<div>' );
        this.snapToGrid = config.snapToGrid !== undefined ? config.snapToGrid : 
10;
        this.outline = !!config.outline;
@@ -37,6 +38,9 @@
        }
        this.resizableOffset = null;
        this.resizableSurface = null;
+       if (!this.enabled ) {
+               return;
+       }
 
        // Events
        this.connect( this, {
@@ -97,6 +101,9 @@
  * @returns {Object} Position coordinates, containing top & left
  */
 ve.ce.ResizableNode.prototype.getResizableOffset = function () {
+       if (!this.enabled ) {
+               return;
+       }
        if ( !this.resizableOffset ) {
                this.resizableOffset = OO.ui.Element.static.getRelativePosition(
                        this.$resizable, 
this.resizableSurface.getSurface().$element
@@ -107,6 +114,10 @@
 
 /** */
 ve.ce.ResizableNode.prototype.setOriginalDimensions = function ( dimensions ) {
+       if (!this.enabled ) {
+               return;
+       }
+
        var scalable = this.model.getScalable();
 
        scalable.setOriginalDimensions( dimensions );
@@ -121,7 +132,12 @@
  * Hide the size label
  */
 ve.ce.ResizableNode.prototype.hideSizeLabel = function () {
+       if (!this.enabled ) {
+               return;
+       }
+
        var node = this;
+
        // Defer the removal of this class otherwise other DOM changes may cause
        // the opacity transition to not play out smoothly
        setTimeout( function () {
@@ -137,6 +153,9 @@
  * Update the contents and position of the size label
  */
 ve.ce.ResizableNode.prototype.updateSizeLabel = function () {
+       if (!this.enabled ) {
+               return;
+       }
        if ( !this.showSizeLabel && !this.canShowScaleLabel ) {
                return;
        }
@@ -187,6 +206,10 @@
  * @param {string[]} [handles] List of handles to show: 'nw', 'ne', 'sw', 
'se'. Show all if undefined.
  */
 ve.ce.ResizableNode.prototype.showHandles = function ( handles ) {
+       if (!this.enabled ) {
+               return;
+       }
+
        var i, len,
                add = [],
                remove = [],
@@ -407,6 +430,10 @@
  * @method
  */
 ve.ce.ResizableNode.prototype.setResizableHandlesSizeAndPosition = function () 
{
+       if (!this.enabled ) {
+               return;
+       }
+
        var width = this.$resizable.width(),
                height = this.$resizable.height();
 
@@ -439,6 +466,10 @@
  * @method
  */
 ve.ce.ResizableNode.prototype.setResizableHandlesPosition = function () {
+       if (!this.enabled ) {
+               return;
+       }
+
        var offset = this.getResizableOffset();
 
        this.$resizeHandles.css( {
@@ -561,7 +592,12 @@
  * @returns {Object} Attribute changes
  */
 ve.ce.ResizableNode.prototype.getAttributeChanges = function ( width, height ) 
{
+       if (!this.enabled ) {
+               return;
+       }
+
        var attrChanges = {};
+
        if ( this.model.getAttribute( 'width' ) !== width ) {
                attrChanges.width = width;
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/213812
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ff34db8178c901110fd395658000623a675e202
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: SuchetaG <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to