diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2017-06-07 14:45:57 -0500 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2017-06-07 14:45:57 -0500 |
commit | 3ec37e2622f6729300a988c8f58dfb6c2aecb996 (patch) | |
tree | d060b5acf30093cbe1d3642ea6dd11e79ccbf6c5 /app/assets/javascripts/settings_panels.js | |
parent | a65f07a256b95ce1c38342518f9469cbf3abf609 (diff) | |
parent | fc1090d9f39231e31f929e37b9703db9738b457c (diff) | |
download | gitlab-ce-3ec37e2622f6729300a988c8f58dfb6c2aecb996.tar.gz |
Merge branch 'master' into 25426-group-dashboard-ui
Diffstat (limited to 'app/assets/javascripts/settings_panels.js')
-rw-r--r-- | app/assets/javascripts/settings_panels.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/assets/javascripts/settings_panels.js b/app/assets/javascripts/settings_panels.js new file mode 100644 index 00000000000..e67f449e1a2 --- /dev/null +++ b/app/assets/javascripts/settings_panels.js @@ -0,0 +1,27 @@ +function expandSection($section) { + $section.find('.js-settings-toggle').text('Close'); + $section.find('.settings-content').addClass('expanded').off('scroll').scrollTop(0); +} + +function closeSection($section) { + $section.find('.js-settings-toggle').text('Expand'); + $section.find('.settings-content').removeClass('expanded').on('scroll', () => expandSection($section)); +} + +function toggleSection($section) { + const $content = $section.find('.settings-content'); + $content.removeClass('no-animate'); + if ($content.hasClass('expanded')) { + closeSection($section); + } else { + expandSection($section); + } +} + +export default function initSettingsPanels() { + $('.settings').each((i, elm) => { + const $section = $(elm); + $section.on('click', '.js-settings-toggle', () => toggleSection($section)); + $section.find('.settings-content:not(.expanded)').on('scroll', () => expandSection($section)); + }); +} |