Esanders has uploaded a new change for review.

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

Change subject: ResizableNode: Factor out getCurrentDimensions
......................................................................

ResizableNode: Factor out getCurrentDimensions

Allows subclasses to override where the width & height
attributes are stored.

Change-Id: I5560a58e7ef28642ccc632f2a874ea6f4db94d18
---
M src/ce/ve.ce.ResizableNode.js
M src/dm/ve.dm.ResizableNode.js
2 files changed, 17 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/49/262449/1

diff --git a/src/ce/ve.ce.ResizableNode.js b/src/ce/ve.ce.ResizableNode.js
index 666d759..7ea7446 100644
--- a/src/ce/ve.ce.ResizableNode.js
+++ b/src/ce/ve.ce.ResizableNode.js
@@ -592,12 +592,13 @@
  * @return {Object} Attribute changes
  */
 ve.ce.ResizableNode.prototype.getAttributeChanges = function ( width, height ) 
{
-       var attrChanges = {};
+       var attrChanges = {},
+               currentDimensions = this.model.getCurrentDimensions();
 
-       if ( this.model.getAttribute( 'width' ) !== width ) {
+       if ( currentDimensions.width !== width ) {
                attrChanges.width = width;
        }
-       if ( this.model.getAttribute( 'height' ) !== height ) {
+       if ( currentDimensions.height !== height ) {
                attrChanges.height = height;
        }
        return attrChanges;
diff --git a/src/dm/ve.dm.ResizableNode.js b/src/dm/ve.dm.ResizableNode.js
index 0fdfae0..97ceb23 100644
--- a/src/dm/ve.dm.ResizableNode.js
+++ b/src/dm/ve.dm.ResizableNode.js
@@ -56,9 +56,18 @@
  */
 ve.dm.ResizableNode.prototype.onResizableAttributeChange = function ( key ) {
        if ( key === 'width' || key === 'height' ) {
-               this.getScalable().setCurrentDimensions( {
-                       width: this.getAttribute( 'width' ),
-                       height: this.getAttribute( 'height' )
-               } );
+               this.getScalable().setCurrentDimensions( 
this.getCurrentDimensions() );
        }
 };
+
+/**
+ * Get the current dimensions from the model
+ *
+ * @return {Object} Current dimensions
+ */
+ve.dm.ResizableNode.prototype.getCurrentDimensions = function () {
+       return {
+               width: this.getAttribute( 'width' ),
+               height: this.getAttribute( 'height' )
+       };
+};

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

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

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

Reply via email to