From 9387efc3995b0e53f42c5703e091cd68d3c42e36 Mon Sep 17 00:00:00 2001 From: Shubham Dhama Date: Tue, 19 Jun 2018 23:46:00 +0530 Subject: [PATCH] scroll_bar: Initialize scroll_bar in ui_init.js. This will help in making the order of ui modules initialization more explicit and clear. --- .eslintrc.json | 1 + static/js/scroll_bar.js | 18 ++++++++++++------ static/js/ui_init.js | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 6c422fcf29..23a0897fe4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -33,6 +33,7 @@ "popovers": false, "server_events": false, "server_events_dispatch": false, + "scroll_bar": false, "message_scroll": false, "keydown_util": false, "info_overlay": false, diff --git a/static/js/scroll_bar.js b/static/js/scroll_bar.js index 47d9d85f3a..de017b4bfb 100644 --- a/static/js/scroll_bar.js +++ b/static/js/scroll_bar.js @@ -1,7 +1,7 @@ -$(function () { - ui.set_up_scrollbar($("#stream-filters-container")); -}); +var scroll_bar = (function () { + +var exports = {}; // From https://stackoverflow.com/questions/13382516/getting-scroll-bar-width-using-javascript function getScrollbarWidth() { @@ -29,9 +29,8 @@ function getScrollbarWidth() { return widthNoScroll - widthWithScroll; } - +exports.initialize = function () { // Workaround for browsers with fixed scrollbars -$(function () { var sbWidth = getScrollbarWidth(); if (sbWidth > 0) { @@ -59,4 +58,11 @@ $(function () { ""); } -}); + ui.set_up_scrollbar($("#stream-filters-container")); +}; + +return exports; +}()); +if (typeof module !== 'undefined') { + module.exports = scroll_bar; +} diff --git a/static/js/ui_init.js b/static/js/ui_init.js index 73a5c30d02..2d377c4642 100644 --- a/static/js/ui_init.js +++ b/static/js/ui_init.js @@ -275,6 +275,7 @@ function initialize_kitchen_sink_stuff() { $(function () { // initialize other stuff + scroll_bar.initialize(); muting_ui.initialize(); message_viewport.initialize(); initialize_kitchen_sink_stuff();