summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorAnnabel Dunstone Gray <annabel.dunstone@gmail.com>2017-02-16 13:17:27 -0600
committerAnnabel Dunstone Gray <annabel.dunstone@gmail.com>2017-02-16 13:19:01 -0600
commit7203826b54bb3944736057436fe8a13011801ecf (patch)
tree70b8845ed0c07303fa406001e6f92cc170b92bc0 /app/assets/javascripts
parent7308e2b961c2891f2ef9bbdf59f80021ebf58bd5 (diff)
downloadgitlab-ce-7203826b54bb3944736057436fe8a13011801ecf.tar.gz
Cache js selectors; fix css26200-convert-sidebar-to-dropdown
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/right_sidebar.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/assets/javascripts/right_sidebar.js b/app/assets/javascripts/right_sidebar.js
index 82c17956f06..f8e42e7a350 100644
--- a/app/assets/javascripts/right_sidebar.js
+++ b/app/assets/javascripts/right_sidebar.js
@@ -21,13 +21,16 @@
};
Sidebar.prototype.addEventListeners = function() {
+ const $document = $(document);
+ const throttledSetSidebarHeight = _.throttle(this.setSidebarHeight, 10);
+
this.sidebar.on('click', '.sidebar-collapsed-icon', this, this.sidebarCollapseClicked);
$('.dropdown').on('hidden.gl.dropdown', this, this.onSidebarDropdownHidden);
$('.dropdown').on('loading.gl.dropdown', this.sidebarDropdownLoading);
$('.dropdown').on('loaded.gl.dropdown', this.sidebarDropdownLoaded);
- $(window).on('resize', () => this.setSidebarHeight());
- $(document).on('scroll', () => this.setSidebarHeight());
- $(document).on('click', '.js-sidebar-toggle', function(e, triggered) {
+ $(window).on('resize', () => throttledSetSidebarHeight());
+ $document.on('scroll', () => throttledSetSidebarHeight());
+ $document.on('click', '.js-sidebar-toggle', function(e, triggered) {
var $allGutterToggleIcons, $this, $thisIcon;
e.preventDefault();
$this = $(this);
@@ -195,11 +198,12 @@
Sidebar.prototype.setSidebarHeight = function() {
const $navHeight = $('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight();
+ const $rightSidebar = $('.js-right-sidebar');
const diff = $navHeight - $('body').scrollTop();
if (diff > 0) {
- $('.js-right-sidebar').outerHeight($(window).height() - diff);
+ $rightSidebar.outerHeight($(window).height() - diff);
} else {
- $('.js-right-sidebar').outerHeight('100%');
+ $rightSidebar.outerHeight('100%');
}
};