summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorAnnabel Dunstone <annabel.dunstone@gmail.com>2016-08-17 16:41:24 -0500
committerAnnabel Dunstone <annabel.dunstone@gmail.com>2016-08-17 16:44:25 -0500
commit74f80465f6078b4a78ae2ebe4e367d4f1d7c890a (patch)
tree983acee75ef3c19150ffbfe92c5f998683d39690 /app/assets/javascripts
parentab44aa7b34e85b498d5aba02e5ad902d6d16fe7f (diff)
downloadgitlab-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.es620
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);
+})();