From 9545ba107aed1d7ecb0e95381bb67d206edb249c Mon Sep 17 00:00:00 2001 From: Josh Hatwich Date: Thu, 7 Jun 2012 04:29:09 -0700 Subject: [PATCH 1/2] Add class 'vertical-scroll' to the working set when the scrollbar is present Provides a hook to adjust the layout of a working set item when teh scroll bar pops in which is useful if you are laying something out to the right edge of that view. --- src/project/WorkingSetView.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index b10ddc9cf37..06fa46deab1 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -61,6 +61,21 @@ define(function (require, exports, module) { $openFilesContainer.triggerHandler("contentChanged"); } + /** + * @private + * adds the style 'vertical-scroll' if a vertical scroll bar is present + */ + function _adjustForScrollbars() { + var $container = $("#open-files-container"); + if ($container[0].scrollHeight > $container[0].clientHeight) { + if (!$container.hasClass("vertical-scroll")) { + $container.addClass("vertical-scroll"); + } + } else { + $container.removeClass("vertical-scroll"); + } + } + /** * @private * Shows/Hides open files list based on working set content. @@ -71,7 +86,7 @@ define(function (require, exports, module) { } else { $openFilesContainer.show(); } - + _adjustForScrollbars(); _fireSelectionChanged(); } From 9ce0b3d22e6aa28e1b1fdf8cf96d868583df04de Mon Sep 17 00:00:00 2001 From: Josh Hatwich Date: Fri, 8 Jun 2012 16:07:47 -0700 Subject: [PATCH 2/2] Save a DOM lookup by using an existing variable --- src/project/WorkingSetView.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 06fa46deab1..67ad7d99a81 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -66,13 +66,12 @@ define(function (require, exports, module) { * adds the style 'vertical-scroll' if a vertical scroll bar is present */ function _adjustForScrollbars() { - var $container = $("#open-files-container"); - if ($container[0].scrollHeight > $container[0].clientHeight) { - if (!$container.hasClass("vertical-scroll")) { - $container.addClass("vertical-scroll"); + if ($openFilesContainer[0].scrollHeight > $openFilesContainer[0].clientHeight) { + if (!$openFilesContainer.hasClass("vertical-scroll")) { + $openFilesContainer.addClass("vertical-scroll"); } } else { - $container.removeClass("vertical-scroll"); + $openFilesContainer.removeClass("vertical-scroll"); } }