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

toggler_behavior.js « behaviors « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5467e3edc69278fb5e8d89b1e2c145df027a0a32 (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
(function(w) {
  $(function() {
    $('body').on('click', '.js-toggle-button', function(e) {
      e.preventDefault();
      $(this)
        .find('.fa')
          .toggleClass('fa-chevron-down fa-chevron-up')
        .end()
        .closest('.js-toggle-container')
          .find('.js-toggle-content')
            .toggle()
      ;
    });

    // If we're accessing a permalink, ensure it is not inside a
    // closed js-toggle-container!
    var hash = w.gl.utils.getLocationHash();
    var anchor = hash && document.getElementById(hash);
    var container = anchor && $(anchor).closest('.js-toggle-container');

    if (container && container.find('.js-toggle-content').is(':hidden')) {
      container.find('.js-toggle-button').trigger('click');
      anchor.scrollIntoView();
    }
  });
})(window);