diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-07-19 19:46:34 +0100 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-07-19 19:46:34 +0100 |
commit | 99193d824f43f23e76b325ad38229a8735fd2344 (patch) | |
tree | ca3120d02d6bcadfd561e0948d08be9777847b6c /app/assets | |
parent | 929c66d6207d19c39d99f09cda79de7f16e8aaae (diff) | |
download | gitlab-ce-99193d824f43f23e76b325ad38229a8735fd2344.tar.gz |
Added scroll_helper tests
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/dispatcher.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/helpers/scroll_helper.js | 43 |
2 files changed, 24 insertions, 23 deletions
diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 6ec5c5959f2..f3a8e435016 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -54,7 +54,7 @@ import RefSelectDropdown from './ref_select_dropdown'; import GfmAutoComplete from './gfm_auto_complete'; import ShortcutsBlob from './shortcuts_blob'; import initSettingsPanels from './settings_panels'; -import { setScrollWidth } from './helpers/scroll_helper'; +import ScrollHelper from './helpers/scroll_helper'; (function() { var Dispatcher; @@ -77,7 +77,7 @@ import { setScrollWidth } from './helpers/scroll_helper'; return false; } - setScrollWidth(); + ScrollHelper.setScrollWidth(); path = page.split(':'); shortcut_handler = null; diff --git a/app/assets/javascripts/helpers/scroll_helper.js b/app/assets/javascripts/helpers/scroll_helper.js index 4a3a9e161a8..4f1fd074daf 100644 --- a/app/assets/javascripts/helpers/scroll_helper.js +++ b/app/assets/javascripts/helpers/scroll_helper.js @@ -1,29 +1,30 @@ -function getScrollWidth() { - const $rulerContainer = $('<div>').css({ - visibility: 'hidden', - width: 100, - overflow: 'scroll', - }); +import $ from 'jquery'; - const $ruler = $('<div>').css({ - width: '100%', - }); +const ScrollHelper = { + getScrollWidth() { + const $rulerContainer = $('<div>').css({ + visibility: 'hidden', + width: 100, + overflow: 'scroll', + }); - $ruler.appendTo($rulerContainer); - $rulerContainer.appendTo('body'); + const $ruler = $('<div>').css({ + width: '100%', + }); - const scrollWidth = $ruler.outerWidth(); + $ruler.appendTo($rulerContainer); + $rulerContainer.appendTo('body'); - $rulerContainer.remove(); + const scrollWidth = $ruler.outerWidth(); - return 100 - scrollWidth; -} + $rulerContainer.remove(); -function setScrollWidth() { - $('body').attr('data-scroll-width', getScrollWidth()); -} + return 100 - scrollWidth; + }, -export { - getScrollWidth, - setScrollWidth, + setScrollWidth() { + $('body').attr('data-scroll-width', ScrollHelper.getScrollWidth()); + }, }; + +export default ScrollHelper; |