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

Change subject: Listen to keypress in ve.ce.surface.$ rather than window
......................................................................


Listen to keypress in ve.ce.surface.$ rather than window

Bug: 50538
Change-Id: Ifddf1bae1ee799ec3467a81c597702fc3f8be089
---
M modules/ve/ui/ve.ui.Toolbar.js
1 file changed, 12 insertions(+), 3 deletions(-)

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



diff --git a/modules/ve/ui/ve.ui.Toolbar.js b/modules/ve/ui/ve.ui.Toolbar.js
index 52042ac..194a59c 100644
--- a/modules/ve/ui/ve.ui.Toolbar.js
+++ b/modules/ve/ui/ve.ui.Toolbar.js
@@ -37,8 +37,10 @@
        this.$window = null;
        this.windowEvents = {
                'resize': ve.bind( this.onWindowResize, this ),
-               'scroll': ve.bind( this.onWindowScroll, this ),
-               'keypress': ve.bind( this.onWindowKeypress, this )
+               'scroll': ve.bind( this.onWindowScroll, this )
+       };
+       this.surfaceViewEvents = {
+               'keypress': ve.bind( this.onSurfaceViewKeyPress, this )
        };
 
        // Events
@@ -127,7 +129,7 @@
  * the cursor is obscured by the toolbar.
  *
  */
-ve.ui.Toolbar.prototype.onWindowKeypress = function () {
+ve.ui.Toolbar.prototype.onSurfaceViewKeyPress = function () {
        var cursorPos = this.surface.view.getSelectionRect(),
                scrollTo = cursorPos.end.y - this.surface.view.$.offset().top,
                obscured = cursorPos.end.y - this.$window.scrollTop() < 
this.$.height() + this.$.offset().top;
@@ -262,6 +264,8 @@
  */
 ve.ui.Toolbar.prototype.enableFloating = function () {
        this.$window = $( this.getElementWindow() ).on( this.windowEvents );
+       this.$surfaceView = this.surface.getView().$.on( this.surfaceViewEvents 
);
+
        // TODO: Place this is a DOM attach event for this.$
        setTimeout( ve.bind( function () {
                // The page may load with a non-zero scroll without trigger the 
scroll event
@@ -279,6 +283,11 @@
                this.$window.off( this.windowEvents );
                this.$window = null;
        }
+       if ( this.$surfaceView ) {
+               this.$surfaceView.off( this.surfaceViewEvents );
+               this.$surfaceView = null;
+       }
+
        if ( this.floating ) {
                this.resetPosition();
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifddf1bae1ee799ec3467a81c597702fc3f8be089
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Robmoen <[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