Mooeypoo has uploaded a new change for review.

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

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 mixin notes, this is a
cleanup for live events. Now while the status of 'live' remains
internally in the ve.ce.View, 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, 41 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/86/144586/1

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..2c2e13b 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,18 @@
 };
 
 /**
- * Handle node live.
+ * Handle node teardown.
  *
  * @method
  */
-ve.ce.FocusableNode.prototype.onFocusableLive = function () {
+ve.ce.FocusableNode.prototype.onFocusableTeardown = 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' } );
-       }
-};
+       surfaceModel.disconnect( this, { 'history': 'onFocusableHistory' } );
 
-/**
- * Handle history event.
- *
- * @method
- */
-ve.ce.FocusableNode.prototype.onFocusableHistory = function () {
-       if ( this.focused ) {
-               this.redrawHighlights();
-       }
-};
-
-/**
- * Handle teardown events.
- *
- * @method
- */
-ve.ce.FocusableNode.prototype.onFocusableTeardown = function () {
        // Exit if not setup or not attached
        if ( !this.isSetup || !this.root ) {
                return;
@@ -165,6 +147,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: newchange
Gerrit-Change-Id: Ieddbf5c684eb0edc3130034de64eb284aeaebbda
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>

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

Reply via email to