Esanders has uploaded a new change for review.

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

Change subject: Update scalable and view on direct attribute change
......................................................................

Update scalable and view on direct attribute change

Change-Id: I21f20227c3fee58b116ab9e81eacbe5411d8dc08
---
M src/ce/ve.ce.ResizableNode.js
M src/dm/nodes/ve.dm.ImageNode.js
M src/dm/ve.dm.ResizableNode.js
3 files changed, 37 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/45/186645/1

diff --git a/src/ce/ve.ce.ResizableNode.js b/src/ce/ve.ce.ResizableNode.js
index 069da74..62296aa 100644
--- a/src/ce/ve.ce.ResizableNode.js
+++ b/src/ce/ve.ce.ResizableNode.js
@@ -46,6 +46,9 @@
                resizeEnd: 'onResizableFocus',
                rerender: 'onResizableFocus'
        } );
+       this.model.connect( this, {
+               attributeChange: 'onResizableAttributeChange'
+       } );
 
        // Initialization
        this.$resizeHandles
@@ -293,6 +296,20 @@
 };
 
 /**
+ * Handle attribute change events from the model.
+ *
+ * @method
+ * @param {string} key Attribute key
+ * @param {string} from Old value
+ * @param {string} to New value
+ */
+ve.ce.ResizableNode.prototype.onResizableAttributeChange = function ( key, 
from, to ) {
+       if ( key === 'width' || key === 'height' ) {
+               this.$resizable.css( key, to );
+       }
+};
+
+/**
  * Handle bounding box handle mousedown.
  *
  * @method
diff --git a/src/dm/nodes/ve.dm.ImageNode.js b/src/dm/nodes/ve.dm.ImageNode.js
index 8c494f7..59330fa 100644
--- a/src/dm/nodes/ve.dm.ImageNode.js
+++ b/src/dm/nodes/ve.dm.ImageNode.js
@@ -15,11 +15,9 @@
  * @constructor
  */
 ve.dm.ImageNode = function VeDmImageNode() {
-       // Mixin constructor
-       ve.dm.ResizableNode.call( this );
-
        // Mixin constructors
        ve.dm.FocusableNode.call( this );
+       ve.dm.ResizableNode.call( this );
 };
 
 /* Inheritance */
diff --git a/src/dm/ve.dm.ResizableNode.js b/src/dm/ve.dm.ResizableNode.js
index e2092c5..9f5e09b 100644
--- a/src/dm/ve.dm.ResizableNode.js
+++ b/src/dm/ve.dm.ResizableNode.js
@@ -15,6 +15,8 @@
  */
 ve.dm.ResizableNode = function VeDmResizableNode() {
        this.scalable = null;
+
+       this.connect( this, { attributeChange: 'onResizableAttributeChange' } );
 };
 
 /* Inheritance */
@@ -44,3 +46,20 @@
 ve.dm.ResizableNode.prototype.createScalable = function () {
        throw new Error( 've.dm.ResizableNode subclass must implement 
createScalable' );
 };
+
+/**
+ * Handle attribute change events from the model.
+ *
+ * @method
+ * @param {string} key Attribute key
+ * @param {string} from Old value
+ * @param {string} to New value
+ */
+ve.dm.ResizableNode.prototype.onResizableAttributeChange = function ( key ) {
+       if ( key === 'width' || key === 'height' ) {
+               this.getScalable().setCurrentDimensions( {
+                       width: this.getAttribute( 'width' ),
+                       height: this.getAttribute( 'height' )
+               } );
+       }
+};

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21f20227c3fee58b116ab9e81eacbe5411d8dc08
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