jenkins-bot has submitted this change and it was merged.

Change subject: Deprecate 'live' event in favor of 'setup' and 'teardown'
......................................................................


Deprecate 'live' event in favor of 'setup' and 'teardown'

Mostly relevant to ve.ce.View and related mixins, this is a
cleanup for live events. Now while ve.ce.View still has the
internal this.live property, the events emitted are either
'setup' or 'teardown' and the code responds to each accordingly.

Bug: 55505
Change-Id: Ieddbf5c684eb0edc3130034de64eb284aeaebbda
---
M modules/ve/ce/ve.ce.BranchNode.js
M modules/ve/ce/ve.ce.FocusableNode.js
M modules/ve/ce/ve.ce.ResizableNode.js
M modules/ve/ce/ve.ce.View.js
4 files changed, 44 insertions(+), 52 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve/ce/ve.ce.BranchNode.js 
b/modules/ve/ce/ve.ce.BranchNode.js
index 974bfe2..7005fe6 100644
--- a/modules/ve/ce/ve.ce.BranchNode.js
+++ b/modules/ve/ce/ve.ce.BranchNode.js
@@ -303,7 +303,6 @@
  *
  * @method
  * @param {boolean} live New live state
- * @fires live
  */
 ve.ce.BranchNode.prototype.setLive = function ( live ) {
        ve.ce.Node.prototype.setLive.call( this, live );
diff --git a/modules/ve/ce/ve.ce.FocusableNode.js 
b/modules/ve/ce/ve.ce.FocusableNode.js
index 9e9eaf5..776d1e7 100644
--- a/modules/ve/ce/ve.ce.FocusableNode.js
+++ b/modules/ve/ce/ve.ce.FocusableNode.js
@@ -40,8 +40,7 @@
                'teardown': 'onFocusableTeardown',
                'resizeStart': 'onFocusableResizeStart',
                'resizeEnd': 'onFocusableResizeEnd',
-               'rerender': 'onFocusableRerender',
-               'live': 'onFocusableLive'
+               'rerender': 'onFocusableRerender'
        } );
 };
 
@@ -83,11 +82,16 @@
 };
 
 /**
- * Handle setup event.
+ * Handle node setup.
  *
  * @method
  */
 ve.ce.FocusableNode.prototype.onFocusableSetup = function () {
+       var surface = this.getRoot().getSurface(),
+               surfaceModel = surface.getModel();
+
+       surfaceModel.connect( this, { 'history': 'onFocusableHistory' } );
+
        // Exit if already setup or not attached
        if ( this.isSetup || !this.root ) {
                return;
@@ -110,40 +114,16 @@
 };
 
 /**
- * Handle node live.
- *
- * @method
- */
-ve.ce.FocusableNode.prototype.onFocusableLive = function () {
-       // We don't set this.surface here because there are cases where 
teardown+setup are emitted
-       // but live isn't :(
-       var surface = this.getRoot().getSurface(),
-               surfaceModel = surface.getModel();
-
-       if ( this.live ) {
-               surfaceModel.connect( this, { 'history': 'onFocusableHistory' } 
);
-       } else {
-               surfaceModel.disconnect( this, { 'history': 
'onFocusableHistory' } );
-       }
-};
-
-/**
- * Handle history event.
- *
- * @method
- */
-ve.ce.FocusableNode.prototype.onFocusableHistory = function () {
-       if ( this.focused ) {
-               this.redrawHighlights();
-       }
-};
-
-/**
- * Handle teardown events.
+ * Handle node teardown.
  *
  * @method
  */
 ve.ce.FocusableNode.prototype.onFocusableTeardown = function () {
+       var surface = this.getRoot().getSurface(),
+               surfaceModel = surface.getModel();
+
+       surfaceModel.disconnect( this, { 'history': 'onFocusableHistory' } );
+
        // Exit if not setup or not attached
        if ( !this.isSetup || !this.root ) {
                return;
@@ -165,6 +145,17 @@
 };
 
 /**
+ * Handle history event.
+ *
+ * @method
+ */
+ve.ce.FocusableNode.prototype.onFocusableHistory = function () {
+       if ( this.focused ) {
+               this.redrawHighlights();
+       }
+};
+
+/**
  * Handle highlight mouse down events.
  *
  * @method
diff --git a/modules/ve/ce/ve.ce.ResizableNode.js 
b/modules/ve/ce/ve.ce.ResizableNode.js
index 8e1a735..4d55d83 100644
--- a/modules/ve/ce/ve.ce.ResizableNode.js
+++ b/modules/ve/ce/ve.ce.ResizableNode.js
@@ -42,7 +42,8 @@
        this.connect( this, {
                'focus': 'onResizableFocus',
                'blur': 'onResizableBlur',
-               'live': 'onResizableLive',
+               'setup': 'onResizableSetup',
+               'teardown': 'onResizableTeardown',
                'resizing': 'onResizableResizing',
                'resizeEnd': 'onResizableFocus',
                'rerender': 'onResizableFocus'
@@ -247,22 +248,30 @@
 };
 
 /**
- * Handle live event.
+ * Handle setup event.
  *
  * @method
  */
-ve.ce.ResizableNode.prototype.onResizableLive = function () {
+ve.ce.ResizableNode.prototype.onResizableSetup = function () {
        var surface = this.getRoot().getSurface(),
                documentModel = surface.getModel().getDocument();
 
-       if ( this.live ) {
-               documentModel.connect( this, { 'transact': 
'setResizableHandlesSizeAndPosition' } );
-               surface.connect( this, { 'position': 
'setResizableHandlesSizeAndPosition' } );
-       } else {
-               documentModel.disconnect( this, { 'transact': 
'setResizableHandlesSizeAndPosition' } );
-               surface.disconnect( this, { 'position': 
'setResizableHandlesSizeAndPosition' } );
-               this.onResizableBlur();
-       }
+       documentModel.connect( this, { 'transact': 
'setResizableHandlesSizeAndPosition' } );
+       surface.connect( this, { 'position': 
'setResizableHandlesSizeAndPosition' } );
+};
+
+/**
+ * Handle setup event.
+ *
+ * @method
+ */
+ve.ce.ResizableNode.prototype.onResizableTeardown = function () {
+       var surface = this.getRoot().getSurface(),
+               documentModel = surface.getModel().getDocument();
+
+       documentModel.disconnect( this, { 'transact': 
'setResizableHandlesSizeAndPosition' } );
+       surface.disconnect( this, { 'position': 
'setResizableHandlesSizeAndPosition' } );
+       this.onResizableBlur();
 };
 
 /**
diff --git a/modules/ve/ce/ve.ce.View.js b/modules/ve/ce/ve.ce.View.js
index 5529589..b9cface 100644
--- a/modules/ve/ce/ve.ce.View.js
+++ b/modules/ve/ce/ve.ce.View.js
@@ -50,11 +50,6 @@
 /* Events */
 
 /**
- * @event live
- * @param {boolean} live The view is being set live
- */
-
-/**
  * @event setup
  */
 
@@ -146,13 +141,11 @@
  *
  * @method
  * @param {boolean} live The view has been attached to the live DOM (use false 
on detach)
- * @fires live
  * @fires setup
  * @fires teardown
  */
 ve.ce.View.prototype.setLive = function ( live ) {
        this.live = live;
-       this.emit( 'live', this.live );
        if ( this.live ) {
                this.emit( 'setup' );
        } else {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ieddbf5c684eb0edc3130034de64eb284aeaebbda
Gerrit-PatchSet: 3
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to