From 6a71e0c864603a972794ffc95f987e1fd4ae56d2 Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Sat, 17 May 2014 12:03:55 -0700 Subject: [PATCH 01/10] Reveal cursor on panel show/resize --- src/view/PanelManager.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/view/PanelManager.js b/src/view/PanelManager.js index 1eb4974af35..1a888490b98 100644 --- a/src/view/PanelManager.js +++ b/src/view/PanelManager.js @@ -40,6 +40,7 @@ define(function (require, exports, module) { "use strict"; var AppInit = require("utils/AppInit"), + EditorManager = require("editor/EditorManager"), Resizer = require("utils/Resizer"); @@ -143,6 +144,26 @@ define(function (require, exports, module) { $panel.on("panelCollapsed panelExpanded panelResizeEnd", function () { updateResizeLimits(); }); + + // Scroll to show cursor above panel if necessary + $panel.on("panelExpanded panelResizeEnd", function () { + var _currentEditor = EditorManager.getCurrentFullEditor(); + + // Make sure that we're not switching files and still on an active editor + if (_currentEditor) { + // Gather info to determine whether to scroll after editor resizies + var height = _currentEditor._codeMirror.getScrollInfo().clientHeight, + textHeight = _currentEditor.getTextHeight(), + cursorTop = _currentEditor._codeMirror.cursorCoords().top, + bottom = cursorTop - $("#editor-holder").offset().top + textHeight - height; + + // Determine whether panel would block text at cursor. + // If so, scroll the editor to expose the cursor above the panel + if (bottom <= $panel.height() && bottom >= 5) { + _currentEditor._codeMirror.scrollIntoView(); + } + } + }); } From e01f1f2bc6cdd5404d3f992272282f1aabacd3f6 Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Sat, 17 May 2014 12:08:56 -0700 Subject: [PATCH 02/10] Remove resize listener from reveal --- src/view/PanelManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/PanelManager.js b/src/view/PanelManager.js index 1a888490b98..6de12f2988a 100644 --- a/src/view/PanelManager.js +++ b/src/view/PanelManager.js @@ -146,7 +146,7 @@ define(function (require, exports, module) { }); // Scroll to show cursor above panel if necessary - $panel.on("panelExpanded panelResizeEnd", function () { + $panel.on("panelExpanded", function () { var _currentEditor = EditorManager.getCurrentFullEditor(); // Make sure that we're not switching files and still on an active editor From 706165bd85c2b623dd3e68091468e8302e8d7c01 Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Tue, 3 Jun 2014 15:02:10 -0700 Subject: [PATCH 03/10] Use editorAreaResize handler instead of manipulating editor inside PanelManager --- src/editor/EditorManager.js | 38 +++++++++++++++++++++++++++---------- src/view/PanelManager.js | 20 ++----------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index b47d1b32ddc..acb7e331c19 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -478,29 +478,47 @@ define(function (require, exports, module) { * some other cases are handled by external code calling resizeEditor() (e.g. ModalBar hide/show). * * @param {number} editorAreaHt - * @param {string=} refreshFlag For internal use. Set to "force" to ensure the editor will refresh, - * "skip" to ensure the editor does not refresh, or leave undefined to let _onEditorAreaResize() - * determine whether it needs to refresh. + * @param {{refresh:string=, scrollToCursor:boolean, panelHeight:number} refreshFlag For internal use. Set + * refresh to "force" to ensure the editor will refresh, "skip" to ensure the editor does not refresh, or + * leave undefined to let _onEditorAreaResize() determine whether it needs to refresh. + * Set scrollToCursor to true and panelHeight to the height of the shown panel to reveal cursor. Use only + * on panel expansion. */ function _onEditorAreaResize(event, editorAreaHt, refreshFlag) { if (_currentEditor) { var curRoot = _currentEditor.getRootElement(), - curWidth = $(curRoot).width(); - if (!curRoot.style.height || $(curRoot).height() !== editorAreaHt) { + curWidth = $(curRoot).width(), + curHeight = $(curRoot).height(); + + if (refreshFlag.scrollToCursor && refreshFlag.panelHeight) { + // Gather info to determine whether to scroll after editor resizies + var height = _currentEditor._codeMirror.getScrollInfo().clientHeight, + textHeight = _currentEditor.getTextHeight(), + cursorTop = _currentEditor._codeMirror.cursorCoords().top, + bottom = cursorTop - $("#editor-holder").offset().top + textHeight - height; + + // Determine whether panel would block text at cursor. + // If so, scroll the editor to expose the cursor above the panel + if (bottom <= refreshFlag.panelHeight && bottom >= 5) { + _currentEditor._codeMirror.scrollIntoView(); + } + } + + if (!curRoot.style.height || curHeight !== editorAreaHt) { // Call setSize() instead of $.height() to allow CodeMirror to // check for options like line wrapping _currentEditor.setSize(null, editorAreaHt); - if (refreshFlag === undefined) { - refreshFlag = REFRESH_FORCE; + if (refreshFlag.refresh === undefined) { + refreshFlag.refresh = REFRESH_FORCE; } } else if (curWidth !== _lastEditorWidth) { - if (refreshFlag === undefined) { - refreshFlag = REFRESH_FORCE; + if (refreshFlag.refresh === undefined) { + refreshFlag.refresh = REFRESH_FORCE; } } _lastEditorWidth = curWidth; - if (refreshFlag === REFRESH_FORCE) { + if (refreshFlag.refresh === REFRESH_FORCE) { _currentEditor.refreshAll(true); } } diff --git a/src/view/PanelManager.js b/src/view/PanelManager.js index 6de12f2988a..144a73cbe89 100644 --- a/src/view/PanelManager.js +++ b/src/view/PanelManager.js @@ -40,7 +40,6 @@ define(function (require, exports, module) { "use strict"; var AppInit = require("utils/AppInit"), - EditorManager = require("editor/EditorManager"), Resizer = require("utils/Resizer"); @@ -102,7 +101,7 @@ define(function (require, exports, module) { $editorHolder.height(editorAreaHeight); // affects size of "not-editor" placeholder as well // Resize editor to fill the space - $(exports).trigger("editorAreaResize", [editorAreaHeight, refreshHint]); + $(exports).trigger("editorAreaResize", [editorAreaHeight, refreshHint || {}]); } @@ -147,22 +146,7 @@ define(function (require, exports, module) { // Scroll to show cursor above panel if necessary $panel.on("panelExpanded", function () { - var _currentEditor = EditorManager.getCurrentFullEditor(); - - // Make sure that we're not switching files and still on an active editor - if (_currentEditor) { - // Gather info to determine whether to scroll after editor resizies - var height = _currentEditor._codeMirror.getScrollInfo().clientHeight, - textHeight = _currentEditor.getTextHeight(), - cursorTop = _currentEditor._codeMirror.cursorCoords().top, - bottom = cursorTop - $("#editor-holder").offset().top + textHeight - height; - - // Determine whether panel would block text at cursor. - // If so, scroll the editor to expose the cursor above the panel - if (bottom <= $panel.height() && bottom >= 5) { - _currentEditor._codeMirror.scrollIntoView(); - } - } + triggerEditorResize({scrollToCursor: true, panelHeight: $panel.height()}); }); } From f9820e18707b3736702fe40cc1f795d64504197d Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Tue, 3 Jun 2014 15:04:14 -0700 Subject: [PATCH 04/10] Add missing curly brace in comment --- src/editor/EditorManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index acb7e331c19..b54a049d45e 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -478,7 +478,7 @@ define(function (require, exports, module) { * some other cases are handled by external code calling resizeEditor() (e.g. ModalBar hide/show). * * @param {number} editorAreaHt - * @param {{refresh:string=, scrollToCursor:boolean, panelHeight:number} refreshFlag For internal use. Set + * @param {{refresh:string=, scrollToCursor:boolean, panelHeight:number}} refreshFlag For internal use. Set * refresh to "force" to ensure the editor will refresh, "skip" to ensure the editor does not refresh, or * leave undefined to let _onEditorAreaResize() determine whether it needs to refresh. * Set scrollToCursor to true and panelHeight to the height of the shown panel to reveal cursor. Use only From 5ea8696c757a902e1a8811cad021f3a243fa9409 Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Wed, 4 Jun 2014 10:04:43 -0700 Subject: [PATCH 05/10] Fix mixed indentation --- src/editor/EditorManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index 0d89083b2b1..b12f0afda00 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -502,8 +502,8 @@ define(function (require, exports, module) { * * @param {number} editorAreaHt * @param {{refresh:string=, scrollToCursor:boolean, panelHeight:number}} refreshFlag For internal use. - * Set to "force" to ensure the editor will refresh, "skip" to ensure the editor does not refresh, or - * leave undefined to let `_onEditorAreaResize()` determine whether it needs to refresh. + * Set to "force" to ensure the editor will refresh, "skip" to ensure the editor does not refresh, or + * leave undefined to let `_onEditorAreaResize()` determine whether it needs to refresh. * Set scrollToCursor to true and panelHeight to the height of the shown panel to reveal cursor. Use only * on panel expansion. */ From e97fa94561b80532fec27a904af2179315dab70e Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Wed, 4 Jun 2014 15:17:30 -0700 Subject: [PATCH 06/10] Use pushUpCursor --- src/editor/Editor.js | 18 ++++++++++++++++++ src/editor/EditorManager.js | 19 ++++--------------- src/view/PanelManager.js | 2 +- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/editor/Editor.js b/src/editor/Editor.js index 2736197bff6..082d051b744 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -1030,6 +1030,24 @@ define(function (require, exports, module) { this.setScrollPos(null, pos); } }; + + /** + * Scrolls the editor viewport to maintain the distance between the cursor + * and the bottom of the editor. Use only for panel expansion. + */ + Editor.prototype.pushUpCursor = function () { + var $scrollerElement = $(this.getScrollerElement()), + editorHeight = $scrollerElement.height(), + statusBarHeight = $scrollerElement.outerHeight() - editorHeight, + menuBarHeight = $scrollerElement.offset().top, + bottom = window.innerHeight - menuBarHeight - statusBarHeight - editorHeight + 4; + + this.setScrollPos(null, this.getScrollPos().y + bottom); + + if (this._codeMirror.cursorCoords(null, "page").bottom < editorHeight / 2) { + this.centerOnCursor(); + } + }; /** * Given a position, returns its index within the text (assuming \n newlines) diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index b12f0afda00..91fa10e4968 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -504,8 +504,7 @@ define(function (require, exports, module) { * @param {{refresh:string=, scrollToCursor:boolean, panelHeight:number}} refreshFlag For internal use. * Set to "force" to ensure the editor will refresh, "skip" to ensure the editor does not refresh, or * leave undefined to let `_onEditorAreaResize()` determine whether it needs to refresh. - * Set scrollToCursor to true and panelHeight to the height of the shown panel to reveal cursor. Use only - * on panel expansion. + * Set scrollToCursor to true to reveal cursor. Use only on panel expansion. */ function _onEditorAreaResize(event, editorAreaHt, refreshFlag) { if (_currentEditor) { @@ -513,18 +512,8 @@ define(function (require, exports, module) { curWidth = $(curRoot).width(), curHeight = $(curRoot).height(); - if (refreshFlag.scrollToCursor && refreshFlag.panelHeight) { - // Gather info to determine whether to scroll after editor resizies - var height = _currentEditor._codeMirror.getScrollInfo().clientHeight, - textHeight = _currentEditor.getTextHeight(), - cursorTop = _currentEditor._codeMirror.cursorCoords().top, - bottom = cursorTop - $("#editor-holder").offset().top + textHeight - height; - - // Determine whether panel would block text at cursor. - // If so, scroll the editor to expose the cursor above the panel - if (bottom <= refreshFlag.panelHeight && bottom >= 5) { - _currentEditor._codeMirror.scrollIntoView(); - } + if (refreshFlag.scrollToCursor) { + _currentEditor.pushUpCursor(); } if (!curRoot.style.height || curHeight !== editorAreaHt) { @@ -565,7 +554,7 @@ define(function (require, exports, module) { // from an older version. editor.setSelection(viewState.selection.start, viewState.selection.end); } - if (viewState.selections) { + if (viewState.selections) {s editor.setSelections(viewState.selections); } if (viewState.scrollPos) { diff --git a/src/view/PanelManager.js b/src/view/PanelManager.js index f80a7223435..2c52f1e76b7 100644 --- a/src/view/PanelManager.js +++ b/src/view/PanelManager.js @@ -155,7 +155,7 @@ define(function (require, exports, module) { // Scroll to show cursor above panel if necessary $panel.on("panelExpanded", function () { - triggerEditorResize({scrollToCursor: true, panelHeight: $panel.height()}); + triggerEditorResize({scrollToCursor: true}); }); } From a76d013b6b01f4e757a9f941a4a8053ff2836725 Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Thu, 5 Jun 2014 14:15:07 -0700 Subject: [PATCH 07/10] Fix trailing 's' --- src/editor/EditorManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index 91fa10e4968..e334e6fbb4f 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -554,7 +554,7 @@ define(function (require, exports, module) { // from an older version. editor.setSelection(viewState.selection.start, viewState.selection.end); } - if (viewState.selections) {s + if (viewState.selections) { editor.setSelections(viewState.selections); } if (viewState.scrollPos) { From 98b5691c76640f890bf1c1a4c9ff1135e455cc27 Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Thu, 5 Jun 2014 15:36:09 -0700 Subject: [PATCH 08/10] Determine visibility of cursor & calculate scroll target --- src/editor/Editor.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/editor/Editor.js b/src/editor/Editor.js index 082d051b744..2199a3cde5d 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -1040,12 +1040,17 @@ define(function (require, exports, module) { editorHeight = $scrollerElement.height(), statusBarHeight = $scrollerElement.outerHeight() - editorHeight, menuBarHeight = $scrollerElement.offset().top, - bottom = window.innerHeight - menuBarHeight - statusBarHeight - editorHeight + 4; + bottom = window.innerHeight - menuBarHeight - statusBarHeight - editorHeight + 4, + cursorPosition = this._codeMirror.cursorCoords(null, "page").bottom; - this.setScrollPos(null, this.getScrollPos().y + bottom); - - if (this._codeMirror.cursorCoords(null, "page").bottom < editorHeight / 2) { - this.centerOnCursor(); + if (cursorPosition > $scrollerElement.outerHeight() + 4) { + var target = this.getScrollPos().y; + if (cursorPosition - bottom < editorHeight / 2) { + target += cursorPosition - editorHeight / 2; + } else { + target += bottom; + } + this.setScrollPos(null, target); } }; From 9da42e7e97567dd21f000527b99387f9dd4982e1 Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Mon, 9 Jun 2014 09:42:51 -0700 Subject: [PATCH 09/10] Address minor issues and improvments --- src/editor/Editor.js | 10 ++++++---- src/editor/EditorManager.js | 4 ++-- src/view/PanelManager.js | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/editor/Editor.js b/src/editor/Editor.js index 2199a3cde5d..50ebe948e85 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -1032,15 +1032,17 @@ define(function (require, exports, module) { }; /** - * Scrolls the editor viewport to maintain the distance between the cursor - * and the bottom of the editor. Use only for panel expansion. + * Determines if the cursor is currently visible and if not, and if not + * scrolls the editor view port maintaining the distance between the cursor + * and the bottom, to a maximum where the cursor is centered vertically + * within the editor. */ Editor.prototype.pushUpCursor = function () { var $scrollerElement = $(this.getScrollerElement()), editorHeight = $scrollerElement.height(), - statusBarHeight = $scrollerElement.outerHeight() - editorHeight, + statusBarHeight = $("#status-bar").outerHeight(), menuBarHeight = $scrollerElement.offset().top, - bottom = window.innerHeight - menuBarHeight - statusBarHeight - editorHeight + 4, + bottom = window.innerHeight - menuBarHeight - statusBarHeight - editorHeight, cursorPosition = this._codeMirror.cursorCoords(null, "page").bottom; if (cursorPosition > $scrollerElement.outerHeight() + 4) { diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index e334e6fbb4f..d424962fe72 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -501,10 +501,10 @@ define(function (require, exports, module) { * some other cases are handled by external code calling `resizeEditor()` (e.g. ModalBar hide/show). * * @param {number} editorAreaHt - * @param {{refresh:string=, scrollToCursor:boolean, panelHeight:number}} refreshFlag For internal use. + * @param {{refresh:string=, revealCursor:boolean=}} refreshFlag For internal use. * Set to "force" to ensure the editor will refresh, "skip" to ensure the editor does not refresh, or * leave undefined to let `_onEditorAreaResize()` determine whether it needs to refresh. - * Set scrollToCursor to true to reveal cursor. Use only on panel expansion. + * Set revealCursor to true to reveal cursor. */ function _onEditorAreaResize(event, editorAreaHt, refreshFlag) { if (_currentEditor) { diff --git a/src/view/PanelManager.js b/src/view/PanelManager.js index 2c52f1e76b7..d3e4cd7fb8d 100644 --- a/src/view/PanelManager.js +++ b/src/view/PanelManager.js @@ -155,7 +155,7 @@ define(function (require, exports, module) { // Scroll to show cursor above panel if necessary $panel.on("panelExpanded", function () { - triggerEditorResize({scrollToCursor: true}); + triggerEditorResize({revealCursor: true}); }); } From a45dbd67564359eca496958d78bcdc23f81a1aec Mon Sep 17 00:00:00 2001 From: Albert Xing Date: Mon, 9 Jun 2014 15:37:19 -0700 Subject: [PATCH 10/10] Switch to delta call from setSize, fix & improve misc. --- src/editor/Editor.js | 38 ++++++++++++++++++------------------- src/editor/EditorManager.js | 20 ++++++++----------- src/view/PanelManager.js | 13 ++++++------- 3 files changed, 33 insertions(+), 38 deletions(-) diff --git a/src/editor/Editor.js b/src/editor/Editor.js index 50ebe948e85..a47ab23da6b 100644 --- a/src/editor/Editor.js +++ b/src/editor/Editor.js @@ -986,8 +986,13 @@ define(function (require, exports, module) { * Set the editor size in pixels or percentage * @param {(number|string)} width * @param {(number|string)} height + * @param {boolean=} revealCursor whether or not to reveal the cursor after resize */ - Editor.prototype.setSize = function (width, height) { + Editor.prototype.setSize = function (width, height, revealCursor) { + if (revealCursor) { + var delta = height - $(this.getScrollerElement()).height(); + this.showCursorAfterResize(delta); + } this._codeMirror.setSize(width, height); }; @@ -1032,27 +1037,22 @@ define(function (require, exports, module) { }; /** - * Determines if the cursor is currently visible and if not, and if not - * scrolls the editor view port maintaining the distance between the cursor - * and the bottom, to a maximum where the cursor is centered vertically - * within the editor. + * Determines if the cursor will be hidden, and if it will scrolls the + * editor viewport restoring the distance between the cursor and the bottom + * of the editor prior to editor resize, or centering the cursor vertically + * in the editor if that requires less scrolling. + * + * @param {number} delta The change in editor height */ - Editor.prototype.pushUpCursor = function () { + Editor.prototype.showCursorAfterResize = function (delta) { var $scrollerElement = $(this.getScrollerElement()), editorHeight = $scrollerElement.height(), - statusBarHeight = $("#status-bar").outerHeight(), - menuBarHeight = $scrollerElement.offset().top, - bottom = window.innerHeight - menuBarHeight - statusBarHeight - editorHeight, - cursorPosition = this._codeMirror.cursorCoords(null, "page").bottom; - - if (cursorPosition > $scrollerElement.outerHeight() + 4) { - var target = this.getScrollPos().y; - if (cursorPosition - bottom < editorHeight / 2) { - target += cursorPosition - editorHeight / 2; - } else { - target += bottom; - } - this.setScrollPos(null, target); + cursorToTop = this._codeMirror.cursorCoords(null, "page").bottom - $scrollerElement.offset().top, + cursorToBottom = editorHeight - cursorToTop; + + if (delta < 0 && -delta > cursorToBottom) { + var scrollTarget = this.getScrollPos().y + Math.min(cursorToTop - (editorHeight + delta) / 2, -delta); + this.setScrollPos(null, scrollTarget); } }; diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index d424962fe72..d090475987a 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -501,36 +501,32 @@ define(function (require, exports, module) { * some other cases are handled by external code calling `resizeEditor()` (e.g. ModalBar hide/show). * * @param {number} editorAreaHt - * @param {{refresh:string=, revealCursor:boolean=}} refreshFlag For internal use. + * @param {{refresh:string=, revealCursor:boolean=}} options For internal use. * Set to "force" to ensure the editor will refresh, "skip" to ensure the editor does not refresh, or * leave undefined to let `_onEditorAreaResize()` determine whether it needs to refresh. * Set revealCursor to true to reveal cursor. */ - function _onEditorAreaResize(event, editorAreaHt, refreshFlag) { + function _onEditorAreaResize(event, editorAreaHt, options) { if (_currentEditor) { var curRoot = _currentEditor.getRootElement(), curWidth = $(curRoot).width(), curHeight = $(curRoot).height(); - if (refreshFlag.scrollToCursor) { - _currentEditor.pushUpCursor(); - } - if (!curRoot.style.height || curHeight !== editorAreaHt) { // Call setSize() instead of $.height() to allow CodeMirror to // check for options like line wrapping - _currentEditor.setSize(null, editorAreaHt); - if (refreshFlag.refresh === undefined) { - refreshFlag.refresh = REFRESH_FORCE; + _currentEditor.setSize(null, editorAreaHt, options.revealCursor); + if (options.refresh === undefined) { + options.refresh = REFRESH_FORCE; } } else if (curWidth !== _lastEditorWidth) { - if (refreshFlag.refresh === undefined) { - refreshFlag.refresh = REFRESH_FORCE; + if (options.refresh === undefined) { + options.refresh = REFRESH_FORCE; } } _lastEditorWidth = curWidth; - if (refreshFlag.refresh === REFRESH_FORCE) { + if (options.refresh === REFRESH_FORCE) { _currentEditor.refreshAll(true); } } diff --git a/src/view/PanelManager.js b/src/view/PanelManager.js index d3e4cd7fb8d..40111c285fd 100644 --- a/src/view/PanelManager.js +++ b/src/view/PanelManager.js @@ -101,16 +101,16 @@ define(function (require, exports, module) { * Calculates a new size for editor-holder and resizes it accordingly, then and dispatches the "editorAreaResize" * event. (The editors within are resized by EditorManager, in response to that event). * - * @param {string=} refreshHint One of "skip", "force", or undefined. See EditorManager docs. + * @param {{refresh:string=, revealCursor:boolean=}} options See EditorManager._onEditorAreaResize docs. */ - function triggerEditorResize(refreshHint) { + function triggerEditorResize(options) { // Find how much space is left for the editor var editorAreaHeight = calcEditorHeight(); $editorHolder.height(editorAreaHeight); // affects size of "not-editor" placeholder as well // Resize editor to fill the space - $(exports).trigger("editorAreaResize", [editorAreaHeight, refreshHint || {}]); + $(exports).trigger("editorAreaResize", [editorAreaHeight, options || {}]); } @@ -144,16 +144,15 @@ define(function (require, exports, module) { /** Trigger editor area resize whenever the given panel is shown/hidden/resized */ function listenToResize($panel) { - // Update editor height when shown/hidden, & continuously as panel is resized - $panel.on("panelCollapsed panelExpanded panelResizeUpdate", function () { + // Update editor height when hidden, & continuously as panel is resized + $panel.on("panelCollapsed panelResizeUpdate", function () { triggerEditorResize(); }); // Update max size of sibling panels when shown/hidden, & at *end* of resize gesture $panel.on("panelCollapsed panelExpanded panelResizeEnd", function () { updateResizeLimits(); }); - - // Scroll to show cursor above panel if necessary + // Update editor height when shown, & scroll to show cursor above panel if necessary $panel.on("panelExpanded", function () { triggerEditorResize({revealCursor: true}); });