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

form.js « pages_domains « projects « pages « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 169530685ad39472cd13cdf69b662a216fce35de (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
28
29
30
31
32
33
import setupToggleButtons from '~/toggle_buttons';

function updateVisibility(selector, isVisible) {
  Array.from(document.querySelectorAll(selector)).forEach((el) => {
    if (isVisible) {
      el.classList.remove('d-none');
    } else {
      el.classList.add('d-none');
    }
  });
}

export default () => {
  const toggleContainer = document.querySelector('.js-auto-ssl-toggle-container');

  if (toggleContainer) {
    const onToggleButtonClicked = (isAutoSslEnabled) => {
      updateVisibility('.js-shown-unless-auto-ssl', !isAutoSslEnabled);

      updateVisibility('.js-shown-if-auto-ssl', isAutoSslEnabled);

      Array.from(document.querySelectorAll('.js-enabled-unless-auto-ssl')).forEach((el) => {
        if (isAutoSslEnabled) {
          el.setAttribute('disabled', 'disabled');
        } else {
          el.removeAttribute('disabled');
        }
      });
    };

    setupToggleButtons(toggleContainer, onToggleButtonClicked);
  }
};