diff options
author | Annabel Dunstone <annabel.dunstone@gmail.com> | 2016-08-17 16:41:24 -0500 |
---|---|---|
committer | Annabel Dunstone <annabel.dunstone@gmail.com> | 2016-08-17 16:44:25 -0500 |
commit | 74f80465f6078b4a78ae2ebe4e367d4f1d7c890a (patch) | |
tree | 983acee75ef3c19150ffbfe92c5f998683d39690 /app/assets/javascripts | |
parent | ab44aa7b34e85b498d5aba02e5ad902d6d16fe7f (diff) | |
download | gitlab-ce-74f80465f6078b4a78ae2ebe4e367d4f1d7c890a.tar.gz |
Remove index from pipeline toggles18141-pipeline-graph
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/pipeline.js.es6 | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/app/assets/javascripts/pipeline.js.es6 b/app/assets/javascripts/pipeline.js.es6 index ae7369004de..bf33eb10100 100644 --- a/app/assets/javascripts/pipeline.js.es6 +++ b/app/assets/javascripts/pipeline.js.es6 @@ -1,13 +1,15 @@ -function toggleGraph() { - const indexOfBtn = $('.toggle-pipeline-btn').index($(this)); +(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'); - $($('.pipeline-graph')[indexOfBtn]).toggleClass('graph-collapsed'); - $($('.toggle-pipeline-btn')[indexOfBtn]).toggleClass('graph-collapsed'); + $($pipelineBtn).add($pipelineGraph).toggleClass('graph-collapsed'); - const $btnText = $($('.toggle-pipeline-btn .btn-text')[indexOfBtn]); - const graphCollapsed = $($('.pipeline-graph')[indexOfBtn]).hasClass('graph-collapsed'); + const graphCollapsed = $pipelineGraph.hasClass('graph-collapsed'); - graphCollapsed ? $btnText.text('Expand') : $btnText.text('Hide') -} + graphCollapsed ? $btnText.text('Expand') : $btnText.text('Hide') + } -$(document).on('click', '.toggle-pipeline-btn', toggleGraph); + $(document).on('click', '.toggle-pipeline-btn', toggleGraph); +})(); |