summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/settings_panels.js
diff options
context:
space:
mode:
authorMike Greiling <mgreiling@gitlab.com>2017-06-07 08:11:44 +0000
committerPhil Hughes <me@iamphill.com>2017-06-07 08:11:44 +0000
commit4b1d956e1308f6c0a9dc03a2693f52eb1d782fd7 (patch)
treef37077f9e1486c07532c79bfbe382966648ef096 /app/assets/javascripts/settings_panels.js
parent5f6926f63249b3bcc6b94d27e038213aa55c9f06 (diff)
downloadgitlab-ce-4b1d956e1308f6c0a9dc03a2693f52eb1d782fd7.tar.gz
Resolve "Simplified Repository Settings page"
Diffstat (limited to 'app/assets/javascripts/settings_panels.js')
-rw-r--r--app/assets/javascripts/settings_panels.js27
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));
+ });
+}