Welcome to mirror list, hosted at ThFree Co, Russian Federation.

settings_panels.js « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e67f449e1a2a5501072f3215cce5acd74d3a5bdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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));
  });
}