From 292de4b1eda863769bf881390d3cccead3bae0c9 Mon Sep 17 00:00:00 2001 From: niteskum Date: Fri, 27 Jul 2018 19:59:25 +0530 Subject: [PATCH 1/5] Fixed ExtractToVariable Menu Close Issue due to scrolling --- .../JavaScriptRefactoring/ExtractToVariable.js | 5 +++++ src/widgets/InlineMenu.js | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js index 554041900aa..c486c701b5e 100644 --- a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js +++ b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js @@ -265,6 +265,11 @@ define(function(require, exports, module) { inlineMenu = new InlineMenu(session.editor, Strings.EXTRACTTO_VARIABLE_SELECT_EXPRESSION); inlineMenu.onHover(function (expnId) { + editor.off("scroll.inlinemenu"); + editor.on("scroll.inlinemenu", function() { + editor.off("scroll.inlinemenu"); + inlineMenu.openRemovedMenu(); + }); editor.setSelection(editor.posFromIndex(expns[expnId].start), editor.posFromIndex(expns[expnId].end)); }); diff --git a/src/widgets/InlineMenu.js b/src/widgets/InlineMenu.js index 685b4bb3d13..30b34c6a2e5 100644 --- a/src/widgets/InlineMenu.js +++ b/src/widgets/InlineMenu.js @@ -413,6 +413,19 @@ define(function (require, exports, module) { } }; + /** + * Displays the last menu which was closed due to Scrolling + */ + InlineMenu.prototype.openRemovedMenu = function () { + if (this.opened === true) { + if (this.$menu && !this.$menu.hasClass("open")) { + var menuPos = this._calcMenuLocation(); + this.$menu.addClass("open") + .css({"left": menuPos.left, "top": menuPos.top, "width": menuPos.width + "px"}); + } + } + }; + /** * Closes the menu */ From e2a4f202b36c65021d99ed2d573afcafa07856ad Mon Sep 17 00:00:00 2001 From: niteskum Date: Tue, 31 Jul 2018 15:03:27 +0530 Subject: [PATCH 2/5] Addressed Review Comments --- .../default/JavaScriptRefactoring/ExtractToVariable.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js index c486c701b5e..d1527f4a9b7 100644 --- a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js +++ b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js @@ -265,8 +265,12 @@ define(function(require, exports, module) { inlineMenu = new InlineMenu(session.editor, Strings.EXTRACTTO_VARIABLE_SELECT_EXPRESSION); inlineMenu.onHover(function (expnId) { + // Remove the scroll Handlers If already Attached. editor.off("scroll.inlinemenu"); editor.on("scroll.inlinemenu", function() { + // Remove the Handlers so that If scroll event is triggerd again by any other operation + // Menu should not be reopened. + // Menu Should be reopened only if Scroll event is triggered by onHover. editor.off("scroll.inlinemenu"); inlineMenu.openRemovedMenu(); }); From 00570211a649c0a104cadb652fe8c1cb7ef338d0 Mon Sep 17 00:00:00 2001 From: niteskum Date: Thu, 2 Aug 2018 12:42:10 +0530 Subject: [PATCH 3/5] Addessed review comments --- .../JavaScriptRefactoring/ExtractToVariable.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js index d1527f4a9b7..5b85710a4e3 100644 --- a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js +++ b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js @@ -267,13 +267,15 @@ define(function(require, exports, module) { inlineMenu.onHover(function (expnId) { // Remove the scroll Handlers If already Attached. editor.off("scroll.inlinemenu"); - editor.on("scroll.inlinemenu", function() { - // Remove the Handlers so that If scroll event is triggerd again by any other operation - // Menu should not be reopened. - // Menu Should be reopened only if Scroll event is triggered by onHover. - editor.off("scroll.inlinemenu"); - inlineMenu.openRemovedMenu(); - }); + if(!editor.isLineVisible(editor.posFromIndex(expns[expnId].end).line)) { + editor.on("scroll.inlinemenu", function() { + // Remove the Handlers so that If scroll event is triggerd again by any other operation + // Menu should not be reopened. + // Menu Should be reopened only if Scroll event is triggered by onHover. + editor.off("scroll.inlinemenu"); + inlineMenu.openRemovedMenu(); + }); + } editor.setSelection(editor.posFromIndex(expns[expnId].start), editor.posFromIndex(expns[expnId].end)); }); From 64b093a40be8d3005907c46292a45510538d6591 Mon Sep 17 00:00:00 2001 From: niteskum Date: Thu, 2 Aug 2018 15:48:14 +0530 Subject: [PATCH 4/5] Addressed Review Comments --- .../default/JavaScriptRefactoring/ExtractToVariable.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js index 5b85710a4e3..b7404f757ff 100644 --- a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js +++ b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js @@ -267,6 +267,8 @@ define(function(require, exports, module) { inlineMenu.onHover(function (expnId) { // Remove the scroll Handlers If already Attached. editor.off("scroll.inlinemenu"); + // Add a scroll handler If Selection Range is not View. + // This is Added for a Bug, where Menu used not to open for the irst Time if(!editor.isLineVisible(editor.posFromIndex(expns[expnId].end).line)) { editor.on("scroll.inlinemenu", function() { // Remove the Handlers so that If scroll event is triggerd again by any other operation From e7d03808fa6f351138e362319fc44030ee05976c Mon Sep 17 00:00:00 2001 From: niteskum Date: Thu, 2 Aug 2018 15:49:49 +0530 Subject: [PATCH 5/5] Addressed Review Comments --- .../default/JavaScriptRefactoring/ExtractToVariable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js index b7404f757ff..4c8c9db55d3 100644 --- a/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js +++ b/src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js @@ -268,7 +268,7 @@ define(function(require, exports, module) { // Remove the scroll Handlers If already Attached. editor.off("scroll.inlinemenu"); // Add a scroll handler If Selection Range is not View. - // This is Added for a Bug, where Menu used not to open for the irst Time + // This is Added for a Bug, where Menu used not to open for the first Time if(!editor.isLineVisible(editor.posFromIndex(expns[expnId].end).line)) { editor.on("scroll.inlinemenu", function() { // Remove the Handlers so that If scroll event is triggerd again by any other operation