summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipeline.js.es6
blob: 8813bb5dfef6b6f012eae6c8b584c30cac218ad1 (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
(function() {
  function toggleGraph() {
    const $pipelineBtn = $(this).closest('.toggle-pipeline-btn');
    const $pipelineGraph = $(this).closest('.row-content-block').next('.pipeline-graph');
    const $btnText = $(this).find('.toggle-btn-text');
    const $icon = $(this).find('.fa');

    $($pipelineBtn).add($pipelineGraph).toggleClass('graph-collapsed');

    const graphCollapsed = $pipelineGraph.hasClass('graph-collapsed');
    const expandIcon = 'fa-caret-down';
    const hideIcon = 'fa-caret-up';

    if(graphCollapsed) {
      $btnText.text('Expand');
      $icon.removeClass(hideIcon).addClass(expandIcon);
    } else {
      $btnText.text('Hide');
      $icon.removeClass(expandIcon).addClass(hideIcon);
    }
  }

  $(document).on('click', '.toggle-pipeline-btn', toggleGraph);
})();